:root{
  --bone:#F2E5CE;
  --bone-dim:#E6D4B5;
  --ochre:#E0A63A;
  --rust:#C7562A;
  --vermilion:#D22B2B;
  --pine:#2E3A2E;
  --olive:#5C6B4A;
  --ink:#1A1714;
  --paper-line:rgba(26,23,20,.18);
  --shelf-h:152px;
  --display:'Big Shoulders Stencil', Impact, sans-serif;
  --text:'Barlow Semi Condensed', 'Arial Narrow', sans-serif;
  --mono:'Martian Mono', ui-monospace, monospace;
}

*{box-sizing:border-box}
html,body{height:100%}
html{background:#12100d}
body{
  margin:0;
  min-height:100%;
  overflow:hidden;
  background:#12100d;
  color:var(--ink);
  font-family:var(--text);
  -webkit-font-smoothing:antialiased;
  -webkit-tap-highlight-color:transparent;
  overscroll-behavior:none;
}
button{font:inherit;color:inherit}
button:focus-visible{outline:2px solid var(--vermilion);outline-offset:2px}
[hidden]{display:none !important}

#app{
  position:relative;
  width:min(100vw,520px);
  height:100vh;
  height:100dvh;
  margin:0 auto;
  overflow:hidden;
  background:var(--bone);
  isolation:isolate;
}
#app::before{
  content:"";
  position:absolute;
  inset:0;
  z-index:80;
  pointer-events:none;
  opacity:.055;
  mix-blend-mode:multiply;
  background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.82' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='180' height='180' filter='url(%23n)'/%3E%3C/svg%3E");
}
.screen{position:absolute;inset:0}

/* ============ campaign board ============ */

.campaign{background:var(--bone);z-index:3}
.board{
  position:relative;
  display:flex;
  flex-direction:column;
  height:100%;
  background:
    radial-gradient(circle at 12% 22%, rgba(199,86,42,.05), transparent 44%),
    radial-gradient(circle at 88% 80%, rgba(46,58,46,.06), transparent 50%),
    var(--bone);
}
.chart-wrap{
  flex:1 1 auto;
  min-height:0;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:10px 8px 4px;
}
.chart{
  position:relative;
  width:min(100%, calc((100vh - var(--shelf-h) - 20px) * .6667));
  width:min(100%, calc((100dvh - var(--shelf-h) - 20px) * .6667));
  aspect-ratio:2/3;
  overflow:hidden;
  background:var(--bone);
  border:1.5px solid var(--ink);
  box-shadow:5px 7px 0 rgba(26,23,20,.18);
  flex:0 0 auto;
}
.chart-paper{
  position:absolute;
  inset:0;
  width:100%;
  height:100%;
  object-fit:cover;
  user-select:none;
  pointer-events:none;
}
.chart-head{
  position:absolute;
  left:0;right:0;top:0;
  z-index:4;
  pointer-events:none;
}
.game-title{
  display:block;
  width:92%;
  height:auto;
  margin:2.4% auto 0;
  transform:rotate(-1.4deg);
  filter:drop-shadow(2px 3px 0 rgba(199,86,42,.42)) drop-shadow(-1px -1px 0 rgba(224,166,58,.38));
  user-select:none;
}
.chart-meta{
  display:flex;
  align-items:center;
  justify-content:center;
  gap:5px;
  width:88%;
  margin:1.5% auto 0;
  padding:2px 0;
  font-size:6.6px;
  font-weight:700;
  letter-spacing:.14em;
  color:rgba(26,23,20,.78);
  white-space:nowrap;
}
.chart-meta i{
  display:block;
  width:3px;height:3px;
  background:var(--rust);
  transform:rotate(45deg);
}

.route-node{
  position:absolute;
  z-index:3;
  width:6%;
  height:auto;
  opacity:.92;
  filter:drop-shadow(2px 2px 0 rgba(26,23,20,.18));
  pointer-events:none;
}
.node-check{left:82%;top:15%}
.node-ring{left:72%;top:30%}
.node-trophy{left:52%;top:47%}
.node-lock{left:48%;top:72%}

.route-label{
  position:absolute;
  z-index:4;
  padding:1px 4px;
  background:rgba(242,229,206,.9);
  border:1px solid rgba(26,23,20,.55);
  font-size:6.2px;
  font-weight:800;
  letter-spacing:.12em;
  color:var(--rust);
  pointer-events:none;
}
.route-label.start{left:79%;top:14%;transform:rotate(-3deg)}
.route-label.finish{left:14%;top:84%;transform:rotate(2deg);color:var(--pine)}

