/* Traversează strada — an endless 3D hopper through a Romanian village (js/traverseaza-strada.js).
   Theme-aware like the other game pages: tokens on :root, redefined under body.dark-theme.
   The village follows the theme too: a summer afternoon in light, an evening with lit windows in dark. */
:root {
    --ts-accent: #15803d;
    --ts-accent-2: #166534;
    --ts-on-accent: #ffffff;
    --ts-page-bg: #f3f9ef;
    --ts-card-bg: #ffffff;
    --ts-card-border: #cfe5c4;
    --ts-muted: #55634d;
    --ts-shadow: 0 10px 30px rgba(20, 70, 20, .14);
    --ts-stage-bg: #9fd8f0;
    --ts-overlay: rgba(16, 32, 16, .42);
    --ts-chip-bg: #f1f8ec;
    --ts-glass: rgba(14, 22, 12, .55);
    --ts-gold: #f5b301;
    --ts-gold-2: #d99a00;
    --ts-lock: #8a8f86;
}

body.dark-theme {
    --ts-accent: #4ade80;
    --ts-accent-2: #22c55e;
    --ts-on-accent: #052e16;
    --ts-page-bg: #0d130e;
    --ts-card-bg: #161f17;
    --ts-card-border: #2b3b2c;
    --ts-muted: #a9bba7;
    --ts-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --ts-stage-bg: #172238;
    --ts-overlay: rgba(4, 8, 6, .6);
    --ts-chip-bg: #1d2a1e;
    --ts-glass: rgba(4, 8, 6, .6);
    --ts-gold: #fbbf24;
    --ts-gold-2: #f59e0b;
    --ts-lock: #7d857b;
}

/* clip, not hidden: the site-wide `body { overflow-x: hidden }` makes <body> a scroll
   container that never scrolls, which silently kills any position: sticky inside. */
.ts-body, body.ts-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--ts-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
body.ts-max { overflow: hidden; }
body.ts-playing { overscroll-behavior: none; }
.ts-main { padding-top: 96px; padding-bottom: 40px; }
.ts-game .container, .ts-hero .container { max-width: 1040px; }

