/* PROTOTYPE - NOT FOR PRODUCTION
   Question: (not set)
   Date: 2026-11-14 */
:root {
  --ink: #23303b;
  --ink-soft: #55636f;
  --panel: rgba(255, 255, 255, 0.88);
  --line: rgba(35, 48, 59, 0.14);
  --accent: #2f8f5b;
  --accent-ink: #ffffff;
  --danger: #c93a32;
  --gold: #e9a91a;
  --radius: 14px;
  --gap: 12px;
  /* Room for a tablet's rounded corners and home bar. */
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  font-family: ui-rounded, "Nunito", "Quicksand", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  background: linear-gradient(#6fbdec 0%, #bfe6f8 52%, #e9f6df 100%);
  -webkit-user-select: none;
  user-select: none;
  /* A game screen: fingers move the camera, never the page. */
  touch-action: none;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
  cursor: grab;
}
#scene.place { cursor: crosshair; }
#scene.pick { cursor: copy; }
#scene.erase { cursor: not-allowed; }
#scene.walk { cursor: none; }

#crosshair {
  position: fixed;
  left: 50%;
  top: 50%;
  width: 18px;
  height: 18px;
  margin: -9px 0 0 -9px;
  pointer-events: none;
  display: none;
  background:
    linear-gradient(#fff, #fff) center / 2px 100% no-repeat,
    linear-gradient(#fff, #fff) center / 100% 2px no-repeat;
  filter: drop-shadow(0 0 2px rgba(0, 0, 0, 0.8));
}
body.walking #crosshair { display: block; }

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(35, 48, 59, 0.12);
}

button {
  font: inherit;
  font-weight: 700;
  color: var(--ink);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
}
button:hover { background: #f1f6f9; }
button:active { transform: translateY(1px); }
button:disabled { opacity: 0.45; cursor: default; }
button:focus-visible, .slot:focus-visible, input:focus-visible { outline: 3px solid #1d6fd1; outline-offset: 2px; }
button.primary { background: var(--accent); color: var(--accent-ink); border-color: transparent; }
button.primary:hover { background: #277a4d; }
[hidden] { display: none !important; }

/* Top bar */
.top {
  position: fixed;
  top: calc(var(--gap) + var(--safe-t));
  left: calc(var(--gap) + var(--safe-l));
  right: calc(var(--gap) + var(--safe-r));
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: var(--gap);
  pointer-events: none;
}
.top > * { pointer-events: auto; }

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px 8px 14px;
  flex-wrap: wrap;
}
.brand h1 { margin: 0; font-size: 20px; letter-spacing: 0.2px; }

.seg { display: flex; background: #e8eef2; border-radius: 10px; padding: 3px; gap: 2px; }
.seg button { border: 0; background: transparent; padding: 6px 10px; color: var(--ink-soft); }
.seg button[aria-pressed="true"] { background: #fff; color: var(--ink); box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15); }

.stats {
  display: grid;
  grid-template-columns: repeat(3, auto);
  column-gap: 18px;
  row-gap: 6px;
  padding: 8px 14px 10px;
  max-width: 330px;
}
.stat { display: flex; flex-direction: column; }
.stat .label { font-size: 12px; color: var(--ink-soft); white-space: nowrap; }
.stat .value { white-space: nowrap; font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; }
#stat-errors.bad { color: var(--danger); }
.bar { grid-column: 1 / -1; height: 8px; background: #dfe7ec; border-radius: 99px; overflow: hidden; }
#bar-fill { height: 100%; width: 0; background: var(--accent); border-radius: 99px; transition: width 0.2s ease; }
.goals { grid-column: 1 / -1; list-style: none; margin: 2px 0 0; padding: 0; display: grid; gap: 2px; font-size: 13px; font-weight: 700; }
.goals li::before { content: "★ "; color: var(--gold); }
.goals li.lost { color: var(--ink-soft); text-decoration: line-through; }
.goals li.lost::before { content: "☆ "; color: var(--ink-soft); }
.meta { grid-column: 1 / -1; margin: 2px 0 0; font-size: 12px; color: var(--ink-soft); }

/* Memory banner and tutorial bubble */
.phase, .coach {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  font-weight: 800;
  max-width: min(560px, calc(100vw - 2 * var(--gap)));
}
.phase { top: 150px; background: #fff7dc; border-color: #e3c768; font-variant-numeric: tabular-nums; }
.coach { top: 96px; flex-wrap: wrap; background: #fff; border: 2px solid var(--accent); }
.coach p { margin: 0; flex: 1 1 260px; font-weight: 700; }
.coach .step { font-size: 12px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.row { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }

/* Bottom */
.help {
  position: fixed;
  left: calc(var(--gap) + var(--safe-l));
  bottom: calc(var(--gap) + var(--safe-b));
  padding: 8px 12px;
  font-size: 13px;
  color: var(--ink-soft);
}
.help p { margin: 2px 0; }
.help b { color: var(--ink); }
.help > div { display: none; }
body:not(.touch):not(.walking) .help .orbit.mouse,
body:not(.touch).walking .help .foot.mouse,
body.touch:not(.walking) .help .orbit.finger { display: block; }
body.touch.walking .help { display: none; }

.tools {
  position: fixed;
  right: calc(var(--gap) + var(--safe-r));
  bottom: calc(var(--gap) + var(--safe-b));
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.tools button { padding: 9px 14px; text-align: left; }

.hotbar {
  position: fixed;
  left: 50%;
  bottom: calc(var(--gap) + var(--safe-b));
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  padding: 8px;
  max-width: calc(100vw - 2 * var(--gap));
}
.slot {
  position: relative;
  width: 58px;
  padding: 4px 4px 3px;
  border: 2px solid transparent;
  border-radius: 10px;
  background: transparent;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 11px;
  font-weight: 700;
  color: var(--ink-soft);
}
.slot img, .slot .eraser {
  width: 44px;
  height: 44px;
  border-radius: 7px;
  display: block;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}
.slot .eraser {
  background: #fff;
  border: 2px dashed var(--danger);
  color: var(--danger);
  font-size: 26px;
  line-height: 40px;
  text-align: center;
  box-shadow: none;
}
.slot kbd {
  position: absolute;
  top: 1px;
  left: 3px;
  font: inherit;
  font-size: 10px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  padding: 0 3px;
  color: var(--ink);
}
.slot[aria-pressed="true"] { border-color: var(--ink); background: #fff; color: var(--ink); }

.toast {
  position: fixed;
  left: 50%;
  top: 212px;
  transform: translate(-50%, -8px);
  background: rgba(35, 48, 59, 0.92);
  color: #fff;
  padding: 8px 14px;
  border-radius: 99px;
  font-weight: 700;
  font-size: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: calc(100vw - 2 * var(--gap));
  text-align: center;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.nogl {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  margin: 0;
  padding: 16px 20px;
  max-width: 420px;
  text-align: center;
  font-weight: 700;
}

/* Win */
.win {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(35, 48, 59, 0.28);
}
.card { padding: 20px 26px 22px; text-align: center; background: #fff; max-width: min(620px, 92vw); }
.card h2 { margin: 0; font-size: 34px; color: var(--accent); }
.card p { margin: 4px 0; }
.stars { font-size: 54px; line-height: 1; letter-spacing: 6px; margin: 6px 0 8px !important; }
.star { display: inline-block; color: #d9dfe4; transform: scale(0.8); transition: transform 0.35s cubic-bezier(0.3, 1.6, 0.5, 1), color 0.2s ease; }
.star.on { color: var(--gold); transform: scale(1); text-shadow: 0 2px 0 #b97f0c; }
.win-goals { list-style: none; margin: 0 0 8px; padding: 0; display: grid; gap: 3px; font-weight: 700; text-align: left; }
.win-goals .ok { color: var(--ink); }
.win-goals .ko { color: var(--ink-soft); }
.recap { font-size: 13px; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.record { font-weight: 800; }
.card .row { margin-top: 14px; }

.confetti {
  position: fixed;
  top: -12px;
  width: 10px;
  height: 14px;
  border-radius: 2px;
  pointer-events: none;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translate(var(--dx), 105vh) rotate(var(--rot)); }
}

/* Menu */
.menu {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 18px 22px 20px;
  width: min(560px, calc(100vw - 24px));
  max-height: calc(100vh - 24px);
  color: var(--ink);
  background: #fff;
  box-shadow: 0 20px 60px rgba(35, 48, 59, 0.35);
  -webkit-user-select: text;
  user-select: text;
  touch-action: pan-y;
  overscroll-behavior: contain;
}
.menu::backdrop { background: rgba(35, 48, 59, 0.35); }
.menu-head { display: flex; justify-content: space-between; align-items: center; }
.menu h2 { margin: 0; font-size: 24px; }
.menu h3 { margin: 18px 0 8px; font-size: 15px; border-bottom: 2px solid #e8eef2; padding-bottom: 4px; }
.menu .line { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0; }
.menu label, .menu .lbl { font-weight: 700; }
.menu .line > label:first-child, .menu .lbl { min-width: 78px; }
.menu input[type="number"], .menu input[type="text"] {
  font: inherit;
  padding: 7px 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  min-width: 0;
}
.menu input[type="number"] { width: 120px; }
.menu input[type="text"] { flex: 1 1 180px; color: var(--ink-soft); }
.menu input[type="range"] { flex: 1 1 180px; accent-color: var(--accent); }
.menu input[type="checkbox"] { accent-color: var(--accent); width: 16px; height: 16px; vertical-align: -2px; }
.note { font-size: 13px; font-weight: 400; color: var(--ink-soft); margin: 4px 0; }
.records { width: 100%; border-collapse: collapse; font-size: 14px; font-variant-numeric: tabular-nums; }
.records th, .records td { text-align: left; padding: 4px 6px; border-bottom: 1px solid #eef2f5; }
.records thead th { font-size: 12px; color: var(--ink-soft); }
.records td:last-child { color: var(--gold); letter-spacing: 2px; }

@media (max-width: 1000px) {
  .help { display: none; }
  .brand h1 { font-size: 16px; }
  .stats { column-gap: 10px; padding: 6px 10px 8px; }
  .stat .value { font-size: 16px; }
  .slot { width: 44px; }
  .slot img, .slot .eraser { width: 34px; height: 34px; }
  .slot .eraser { line-height: 30px; font-size: 20px; }
  .slot span.name { display: none; }
  .tools { bottom: 84px; }
  .phase { top: auto; bottom: 150px; }
  .coach { top: auto; bottom: 150px; }
  .toast { top: auto; bottom: 230px; }
}

@media (max-width: 480px) {
  .top { flex-direction: column; align-items: stretch; gap: 6px; }
  .brand { gap: 6px; padding: 6px 8px; }
  .brand button { padding: 6px 8px; }
  .stats { grid-template-columns: repeat(3, 1fr); max-width: none; }
  .stat { flex-direction: row; align-items: baseline; gap: 6px; }
  .goals, .meta { display: none; }
  .hotbar { gap: 2px; padding: 4px; }
  .slot { width: 33px; padding: 2px; }
  .slot img, .slot .eraser { width: 26px; height: 26px; }
  .slot .eraser { line-height: 22px; font-size: 16px; }
  .slot kbd { display: none; }
  .tools { flex-direction: row; flex-wrap: wrap; left: var(--gap); bottom: 54px; justify-content: center; }
  .tools button { padding: 7px 9px; font-size: 13px; }
  .phase, .coach { bottom: 140px; }
}

@media (max-height: 600px) {
  .tools { display: grid; grid-template-columns: repeat(2, auto); gap: 4px; }
  .tools button { padding: 6px 10px; font-size: 13px; }
  .goals { font-size: 12px; }
  .meta { display: none; }
}

/* Touch (tablet): targets a finger can hit, the walk stick, no keyboard hints. */
.pad { display: none; }
body.touch button { min-height: 44px; padding: 10px 14px; }
body.touch .seg button { padding: 8px 12px; min-height: 40px; }
body.touch .slot { min-height: 0; padding: 4px 4px 3px; }
body.touch .slot kbd { display: none; }
body.touch .slot img { pointer-events: none; -webkit-user-drag: none; }
body.touch .tools { gap: 8px; }
body.touch .tools button { padding: 10px 16px; }
body.touch .menu input[type="checkbox"] { width: 22px; height: 22px; vertical-align: -5px; }
body.touch .menu input[type="range"] { min-height: 32px; }
body.touch .menu input[type="number"], body.touch .menu input[type="text"] { min-height: 44px; font-size: 16px; }
body.touch #scene, body.touch #scene.place, body.touch #scene.pick, body.touch #scene.erase { cursor: default; }

body.touch.walking .pad { display: block; }
.stick {
  position: fixed;
  left: calc(22px + var(--safe-l));
  bottom: calc(104px + var(--safe-b));
  width: 132px;
  height: 132px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.34);
  border: 2px solid rgba(255, 255, 255, 0.8);
  box-shadow: 0 4px 14px rgba(35, 48, 59, 0.25);
  touch-action: none;
}
.knob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 58px;
  height: 58px;
  margin: -29px 0 0 -29px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(35, 48, 59, 0.35);
  pointer-events: none;
}
body.touch button.jump {
  position: fixed;
  right: calc(22px + var(--safe-r));
  bottom: calc(104px + var(--safe-b));
  width: 92px;
  height: 92px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.86);
  border: 2px solid rgba(255, 255, 255, 0.9);
  box-shadow: 0 4px 14px rgba(35, 48, 59, 0.25);
  touch-action: none;
}
body.touch button.jump:active { transform: scale(0.94); background: #fff; }
/* On foot the right thumb jumps: the tools move up, out of its way. */
body.touch.walking .tools { bottom: calc(214px + var(--safe-b)); }

@media (min-width: 700px) and (min-height: 600px) {
  body.touch .slot { width: 60px; }
  body.touch .slot img, body.touch .slot .eraser { width: 48px; height: 48px; }
  body.touch .slot .eraser { line-height: 44px; font-size: 26px; }
  body.touch .hotbar { gap: 4px; }
  body.touch .tools { bottom: calc(96px + var(--safe-b)); }
  /* The top bar wraps on two rows with finger-sized buttons: messages sit below it. */
  body.touch .coach, body.touch .phase { top: calc(206px + var(--safe-t)); bottom: auto; }
  body.touch .toast { top: calc(292px + var(--safe-t)); bottom: auto; }
}
@media (min-width: 1001px) and (min-height: 600px) {
  body.touch .coach, body.touch .phase { top: calc(150px + var(--safe-t)); }
  body.touch .toast { top: calc(236px + var(--safe-t)); }
}
/* The wider block bar needs the room: the tutorial teaches the gestures instead. */
@media (max-width: 1279px) {
  body.touch .help { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  #bar-fill, .toast, .star { transition: none; }
}