.stage-pin{
  position:absolute;
  z-index:6;
  width:25%;
  padding:0;
  border:0;
  background:none;
  transform:rotate(var(--r,-2deg));
  cursor:pointer;
  filter:drop-shadow(4px 5px 0 rgba(26,23,20,.22));
  transition:transform .13s ease, filter .13s ease;
  -webkit-user-select:none;
  user-select:none;
}
.stage-pin img{display:block;width:100%;height:auto;pointer-events:none}
.stage-pin:hover{transform:rotate(var(--r,-2deg)) translateY(-2px)}
.stage-pin.selected{transform:rotate(var(--r,-2deg)) translateY(-3px) scale(1.035);filter:drop-shadow(5px 7px 0 rgba(26,23,20,.25))}
.stage-pin.locked img{filter:grayscale(.72) brightness(.96) contrast(.95);opacity:.9}
.stage-pin.locked{cursor:not-allowed}
.pin-1{left:41%;top:18%;--r:-3.2deg}
.pin-2{left:59%;top:38%;--r:2.6deg}
.pin-3{left:18%;top:58%;--r:-2.2deg}

.pin-state{
  position:absolute;
  top:-4%;
  right:-7%;
  z-index:2;
  padding:2px 5px;
  background:var(--bone);
  border:1.4px solid var(--ink);
  box-shadow:2px 2px 0 rgba(26,23,20,.22);
  font-family:var(--display);
  font-weight:800;
  font-size:7px;
  letter-spacing:.1em;
  line-height:1;
  transform:rotate(6deg);
  pointer-events:none;
}
.stage-pin.open .pin-state{background:var(--ochre)}
.stage-pin.cleared .pin-state{background:var(--vermilion);color:var(--bone)}
.stage-pin.locked .pin-state{background:#CFC3AE;color:#4F4A3F}

.pin-time{
  position:absolute;
  left:23%;
  bottom:10%;
  width:64%;
  text-align:center;
  font-family:var(--text);
  font-style:italic;
  font-weight:600;
  font-size:7.4px;
  line-height:1.05;
  letter-spacing:.01em;
  color:var(--ink);
  transform:rotate(-1.5deg);
  pointer-events:none;
  white-space:nowrap;
}
.pin-time:empty{display:none}
.pin-time.cover{
  bottom:10.5%;
  padding:1px 2px;
  background:rgba(242,229,206,.9);
  border-bottom:1px solid rgba(26,23,20,.3);
}

.tape{
  position:absolute;
  z-index:3;
  background:rgba(224,166,58,.55);
  border-left:1px dashed rgba(26,23,20,.22);
  border-right:1px dashed rgba(26,23,20,.22);
  mix-blend-mode:multiply;
  pointer-events:none;
}
.tape-top{
  top:-3.5%;
  left:13%;
  width:42%;
  height:7.5%;
  transform:rotate(-8deg);
}
.pin-tape{
  display:none;
  position:absolute;
  z-index:3;
  top:42%;
  left:2%;
  width:96%;
  min-height:27%;
  padding:5% 1.5% 4%;
  background:var(--bone);
  border:1.5px solid var(--rust);
  color:var(--vermilion);
  font-family:var(--display);
  font-weight:800;
  font-size:15px;
  letter-spacing:.06em;
  line-height:.9;
  text-align:center;
  transform:rotate(-10deg);
  box-shadow:2px 3px 0 rgba(26,23,20,.2);
  pointer-events:none;
  display:none;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:2px;
  clip-path:polygon(0 3%,97% 0,100% 94%,3% 100%);
}
.pin-tape.show{display:flex}
.pin-tape b{font-size:15px;font-weight:800;line-height:.9}
.pin-tape b{font-size:13px}
.pin-tape i{font-family:var(--text);font-style:normal;font-size:5.6px;font-weight:800;letter-spacing:.12em;color:var(--rust)}

.note{
  position:absolute;
  z-index:3;
  font-family:var(--text);
  font-style:italic;
  font-weight:600;
  font-size:6.2px;
  letter-spacing:.02em;
  color:#5A3A22;
  opacity:.78;
  white-space:nowrap;
  pointer-events:none;
}
.n1{left:7%;top:24%;transform:rotate(-8deg)}
.n2{left:9%;top:44%;transform:rotate(4deg)}
.n3{left:52%;top:67%;transform:rotate(-5deg)}
.n4{left:57%;top:76%;transform:rotate(3deg)}

.stage-pin.just-unlocked .pin-state{animation:stampIn .55s cubic-bezier(.2,.9,.25,1.4)}
.stage-tag.just-unlocked .tag-mark{animation:stampIn .55s cubic-bezier(.2,.9,.25,1.4)}
@keyframes stampIn{0%{transform:scale(1.9) rotate(14deg);opacity:0}60%{opacity:1}100%{transform:scale(1) rotate(4deg);opacity:1}}
.start-plate.denied{animation:deny .35s ease}
@keyframes deny{0%,100%{transform:translateX(0)}25%{transform:translateX(-4px)}55%{transform:translateX(4px)}80%{transform:translateX(-2px)}}
.chart-crease{
  position:absolute;
  z-index:2;
  left:0;right:0;top:52%;
  height:1px;
  background:rgba(26,23,20,.2);
  box-shadow:0 2px 0 rgba(255,255,255,.24);
  pointer-events:none;
}
.chart-grain{
  position:absolute;
  inset:0;
  z-index:5;
  pointer-events:none;
  opacity:.1;
  mix-blend-mode:multiply;
  background-image:radial-gradient(rgba(26,23,20,.8) .55px, transparent .7px);
  background-size:3px 3px;
}

/* ============ shelf ============ */

.shelf{
  position:relative;
  z-index:10;
  flex:0 0 auto;
  padding:8px 10px calc(8px + env(safe-area-inset-bottom));
  background:var(--bone);
  border-top:2px solid var(--ink);
  box-shadow:0 -3px 0 rgba(26,23,20,.1);
}
.shelf::before{
  content:"";
  position:absolute;
  left:0;right:0;top:-5px;
  height:3px;
  background:repeating-linear-gradient(90deg,var(--rust) 0 10px,transparent 10px 22px);
  opacity:.55;
}
.shelf-top{
  display:flex;
  align-items:center;
  gap:5px;
  min-height:15px;
  font-size:6.6px;
  font-weight:700;
  letter-spacing:.08em;
  white-space:nowrap;
}
.log-label{
  font-family:var(--display);
  font-size:11px;
  font-weight:800;
  letter-spacing:.1em;
  line-height:1;
}
#camp-progress{
  padding-left:5px;
  border-left:1px solid rgba(26,23,20,.35);
  font-family:var(--mono);
  font-size:6.2px;
}
#camp-total{
  margin-left:auto;
  font-family:var(--mono);
  font-size:6.2px;
  color:rgba(26,23,20,.78);
}
.mini-btn{
  padding:2px 4px;
  background:transparent;
  border:1px solid rgba(26,23,20,.55);
  font-size:6.2px;
  font-weight:800;
  letter-spacing:.08em;
  line-height:1;
  cursor:pointer;
}
.mini-btn:active{background:var(--ochre)}
.mini-btn.sound.on{background:var(--ochre)}