/* ---- hero ---- */
.ts-hero { text-align: center; padding: 4px 0 12px; }
.ts-hero h1 { font-weight: 800; font-size: clamp(1.6rem, 5vw, 2.3rem); margin: 0 0 6px; display: inline-flex; align-items: center; gap: 12px; }
.ts-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #22c55e, #0e7490); box-shadow: var(--ts-shadow); }
.ts-lead { max-width: 620px; margin: 0 auto; color: var(--ts-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage: the 3D village fills it ---- */
.ts-stage {
    --ts-h: clamp(460px, calc(100vh - 150px), 820px);
    position: relative;
    height: var(--ts-h);
    width: 100%;
    margin: 0 auto;
    background: var(--ts-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--ts-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    color: #fff;
}
@supports (height: 100svh) {
    .ts-stage { --ts-h: clamp(460px, calc(100svh - 150px), 820px); }
}
.ts-stage:focus-visible { box-shadow: 0 0 0 3px var(--ts-accent), var(--ts-shadow); }
@media (max-width: 575.98px) {
    .ts-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.ts-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: pointer; }
.ts-stage[data-phase="setup"] .ts-canvas, .ts-stage[data-phase="over"] .ts-canvas { cursor: default; }

.ts-stage:fullscreen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.ts-stage:-webkit-full-screen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.ts-stage.is-max { position: fixed; inset: 0; z-index: 1052; width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
@supports (height: 100dvh) { .ts-stage.is-max { height: 100dvh; } }

/* ---- HUD ---- */
.ts-hud { position: absolute; left: 10px; right: 64px; top: 10px; z-index: 2; display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; }
.ts-hud[hidden] { display: none; }
.ts-score-box { display: flex; flex-direction: column; align-items: flex-start; line-height: 1; }
.ts-score { font-size: clamp(2.4rem, 11vw, 3.4rem); font-weight: 900; font-variant-numeric: tabular-nums; text-shadow: 0 3px 0 rgba(0, 0, 0, .28), 0 0 14px rgba(0, 0, 0, .25); letter-spacing: .01em; }
.ts-best { margin-top: 4px; padding: 3px 9px; border-radius: 999px; background: var(--ts-glass); font-size: .76rem; font-weight: 700; white-space: nowrap; }
.ts-best:empty { display: none; }
.ts-coins-box { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px 6px 8px; border-radius: 999px; background: var(--ts-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.ts-coin-dot { display: inline-block; flex: none; width: 1em; height: 1em; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff3b0 0 18%, transparent 20%), radial-gradient(circle, var(--ts-gold) 0 52%, var(--ts-gold-2) 54% 100%); box-shadow: inset 0 0 0 2px rgba(0, 0, 0, .12); vertical-align: -.15em; }

.ts-tools { position: absolute; right: 10px; top: 10px; z-index: 4; display: flex; flex-direction: column; gap: 8px; }
.ts-round { width: 44px; height: 44px; border-radius: 50%; border: 0; display: grid; place-items: center; background: var(--ts-glass); color: #fff; font-size: 16px; cursor: pointer; touch-action: manipulation; backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }
.ts-round:hover, .ts-round:focus-visible { background: rgba(21, 128, 61, .9); }
.ts-round:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.ts-round[hidden], .ts-round span[hidden] { display: none; }

.ts-hint { position: absolute; left: 50%; bottom: 22px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 10px 18px; border-radius: 16px; background: var(--ts-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); text-align: center; pointer-events: none; max-width: calc(100% - 24px); animation: ts-hint 1.6s ease-in-out infinite; }
.ts-hint[hidden] { display: none; }
.ts-hint strong { display: block; font-size: 1.05rem; }
.ts-hint small { display: block; font-size: .8rem; opacity: .9; margin-top: 2px; }
@keyframes ts-hint { 50% { transform: translateX(-50%) translateY(-4px); } }

.ts-hawk { position: absolute; left: 50%; top: 92px; z-index: 3; transform: translateX(-50%); margin: 0; padding: 7px 14px; border-radius: 999px; background: rgba(153, 27, 27, .88); font-weight: 800; font-size: .92rem; white-space: nowrap; pointer-events: none; animation: ts-pulse .8s ease-in-out infinite; }
.ts-hawk[hidden] { display: none; }
@keyframes ts-pulse { 50% { transform: translateX(-50%) scale(1.07); } }

.ts-banner { position: absolute; left: 50%; top: 30%; z-index: 3; transform: translate(-50%, -50%) scale(.9); margin: 0; padding: 10px 22px; border-radius: 18px; max-width: 92%; text-align: center; color: #fff; font-weight: 900; font-size: clamp(1.4rem, 7vw, 2.3rem); line-height: 1.15; text-shadow: 0 3px 12px rgba(0, 0, 0, .45); background: rgba(14, 22, 12, .55); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.ts-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.ts-banner.is-gold { background: linear-gradient(135deg, rgba(245, 158, 11, .95), rgba(234, 88, 12, .9)); }

.ts-loading { position: absolute; inset: 0; z-index: 6; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: #fff; font-weight: 700; background: linear-gradient(#8fd0ec, #5c9e3c); }
body.dark-theme .ts-loading { background: linear-gradient(#172238, #1d3320); }
.ts-loading[hidden] { display: none; }

/* ---- overlays (setup, pause, game over) ---- */
.ts-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 14px; background: var(--ts-overlay); backdrop-filter: blur(2px); -webkit-backdrop-filter: blur(2px); overflow-y: auto; touch-action: manipulation; color: var(--text-color); }
.ts-overlay[hidden] { display: none; }
.ts-card { width: 100%; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px; border-radius: 18px; background: var(--ts-card-bg); border: 1px solid var(--ts-card-border); box-shadow: var(--ts-shadow); color: var(--text-color); text-align: center; }
.ts-card h2 { font-weight: 800; font-size: 1.4rem; margin: 0; }
.ts-label { font-weight: 700; font-size: .9rem; color: var(--ts-muted); }

.ts-chars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.ts-char { position: relative; min-height: 112px; padding: 4px 4px 6px; border: 2px solid var(--ts-card-border); border-radius: 14px; background: var(--ts-chip-bg); color: inherit; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; gap: 1px; cursor: pointer; touch-action: manipulation; }
.ts-char-pic { width: 72px; height: 72px; display: grid; place-items: center; }
.ts-char-pic img { width: 72px; height: 72px; display: block; }
.ts-char-name { font-weight: 800; font-size: .84rem; line-height: 1.1; }
.ts-char-price { display: inline-flex; align-items: center; gap: 4px; font-size: .74rem; font-weight: 700; color: var(--ts-muted); }
.ts-char.is-locked .ts-char-pic img { filter: grayscale(1) brightness(.55) contrast(.9); opacity: .75; }
.ts-char.is-locked .ts-char-price { color: var(--ts-gold-2); }
body.dark-theme .ts-char.is-locked .ts-char-price { color: var(--ts-gold); }
.ts-char[aria-checked="true"] { border-color: var(--ts-accent); background: color-mix(in srgb, var(--ts-accent) 14%, var(--ts-chip-bg)); box-shadow: 0 0 0 2px var(--ts-accent); }
.ts-wallet { margin: 0; display: flex; align-items: center; justify-content: center; gap: 6px; font-weight: 800; font-size: .95rem; }

.ts-chips { display: flex; gap: 6px; justify-content: center; }
.ts-chip { flex: 1; min-height: 46px; padding: 4px 8px; border-radius: 12px; border: 1px solid var(--ts-card-border); background: var(--ts-chip-bg); color: inherit; font-weight: 800; font-size: 1rem; cursor: pointer; touch-action: manipulation; }
.ts-chip[aria-checked="true"] { background: var(--ts-accent); border-color: var(--ts-accent); color: var(--ts-on-accent); }
.ts-char:focus-visible, .ts-chip:focus-visible, .ts-btn:focus-visible { outline: 3px solid var(--ts-accent); outline-offset: 2px; }

.ts-btn { min-height: 50px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--ts-card-border); background: var(--ts-card-bg); color: inherit; font-weight: 800; font-size: 1.02rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; }
.ts-btn:hover { border-color: var(--ts-accent); }
.ts-btn[hidden] { display: none; }
.ts-btn:disabled { opacity: .62; cursor: default; }
.ts-btn-primary { background: var(--ts-accent); border-color: var(--ts-accent); color: var(--ts-on-accent); }
.ts-btn-primary:hover { background: var(--ts-accent-2); border-color: var(--ts-accent-2); }
.ts-btn-primary:disabled { background: var(--ts-chip-bg); border-color: var(--ts-card-border); color: var(--ts-muted); }
.ts-btn-ghost { background: transparent; border-color: transparent; color: var(--ts-muted); }

.ts-over-big { margin: 0; display: flex; align-items: baseline; justify-content: center; gap: 8px; line-height: 1; color: var(--ts-accent); }
.ts-over-big span { font-size: 3.2rem; font-weight: 900; font-variant-numeric: tabular-nums; }
.ts-over-big small { font-size: 1rem; font-weight: 700; color: var(--ts-muted); }
.ts-over-tag { margin: 0; font-weight: 800; color: var(--ts-gold-2); }
body.dark-theme .ts-over-tag { color: var(--ts-gold); }
.ts-over-sub { margin: 0; color: var(--ts-muted); font-size: .92rem; line-height: 1.45; }
.ts-over-sub:empty { display: none; }
.ts-over-unlock { margin: 0; padding: 6px 10px; border-radius: 10px; background: color-mix(in srgb, var(--ts-gold) 22%, transparent); font-weight: 800; font-size: .9rem; }
.ts-over-unlock[hidden] { display: none; }

.ts-actions { display: flex; justify-content: center; margin: 14px 0 10px; }
.ts-actions .ts-btn { min-width: 180px; }
.ts-record { margin: 12px 0 0; text-align: center; color: var(--ts-muted); font-size: .9rem; line-height: 1.6; }
.ts-record:empty { display: none; }
.ts-reset-wrap { text-align: center; margin: 2px 0 12px; }
.ts-link { border: 0; background: none; padding: 6px; color: var(--ts-muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }

/* ---- help ---- */
.ts-help { max-width: 780px; margin: 8px auto 0; padding: 12px 14px; border-radius: 14px; background: var(--ts-card-bg); border: 1px solid var(--ts-card-border); }
.ts-help summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.ts-help ul { margin: 10px 0 4px; padding-left: 20px; line-height: 1.55; }
.ts-help li { margin-bottom: 4px; }
.ts-credit { margin: 8px 0 0; font-size: .82rem; color: var(--ts-muted); }
.ts-powered { text-align: center; color: var(--ts-muted); font-size: .85rem; margin: 22px 0 0; }
.ts-powered a { color: var(--ts-accent); }
body.dark-theme .ts-help kbd { background: #2b3b2c; }

body.dark-theme .ts-round, body.dark-theme .ts-coins-box, body.dark-theme .ts-best, body.dark-theme .ts-hint { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }

@media (min-width: 700px) {
    .ts-stage[data-phase="setup"] .ts-card { max-width: 620px; }
    .ts-chars { grid-template-columns: repeat(6, minmax(0, 1fr)); }
    .ts-char { min-height: 104px; }
    .ts-char-pic, .ts-char-pic img { width: 64px; height: 64px; }
}
@media (max-width: 420px) {
    .ts-main { padding-top: 88px; }
    .ts-char { min-height: 104px; }
    .ts-char-pic, .ts-char-pic img { width: 62px; height: 62px; }
    .ts-card { padding: 14px 12px; gap: 8px; }
}
@media (max-height: 640px) {
    .ts-char { min-height: 90px; }
    .ts-char-pic, .ts-char-pic img { width: 52px; height: 52px; }
}
@media (prefers-reduced-motion: reduce) {
    .ts-hint, .ts-hawk { animation: none; }
    .ts-banner { transition: none; }
}
