/* ==========================================================================
   ARCADE SHARED STYLES
   A dark, sleek look for the teen-and-adult section. Same screen model as the
   children's games (one .screen.active at a time), sized for phones first.
   ========================================================================= */

:root {
  --ar-bg: #0f1520;
  --ar-bg2: #172131;
  --ar-panel: #1d2940;
  --ar-line: #2c3b57;
  --ar-ink: #eef3fb;
  --ar-dim: #9fb0c8;
  --ar-accent: #ffd23f;
  --ar-go: #22c55e;
  --ar-warn: #ff6b6b;
  --ar-radius: 14px;
  --ar-font: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--ar-bg);
  color: var(--ar-ink);
  font-family: var(--ar-font);
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app { min-height: 100%; }

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

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 12px 14px calc(16px + env(safe-area-inset-bottom));
  max-width: 980px;
  margin: 0 auto;
}
.screen.active { display: block; }

/* The play screen takes the whole viewport */
.screen.play-screen.active {
  display: flex;
  flex-direction: column;
  max-width: none;
  height: 100vh;
  height: 100dvh;
  padding: 0;
}

/* ---------- menu ---------- */

.scr-menu { text-align: center; position: relative; padding-top: 56px; }
.corner-btn {
  position: absolute;
  top: 12px;
  background: var(--ar-panel);
  color: var(--ar-ink);
  border: 1px solid var(--ar-line);
  border-radius: 999px;
  padding: 8px 14px;
  font: 600 14px var(--ar-font);
  text-decoration: none;
  cursor: pointer;
}
.corner-btn.left { left: 12px; }
.corner-btn.right { right: 12px; }

.lm-logo { width: 64px; height: auto; margin: 4px auto 6px; display: block; }
.scr-menu h1 {
  margin: 4px 0 6px;
  font-size: clamp(28px, 7vw, 46px);
  letter-spacing: 0.5px;
  line-height: 1.05;
  background: linear-gradient(90deg, #fff, var(--ar-accent));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.menu-lead { color: var(--ar-dim); margin: 0 auto 14px; max-width: 560px; font-size: 16px; line-height: 1.4; }

.help-btn {
  background: transparent;
  color: var(--ar-accent);
  border: 1px solid var(--ar-accent);
  border-radius: 999px;
  padding: 7px 16px;
  font: 600 14px var(--ar-font);
  cursor: pointer;
  margin-bottom: 16px;
}

.section-label {
  color: var(--ar-dim);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  font-size: 12px;
  font-weight: 700;
  margin: 18px 0 8px;
}

.seg {
  display: inline-flex;
  background: var(--ar-bg2);
  border: 1px solid var(--ar-line);
  border-radius: 999px;
  padding: 4px;
  gap: 4px;
}
.seg button {
  border: 0;
  background: transparent;
  color: var(--ar-dim);
  font: 700 15px var(--ar-font);
  padding: 9px 18px;
  border-radius: 999px;
  cursor: pointer;
}
.seg button.on { background: var(--ar-accent); color: #1a1a1a; }
.seg-note { color: var(--ar-dim); font-size: 13px; margin: 8px 0 0; }

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

.big-btn {
  display: inline-block;
  border: 0;
  border-radius: var(--ar-radius);
  background: var(--ar-go);
  color: #08130b;
  font: 800 17px var(--ar-font);
  padding: 13px 22px;
  cursor: pointer;
  text-decoration: none;
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.25);
}
.big-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25); }
.big-btn.secondary { background: var(--ar-panel); color: var(--ar-ink); border: 1px solid var(--ar-line); }
.button-row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 18px; }

/* ---------- level tiles ---------- */

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 10px;
  text-align: left;
  margin-top: 6px;
}
.course-tile {
  display: flex;
  flex-direction: column;
  gap: 3px;
  background: var(--ar-panel);
  border: 1px solid var(--ar-line);
  border-radius: var(--ar-radius);
  color: var(--ar-ink);
  padding: 12px;
  font-family: var(--ar-font);
  cursor: pointer;
  text-align: left;
  transition: transform 0.12s, border-color 0.12s;
}
.course-tile:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--ar-accent); }
.course-tile.locked { opacity: 0.45; cursor: default; }
.tile-num { font-size: 12px; font-weight: 800; color: var(--ar-accent); }
.tile-name { font-size: 16px; font-weight: 800; }
.tile-best { font-size: 13px; color: var(--ar-dim); }