.stage-tags{
  display:grid;
  grid-template-columns:repeat(3,minmax(0,1fr));
  gap:5px;
  margin:7px 0 7px;
}
.stage-tag{
  position:relative;
  display:flex;
  align-items:stretch;
  gap:4px;
  min-height:52px;
  padding:4px 5px 3px;
  background:rgba(242,229,206,.7);
  border:1.5px solid rgba(26,23,20,.55);
  text-align:left;
  cursor:pointer;
  transition:background .1s ease,transform .1s ease;
}
.stage-tag .tag-num{
  flex:0 0 auto;
  font-family:var(--display);
  font-size:23px;
  font-weight:800;
  line-height:.86;
  letter-spacing:-.02em;
  align-self:center;
}
.tag-body{
  display:flex;
  flex-direction:column;
  justify-content:center;
  min-width:0;
  gap:1px;
}
.tag-body b{
  font-size:8.4px;
  font-weight:800;
  letter-spacing:.04em;
  line-height:1;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.tag-body small{
  font-size:6.2px;
  font-weight:600;
  letter-spacing:.05em;
  color:rgba(26,23,20,.72);
  line-height:1.1;
}
.tag-body em{
  font-family:var(--mono);
  font-style:normal;
  font-size:6.2px;
  font-weight:500;
  line-height:1.15;
  letter-spacing:-.02em;
  color:var(--pine);
}
.stage-tag.selected{
  background:var(--ochre);
  border-color:var(--ink);
  box-shadow:2px 2px 0 rgba(26,23,20,.28);
  transform:translateY(-1px);
}
.stage-tag.selected .tag-body small{color:rgba(26,23,20,.85)}
.stage-tag.cleared .tag-num{color:var(--vermilion)}
.stage-tag.locked{background:rgba(207,195,174,.6);color:#575145;cursor:not-allowed}
.stage-tag.locked .tag-num{opacity:.65}
.stage-tag .tag-mark{
  position:absolute;
  top:2px;
  right:3px;
  padding:1px 3px;
  background:var(--bone);
  border:1px solid var(--ink);
  font-family:var(--display);
  font-size:6.4px;
  font-weight:800;
  letter-spacing:.06em;
  line-height:1;
  transform:rotate(4deg);
  pointer-events:none;
}
.stage-tag.cleared .tag-mark{background:var(--vermilion);color:var(--bone)}
.stage-tag.selected .tag-mark{background:var(--ink);color:var(--bone)}

.start-plate{
  display:block;
  width:100%;
  height:50px;
  padding:0;
  border:2px solid var(--ink);
  background:var(--ochre);
  background-image:url("../assets/sprites/ui_orange.webp");
  background-size:cover;
  background-position:center;
  box-shadow:3px 3px 0 rgba(26,23,20,.3);
  clip-path:polygon(0 4%,99.5% 0,100% 95%,.5% 100%);
  cursor:pointer;
  position:relative;
  overflow:hidden;
}
.start-plate::after{
  content:"";
  position:absolute;
  inset:0;
  background:rgba(224,166,58,.3);
  pointer-events:none;
}
.start-plate:active{transform:translate(2px,2px);box-shadow:1px 1px 0 rgba(26,23,20,.3)}
.start-plate[disabled]{cursor:not-allowed;filter:grayscale(.6);opacity:.72}
.start-face{
  position:relative;
  z-index:1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:1px;
  height:100%;
  padding:0 8px;
}
#start-label{
  font-family:var(--display);
  font-size:24px;
  font-weight:800;
  letter-spacing:.06em;
  line-height:.9;
  color:var(--ink);
  text-shadow:-1px -1px 0 rgba(247,236,214,.35);
}
#start-sub{
  font-size:6.6px;
  font-weight:800;
  letter-spacing:.12em;
  color:rgba(26,23,20,.82);
}
.hint-line{
  margin-top:4px;
  text-align:center;
  font-size:6.3px;
  font-weight:600;
  letter-spacing:.1em;
  color:rgba(26,23,20,.68);
  white-space:nowrap;
}

