/* Tenis — a clay-court match in 3D (js/tenis.js). Theme-aware like the other game pages:
   tokens on :root, redefined under body.dark-theme. The court follows the theme too: an
   afternoon in light, the floodlights in dark. */
:root {
    --tz-accent: #c2410c;
    --tz-accent-2: #2563eb;
    --tz-on-accent: #ffffff;
    --tz-page-bg: #fdf4ee;
    --tz-card-bg: #ffffff;
    --tz-card-border: #f3cdb6;
    --tz-muted: #6b5546;
    --tz-shadow: 0 10px 30px rgba(124, 45, 18, .14);
    --tz-stage-bg: #9cc8e6;
    --tz-overlay: rgba(28, 22, 18, .45);
    --tz-chip-bg: #fdf1e9;
    --tz-glass: rgba(20, 14, 10, .6);
    --tz-good: #16a34a;
    --tz-gold: #f59e0b;
}

body.dark-theme {
    --tz-accent: #fb923c;
    --tz-accent-2: #60a5fa;
    --tz-on-accent: #1c1007;
    --tz-page-bg: #130d0a;
    --tz-card-bg: #201713;
    --tz-card-border: #43302a;
    --tz-muted: #c9b2a3;
    --tz-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --tz-stage-bg: #0b1220;
    --tz-overlay: rgba(8, 6, 4, .6);
    --tz-chip-bg: #2b1f19;
    --tz-glass: rgba(8, 6, 4, .64);
    --tz-good: #4ade80;
    --tz-gold: #fbbf24;
}

/* 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. */
.tz-body, body.tz-body#page-top {
    font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
    background: var(--tz-page-bg);
    color: var(--text-color);
    min-height: 100vh;
    overflow-x: clip;
}
body.tz-max { overflow: hidden; }
.tz-main { padding-top: 96px; padding-bottom: 40px; }
.tz-game .container, .tz-hero .container { max-width: 760px; }