/* ---------- play ---------- */

.top-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  padding-top: calc(8px + env(safe-area-inset-top));
  background: var(--ar-bg2);
  border-bottom: 1px solid var(--ar-line);
}
.top-bar h2 {
  flex: 1;
  margin: 0;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.back-btn, .icon-btn, .help-q {
  background: var(--ar-panel);
  color: var(--ar-ink);
  border: 1px solid var(--ar-line);
  border-radius: 10px;
  padding: 7px 12px;
  font: 700 14px var(--ar-font);
  cursor: pointer;
}
.help-q { width: 36px; padding: 7px 0; }

.game-area {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.game-area canvas { display: block; position: absolute; inset: 0; }

.keys-hint {
  margin: 0;
  padding: 6px 10px calc(6px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--ar-dim);
  font-size: 13px;
  background: var(--ar-bg2);
  border-top: 1px solid var(--ar-line);
}
html.coarse .keys-hint { display: none; }

.pause-banner {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: rgba(8, 12, 20, 0.72);
  z-index: 5;
}
.pause-banner[hidden] { display: none; }
.pause-banner h3 { margin: 0; font-size: 30px; }

/* ---------- result ---------- */

.result-panel {
  text-align: center;
  background: var(--ar-panel);
  border: 1px solid var(--ar-line);
  border-radius: 20px;
  padding: 22px 16px;
  margin: 30px auto 0;
  max-width: 520px;
}
.result-panel h2 { margin: 0 0 6px; font-size: 30px; color: var(--ar-accent); }
.result-medal { font-size: 64px; line-height: 1.1; }
.result-time { font-size: 44px; font-weight: 900; margin: 4px 0 8px; font-variant-numeric: tabular-nums; }
.result-line { margin: 6px 0; color: var(--ar-dim); line-height: 1.4; }
.result-line.good { color: var(--ar-go); font-weight: 700; }
.result-line.small { font-size: 14px; }

/* ---------- settings ---------- */

.settings-list { max-width: 560px; margin: 16px auto; display: flex; flex-direction: column; gap: 10px; }
.settings-row {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--ar-panel);
  border: 1px solid var(--ar-line);
  border-radius: var(--ar-radius);
  padding: 12px 14px;
}
.row-label { flex: 1; font-weight: 700; }
.row-label small { display: block; font-weight: 400; color: var(--ar-dim); margin-top: 2px; }
.toggle {
  width: 54px;
  height: 30px;
  border-radius: 999px;
  border: 0;
  position: relative;
  cursor: pointer;
  background: #3a4660;
}
.toggle::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  transition: left 0.15s;
}
.toggle.on { background: var(--ar-go); }
.toggle.on::after { left: 27px; }

/* ---------- help ---------- */

#arcade-help {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(5, 8, 14, 0.75);
  z-index: 50;
  padding: 16px;
}
#arcade-help.open { display: flex; }
.help-panel {
  background: var(--ar-panel);
  border: 1px solid var(--ar-line);
  border-radius: 18px;
  max-width: 560px;
  width: 100%;
  max-height: 86vh;
  display: flex;
  flex-direction: column;
  padding: 18px;
}
.help-title { margin: 0 0 8px; color: var(--ar-accent); }
.help-body { overflow-y: auto; line-height: 1.5; }
.help-body h3 { margin: 14px 0 4px; font-size: 16px; }
.help-body p { margin: 6px 0; color: var(--ar-ink); }
.help-actions { margin-top: 12px; text-align: right; }

/* ---------- section index ---------- */