/* ============ overlays and sheets ============ */

.overlay{
  position:absolute;
  inset:0;
  z-index:40;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:16px;
  background:rgba(26,23,20,.56);
}
.sheet{
  position:relative;
  width:min(100%,390px);
  max-height:calc(100% - 10px);
  overflow:auto;
  padding:18px 16px 15px;
  background:var(--bone);
  border:2px solid var(--ink);
  box-shadow:8px 9px 0 rgba(0,0,0,.34);
  transform:rotate(-.7deg);
  clip-path:polygon(0 1.5%,99% 0,100% 2%,99.4% 99%,2% 100%,0 97.5%);
}
.sheet::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  opacity:.08;
  mix-blend-mode:multiply;
  background-image:radial-gradient(rgba(26,23,20,.8) .55px, transparent .7px);
  background-size:3px 3px;
}
.sheet > *{position:relative;z-index:1}
.sheet h2{
  margin:2px 0 10px;
  font-family:var(--display);
  font-size:28px;
  font-weight:800;
  line-height:.92;
  letter-spacing:.03em;
}
.plate-kicker{
  margin:0;
  font-size:7px;
  font-weight:800;
  letter-spacing:.18em;
  color:var(--rust);
}
.sheet-close{
  position:absolute;
  z-index:2;
  top:5px;
  right:6px;
  width:27px;height:27px;
  padding:0;
  background:var(--bone);
  border:1.5px solid var(--ink);
  font-family:var(--display);
  font-size:19px;
  font-weight:800;
  line-height:1;
  cursor:pointer;
}
.sheet-note{
  margin:10px 0 0;
  font-size:8.5px;
  line-height:1.35;
  color:rgba(26,23,20,.72);
}
.sheet-actions{display:flex;flex-direction:column;gap:7px;margin-top:12px}
.plate-btn{
  display:block;
  width:100%;
  min-height:38px;
  padding:8px 12px;
  border:2px solid var(--ink);
  background:var(--bone);
  font-family:var(--display);
  font-size:17px;
  font-weight:800;
  letter-spacing:.06em;
  line-height:1;
  cursor:pointer;
  box-shadow:2px 2px 0 rgba(26,23,20,.22);
  clip-path:polygon(0 4%,99.4% 0,100% 96%,.6% 100%);
}
.plate-btn.ochre{background:var(--ochre)}
.plate-btn.bone{background:var(--bone-dim)}
.plate-btn:active{transform:translate(1px,2px);box-shadow:none}
.howto-list{list-style:none;margin:10px 0 0;padding:0;display:flex;flex-direction:column;gap:8px}
.howto-list li{display:grid;grid-template-columns:62px 1fr;gap:8px;align-items:start;border-top:1px solid rgba(26,23,20,.18);padding-top:7px}
.howto-list b{font-family:var(--display);font-size:12px;letter-spacing:.05em;line-height:1}
.howto-list span{font-size:9px;line-height:1.3}

