/* yamtam arcade: standalone dark styling for the hub and mini-games.
   No main-site CSS dependency; layout must hold from portrait phone to
   landscape desktop. */

:root {
  --bg: #111827;
  --panel: #1c2536;
  --panel-2: #242f45;
  --line: #32405c;
  --text: #e8edf5;
  --muted: #93a0b8;
  --accent: #ffd23f;
  --right: #2f9e44;
  --wrong: #c92a2a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Arial, sans-serif;
  display: flex;
  flex-direction: column;
}

#arcade {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#arcade,
.wl {
  overflow-y: auto;
}

a {
  color: var(--accent);
}

[hidden] {
  display: none !important;
}

/* ---------- hub ---------- */

/* ---------- back-to-map nav bar ---------- */

.arcade-nav {
  flex: none;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.arcade-back {
  color: var(--text);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 5px 10px;
}

.arcade-back:active {
  transform: scale(0.97);
}

.arcade-brand {
  font-weight: 800;
  letter-spacing: 0.02em;
}

.hub-head {
  padding: 14px 16px 4px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.streak-banner {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 0.95rem;
  margin-bottom: 6px;
}

.best-line {
  color: var(--muted);
  font-size: 0.85rem;
  padding: 2px 2px 6px;
}

.hub-actions {
  padding: 2px 0 8px;
}

/* ---------- Line Match ---------- */

.lm {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

.lm-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 5px;
  width: min(100%, 60vh, 460px);
}

.lm-cell {
  aspect-ratio: 1;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
}

.lm-cell .arcade-badge {
  font-size: 0.8rem;
  min-width: 1.9em;
  height: 1.9em;
}

.lm-cell.sel {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

.lm-cell.nope {
  outline: 2px solid var(--wrong);
}

.lm-cell.pop {
  background: rgba(255, 210, 63, 0.35);
}

.lm-status {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 6px 0 max(8px, env(safe-area-inset-bottom));
  text-align: center;
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
  padding: 12px 16px 32px;
  max-width: 860px;
  margin: 0 auto;
  width: 100%;
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.card h3 {
  margin: 0;
  font-size: 1.15rem;
}

.card-tags {
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.card-stats {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.card-btns {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card.upcoming {
  opacity: 0.55;
}

/* ---------- buttons ---------- */

button {
  font: inherit;
  color: var(--text);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 9px;
  padding: 9px 14px;
  cursor: pointer;
}

button:active {
  transform: scale(0.97);
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1c2333;
  font-weight: 700;
}

button:disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---------- game frame ---------- */

.game-mount {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.frame {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.frame-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.frame-quit {
  padding: 6px 10px;
}

.frame-title {
  font-weight: 700;
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.frame-score {
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--accent);
}

.frame-pause {
  padding: 6px 10px;
}

.frame-body {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.pause-veil {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 29, 0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 800;
  z-index: 5;
}

.loading {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

/* ---------- game-over panel ---------- */

.over-panel {
  position: absolute;
  inset: 0;
  background: rgba(11, 17, 29, 0.88);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 20px;
  z-index: 6;
  overflow-y: auto;
}

.over-panel h2 {
  margin: 0;
  font-size: 1.3rem;
  color: var(--muted);
}

.over-score {
  font-size: 2.6rem;
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.over-line {
  margin: 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.over-line.daily {
  font-size: 0.85rem;
}

.over-top10 {
  list-style: none;
  margin: 8px 0 0;
  padding: 0;
  width: min(320px, 100%);
}

.over-top10 li {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.9rem;
  color: var(--muted);
}

.over-top10 li b {
  font-variant-numeric: tabular-nums;
}

.over-top10 li.you {
  background: var(--panel-2);
  color: var(--accent);
}

.over-btns {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

/* ---------- badges ---------- */

.arcade-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 2.1em;
  height: 2.1em;
  padding: 0 0.45em;
  border-radius: 999px;
  color: #fff;
  font-weight: 800;
  font-size: 1rem;
  line-height: 1;
}

.arcade-badge.subway {
  border-radius: 50%;
  min-width: 2.1em;
  padding: 0;
}

/* ---------- Train Snake ---------- */

.snake-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  touch-action: none;
  background: #0b111d;
}

.snake-stage canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.stage-toggle {
  align-self: center;
  margin: 8px 0 max(8px, env(safe-area-inset-bottom));
  font-size: 0.8rem;
  padding: 6px 10px;
  color: var(--muted);
}

.dpad {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  z-index: 4;
  opacity: 0.85;
}

.dpad-row {
  display: flex;
  gap: 34px;
}

.dpad button {
  width: 46px;
  height: 46px;
  padding: 0;
  border-radius: 10px;
  font-size: 1.1rem;
  background: rgba(36, 47, 69, 0.9);
  touch-action: none;
}

/* ---------- What Line? ---------- */

.wl {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px 16px max(18px, env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.wl-name {
  margin: 4px 0 0;
  font-size: 1.45rem;
  text-align: center;
  line-height: 1.25;
}

.wl-hints {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.wl-hint {
  min-height: 1.6em;
  text-align: center;
  color: var(--accent);
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.wl-swatch {
  display: inline-block;
  width: 1.2em;
  height: 1.2em;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.5);
}

.wl-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.wl-option {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
  min-height: 64px;
}

.wl-option.right {
  border-color: var(--right);
  background: rgba(47, 158, 68, 0.25);
}

.wl-option.wrong {
  border-color: var(--wrong);
  background: rgba(201, 42, 42, 0.25);
}

.wl-option.revealed {
  pointer-events: none;
}

.wl-hintbtns {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.wl-hintbtns button {
  font-size: 0.85rem;
}

/* ---------- Corner Quiz ---------- */

.cq-options {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.cq-option {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 10px;
  min-height: 64px;
}

.cq-option .arcade-badge {
  font-size: 0.85rem;
}

.cq-option.right {
  border-color: var(--right);
  background: rgba(47, 158, 68, 0.25);
}

.cq-option.wrong {
  border-color: var(--wrong);
  background: rgba(201, 42, 42, 0.25);
}

.cq-option.revealed {
  pointer-events: none;
}

.cq-option.gone {
  opacity: 0.22;
  pointer-events: none;
}

/* ---------- Bus Lock ---------- */

.bl {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 12px;
}

.bl-board {
  position: relative;
  width: min(100%, 60vh, 440px);
  aspect-ratio: 1;
  background: #0b111d;
  border: 2px solid var(--line);
  border-radius: 12px;
  background-image:
    linear-gradient(to right, rgba(50, 64, 92, 0.5) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(50, 64, 92, 0.5) 1px, transparent 1px);
  background-size:
    calc(100% / 6) 100%,
    100% calc(100% / 6);
}

.bl-veh {
  position: absolute;
  padding: 3px;
  cursor: pointer;
}

.bl-veh::after {
  content: "";
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 8px;
  background: inherit;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.bl-veh.sel::after {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.25),
    0 0 0 3px var(--accent);
}

.bl-veh.target::before {
  content: "YOU";
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #1c2333;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.bl-exit {
  position: absolute;
  right: -2px;
  top: calc(2 / 6 * 100%);
  height: calc(100% / 6);
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
  font-size: 1.1rem;
  pointer-events: none;
}

.bl-controls {
  display: flex;
  gap: 10px;
}

.bl-controls button {
  font-size: 0.85rem;
}

.bl-status {
  color: var(--muted);
  font-size: 0.9rem;
  padding: 0 0 max(8px, env(safe-area-inset-bottom));
  text-align: center;
}

/* ---------- Opening Order ---------- */

.oo {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px max(14px, env(safe-area-inset-bottom));
  max-width: 560px;
  margin: 0 auto;
  width: 100%;
}

.oo-prompt {
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

.oo-slots {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.oo-slot {
  border: 1px dashed var(--line);
  border-radius: 8px;
  padding: 6px 10px;
  color: var(--muted);
  font-size: 0.8rem;
  min-height: 1.4em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oo-slot.filled {
  border-style: solid;
  color: var(--text);
  background: var(--panel);
}

.oo-slot.done {
  border-color: var(--right);
}

.oo-tiles {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.oo-tile {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  cursor: pointer;
  min-height: 84px;
}

.oo-tile-name {
  font-weight: 700;
  line-height: 1.25;
}

.oo-tile-meta {
  color: var(--muted);
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.oo-tile-date {
  color: var(--accent);
  font-size: 0.85rem;
  font-weight: 700;
}

.oo-tile.placed {
  border-color: var(--right);
  background: rgba(47, 158, 68, 0.18);
  opacity: 0.7;
  cursor: default;
}

.oo-tile.bad {
  border-color: var(--wrong);
  background: rgba(201, 42, 42, 0.25);
}

.oo-tile.right {
  border-color: var(--right);
}

/* ---------- toasts ---------- */

#toasts {
  position: fixed;
  left: 50%;
  bottom: calc(18px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 20;
  pointer-events: none;
}

.toast {
  background: var(--accent);
  color: #1c2333;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 999px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
  transition: opacity 0.5s;
  white-space: nowrap;
}

.toast.fade {
  opacity: 0;
}

/* ---------- small screens ---------- */

@media (max-width: 420px) {
  .wl-options {
    gap: 9px;
  }

  .wl-option {
    min-height: 56px;
    padding: 10px;
  }

  .cq-options {
    gap: 9px;
  }

  .cq-option {
    min-height: 56px;
    padding: 10px 8px;
  }

  .over-score {
    font-size: 2.1rem;
  }
}