.arcade-index { max-width: 760px; margin: 0 auto; padding: 14px; text-align: center; }
.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  text-align: left;
  background: var(--ar-panel);
  border: 1px solid var(--ar-line);
  border-radius: 18px;
  padding: 14px;
  margin: 10px 0;
  color: var(--ar-ink);
  text-decoration: none;
  transition: transform 0.12s, border-color 0.12s;
}
.game-card:hover { transform: translateY(-2px); border-color: var(--ar-accent); }
.game-card .icon {
  flex: 0 0 64px;
  height: 64px;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 34px;
}
.game-card h2 { margin: 0 0 3px; font-size: 19px; }
.game-card p { margin: 0; color: var(--ar-dim); font-size: 14px; line-height: 1.35; }
.game-card .tag { display: inline-block; margin-top: 5px; font-size: 12px; color: var(--ar-accent); font-weight: 700; }

/* ---------- who is playing, and high scores ---------- */

.player-chip-host { margin: 0 auto 10px; max-width: 520px; }
.player-chip {
  background: var(--ar-bg2);
  color: var(--ar-ink);
  border: 1px solid var(--ar-line);
  border-radius: 999px;
  padding: 8px 16px;
  font: 500 15px var(--ar-font);
  cursor: pointer;
  max-width: 100%;
}
.player-chip .pc-name { color: var(--ar-accent); }
.player-chip .pc-edit { color: var(--ar-dim); font-size: 13px; }
.name-form {
  background: var(--ar-panel);
  border: 1px solid var(--ar-line);
  border-radius: var(--ar-radius);
  padding: 12px;
  text-align: left;
}
.name-form[hidden], .player-chip[hidden] { display: none; }
.nf-row { display: flex; gap: 8px; align-items: flex-end; }
.nf-label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 13px; color: var(--ar-dim); font-weight: 600; }
.nf-input {
  font: 600 17px var(--ar-font);
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--ar-line);
  background: var(--ar-bg);
  color: var(--ar-ink);
  width: 100%;
  min-width: 0;
}
.nf-ok { padding: 11px 18px; }
.nf-recent { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.nf-recent-label { color: var(--ar-dim); font-size: 13px; }
.nf-name {
  background: var(--ar-bg2);
  color: var(--ar-ink);
  border: 1px solid var(--ar-line);
  border-radius: 999px;
  padding: 6px 12px;
  font: 600 14px var(--ar-font);
  cursor: pointer;
}

.score-box { max-width: 520px; margin: 8px auto 0; }
.score-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.score-table th, .score-table td { padding: 6px 8px; text-align: left; border-bottom: 1px solid var(--ar-line); }
.score-table th { color: var(--ar-dim); font-size: 12px; text-transform: uppercase; letter-spacing: 1px; }
.score-table td:first-child, .score-table th:first-child { width: 2.2em; color: var(--ar-dim); }
.score-table td:nth-child(3), .score-table th:nth-child(3) { text-align: right; }
.score-table td:nth-child(2) { overflow-wrap: anywhere; }
.score-table tr.mine td { color: var(--ar-accent); font-weight: 700; }
.score-table tr.fresh td { background: rgba(255, 210, 63, 0.14); }
.score-empty, .score-mine { color: var(--ar-dim); font-size: 14px; margin: 8px 0; }

.menu-actions { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin: 6px 0 4px; }

/* ---------- on-screen buttons for touch screens (Quarry, Skyway, Fathom) ---------- */

.touch-pad {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  justify-content: space-between;
  align-items: flex-end;
  gap: 8px;
  pointer-events: none;
  z-index: 3;
}
html.coarse .touch-pad { display: flex; }
.touch-pad .tp-group { display: flex; gap: 8px; pointer-events: auto; }
.tbtn {
  width: 58px;
  height: 58px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(20, 30, 48, 0.62);
  color: #fff;
  font: 800 20px var(--ar-font);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  cursor: pointer;
}
.tbtn small { display: block; font-size: 10px; font-weight: 700; opacity: 0.8; }
.tbtn.held, .tbtn:active { background: rgba(255, 210, 63, 0.5); color: #111; }
.tbtn.wide { width: 74px; }
.top-bar .icon-btn.view-btn { min-width: 62px; }

@media (max-width: 420px) {
  .seg button { padding: 8px 13px; font-size: 14px; }
  .tile-grid { grid-template-columns: repeat(2, 1fr); }
}
