/* Groapa — jocul șofatului prin București */
:root {
  color-scheme: light;
  --bg: #f6f3ea;
  --panel: #ffffff;
  --panel-2: #efece1;
  --text: #211e18;
  --muted: #57534a;
  --line: #ddd9cb;
  --accent: #8a4400;
  --accent-contrast: #ffffff;
  --btn-bg: #211e18;
  --btn-text: #f6f3ea;
  --stage-line: #2c2c36;
  --focus: #8a4400;
  --ok: #1d6f3c;
  --danger: #8f1d10;
}
@media (prefers-color-scheme: dark) {
  :root {
    color-scheme: dark;
    --bg: #131318;
    --panel: #1e1e26;
    --panel-2: #17171d;
    --text: #f2efe6;
    --muted: #b9b5a7;
    --line: #2e2e38;
    --accent: #ffd84d;
    --accent-contrast: #1d1a16;
    --btn-bg: #ffd84d;
    --btn-text: #1d1a16;
    --stage-line: #2c2c36;
    --focus: #ffd84d;
    --ok: #7fe0a4;
    --danger: #ff8a7a;
  }
}
:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f6f3ea; --panel: #ffffff; --panel-2: #efece1; --text: #211e18;
  --muted: #57534a; --line: #ddd9cb; --accent: #8a4400; --accent-contrast: #ffffff;
  --btn-bg: #211e18; --btn-text: #f6f3ea; --stage-line: #2c2c36; --focus: #8a4400;
  --ok: #1d6f3c; --danger: #8f1d10;
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #131318; --panel: #1e1e26; --panel-2: #17171d; --text: #f2efe6;
  --muted: #b9b5a7; --line: #2e2e38; --accent: #ffd84d; --accent-contrast: #1d1a16;
  --btn-bg: #ffd84d; --btn-text: #1d1a16; --stage-line: #2c2c36; --focus: #ffd84d;
  --ok: #7fe0a4; --danger: #ff8a7a;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.55;
}
::selection { background: var(--accent); color: var(--accent-contrast); }
.skip { position: absolute; left: -9999px; top: 0; background: var(--panel); color: var(--text); padding: .6rem .9rem; border: 2px solid var(--focus); border-radius: 0 0 .5rem 0; z-index: 60; }
.skip:focus { left: 0; }
.best-chip[hidden], .to-top[hidden] { display: none; }

a { color: var(--accent); }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 2px; }