.times-table{display:flex;flex-direction:column;gap:1px;margin-top:8px}
.time-row{
  display:grid;
  grid-template-columns:20px 1fr auto;
  gap:6px;
  align-items:baseline;
  padding:5px 3px;
  border-bottom:1px solid rgba(26,23,20,.16);
  font-size:9px;
}
.time-row .rank{font-family:var(--mono);font-size:8px;color:var(--rust)}
.time-row .who{font-weight:700;letter-spacing:.03em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.time-row .who a{color:inherit;text-decoration:none;border-bottom:1px dotted rgba(26,23,20,.5)}
.time-row .val{font-family:var(--mono);font-size:9px;font-weight:700}
.time-row.mine{background:rgba(224,166,58,.28)}
.empty-line{font-family:var(--mono);font-size:8px;color:rgba(26,23,20,.62);padding:10px 2px}

/* ============ stage screen ============ */

.stage{background:#8a6838;overflow:hidden;z-index:2}
#game-canvas{position:absolute;inset:0;z-index:0}
#game-canvas canvas{display:block;width:100% !important;height:100% !important;touch-action:none}
.stage-haze{
  position:absolute;
  inset:0;
  z-index:1;
  pointer-events:none;
  opacity:.18;
  mix-blend-mode:multiply;
  background-image:radial-gradient(rgba(26,23,20,.55) .55px,transparent .75px);
  background-size:3px 3px;
}

.hud-top{
  position:absolute;
  z-index:12;
  top:calc(7px + env(safe-area-inset-top));
  left:8px;
  right:8px;
  display:flex;
  align-items:flex-start;
  gap:7px;
  pointer-events:none;
}
.hud-top > *{pointer-events:auto}
.square-plate{
  flex:0 0 auto;
  width:42px;
  height:44px;
  padding:0;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:1px;
  background:var(--bone);
  border:2px solid var(--ink);
  box-shadow:3px 3px 0 rgba(26,23,20,.32);
  cursor:pointer;
  clip-path:polygon(0 4%,97% 0,100% 96%,3% 100%);
}
.square-plate:active{transform:translate(1px,2px);box-shadow:1px 1px 0 rgba(26,23,20,.32)}
.route-plate .route-arrow{font-family:var(--display);font-size:16px;line-height:.8}
.square-plate small{font-size:5.6px;font-weight:800;letter-spacing:.08em;line-height:1}
.pause-plate img{width:32px;height:32px;object-fit:contain;display:block}

.timer-block{
  flex:1 1 auto;
  min-width:0;
  display:flex;
  flex-direction:column;
  align-items:center;
}
.timer-plate{
  position:relative;
  width:min(100%,232px);
  height:47px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:0 14px;
  background:var(--ink);
  border:2px solid var(--bone);
  outline:2px solid var(--ink);
  box-shadow:3px 3px 0 rgba(26,23,20,.4);
  clip-path:polygon(0 9%,2% 0,98% 3%,100% 91%,97% 100%,2% 97%);
}
.timer-plate::before{
  content:"";
  position:absolute;
  inset:4px 8px;
  border-top:1px solid rgba(242,229,206,.18);
  border-bottom:1px solid rgba(242,229,206,.12);
  pointer-events:none;
}
#timer{
  position:relative;
  z-index:1;
  font-family:var(--mono);
  font-weight:700;
  font-size:21px;
  letter-spacing:.01em;
  color:var(--bone);
  line-height:1;
  text-shadow:0 0 0 transparent;
}
.stage-sub{
  display:flex;
  align-items:center;
  gap:4px;
  margin-top:2px;
  padding:1px 5px;
  max-width:100%;
  background:rgba(242,229,206,.94);
  border:1px solid var(--ink);
  font-size:6.2px;
  font-weight:700;
  letter-spacing:.07em;
  white-space:nowrap;
  overflow:hidden;
}
#hud-stage{font-family:var(--display);font-size:10px;letter-spacing:.06em;line-height:1}
#hud-name{overflow:hidden;text-overflow:ellipsis}
#hud-surface{font-style:normal;background:var(--rust);color:var(--bone);padding:1px 3px;font-size:5.8px}

.progress-row{
  position:absolute;
  z-index:10;
  top:calc(66px + env(safe-area-inset-top));
  left:13px;
  right:13px;
  pointer-events:none;
}
.progress{
  position:relative;
  height:7px;
  background:rgba(242,229,206,.86);
  border:1.5px solid var(--ink);
  box-shadow:2px 2px 0 rgba(26,23,20,.24);
}
.progress-fill{
  height:100%;
  width:0;
  background:var(--ochre);
  border-right:2px solid var(--ink);
  transition:width .09s linear;
}
.pmark{position:absolute;top:-4px;bottom:-4px;width:2px;background:var(--ink);opacity:.75}
.pm1{left:33.33%}
.pm2{left:66.66%}
.pmf{right:0;width:3px;background:var(--vermilion);opacity:1}
.progress-labels{
  display:flex;
  justify-content:space-between;
  align-items:center;
  margin-top:2px;
  font-family:var(--mono);
  font-size:6.2px;
  letter-spacing:.02em;
  color:var(--bone);
  text-shadow:0 1px 0 rgba(26,23,20,.8),1px 0 0 rgba(26,23,20,.5);
}
#split-flash{
  font-family:var(--display);
  font-size:9px;
  letter-spacing:.1em;
  color:var(--ochre);
  opacity:0;
  transform:rotate(-2deg);
  transition:opacity .12s ease;
}
#split-flash.show{opacity:1}

