:root {
  --plate: #4e535a;
  --plate-2: #5c6168;
  --ink: #1e2226;
  --paper: #f3eee4;
  --yellow: #f0c000;
  --silver: #cfd6dc;
  --orange: #e87722;
  --crate: #c45c26;
  --ok: #3a7d54;
  --text: #f7f4ee;
  --muted: #d4cfc4;
  --navy: #123049;
  --font: "Barlow", "Noto Sans", "Noto Sans Arabic", "Noto Sans Ethiopic", "Segoe UI", system-ui, sans-serif;
  --radius-sm: 8px;
  --radius: 10px;
  --radius-lg: 16px;
  --rail: 76px;
  --rail-open: 204px;
  --motion-quick: 150ms;
  --motion-fast: 220ms;
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --hair: color-mix(in srgb, var(--yellow) 72%, #2a2e33);
  --plate-img:
    linear-gradient(30deg, #484d54 12%, transparent 12.5%, transparent 87%, #484d54 87.5%, #484d54),
    linear-gradient(150deg, #484d54 12%, transparent 12.5%, transparent 87%, #484d54 87.5%, #484d54),
    linear-gradient(30deg, #484d54 12%, transparent 12.5%, transparent 87%, #484d54 87.5%, #484d54),
    linear-gradient(150deg, #484d54 12%, transparent 12.5%, transparent 87%, #484d54 87.5%, #484d54);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--ink); color: var(--text); font-family: var(--font); font-weight: 500; font-feature-settings: "ss01", "tnum"; -webkit-font-smoothing: antialiased; overflow: hidden; overscroll-behavior: none; }
button, input, select { font-family: inherit; }
button:not(:disabled), [role="button"]:not(:disabled) { cursor: pointer; }
:focus { outline: none; }
:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}
.tool.on:focus-visible, .btn.on:focus-visible { outline-offset: 3px; }
[hidden] { display: none !important; }
html[data-big="1"] body { font-size: 18px; }
html[data-big="1"] .btn,
html[data-big="1"] .tool,
html[data-big="1"] .howto-card,
html[data-big="1"] .menu-card { font-size: 17px; }
#access .btn { width: 100%; }

#app {
  display: grid;
  grid-template-columns: var(--rail) minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  height: 100%;
  height: 100dvh;
  direction: ltr;
}
.hud { grid-column: 1 / -1; grid-row: 1; }
.rail { grid-column: 1; grid-row: 2; min-height: 0; }
.shop {
  grid-column: 2;
  grid-row: 2;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr) auto;
  min-width: 0;
  min-height: 0;
  direction: ltr;
}
.job-stack { min-width: 0; }
.job-strip {
  display: flex;
  gap: 8px;
  align-items: center;
  overflow-x: auto;
  min-width: 0;
  padding: 6px 10px;
  background:
    linear-gradient(#2c3136, #2c3136) padding-box,
    #24282c;
  border-bottom: 1px solid #1a1d21;
  box-shadow: inset 0 1px 0 #ffffff14;
}
.job-plate {
  position: relative;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 44px;
  min-width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid #1c2024;
  background:
    radial-gradient(circle at 35% 30%, #6a7078, #3e444b 62%, #2e3338);
  color: #f4efe6;
  font-weight: 700;
  box-shadow: inset 0 1px 0 #ffffff2e, 0 1px 0 #0006;
}
.job-plate b { font-size: 16px; line-height: 1; letter-spacing: 0; }
.job-plate span {
  position: absolute;
  width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0);
}
.job-plate.lock {
  background: radial-gradient(circle at 35% 30%, #4a5056, #2a2e33 70%);
  color: #8d949b;
  box-shadow: inset 0 2px 5px #0008;
}
.job-plate.now {
  background: radial-gradient(circle at 35% 28%, #ffe978, #e2b000 70%);
  color: #1a1400;
  border-color: #fff6;
  box-shadow: 0 0 0 2px #1a1400, 0 0 0 3px var(--yellow);
}
.job-plate.clear {
  background: radial-gradient(circle at 35% 30%, #4e9a6e, #246246 70%);
  color: #f7f4ee;
}
.job-plate.here { box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1400; }
.job-plate.now.here { box-shadow: 0 0 0 2px #1a1400, 0 0 0 4px var(--yellow); }
.job-plate.race {
  background: radial-gradient(circle at 35% 30%, #4a5158, #1c2126 68%);
  color: #f0c000;
}
.job-plate.race b {
  width: auto;
  height: auto;
  display: block;
  border-radius: 0;
  background: none;
  color: #f0c000;
}
.job-plate.race.here { box-shadow: 0 0 0 2px #1a1400, 0 0 0 4px #f0c000; }
.race-k {
  margin-left: 6px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #f0c000;
}
.job-plate.test { box-shadow: 0 0 0 2px var(--yellow); }
.job-name {
  margin-left: 4px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.01em;
  color: var(--paper);
  white-space: nowrap;
}
.curr-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 4px 10px;
  overflow-x: auto;
  background: var(--paper);
  color: #1a1400;
  border-bottom: 2px solid #1a1400;
}
.curr-k {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #c2410c;
}
.curr-steps { display: flex; gap: 4px; flex: 0 0 auto; }
.curr-bar .step {
  min-height: 36px;
  background: #fff;
  color: #1a1400;
  border-color: #1a140022;
}
.curr-bar .step.on { background: var(--yellow); color: #1a1400; }
.curr-line {
  margin: 0;
  flex: 1 1 8rem;
  min-width: 8rem;
  font-size: 14px;
  font-weight: 700;
  white-space: nowrap;
}
.curr-bar .btn {
  flex: 0 0 auto;
  min-height: 36px;
  background: #fff;
  color: #1a1400;
  border-color: #1a140033;
}
.glyph { display: block; width: 18px; height: 18px; flex: 0 0 18px; }
.hud-play .lbl,
.menu-btn .lbl {
  position: static;
  width: auto;
  height: auto;
  overflow: visible;
  clip: auto;
  font-size: 14px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0;
}
.hud-play .btn {
  position: relative;
  width: auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  gap: 4px;
  display: inline-flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
}
.menu-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 10px;
}
.key {
  position: absolute;
  left: calc(100% + 8px);
  top: 50%;
  transform: translateY(-50%);
  height: 22px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--paper);
  color: #1a1400;
  border: 1px solid #1a1400;
  font-size: 12px;
  font-weight: 800;
  line-height: 20px;
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  letter-spacing: 0;
  opacity: 0;
  z-index: 12;
  box-shadow: 0 8px 16px -10px #000a;
}
.tool:hover > .key,
.tool:focus-visible > .key,
.hud-play .btn:hover > .key,
.hud-play .btn:focus-visible > .key { opacity: 1; }
.hud-play .key {
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
}
.calm-fail {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 4;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(36rem, calc(100% - 24px));
  padding: 8px 8px 8px 14px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid #e2d3b8;
  border-radius: 14px;
  box-shadow: 0 12px 28px -18px #000a;
}
.calm-fail[hidden] { display: none !important; }
.calm-fail p { margin: 0; font-size: 14px; font-weight: 600; line-height: 1.3; }
#btn-retry { flex: 0 0 auto; min-height: 44px; min-width: 44px; }

.rail {
  width: var(--rail);
  min-width: var(--rail);
  max-width: var(--rail);
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 1px 4px;
  overflow: visible;
  color: var(--text);
  background-color: var(--plate);
  background-image: var(--plate-img);
  background-size: 18px 32px;
  background-position: 0 0, 0 0, 9px 16px, 9px 16px;
  border-right: 3px solid var(--hair);
  box-shadow: inset -8px 0 12px #0002;
  z-index: 6;
}
.rail:hover,
.rail:focus-within,
.rail.open { width: var(--rail); max-width: var(--rail); }
#btn-rail { display: none; }
.rail .lbl {
  position: static;
  width: 100%;
  height: auto;
  overflow: hidden;
  clip: auto;
  display: block;
  font-size: 11px;
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
  text-align: center;
  color: #fff;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.tool.on .lbl { color: #1a1400; }

.rail-pin {
  display: flex; align-items: center; gap: 10px;
  min-height: 44px; min-width: 44px; padding: 6px 8px;
  border: 0; border-radius: var(--radius);
  background: #0003; color: var(--yellow);
  font-weight: 700;
}
.chev {
  width: 10px; height: 10px; flex: 0 0 10px;
  border-right: 2.5px solid var(--yellow);
  border-bottom: 2.5px solid var(--yellow);
  transform: rotate(-45deg);
  margin-left: 10px;
  transition: transform var(--motion-quick) var(--ease-out), margin-left var(--motion-quick) var(--ease-out);
}
.rail.open .chev, .rail:hover .chev { transform: rotate(45deg); margin-left: 6px; }

.rail-tabs, .rail-tools { display: flex; flex-direction: column; gap: 0; }
.rail-tools { flex: 1 1 auto; min-height: 0; overflow-y: auto; }
.rail-tabs { padding-bottom: 8px; border-bottom: 2px solid #0004; }

.tool {
  position: relative;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
  min-height: 44px; height: 44px; min-width: 44px; padding: 1px 2px 2px;
  border: 1px solid #1a140e;
  border-radius: 12px;
  background: linear-gradient(180deg, #5e656d, #2e343a);
  color: #fff;
  text-align: center;
  box-shadow: inset 0 1px 0 #fff4, 0 1px 0 #0005;
}
.tool:hover { background: linear-gradient(180deg, #848b94, #4a5158); }
.tool.on {
  background: linear-gradient(180deg, #ffe978, #e2b000);
  border-color: #1a1400;
  box-shadow: inset 0 1px 0 #fff8, 0 0 0 2px #1a1400;
}
.tool:active { transform: scale(0.98); }

.pic {
  position: relative;
  width: 40px;
  height: 40px;
  flex: 0 0 40px;
  display: grid;
  place-items: center;
}
.rail .pic {
  width: 40px;
  height: 40px;
  flex: 0 0 auto;
  transform: scale(0.5);
  margin: -10px 0 -9px;
}
.pic.drive, .pic.roller {
  border-radius: 50%;
  box-shadow: inset 0 0 0 2px #1a140e, 0 2px 3px #0005;
}
.pic.drive {
  background:
    radial-gradient(circle at 50% 50%, #e87722 0 18%, #efe6d4 19% 54%, transparent 55%),
    repeating-conic-gradient(#3d362e 0 9deg, #1a1714 9deg 15deg);
}
.pic.roller {
  background:
    radial-gradient(circle at 50% 50%, #cfd6dc 0 16%, #efe6d4 17% 54%, transparent 55%),
    repeating-conic-gradient(#3d362e 0 9deg, #1a1714 9deg 15deg);
}
.pic.drive::before {
  content: "";
  position: absolute;
  top: 50%;
  width: 0;
  height: 0;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  transform: translateY(-50%);
  opacity: 0.92;
  pointer-events: none;
}
.pic.drive.r::before {
  right: 1px;
  border-left: 8px solid var(--yellow);
  filter: drop-shadow(-1px 0 0 #1a140e);
}
.pic.drive.l::before {
  left: 1px;
  border-right: 8px solid var(--yellow);
  filter: drop-shadow(1px 0 0 #1a140e);
}
.pic.drive::after {
  font-size: 11px; font-weight: 700; color: #1a1208;
}
.pic.drive.r::after { content: "R"; }
.pic.drive.l::after { content: "L"; }
.pic.steel::before {
  content: "";
  width: 34px; height: 14px;
  border-radius: 7px;
  background: linear-gradient(#f7f9fb, #9aa3ac);
  box-shadow: inset 0 1px 0 #fff, inset 0 -1px 0 #6a737c, 0 1px 2px #0005;
}
.pic.ghost::before {
  content: "";
  width: 34px; height: 14px;
  border-radius: 7px;
  border: 2px dashed #e87722;
  background: rgb(232 119 34 / 16%);
}
.pic.move::before {
  content: "";
  width: 18px; height: 18px;
  background:
    linear-gradient(var(--silver), var(--silver)) center/2px 18px no-repeat,
    linear-gradient(var(--silver), var(--silver)) center/18px 2px no-repeat;
}
.pic.erase::before {
  content: "";
  width: 22px; height: 14px;
  transform: skewX(-18deg);
  border-radius: 3px;
  background: linear-gradient(90deg, #e8c4b0, #d9a890 55%, #6a9ad4);
  box-shadow: 0 1px 2px #0004;
}
.pic.floor::before {
  content: "";
  width: 28px; height: 20px;
  border: 2px dashed #2a2e33;
  border-radius: 4px;
  background: repeating-linear-gradient(90deg, #eadcc3 0 4px, #dcc9a8 4px 8px);
}
.pic.drop::before {
  content: "";
  width: 28px; height: 20px;
  border: 2px dashed var(--orange);
  border-radius: 4px;
  background: rgb(232 119 34 / 22%);
}
.pic.slab::before {
  content: "";
  width: 30px; height: 12px;
  border-radius: 3px;
  background: linear-gradient(#8b929a, #5c636b);
  box-shadow: inset 0 1px 0 #c5ccd3, 0 1px 2px #0005;
}
.pic.crate::before {
  content: "";
  width: 24px; height: 24px;
  border-radius: 3px;
  background:
    linear-gradient(#0000, #0000) center/100% 2px no-repeat,
    repeating-linear-gradient(90deg, #c45c26 0 5px, #a84b1e 5px 6px);
  background-color: #c45c26;
  box-shadow: inset 0 0 0 2px #2a1a10, 0 1px 2px #0005;
  background-blend-mode: multiply, normal;
}
.pic.cog::before {
  content: "";
  width: 22px; height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, var(--plate) 0 28%, var(--silver) 30% 100%);
  box-shadow: 0 0 0 3px var(--silver), 0 1px 2px #0005;
}
.pic.site::before {
  content: "";
  width: 26px; height: 18px;
  border-radius: 3px;
  background: linear-gradient(#eadcc3 0 55%, #8b929a 55%);
  box-shadow: inset 0 0 0 2px #2a2e33;
}
.pic.clip::before {
  content: "";
  width: 18px; height: 24px;
  border-radius: 3px;
  background: var(--paper);
  box-shadow: inset 0 0 0 2px #2a2e33, 0 -3px 0 var(--silver);
}
.pic.tape::before {
  content: "";
  width: 26px; height: 18px;
  border-radius: 4px;
  background: var(--yellow);
  box-shadow: inset 0 0 0 2px #1a1400;
}
.pic.tape::after {
  content: "";
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: #2a2e33;
}

.lesson {
  position: absolute; top: 8px; right: 8px; left: auto;
  width: min(13.5rem, 36vw);
  background: rgb(243 238 228 / 92%);
  color: var(--ink);
  border: 1px solid var(--hair);
  border-radius: calc(var(--radius) + 6px);
  padding: 8px 10px 6px;
  z-index: 3;
  font-weight: 500;
  font-size: 12px;
  line-height: 1.35;
  pointer-events: none;
}
.lesson-kicker {
  margin: 0 0 4px;
  font-size: 10px; font-weight: 700;
  letter-spacing: .1em; text-transform: uppercase;
  color: var(--orange);
}
.lesson ol { margin: 0 0 6px; padding-left: 1.15rem; }
.lesson li { margin: 0 0 3px; }
.lesson li.ok { color: var(--ok); text-decoration: none; }
.lesson li.ok::marker { color: var(--ok); }
body[data-play="1"] .lesson { opacity: 0.86; }
body[data-play="1"] .lesson .hint { display: none; }

.rail-guide {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-top: 8px;
  border-top: 2px solid #0004;
}
.guide-line { display: none; }
.guide-drawer {
  position: fixed;
  left: calc(var(--rail) + 16px);
  top: 112px;
  bottom: auto;
  width: 16.5rem;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  background: var(--paper);
  color: #1a1400;
  border: 2px solid #1a1400;
  border-radius: 16px;
  box-shadow: 4px 4px 0 #1a1400;
  z-index: 8;
}
.guide-drawer .step {
  background: #fff;
  color: #1a1400;
  border-color: #1a140022;
}
.guide-drawer .step.on { background: var(--yellow); color: #1a1400; }
.guide-drawer .btn:not(.gold) {
  background: #fff;
  color: #1a1400;
  border-color: #1a140033;
}
.rail-guide { position: relative; }
.guide-steps { display: flex; flex-wrap: wrap; gap: 4px; }
.step {
  min-height: 32px; padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #0004;
  background: #0003;
  color: var(--text);
  font-weight: 700; font-size: 11px;
}
.step.on { background: var(--yellow); color: #1a1400; }

.hud {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  padding: 2px 8px;
  min-height: 48px;
  height: 48px;
  min-width: 0;
  overflow-x: auto;
  color: var(--text);
  background: #3c4148;
  border-bottom: 1px solid var(--hair);
  direction: ltr;
}
.brand {
  font-weight: 700; line-height: 1.05; flex: 0 0 auto;
  letter-spacing: -0.02em;
}
.brand small {
  display: block; font-weight: 600; color: var(--yellow);
  font-size: 10px; letter-spacing: .12em; text-transform: uppercase;
}
.rank {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1 1 8rem; max-width: 15rem;
}
.rank-name {
  font-size: 10px; font-weight: 700; color: var(--yellow);
  letter-spacing: .1em; text-transform: uppercase; white-space: nowrap;
}
.xp {
  flex: 1; height: 6px; min-width: 3rem;
  background: #2a2e33; border-radius: 999px; overflow: hidden;
}
.xp i {
  display: block; height: 100%; width: 0%;
  background: var(--yellow);
  transition: width var(--motion-fast) var(--ease-out);
}
.xp-n { font-size: 11px; font-weight: 600; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.hud-pick {
  min-width: 44px; min-height: 44px; flex: 0 1 10rem; max-width: 12rem;
  color: var(--text);
  appearance: none;
  background-color: #4a4f56;
  background-image: linear-gradient(45deg, transparent 50%, var(--muted) 50%),
    linear-gradient(135deg, var(--muted) 50%, transparent 50%);
  background-position: calc(100% - 14px) calc(50% - 3px), calc(100% - 9px) calc(50% - 3px);
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
  padding-right: 22px;
}
.hud-play { display: flex; gap: 6px; flex: 0 0 auto; position: relative; }
.coach-play {
  position: absolute;
  left: 4px;
  top: calc(100% + 4px);
  z-index: 6;
  background: var(--yellow);
  color: #1a1400;
  font-weight: 800;
  font-size: 12px;
  line-height: 1;
  padding: 5px 8px 6px;
  border-radius: 999px;
  pointer-events: none;
  box-shadow: 0 8px 16px -10px #000a;
}
.coach-play::before {
  content: "";
  position: absolute;
  left: 14px;
  top: -6px;
  border: 6px solid transparent;
  border-bottom-color: var(--yellow);
  border-top: 0;
}
#btn-play.nudge { box-shadow: 0 0 0 3px var(--yellow); }
body[data-coach="1"] #level-pick,
body[data-coach="1"] #rank,
body[data-coach="1"] #heat,
body[data-coach="1"] #btn-fill,
body[data-coach="1"] #btn-settings,
body[data-coach="1"] .status > span:not(#status-hint) { display: none !important; }
body[data-coach="1"] #status-hint {
  flex: 1;
  min-width: 0;
  font-size: 18px;
  font-weight: 700;
}
body[data-coach="1"] #guide,
body[data-coach="1"] .rail-tabs { display: none !important; }
#btn-crew { flex: 0 0 auto; }

.btn {
  background: linear-gradient(180deg, #6a7078, #3e444b);
  color: var(--text);
  border: 1px solid #1a140e;
  border-radius: 12px;
  padding: 7px 12px;
  font-weight: 700;
  font-size: 13px;
  min-height: 44px;
  min-width: 44px;
  white-space: nowrap;
  letter-spacing: 0.01em;
  box-shadow: inset 0 1px 0 #fff3;
  transition: background var(--motion-quick) var(--ease-out), transform var(--motion-quick) var(--ease-out);
}
.btn:hover { background: linear-gradient(180deg, #808890, #4a525a); }
.btn:active { transform: scale(0.98); }
.btn.on { box-shadow: inset 0 0 0 1px var(--yellow); }
.btn.gold { background: var(--yellow); color: #1a1400; border-color: #c9a000; }
.btn.gold:hover { background: #ffd21a; }
.btn.ok { background: #1f6b42; color: #fff; border-color: #185536; }
.btn.ok:hover { background: #258152; }
.btn.ghost { background: transparent; }
.btn.tight { min-height: 44px; min-width: 44px; padding: 6px 10px; border-radius: var(--radius-sm); }
.btn:disabled { opacity: .45; cursor: default; transform: none; }
.sheet-card .btn, .howto-card .btn {
  color: var(--text);
}
.sheet-card .btn.gold, .howto-card .btn.gold { color: #1a1400; }
.sheet-card a.btn, .howto-card a.btn,
.sheet-card .btn.ghost, .howto-card .btn.ghost {
  background: #ece4d6;
  color: var(--ink);
  border: 1px solid #c9bda8;
}
.sheet-card a.btn:hover, .howto-card a.btn:hover {
  background: #e0d4c2;
}
body:not([data-site="1"]) [data-layer="level"] { display: none !important; }
body:not([data-site="1"]) .rail-tabs { display: none; }
.row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.title {
  width: 100%; background: var(--paper); color: var(--ink);
  border: 1px solid #d9cbb3; border-radius: var(--radius); padding: 8px 10px; font-weight: 700;
  min-height: 44px; margin-bottom: 10px;
}
.title:focus-visible { outline-offset: 0; border-color: #c9a000; box-shadow: 0 0 0 2px var(--yellow); }
.crew-label { display: block; font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; margin: 8px 0 4px; color: #8a5a2b; }
.hint { font-size: 12px; color: var(--muted); }

/* Playfield stretch: the flat canvas fills the shop cell.
   No fixed 1280×760 box. No grey gutter. No 3D. */
.stage-fit {
  position: relative;
  min-width: 0;
  min-height: 0;
  display: grid;
  place-items: stretch;
  background-color: #d3c4ae;
  background-image:
    linear-gradient(180deg, #e7dcc8 0%, #d3c4ae 42%, #c4b49c 100%);
}
.stage {
  position: relative;
  min-width: 0;
  min-height: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #d9cbb8;
  touch-action: none;
}
#c { display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.wheel-drop {
  position: absolute;
  z-index: 6;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: #1a1400;
  cursor: pointer;
  touch-action: manipulation;
}
.wheel-drop[hidden] { display: none !important; }
.wheel-drop:focus { outline: none; }
.wheel-drop:focus-visible { outline: none; }
.wheel-drop:focus-visible .wheel-drop-ring {
  outline: 3px solid #2dd4bf;
  outline-offset: 3px;
  border-radius: 50%;
}
.wheel-drop-ring {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--ring, 48px);
  height: var(--ring, 48px);
  transform: translate(-50%, -50%);
  overflow: visible;
  pointer-events: none;
  animation: bb-ring-pulse 1.8s ease-in-out 2;
}
.wheel-drop-ico {
  position: absolute;
  left: 50%;
  top: 50%;
  width: var(--ring, 48px);
  height: var(--ring, 48px);
  transform: translate(-50%, -50%);
  display: grid;
  place-items: center;
  opacity: 0.6;
  pointer-events: none;
}
.wheel-drop-ico .pic {
  width: 72%;
  height: 72%;
  margin: 0;
  transform: none;
}
.wheel-drop-lab {
  position: absolute;
  left: 50%;
  top: calc(50% + (var(--ring, 48px) / 2) + 6px);
  transform: translateX(-50%);
  max-width: 220px;
  padding: 3px 8px;
  border: 2px solid #1a1400;
  border-radius: 10px;
  background: #f7f1e6;
  color: #1a1400;
  font-weight: 800;
  font-size: 13px;
  line-height: 1.2;
  white-space: nowrap;
  pointer-events: none;
}
@keyframes bb-ring-pulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); }
  50% { transform: translate(-50%, -50%) scale(1.06); }
}
@media (prefers-reduced-motion: reduce) {
  .wheel-drop-ring { animation: none; }
}

.btn[data-tool="driveR"],
.btn[data-tool="driveL"],
.btn[data-tool="roller"],
.tool[data-tool="driveR"],
.tool[data-tool="driveL"],
.tool[data-tool="roller"] { touch-action: none; }
.toast {
  position: absolute; top: 12px; left: 50%;
  transform: translateX(-50%) translateY(-6px);
  background: var(--paper); border: 1px solid var(--hair); color: var(--ink);
  padding: 8px 14px; border-radius: var(--radius-lg); font-weight: 600; z-index: 2;
  opacity: 0; pointer-events: none;
  transition: opacity var(--motion-fast) var(--ease-out), transform var(--motion-fast) var(--ease-out);
  box-shadow: 0 12px 28px -16px #0007;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.win {
  position: absolute;
  inset: auto 16px 16px auto;
  z-index: 5;
  display: none;
  width: min(16rem, calc(100% - 24px));
  padding: 0;
  background: none;
  pointer-events: none;
}
.win.show { display: block; }
.win-card {
  pointer-events: auto;
  width: min(26rem, 100%);
  background:
    linear-gradient(#3a7d54, #3a7d54) 0 0 / 100% 4px no-repeat,
    #f7f1e6;
  color: #241f18;
  border-radius: 16px;
  padding: 12px 16px 10px;
  box-shadow: 0 18px 40px -20px #000c;
}
.win-card h2 {
  margin: 0 0 4px;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  line-height: 1.1;
}
.win-card p { margin: 0 0 8px; font-size: 14px; font-weight: 600; line-height: 1.3; }
.win-card .btn { min-height: 44px; }
.win-card .howto-actions { margin: 0; }

.howto, .sheet {
  position: absolute; inset: 0;
  background: rgb(30 34 38 / 62%);
  display: grid; place-items: center;
  padding: 8px; z-index: 6;
  overflow: hidden;
}
#crew.sheet {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  padding: 0;
  direction: ltr;
  background: rgb(30 34 38 / 46%);
}
#crew .sheet-card {
  width: min(22rem, 88vw);
  max-width: 22rem;
  height: 100%;
  max-height: 100%;
  margin: 0;
  border-radius: 0 18px 18px 0;
  box-shadow: 12px 0 40px -18px #000c;
}
.howto { z-index: 8; }
#access.sheet {
  position: fixed;
  inset: 0;
  z-index: 31;
  display: flex;
  justify-content: flex-start;
  align-items: stretch;
  padding: 0;
  direction: ltr;
  background: rgb(30 34 38 / 46%);
}
#access .sheet-card {
  width: min(22rem, 88vw);
  max-width: 22rem;
  height: 100%;
  max-height: 100%;
  margin: 0;
  border-radius: 0 18px 18px 0;
  box-shadow: 12px 0 40px -18px #000c;
}
#access-close {
  position: sticky;
  top: 0;
  z-index: 2;
  min-height: 44px;
  min-width: 44px;
}
.howto[hidden], .sheet[hidden] { display: none !important; }
.howto-card, .sheet-card {
  width: min(32rem, 100%);
  max-height: 100%;
  overflow: auto;
  background:
    linear-gradient(var(--yellow), var(--yellow)) 0 0 / 100% 4px no-repeat,
    #f7f1e6;
  color: #241f18;
  border: 1px solid #e4d5bc;
  border-radius: 18px;
  padding: 12px 16px 10px;
  box-shadow: 0 28px 64px -32px #000c;
}
.howto-kicker {
  margin: 2px 0 8px;
  font-size: 11px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--orange);
}
#howto-demo {
  display: block; width: 100%; height: 148px;
  border-radius: 12px; background: #efe6d4;
  margin: 0 0 14px;
  box-shadow: inset 0 0 0 1px #e2d3b8;
}
.howto-card h2, .sheet-card h2 {
  margin: 0 0 8px;
  font-size: 1.45rem; font-weight: 700; letter-spacing: -0.03em; line-height: 1.15;
}
.howto-card p, .sheet-card p {
  margin: 0 0 12px;
  font-size: 15px; line-height: 1.45; font-weight: 500; color: #3a342c;
}
.howto-actions { justify-content: flex-end; margin-top: 4px; gap: 8px; position: sticky; bottom: 0; background: #f7f1e6; padding-top: 6px; }
.howto-card .btn, .sheet-card .btn { font-weight: 600; letter-spacing: 0.01em; border-radius: 12px; }
.sheet-card .row { margin-bottom: 8px; }
.ipof { margin: 0 0 12px; padding-left: 1.2rem; line-height: 1.45; }
.ipof li { margin: 0 0 8px; }
.systems-course { color: var(--ink); }
.sheet-card .hint { color: #4a5c6a; }
.path-done {
  list-style: none;
  margin: 0 0 10px;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.path-done li { margin: 0; }
.path-empty { font-size: 14px; font-weight: 600; color: #6b6256; }
.path-link, .path-next, #btn-more {
  width: 100%;
}
.path-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid #c9bda8;
  background: #fff;
  color: #241f18;
  font-weight: 600;
  font-size: 13px;
}
.path-link::before { content: "✓"; color: var(--ok); font-weight: 700; }
.path-next { margin-bottom: 8px; }
#btn-more { margin-bottom: 8px; }
#menu-more { margin-bottom: 8px; }
.menu-guide {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.4;
  color: #241f18;
}
.menu-steps { margin-bottom: 8px; }
.menu-steps .step {
  background: #fff;
  color: #241f18;
  border-color: #e2d3b8;
}
.menu-card .crew-label { margin-top: 4px; }
.menu-plate {
  margin: 0 0 8px;
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.15;
  color: #1a1400;
}
.menu-plate b {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  letter-spacing: 0.08em;
  color: #c2410c;
}
.menu-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  width: 100%;
  min-height: 44px;
  margin: 0 0 8px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #1a140e;
  background: #fff;
  color: #1a1400;
  font-weight: 800;
  font-size: 16px;
  line-height: 1.25;
  text-align: left;
}
.menu-row strong {
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #c2410c;
}
.menu-row span { font-weight: 700; font-size: 15px; }
html[dir="rtl"] .menu-row,
html[dir="rtl"] .menu-plate { direction: rtl; text-align: right; align-items: flex-end; }
.menu-card .row .btn { flex: 1 1 auto; }

.status {
  grid-column: 1 / -1;
  min-width: 0;
  display: flex; align-items: center; gap: 14px;
  padding: 0 12px;
  background: #2a2e33;
  color: #f7f4ee;
  font-size: 12px; font-weight: 600;
  min-height: 28px;
  overflow: hidden;
  border-top: 2px solid var(--yellow);
}
.status .hint { color: #f7f4ee; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.whats-new {
  flex: 0 1 auto;
  min-width: 0;
  color: var(--yellow);
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.status .whats-new {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.status b { color: var(--yellow); font-variant-numeric: tabular-nums; }
#mode {
  font-size: 10px; font-weight: 700; letter-spacing: .12em;
  text-transform: uppercase; color: var(--yellow);
}
a { color: var(--orange); }

#rotate-gate {
  display: none;
  position: fixed; inset: 0; z-index: 80;
  width: 100%;
  height: 100dvh;
  background: var(--plate);
  background-image: var(--plate-img);
  background-size: 18px 32px;
  color: var(--paper);
  place-items: center;
  align-content: center;
  text-align: center;
  padding: 28px 20px;
  gap: 12px;
}
.rotate-icon { width: 72px; height: 72px; color: var(--yellow); }
#rotate-gate h1 { margin: 0; font-size: 1.6rem; }
#rotate-gate p { margin: 0; max-width: 28rem; line-height: 1.4; font-weight: 600; }
.rotate-kicker {
  font-size: 12px; font-weight: 700;
  color: var(--ink); background: var(--yellow); padding: 4px 10px; border-radius: 999px;
}

#rotate-gate { display: none !important; }
#app { visibility: visible; pointer-events: auto; }
/* One ☰. The shop Menu stays top-left. The Hub bar must not add a second one. */
html:not(.kb-framed) .kb-bar { display: none !important; }
html:not(.kb-framed) body.kb-on { padding-top: 0 !important; }
#btn-crew.kb-menu-dupe { display: inline-flex !important; }

@media (orientation: portrait) and (max-width: 900px) {
  #rotate-gate { display: none !important; }
  #app { visibility: visible; pointer-events: auto; }
}

@media (min-height: 640px) {
  .tool { height: auto; min-height: 62px; padding: 4px 2px 5px; }
  .rail .pic { transform: scale(0.78); margin: -2px 0 0; }
  .rail .lbl { font-size: 12px; line-height: 1.1; }
}
@media (hover: none) {
  .rail,
  .rail:hover,
  .rail:focus-within,
  .rail.open { width: var(--rail); max-width: var(--rail); }
  .role { display: none; }
  .btn, .role-btn, .tool { min-height: 44px; }
}

@media (max-width: 1100px) {
  .hud { gap: 6px; padding: 2px 8px; min-height: 48px; height: 48px; }
  .hud-pick {
    flex: 1 1 6.5rem;
    max-width: 10rem;
    min-height: 44px;
    min-width: 44px;
    padding: 6px 8px;
    font-size: 13px;
  }
  .hud-play .btn, #btn-crew { min-height: 44px; min-width: 44px; }
}

@media (max-height: 520px) {
  .howto, .sheet { padding: 4px; }
  .howto-card, .sheet-card { padding: 8px 12px 8px; border-radius: 14px; }
  .howto-kicker { margin: 0 0 2px; }
  #howto-demo { height: 72px; margin-bottom: 6px; }
  .howto-card h2, .sheet-card h2 { font-size: 1.05rem; margin-bottom: 4px; }
  .howto-card p, .sheet-card p { font-size: 13px; line-height: 1.3; margin-bottom: 4px; }
  .job-strip { padding: 4px 6px; }
}

@media (max-width: 860px) {
  :root { --rail: 76px; }
  .hud-pick { max-width: 8.5rem; }
  .lesson { width: min(11rem, 34vw); padding: 6px 8px 4px; font-size: 11px; top: 6px; right: 6px; }
  .role { display: none; }
  .tool { min-height: 44px; min-width: 44px; padding: 2px 4px; }
  .pic { width: 36px; height: 36px; flex-basis: 36px; }
  .status .hint { max-width: 42vw; }
}

@media (prefers-reduced-motion: reduce) {
  .rail, .rail .lbl, .chev, .btn, .toast, .xp i, .tool { transition: none; }
  .btn:active, .tool:active { transform: none; }
}

body[data-embed="1"] #rotate-gate { display: none; }
body[data-embed="1"] .howto { display: none !important; }
body[data-embed="1"] .rank { display: none; }
body[data-embed="1"] .hud { min-height: 44px; }

.heat {
  display: grid; place-items: center;
  width: 44px; height: 44px; min-height: 44px; padding: 0;
  flex: 0 0 44px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #6a7078, #3e444b 62%, #2e3338);
  border: 1px solid #1c2024;
  box-shadow: inset 0 1px 0 #ffffff2e;
}
.heat-k {
  position: absolute;
  width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0);
}
.heat strong { font-size: 15px; font-weight: 700; color: var(--paper); line-height: 1; font-variant-numeric: tabular-nums; }
.heat-u { font-size: 11px; font-weight: 500; color: var(--muted); }
.role {
  position: absolute; left: 10px; bottom: 12px; z-index: 3;
  display: flex; gap: 4px; pointer-events: auto;
  padding: 3px;
  background: rgb(30 34 38 / 55%);
  border-radius: 999px;
  border: 1px solid #0003;
}
.role-btn {
  min-height: 44px; min-width: 44px; padding: 6px 12px;
  border-radius: 999px; font-weight: 600; font-size: 12px; letter-spacing: .02em;
  background: transparent; color: var(--text); border: 0;
}
.role-btn.on { background: var(--yellow); color: #1a1400; }
html[dir="rtl"] body,
html[dir="rtl"] #app,
html[dir="rtl"] .hud,
html[dir="rtl"] .rail,
html[dir="rtl"] .shop,
html[dir="rtl"] .stage,
html[dir="rtl"] .job-strip,
html[dir="rtl"] #crew.sheet,
html[dir="rtl"] #access.sheet,
html[dir="rtl"] canvas {
  direction: ltr;
}
html[dir="rtl"] .lbl,
html[dir="rtl"] .job-name,
html[dir="rtl"] .race-k,
html[dir="rtl"] #status-hint,
html[dir="rtl"] .sheet-card,
html[dir="rtl"] .whats-new,
html[dir="rtl"] .menu-lead,
html[dir="rtl"] .guide-line,
html[dir="rtl"] .curr-line,
html[dir="rtl"] .howto-card,
html[dir="rtl"] #rotate-gate,
html[dir="rtl"] .brand {
  direction: rtl;
}
@media (max-width: 1100px) {
  .heat { min-height: 40px; padding: 4px 8px; }
  .heat-u { display: none; }
}

/* BB 0.19.35 — phone bar: Stop stays on screen. Desktop and 915-wide unchanged. */
@media (max-width: 480px) {
  html, body, #app { max-width: 100%; }
  .hud {
    gap: 4px;
    padding: 2px 6px;
    overflow-x: hidden;
  }
  .brand {
    min-width: 0;
    flex: 1 1 auto;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }
  #btn-settings,
  #heat,
  #level-pick,
  #rank,
  .status .whats-new { display: none !important; }
  .hud-play { gap: 4px; min-width: 0; }
  .hud-play .btn {
    width: 44px;
    height: 44px;
    min-width: 44px;
    min-height: 44px;
    max-width: 44px;
    padding: 0;
    flex: 0 0 44px;
  }
  .hud-play .lbl {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
  }
  .menu-btn { min-width: 44px; min-height: 44px; flex: 0 0 auto; }
}

.lesson .hint { color: #4a5c6a; }
.lesson-kicker { color: #8a3412; }

/* BB 0.19.38 — upright phone only. Wider layouts stay as they are. */
@media (max-width: 699px) {
  .status {
    height: auto;
    min-height: 44px;
    align-items: center;
    overflow: visible;
    padding: 8px 12px calc(8px + env(safe-area-inset-bottom, 0px));
  }
  .status .hint,
  body[data-coach="1"] #status-hint {
    flex: 1 1 auto;
    min-width: 0;
    max-width: none;
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    font-size: 16px;
    line-height: 1.3;
    color: #f7f4ee;
  }
}