/* ---------- Topbar ---------- */
.topbar { border-bottom: 1px solid var(--line); background: var(--bg); }
.topbar-inner {
  max-width: 72rem; margin: 0 auto; height: 52px; padding: 0 1.25rem;
  display: flex; align-items: center; gap: .65rem;
}
.brand { color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 600; letter-spacing: .01em; padding: .35rem .2rem; }
.brand:hover { color: var(--text); }
.topbar-sep { width: 1px; height: 1.1rem; background: var(--line); }
.brand-sub { font-size: .82rem; font-weight: 800; letter-spacing: .02em; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: .35rem; }
.lang-switch { display: inline-flex; align-items: center; gap: .35rem; font-size: .8rem; font-weight: 700; }
.lang-switch a { color: var(--muted); text-decoration: none; padding: .35rem .4rem; border-radius: .4rem; }
.lang-switch a[aria-current="true"] { color: var(--text); background: var(--panel-2); }
.lang-switch span[aria-hidden] { color: var(--muted); }
.icon-btn {
  width: 38px; height: 38px; border: 1px solid var(--line); border-radius: .55rem;
  background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn:hover { background: var(--panel-2); }
.icon-sound-off { display: none; }
.icon-btn[aria-pressed="true"] .icon-sound-on { display: none; }
.icon-btn[aria-pressed="true"] .icon-sound-off { display: block; }

/* theme icons: light shows the moon (tap for dark), dark shows the sun */
.icon-sun { display: none; }
:root[data-theme="dark"] .icon-sun { display: block; }
:root[data-theme="dark"] .icon-moon { display: none; }

/* ---------- Hero ---------- */
.hero {
  max-width: 72rem; margin: 0 auto; padding: 1.75rem 1.25rem 2.5rem;
  display: grid; grid-template-columns: minmax(0, 27rem) minmax(0, 1fr); gap: 2.5rem; align-items: center;
}
.kicker { margin: 0 0 .6rem; font-size: .74rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--accent); }
h1 { margin: 0; font-size: clamp(3.4rem, 9vw, 5rem); line-height: .95; letter-spacing: -0.02em; font-weight: 900; }
.deck { margin: .9rem 0 0; font-size: 1.13rem; line-height: 1.5; color: var(--text); }
.controls-hint { margin: 1rem 0 0; font-size: .86rem; color: var(--muted); }
kbd {
  display: inline-block; min-width: 1.65rem; text-align: center;
  border: 1px solid var(--line); border-bottom-width: 3px; border-radius: .35rem;
  padding: .08rem .4rem; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: .82em; background: var(--panel);
}
.best-chip { margin-top: 1.1rem; display: inline-flex; align-items: center; gap: .55rem; border: 1px solid var(--line); border-radius: 999px; padding: .38rem .8rem; font-size: .86rem; background: var(--panel); }
.best-chip-label { color: var(--muted); font-weight: 600; }
.best-chip-value { font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---------- Stage ---------- */
.stage-wrap { display: flex; justify-content: center; }
.stage {
  position: relative; width: 100%; max-width: 30rem; height: 560px;
  border-radius: 1.1rem; overflow: hidden; border: 1px solid var(--stage-line);
  box-shadow: 0 30px 60px -30px rgba(0, 0, 0, .55), 0 0 0 6px var(--panel-2);
  background: #101018; touch-action: none;
}
#game-canvas { display: block; width: 100%; height: 100%; }
#game-canvas:focus-visible { outline: 3px solid var(--focus); outline-offset: -3px; }

.hud {
  position: absolute; top: 0; left: 0; right: 0; display: flex; justify-content: space-between;
  padding: .65rem .8rem; pointer-events: none; color: #f2efe6;
  background: linear-gradient(to bottom, rgba(10,10,16,.62), rgba(10,10,16,0));
}
.hud-km { font-size: 1.7rem; font-weight: 900; line-height: 1; font-variant-numeric: tabular-nums; }
.hud-unit { font-size: .68rem; font-weight: 800; color: #cfc9ba; margin-left: .3rem; letter-spacing: .08em; }
.hud-susp { display: flex; gap: .3rem; margin-top: .35rem; color: #ffd84d; }
.susp-icon { transition: opacity .15s, transform .15s; }
.susp-icon.is-gone { opacity: .22; transform: scale(.85); color: #f2efe6; }
.hud-lei { display: flex; align-items: center; gap: .42rem; font-size: 1.35rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.coin-dot { width: 1.05rem; height: 1.05rem; border-radius: 50%; background: radial-gradient(circle at 38% 34%, #ffe98a, #d9a53b 72%); border: 1.5px solid #8a6a1f; display: inline-block; }

.radio {
  position: absolute; left: 0; right: 0; bottom: 0; height: 2.35rem;
  display: flex; align-items: center; gap: .5rem; padding: 0 .75rem;
  background: rgba(9, 9, 14, .88); border-top: 1px solid #2c2c36; color: #d9d4c6;
  font-size: .76rem; letter-spacing: .01em; overflow: hidden;
}
.radio-dot { flex: none; width: .5rem; height: .5rem; border-radius: 50%; background: #ff6b57; animation: radio-pulse 1.6s ease-in-out infinite; }
.radio-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
@keyframes radio-pulse { 0%, 100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255, 107, 87, .5); } 50% { opacity: .55; box-shadow: 0 0 0 4px rgba(255, 107, 87, .12); } }

/* ---------- Overlays ---------- */
.overlay {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  padding: 1rem; background: rgba(9, 9, 15, .58);
}
.overlay[hidden] { display: none; }
.overlay-panel {
  width: 100%; max-width: 24.5rem; background: #17171f; border: 1px solid #2c2c36;
  border-radius: 1rem; padding: 1.15rem 1.25rem 1.25rem; text-align: center; color: #f2efe6;
  box-shadow: 0 22px 50px -20px rgba(0,0,0,.7);
  animation: panel-in .28s ease-out;
}
@keyframes panel-in { from { opacity: 0; transform: translateY(12px) scale(.97); } to { opacity: 1; transform: none; } }
.dacia-badge { width: min(74%, 240px); height: auto; margin: 0 auto .35rem; display: block; }
.overlay-title { margin: 0; font-size: 1.55rem; font-weight: 900; letter-spacing: -0.01em; color: #ffd84d; }
.overlay-sub { margin: .3rem 0 0; font-size: .92rem; color: #cfc9ba; }
.overlay-hint { margin: .7rem 0 0; font-size: .72rem; color: #8f8c80; }
.over-kicker { margin: 0 0 .15rem; font-size: .72rem; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: #ff8a7a; }
.over-quip { margin: .3rem 0 0; font-size: .92rem; color: #d9d4c6; }
.new-best { margin: .45rem auto 0; display: inline-block; background: #ffd84d; color: #1d1a16; font-weight: 900; font-size: .78rem; letter-spacing: .1em; text-transform: uppercase; padding: .18rem .6rem; border-radius: .35rem; }
.new-best[hidden] { display: none; }
.stats { display: grid; grid-template-columns: repeat(2, 1fr); gap: .55rem; margin: .85rem 0 0; }
.stat { background: #1e1e27; border: 1px solid #2c2c36; border-radius: .7rem; padding: .5rem .35rem .55rem; }
.stat-value { display: block; font-size: 1.32rem; font-weight: 900; font-variant-numeric: tabular-nums; color: #f2efe6; }
.stat-label { display: block; font-size: .68rem; color: #a6a294; letter-spacing: .02em; margin-top: .1rem; }
.over-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: center; margin-top: .85rem; }

.btn {
  border: none; border-radius: .7rem; padding: .68rem 1.15rem; font-size: .98rem; font-weight: 800; cursor: pointer; font-family: inherit;
  transition: transform .12s ease, filter .12s ease;
}
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary { background: #ffd84d; color: #1d1a16; box-shadow: 0 6px 0 #b8901f; }
.btn-primary:hover { filter: brightness(1.05); }
.btn-primary:active { box-shadow: 0 2px 0 #b8901f; }
.btn-ghost { background: transparent; color: #f2efe6; border: 1px solid #4a4a58; }
.btn-ghost:hover { background: #23232e; }

/* big start button */
#start-btn { font-size: 1.14rem; padding: .82rem 2.1rem; margin-top: .8rem; }

/* ---------- Share rows ---------- */
.share-row, .hero-share { display: flex; align-items: center; gap: .45rem; flex-wrap: wrap; }
.hero-share { max-width: 72rem; margin: -0.25rem auto 0; padding: 0 1.25rem 1.5rem; }
.share-label { font-size: .78rem; color: var(--muted); font-weight: 600; margin-right: .15rem; }
.share-btn {
  width: 2.75rem; height: 2.75rem; border-radius: 999px; border: 1px solid var(--line);
  background: transparent; color: var(--text); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; text-decoration: none; transition: border-color .15s, color .15s, transform .15s;
}
.share-btn:hover { border-color: var(--accent); color: var(--accent); }
.share-btn:active { transform: scale(.94); }
.share-row .share-btn { border-color: #3a3a46; color: #f2efe6; }
.share-row .share-btn:hover { border-color: #ffd84d; color: #ffd84d; }
.share-row { justify-content: center; margin-top: .8rem; }
.share-row .share-label { color: #a6a294; }
.share-status { font-size: .78rem; color: var(--ok); min-width: 3ch; }
.share-row .share-status { color: #7fe0a4; }
@media (max-width: 560px) { .share-btn { width: 2.75rem; height: 2.75rem; } .hero-share { padding-bottom: 1.1rem; } }

/* ---------- Info sections ---------- */
.info { max-width: 72rem; margin: 0 auto; padding: 1.6rem 1.25rem 2.25rem; border-top: 1px solid var(--line); }
.info h2 { margin: 0 0 .55rem; font-size: 1.45rem; font-weight: 900; letter-spacing: -0.01em; }
.info-lead { margin: 0 0 1rem; color: var(--muted); max-width: 46rem; }
.rank-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: .8rem; background: var(--panel); }
.rank-table { width: 100%; border-collapse: collapse; font-size: .92rem; min-width: 34rem; }
.rank-table th { text-align: left; padding: .55rem .8rem; border-bottom: 2px solid var(--line); color: var(--muted); font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.rank-table td { padding: .5rem .8rem; border-bottom: 1px solid var(--line); }
.rank-table tr:last-child td { border-bottom: none; }
.rank-table tbody tr:nth-child(odd) td { background: var(--panel-2); }
.rank-table td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; color: var(--muted); }
.rank-table td:nth-child(2) { font-weight: 800; }

.obstacle-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(158px, 1fr)); gap: .75rem; }
.obstacle-card { background: var(--panel); border: 1px solid var(--line); border-radius: .8rem; padding: .8rem .85rem .9rem; }
.obstacle-card h3 { margin: .15rem 0 .25rem; font-size: .95rem; }
.obstacle-card p { margin: 0; font-size: .82rem; color: var(--muted); }
.obstacle-icon { width: 4.5rem; height: 2.75rem; display: block; margin-bottom: .35rem; color: var(--text); }
.info-final p { max-width: 46rem; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 72rem; margin: 0 auto; padding: 1.1rem 1.25rem 1.5rem;
  border-top: 1px solid var(--line); color: var(--muted); font-size: .83rem;
  display: flex; flex-wrap: wrap; gap: .35rem 1.4rem; align-items: baseline;
}
.site-footer a { color: var(--accent); text-decoration: none; font-weight: 600; }

/* ---------- to-top ---------- */
.to-top {
  position: fixed; right: .9rem; bottom: calc(.9rem + env(safe-area-inset-bottom)); z-index: 40;
  width: 2.75rem; height: 2.75rem; border-radius: 999px; border: 1.5px solid var(--line);
  background: var(--bg); color: var(--text); display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; opacity: 0; transform: translateY(8px); pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
}
.to-top.is-visible { opacity: .82; transform: none; pointer-events: auto; }
.to-top:hover { opacity: 1; border-color: var(--accent); color: var(--accent); }

/* ---------- Responsive ---------- */
@media (max-width: 940px) {
  .hero { display: flex; flex-direction: column; align-items: stretch; gap: 1.35rem; padding-top: 1.1rem; }
  .stage-wrap { order: -1; }
  h1 { font-size: clamp(2.9rem, 13vw, 4.2rem); }
  .stage { max-width: 100%; height: 500px; }
  .hero-share { margin-top: 0; }
}
@media (max-width: 480px) {
  .topbar-inner { padding: 0 .8rem; gap: .4rem; }
  .brand { font-size: .76rem; }
  .stage { height: 470px; }
  .hud-km { font-size: 1.4rem; }
  .hud-lei { font-size: 1.1rem; }
  .overlay-panel { padding: .9rem 1rem 1.05rem; }
  .stats { gap: .4rem; }
  .stat-value { font-size: 1.1rem; }
  .hero { padding-left: .8rem; padding-right: .8rem; }
  .info { padding-left: .8rem; padding-right: .8rem; }
  .site-footer, .hero-share { padding-left: .8rem; padding-right: .8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .radio-dot { animation: none; }
  .overlay-panel { animation: none; }
  .btn { transition: none; }
  .to-top { transition: none; }
}