/* ---- hero ---- */
.tz-hero { text-align: center; padding: 4px 0 12px; }
.tz-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; }
.tz-hero-icon { width: 46px; height: 46px; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #ea580c, #9a3412); box-shadow: var(--tz-shadow); }
.tz-lead { max-width: 600px; margin: 0 auto; color: var(--tz-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage ---- */
.tz-stage {
    --tz-h: clamp(440px, calc(100vh - 150px), 780px);
    position: relative;
    height: var(--tz-h);
    width: 100%;
    margin: 0 auto;
    background: var(--tz-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--tz-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
    color: #fff;
}
@supports (height: 100svh) {
    .tz-stage { --tz-h: clamp(440px, calc(100svh - 150px), 780px); }
}
.tz-stage:focus-visible { box-shadow: 0 0 0 3px var(--tz-accent), var(--tz-shadow); }
@media (max-width: 575.98px) {
    .tz-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.tz-canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; cursor: crosshair; }
.tz-stage:fullscreen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.tz-stage:-webkit-full-screen { width: 100%; height: 100%; border-radius: 0; margin: 0; }
.tz-stage.is-max { position: fixed; inset: 0; z-index: 1052; width: 100vw; height: 100vh; margin: 0; border-radius: 0; }
@supports (height: 100dvh) { .tz-stage.is-max { height: 100dvh; } }

/* ---- scoreboard ---- */
.tz-board { position: absolute; left: 10px; top: 10px; z-index: 2; min-width: 190px; max-width: calc(100% - 76px); padding: 6px 8px 6px; border-radius: 12px; background: var(--tz-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); pointer-events: none; font-variant-numeric: tabular-nums; }
.tz-board[hidden] { display: none; }
.tz-score-head, .tz-row { display: grid; grid-template-columns: 9px minmax(0, 1fr) auto auto auto; align-items: center; column-gap: 6px; }
.tz-score-head { min-height: 14px; margin-bottom: 2px; color: rgba(255,255,255,.7); font-size: .52rem; font-weight: 800; letter-spacing: .04em; line-height: 1; }
.tz-row { height: 26px; font-weight: 800; }
.tz-srv { width: 9px; height: 9px; flex: none; border-radius: 50%; background: transparent; }
.tz-row.is-srv .tz-srv { background: #d9f99d; box-shadow: 0 0 6px rgba(217, 249, 157, .8); }
.tz-name { min-width: 0; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tz-row:nth-of-type(2) .tz-name { color: #fdba74; }
.tz-row:nth-of-type(3) .tz-name { color: #93c5fd; }
.tz-sets { display: flex; gap: 6px; font-size: .9rem; opacity: .8; }
.tz-sets span { min-width: 1ch; text-align: center; }
.tz-games { min-width: 1.4ch; text-align: center; font-size: 1.05rem; }
.tz-pts { min-width: 2.6ch; padding: 0 5px; border-radius: 6px; text-align: center; background: rgba(255, 255, 255, .16); font-size: 1.05rem; }
.tz-status { font-size: .74rem; font-weight: 700; opacity: .9; margin-top: 2px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tz-status:empty { display: none; }

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

/* Touch movement is kept in the near corner so swipes across the court still hit the ball. */
.tz-stick { position: absolute; left: 16px; bottom: 16px; z-index: 3; display: grid; place-items: center; width: 92px; height: 92px; border: 1px solid rgba(255,255,255,.4); border-radius: 50%; background: rgba(20,14,10,.34); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); touch-action: none; cursor: pointer; }
.tz-stick-knob { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border: 1px solid rgba(255,255,255,.55); border-radius: 50%; background: rgba(255,255,255,.42); box-shadow: 0 2px 8px rgba(0,0,0,.24); pointer-events: none; }
.tz-stick-mark { position: absolute; color: rgba(255,255,255,.7); font-size: 10px; pointer-events: none; }
.tz-stick-up { top: 5px; } .tz-stick-down { bottom: 5px; }
.tz-stick-left { left: 5px; } .tz-stick-right { right: 5px; }
.tz-power { position: absolute; right: 108px; bottom: 32px; z-index: 3; display: flex; flex-direction: column; justify-content: center; gap: 5px; width: 112px; min-height: 52px; padding: 7px 9px; border: 1px solid rgba(255,255,255,.28); border-radius: 12px; background: rgba(20,14,10,.66); color: #fff; font: 700 10px/1 system-ui, sans-serif; box-shadow: 0 3px 12px rgba(0,0,0,.2); pointer-events: none; transition: transform .12s, background .12s; }
.tz-power.is-active { transform: translateY(-2px); background: rgba(20,14,10,.84); }
.tz-power-head { display: flex; align-items: center; justify-content: space-between; letter-spacing: .08em; opacity: .9; }
.tz-power-head b { font-size: 12px; letter-spacing: 0; }
.tz-power-track { display: block; width: 100%; height: 7px; overflow: hidden; border-radius: 999px; background: rgba(255,255,255,.2); box-shadow: inset 0 1px 2px rgba(0,0,0,.25); }
.tz-power-track > span { display: block; width: 62%; height: 100%; border-radius: inherit; background: linear-gradient(90deg,#22c55e,#facc15 62%,#f97316); transition: width .08s linear; }
.tz-power-level { font-size: 9px; letter-spacing: .1em; opacity: .8; }
.tz-hit { position: absolute; right: 16px; bottom: 28px; z-index: 3; display: grid; place-items: center; width: 78px; height: 58px; padding: 0; border: 1px solid rgba(255,255,255,.5); border-radius: 16px; background: rgba(194,65,12,.9); color: #fff; font: 800 .78rem system-ui, sans-serif; box-shadow: 0 3px 12px rgba(0,0,0,.25); touch-action: manipulation; cursor: pointer; }
.tz-hit:active { transform: scale(.96); background: rgba(154,52,18,.96); }
@media (pointer: coarse) {
    .tz-stick { position: absolute; left: 16px; bottom: 16px; z-index: 3; display: grid; place-items: center; width: 116px; height: 116px; border: 1px solid rgba(255,255,255,.4); border-radius: 50%; background: rgba(20,14,10,.34); box-shadow: inset 0 0 0 1px rgba(0,0,0,.12); touch-action: none; }
    .tz-stick-knob { width: 48px; height: 48px; margin: -24px; }
    .tz-stick-mark { font-size: 11px; }
    .tz-stick-up { top: 7px; } .tz-stick-down { bottom: 7px; }
    .tz-stick-left { left: 7px; } .tz-stick-right { right: 7px; }
    .tz-hit { right: 16px; bottom: 30px; width: 84px; height: 64px; border-radius: 18px; font-size: .8rem; }
    .tz-power { right: 108px; bottom: 36px; width: 104px; min-height: 52px; }
    .tz-hint { left: 12px; right: 12px; bottom: 140px; transform: none; width: auto; text-align: center; white-space: normal; font-size: .78rem; }
    .tz-hint.is-on { transform: none; }
}

/* ---- messages ---- */
.tz-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, .5); background: rgba(20, 14, 10, .55); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.tz-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.tz-banner small { display: block; font-size: .5em; font-weight: 700; opacity: .92; }
.tz-banner.is-good { background: linear-gradient(135deg, rgba(234, 88, 12, .92), rgba(154, 52, 18, .9)); }
.tz-banner.is-gold { background: linear-gradient(135deg, rgba(245, 158, 11, .95), rgba(234, 88, 12, .9)); }
.tz-banner.is-cool { background: linear-gradient(135deg, rgba(37, 99, 235, .9), rgba(14, 165, 233, .9)); }
.tz-hint { position: absolute; left: 50%; bottom: 14px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px; background: var(--tz-glass); font-weight: 700; font-size: .92rem; white-space: nowrap; pointer-events: none; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.tz-hint[hidden] { display: none; }
.tz-loading { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: #fff; font-weight: 700; background: linear-gradient(#7fb6dc, #b4532a); }
.tz-loading[hidden] { display: none; }

/* ---- overlays ---- */
.tz-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 14px; background: var(--tz-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; touch-action: manipulation; color: var(--text-color); }
.tz-overlay[hidden] { display: none; }
.tz-card { width: 100%; max-width: 380px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px; border-radius: 18px; background: var(--tz-card-bg); border: 1px solid var(--tz-card-border); box-shadow: var(--tz-shadow); color: var(--text-color); text-align: center; }
.tz-card h2 { font-weight: 800; font-size: 1.4rem; margin: 0; }
.tz-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.tz-mode { min-height: 64px; padding: 8px; border: 1px solid var(--tz-card-border); border-radius: 12px; background: var(--tz-chip-bg); color: inherit; font-weight: 800; font-size: .9rem; line-height: 1.15; display: flex; align-items: center; gap: 8px; cursor: pointer; touch-action: manipulation; text-align: left; }
.tz-mode > svg, .tz-mode > i { flex: none; width: 1.1em; font-size: 1.05rem; color: var(--tz-accent); }
.tz-mode small { display: block; margin-top: 2px; font-weight: 500; font-size: .74rem; color: var(--tz-muted); }
.tz-mode[aria-checked="true"] { background: var(--tz-accent); border-color: var(--tz-accent); color: var(--tz-on-accent); }
.tz-mode[aria-checked="true"] > svg, .tz-mode[aria-checked="true"] > i { color: inherit; }
.tz-mode[aria-checked="true"] small { color: inherit; opacity: .85; }
.tz-opt { display: flex; flex-direction: column; gap: 6px; }
.tz-opt[hidden] { display: none; }
.tz-label { font-weight: 700; font-size: .9rem; color: var(--tz-muted); }
.tz-chips { display: flex; gap: 6px; justify-content: center; }
.tz-chip { flex: 1; min-height: 46px; padding: 4px 6px; border-radius: 12px; border: 1px solid var(--tz-card-border); background: var(--tz-chip-bg); color: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; display: inline-flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1.1; }
.tz-chip small { font-weight: 500; font-size: .7rem; opacity: .8; }
.tz-chip[aria-checked="true"] { background: var(--tz-accent); border-color: var(--tz-accent); color: var(--tz-on-accent); }
.tz-mode-note { margin: 0; font-size: .85rem; color: var(--tz-muted); line-height: 1.4; }
.tz-mode-note:empty { display: none; }
.tz-mode:focus-visible, .tz-chip:focus-visible, .tz-btn:focus-visible { outline: 2px solid var(--tz-accent); outline-offset: 2px; }

.tz-btn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--tz-card-border); background: var(--tz-card-bg); color: inherit; font-weight: 700; font-size: 1rem; display: inline-flex; align-items: center; justify-content: center; gap: 8px; cursor: pointer; touch-action: manipulation; }
.tz-btn:hover { border-color: var(--tz-accent); }
.tz-btn[hidden] { display: none; }
.tz-btn-primary { background: var(--tz-accent); border-color: var(--tz-accent); color: var(--tz-on-accent); }
.tz-btn-ghost { background: transparent; border-color: transparent; color: var(--tz-muted); }
.tz-over-icon { width: 54px; height: 54px; margin: 0 auto; border-radius: 50%; display: grid; place-items: center; font-size: 24px; color: #fff; background: linear-gradient(135deg, #f59e0b, #c2410c); }
.tz-over-big { margin: 0; font-size: 2rem; font-weight: 900; line-height: 1.1; color: var(--tz-accent); font-variant-numeric: tabular-nums; }
.tz-over-big:empty { display: none; }
.tz-over-sub { margin: 0; color: var(--tz-muted); font-size: .92rem; line-height: 1.45; }
.tz-over-sub:empty { display: none; }

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

/* ---- help ---- */
.tz-help { margin: 8px auto 0; padding: 12px 14px; border-radius: 14px; background: var(--tz-card-bg); border: 1px solid var(--tz-card-border); }
.tz-help summary { font-weight: 700; cursor: pointer; min-height: 32px; }
.tz-help ul { margin: 10px 0 4px; padding-left: 20px; line-height: 1.55; }
.tz-help li { margin-bottom: 4px; }
.tz-credit { margin: 8px 0 0; font-size: .82rem; color: var(--tz-muted); }
.tz-credit a, .tz-powered a { color: var(--tz-accent); }
.tz-powered { text-align: center; color: var(--tz-muted); font-size: .85rem; margin: 22px 0 0; }
body.dark-theme .tz-help kbd { background: #43302a; }
body.dark-theme .tz-board, body.dark-theme .tz-round, body.dark-theme .tz-hint { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }

@media (max-width: 420px) {
    .tz-main { padding-top: 88px; }
    .tz-mode { font-size: .84rem; gap: 6px; padding: 7px 6px; min-height: 60px; }
    .tz-mode small { font-size: .7rem; }
}
@media (prefers-reduced-motion: reduce) {
    .tz-banner { transition: none; }
}
