/* --- Tokens ---------------------------------------------------------- */
:root {
  --bg-0: #0b0d12;
  --bg-1: #11141a;
  --bg-2: #181c25;
  --line: #262b35;
  --line-soft: #1c202a;
  --text:  #e8ebf2;
  --muted: #8a90a0;
  --accent: #6ea8ff;
  --accent-soft: rgba(110, 168, 255, 0.18);
  --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.45), 0 2px 6px rgba(0, 0, 0, 0.35);
  --radius: 12px;
  --radius-sm: 8px;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background:
    radial-gradient(1200px 600px at 50% -10%, rgba(110, 168, 255, 0.08), transparent 60%),
    var(--bg-0);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
}

body {
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* --- Header --------------------------------------------------------- */
header {
  text-align: center;
  padding: 0.9rem 1rem 0.3rem;
  max-width: 720px;
}

header h1 {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.01em;
}

header .subtitle {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  max-width: 56ch;
}

/* --- Controls strip ------------------------------------------------- */
.controls {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.35rem 0.7rem;
  padding: 0.55rem 1rem;
  max-width: 760px;
}

.control-group {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
}

.release-presentation .controls {
  gap: 0.5rem;
  padding: 0.65rem 1rem 0.5rem;
}

.release-presentation .primary-flow {
  position: relative;
  padding: 0.45rem 0.65rem;
  border: 1px solid rgba(110, 168, 255, 0.34);
  border-radius: 999px;
  background: rgba(110, 168, 255, 0.08);
}

.release-presentation .primary-flow::before {
  content: attr(data-step);
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 999px;
  background: var(--accent);
  color: #07162c;
  font: 700 0.7rem var(--mono);
}

.flow-arrow { align-self: center; color: var(--muted); }

.box-task-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.5rem;
  max-width: 760px;
  padding: 0.25rem 1rem 0.75rem;
}
.box-task-controls button {
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #07162c;
  padding: 0.5rem 0.85rem;
  font: 600 0.8rem var(--sans);
  cursor: pointer;
}
.box-task-controls button.secondary { background: var(--bg-2); color: var(--text); border-color: var(--line); }
.box-task-controls button:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.box-task-controls button:disabled { opacity: 0.5; cursor: default; }
#task-status { display: block; text-align: center; font-size: 0.75rem; color: var(--text); }
#skill-decision-status { display: block; text-align: center; font: 500 0.65rem var(--mono); color: #a7c9ff; opacity: 0.78; }
.mode-box-task, .mode-box-carry, .mode-turn { background: rgba(38, 152, 80, 0.78); color: #f0fff4; }

.control-label {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 0.15rem;
}

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.4em;
  height: 1.5em;
  padding: 0 0.45em;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 5px;
  background: linear-gradient(180deg, var(--bg-2), var(--bg-1));
  color: var(--text);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  user-select: none;
}

/* --- Stage (the canvas card) --------------------------------------- */
.stage {
  position: relative;
  display: flex;
  justify-content: center;
  padding: 0.35rem;
  margin: 0 1rem;
  border-radius: var(--radius);
  background: var(--bg-1);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--line-soft);
}

.player-hud {
  position: absolute;
  left: 50%;
  bottom: 0.9rem;
  z-index: 6;
  width: min(88%, 34rem);
  transform: translateX(-50%);
  padding: 0.45rem 0.7rem;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(7, 10, 16, 0.72);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(7px);
  pointer-events: none;
}

canvas {
  display: block;
  border-radius: calc(var(--radius) - 4px);
  background: #0e1218;
  aspect-ratio: 3 / 2;
  max-width: 100%;
  max-height: calc(100vh - 250px);
  height: auto;
  width: auto;
}

/* --- Mode badge ----------------------------------------------------- */
#mode-badge {
  position: absolute;
  top: 0.9rem;
  left: 0.9rem;
  padding: 0.25rem 0.7rem;
  border-radius: 999px;
  font-family: var(--mono);
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  z-index: 5;
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.35);
}
.mode-idle         { background: rgba(60, 65, 80, 0.7);   color: #c8cee0; }
.mode-loco         { background: rgba(40, 90, 170, 0.78);  color: #e8efff; }
.mode-hoi-full     { background: rgba(38, 152, 80, 0.78);  color: #f0fff4; }
.mode-hoi-obj-only { background: rgba(196, 142, 28, 0.85); color: #1c1207; }
.mode-recover      { background: rgba(196, 60, 60, 0.88);  color: #fff2f2; }
.mode-paused       { background: rgba(112, 76, 25, 0.9); color: #fff3d8; }

/* --- Info panel ----------------------------------------------------- */
.info-panel {
  position: absolute;
  right: 0.8rem;
  bottom: 0.8rem;
  margin: 0;
  padding: 0.55rem 0.75rem;
  min-width: 14em;
  background: rgba(11, 13, 18, 0.72);
  backdrop-filter: blur(6px);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: var(--radius-sm);
  color: #d8dde9;
  font-family: var(--mono);
  font-size: 0.7rem;
  line-height: 1.45;
  white-space: pre;
  pointer-events: none;
  z-index: 5;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}

.info-panel[hidden] { display: none; }

/* --- Status text & footer ------------------------------------------ */
.control-group[hidden] { display: none; }
.control-mode-note {
  margin: 0.2rem auto 0.55rem;
  padding: 0 1rem;
  max-width: 56rem;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.5;
  text-align: center;
}

.status {
  font-family: var(--mono);
  font-size: 0.72rem;
  color: var(--muted);
  padding: 0.55rem 1rem 0.2rem;
  text-align: center;
}

footer {
  margin-top: auto;
  padding: 0.6rem 1rem 1rem;
  text-align: center;
  font-size: 0.72rem;
  color: var(--muted);
}

footer a {
  color: var(--accent);
  text-decoration: none;
  transition: color 120ms ease;
}
footer a:hover { color: #9fc4ff; text-decoration: underline; }

/* --- Responsive ----------------------------------------------------- */
@media (max-width: 640px) {
  header h1 { font-size: 1.1rem; }
  header .subtitle { font-size: 0.78rem; }
  .controls { gap: 0.3rem 0.45rem; padding: 0.4rem 0.6rem; }
  .key { font-size: 0.68rem; }
  .info-panel { display: none; } /* save space on phones */
}