.call-plate.flick{animation:callFlick .3s ease-out}
@keyframes callFlick{0%{transform:rotate(-1.4deg) scale(1.12)}100%{transform:rotate(-1.4deg) scale(1)}}
.call-plate{
  position:absolute;
  z-index:11;
  left:9px;
  top:calc(94px + env(safe-area-inset-top));
  display:flex;
  align-items:center;
  gap:3px;
  padding:3px 7px 4px;
  background:rgba(242,229,206,.95);
  border:2px solid var(--ink);
  box-shadow:3px 3px 0 rgba(26,23,20,.28);
  transform:rotate(-1.4deg);
}
.call-arrow{font-family:var(--display);font-size:25px;line-height:.8;color:var(--rust);min-width:16px;text-align:center}
.call-grade{font-family:var(--display);font-size:22px;line-height:.8}
.call-plate small{font-size:5.6px;font-weight:800;letter-spacing:.12em;line-height:1;writing-mode:vertical-rl;color:rgba(26,23,20,.6)}

.telemetry{
  position:absolute;
  z-index:11;
  right:9px;
  top:calc(94px + env(safe-area-inset-top));
  display:flex;
  align-items:baseline;
  gap:3px;
  padding:2px 6px 3px;
  background:var(--ink);
  color:var(--bone);
  border:1px solid var(--bone);
  box-shadow:3px 3px 0 rgba(26,23,20,.3);
}
#speed-num{font-family:var(--mono);font-size:17px;font-weight:700;line-height:1}
.telemetry small{font-size:5.6px;font-weight:800;letter-spacing:.1em;color:var(--ochre)}

.split-strip{
  position:absolute;
  z-index:10;
  right:9px;
  top:calc(120px + env(safe-area-inset-top));
  display:flex;
  flex-direction:column;
  gap:1px;
  padding:2px 5px;
  background:rgba(242,229,206,.84);
  border:1px solid rgba(26,23,20,.55);
  font-family:var(--mono);
  font-size:6.1px;
  line-height:1.35;
  color:var(--ink);
  white-space:nowrap;
}
.split-strip b{font-weight:700}

.controls{
  position:absolute;
  z-index:14;
  left:10px;
  right:10px;
  bottom:calc(10px + env(safe-area-inset-bottom));
  display:flex;
  align-items:flex-end;
  justify-content:space-between;
  pointer-events:none;
}
.controls > *{pointer-events:auto}
.steer-group{display:flex;gap:7px}
.ctrl-plate{
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  width:62px;
  height:58px;
  padding:0;
  gap:1px;
  background:var(--bone);
  border:2px solid var(--ink);
  box-shadow:3px 4px 0 rgba(26,23,20,.34);
  font-family:var(--display);
  font-size:24px;
  font-weight:800;
  line-height:1;
  cursor:pointer;
  touch-action:none;
  clip-path:polygon(0 4%,97% 0,100% 95%,3% 100%);
  -webkit-user-select:none;
  user-select:none;
}
.ctrl-plate small{font-family:var(--text);font-size:5.8px;font-weight:700;letter-spacing:.04em;line-height:1}
.brake-plate{width:86px;background:var(--ochre);font-size:19px}
.ctrl-plate.pressed{transform:translate(2px,3px);box-shadow:1px 1px 0 rgba(26,23,20,.34);background:var(--rust);color:var(--bone)}

.countdown{
  position:absolute;
  inset:0;
  z-index:30;
  display:flex;
  align-items:center;
  justify-content:center;
  pointer-events:none;
}
.countdown-plate{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:2px;
  padding:13px 32px 11px;
  background:rgba(242,229,206,.95);
  border:3px solid var(--ink);
  box-shadow:8px 9px 0 rgba(26,23,20,.38);
  transform:rotate(-2deg);
}
#countdown-num{
  font-family:var(--display);
  font-size:74px;
  font-weight:800;
  line-height:.82;
  color:var(--vermilion);
  text-shadow:3px 3px 0 rgba(26,23,20,.18);
}
#countdown-num.go{color:var(--pine);font-size:54px}
#countdown-sub{font-size:7px;font-weight:800;letter-spacing:.16em;color:rgba(26,23,20,.75)}
.countdown-plate.tick{animation:tick .32s ease-out}
@keyframes tick{
  0%{transform:rotate(-2deg) scale(1.16)}
  100%{transform:rotate(-2deg) scale(1)}
}

.pause-time{
  display:flex;
  align-items:baseline;
  gap:8px;
  margin:4px 0 3px;
  padding:6px 8px;
  background:var(--ink);
  color:var(--bone);
  border:1px solid var(--ink);
}
.pause-time span{font-family:var(--mono);font-size:24px;font-weight:700;line-height:1}
.pause-time small{font-size:6.5px;font-weight:800;letter-spacing:.14em;color:var(--ochre)}

.finish-sheet h2{font-size:25px}
.finish-sheet .finish-stage{
  font-size:7.5px;
  font-weight:800;
  letter-spacing:.12em;
  color:var(--rust);
}
.finish-stamp{
  position:absolute;
  top:14px;
  right:13px;
  padding:4px 7px;
  border:3px solid var(--vermilion);
  color:var(--vermilion);
  font-family:var(--display);
  font-size:16px;
  font-weight:800;
  letter-spacing:.12em;
  line-height:1;
  transform:rotate(-13deg);
  opacity:.86;
  z-index:2;
}
.finish-stamp.small{font-size:11px;padding:3px 5px}
.result-time{
  display:flex;
  align-items:baseline;
  gap:7px;
  margin:2px 0 9px;
  padding:5px 8px 6px;
  background:var(--ink);
  color:var(--bone);
  border:1px solid var(--ink);
}
.result-time b{font-family:var(--mono);font-size:29px;font-weight:700;line-height:1}
.result-time small{font-size:6.4px;font-weight:800;letter-spacing:.14em;color:var(--ochre)}
.result-grid{
  display:grid;
  grid-template-columns:1fr 1fr;
  gap:4px 9px;
  margin:8px 0;
  font-size:8.5px;
}
.result-grid div{display:flex;justify-content:space-between;gap:5px;border-bottom:1px dotted rgba(26,23,20,.35);padding:2px 0}
.result-grid b{font-family:var(--mono);font-size:8.5px;font-weight:700}
.result-best{
  margin:7px 0;
  padding:4px 6px;
  border:1.5px dashed var(--rust);
  font-family:var(--mono);
  font-size:8.5px;
  color:var(--rust);
}
.result-unlock{
  display:flex;
  align-items:center;
  gap:7px;
  margin:8px 0;
  padding:5px 7px;
  background:var(--ochre);
  border:1.5px solid var(--ink);
  font-family:var(--display);
  font-size:14px;
  font-weight:800;
  letter-spacing:.05em;
  line-height:1;
  transform:rotate(-1deg);
}
.result-unlock img{width:22px;height:22px;object-fit:contain}
.trophy-row{display:flex;align-items:center;gap:8px;margin:5px 0 7px}
.trophy-row img{width:44px;height:44px;object-fit:contain}
.trophy-row b{font-family:var(--display);font-size:16px;line-height:1;letter-spacing:.04em}

.toast{
  position:absolute;
  left:50%;
  bottom:calc(var(--shelf-h) + 14px);
  transform:translateX(-50%) rotate(-1deg);
  z-index:60;
  padding:6px 10px;
  background:var(--ink);
  color:var(--bone);
  border:1px solid var(--bone);
  box-shadow:3px 3px 0 rgba(0,0,0,.25);
  font-size:8px;
  font-weight:800;
  letter-spacing:.1em;
  white-space:nowrap;
  pointer-events:none;
  opacity:0;
  transition:opacity .18s ease;
}
.toast.show{opacity:1}
.boot-note{
  position:absolute;
  z-index:70;
  left:50%;
  top:50%;
  transform:translate(-50%,-50%) rotate(-1deg);
  padding:10px 14px;
  background:var(--bone);
  border:2px solid var(--ink);
  box-shadow:4px 4px 0 rgba(26,23,20,.3);
  font-family:var(--display);
  font-size:15px;
  letter-spacing:.08em;
  white-space:nowrap;
}

/* ============ small and short screens ============ */

@media (max-height:650px){
  :root{--shelf-h:132px}
  .chart-wrap{padding-top:6px}
  .stage-tag{min-height:44px}
  .stage-tag .tag-num{font-size:20px}
  .start-plate{height:44px}
  #start-label{font-size:21px}
  .hint-line{display:none}
  .shelf{padding-top:6px}
  .timer-plate{height:42px}
  #timer{font-size:19px}
  .call-plate.flick{animation:callFlick .3s ease-out}
@keyframes callFlick{0%{transform:rotate(-1.4deg) scale(1.12)}100%{transform:rotate(-1.4deg) scale(1)}}
.call-plate{top:calc(88px + env(safe-area-inset-top))}
  .telemetry{top:calc(88px + env(safe-area-inset-top))}
  .split-strip{top:calc(113px + env(safe-area-inset-top))}
}
@media (max-width:370px){
  .log-label{font-size:9.5px}
  #camp-progress{display:none}
  .mini-btn{padding:2px 3px;font-size:5.8px}
  .stage-tags{gap:4px}
  .stage-tag{padding:3px 4px;gap:3px}
  .stage-tag .tag-num{font-size:19px}
  .tag-body b{font-size:7.6px}
  .tag-body small{font-size:5.7px}
  .tag-body em{font-size:5.7px}
  .start-plate{height:46px}
  .hint-line{font-size:5.8px}
  .ctrl-plate{width:56px;height:56px}
  .brake-plate{width:78px}
}

@media (orientation:landscape) and (max-height:560px){
  #app{height:100dvh}
  #app.campaign-mode{width:100vw;max-width:none}
  .chart-wrap{padding:8px 6px}
  .chart{width:min(100%, calc((100dvh - 20px) * .6667))}
  .campaign .board{flex-direction:row}
  .shelf{
    width:340px;
    flex:0 0 340px;
    height:100%;
    overflow:auto;
    border-top:0;
    border-left:2px solid var(--ink);
    display:flex;
    flex-direction:column;
    justify-content:center;
    padding:10px 10px calc(10px + env(safe-area-inset-bottom));
  }
  .shelf::before{top:0;left:-5px;width:3px;height:auto;bottom:0;background:repeating-linear-gradient(180deg,var(--rust) 0 10px,transparent 10px 22px)}
  .shelf-top{flex-wrap:wrap;row-gap:4px;white-space:normal}
  #camp-total{margin-left:0}
  .stage-tags{grid-template-columns:1fr;margin:8px 0}
  .stage-tag{min-height:42px}
  .hint-line{display:none}
  .hud-top{left:12px;right:12px}
  .controls{bottom:calc(9px + env(safe-area-inset-bottom))}
}
@media (prefers-reduced-motion:reduce){
  *{animation-duration:.001ms !important;transition-duration:.001ms !important}
}
