/* Penalty-uri — a penalty shootout in 3D on a village pitch (js/penalty.js). Theme-aware like the
   other game pages: tokens on :root, redefined under body.dark-theme. The stadium follows the
   theme too: a sunny afternoon in light, a floodlit evening in dark. */
:root {
    --pn-accent: #15803d;
    --pn-accent-2: #2563eb;
    --pn-on-accent: #ffffff;
    --pn-page-bg: #f0fdf4;
    --pn-card-bg: #ffffff;
    --pn-card-border: #bbf7d0;
    --pn-muted: #4b5f52;
    --pn-shadow: 0 10px 30px rgba(20, 83, 45, .16);
    --pn-stage-bg: #8ec5ea;
    --pn-overlay: rgba(15, 23, 18, .45);
    --pn-chip-bg: #f0fdf4;
    --pn-glass: rgba(10, 18, 12, .58);
    --pn-goal: #22c55e;
    --pn-miss: #ef4444;
    --pn-gold: #f59e0b;
    --pn-t0: #dc2626;
    --pn-t1: #2563eb;
}

body.dark-theme {
    --pn-accent: #4ade80;
    --pn-accent-2: #60a5fa;
    --pn-on-accent: #052e16;
    --pn-page-bg: #07120b;
    --pn-card-bg: #0f1d14;
    --pn-card-border: #1f3d2a;
    --pn-muted: #a7c4b0;
    --pn-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --pn-stage-bg: #0b1220;
    --pn-overlay: rgba(3, 8, 5, .62);
    --pn-chip-bg: #142a1c;
    --pn-glass: rgba(3, 8, 5, .62);
    --pn-goal: #4ade80;
    --pn-miss: #f87171;
    --pn-gold: #fbbf24;
    --pn-t0: #f87171;
    --pn-t1: #60a5fa;
}

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

/* ---- hero ---- */
.pn-hero { text-align: center; padding: 4px 0 12px; }
.pn-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; }
.pn-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, #166534); box-shadow: var(--pn-shadow); }
.pn-lead { max-width: 600px; margin: 0 auto; color: var(--pn-muted); font-size: 1rem; line-height: 1.55; }

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

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

/* ---- scoreboard ---- */
.pn-board { position: absolute; left: 10px; right: 62px; top: 10px; z-index: 2; display: grid; gap: 4px; pointer-events: none; }
.pn-board[hidden] { display: none; }
.pn-row { display: flex; align-items: center; gap: 8px; padding: 5px 10px; border-radius: 12px; background: var(--pn-glass); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); border: 2px solid transparent; min-height: 34px; }
.pn-row.is-cur { border-color: var(--c, #dc2626); }
.pn-row-name { flex: 0 1 auto; min-width: 0; max-width: 42%; font-weight: 800; font-size: .88rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pn-row-dots { flex: 1; display: flex; gap: 4px; justify-content: flex-start; min-width: 0; overflow: hidden; }
.pn-row-dots i { flex: none; width: 13px; height: 13px; border-radius: 50%; box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .45); font-style: normal; position: relative; }
.pn-row-dots i.is-in { background: var(--pn-goal); box-shadow: none; }
.pn-row-dots i.is-out { background: var(--pn-miss); box-shadow: none; }
.pn-row-dots i.is-out::after { content: ""; position: absolute; left: 3px; right: 3px; top: 5.5px; height: 2px; background: rgba(255, 255, 255, .9); transform: rotate(-45deg); }
.pn-row-dots i.is-sd { border-radius: 3px; }
.pn-row-dots i.is-now { box-shadow: inset 0 0 0 2px #fff, 0 0 0 2px rgba(255, 255, 255, .35); }
.pn-row-score { font-weight: 900; font-size: 1.15rem; font-variant-numeric: tabular-nums; min-width: 2ch; text-align: right; }
.pn-row-sub { font-size: .76rem; opacity: .85; white-space: nowrap; }
.pn-dot { width: 14px; height: 14px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .65), transparent 45%), var(--c, #dc2626); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }

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

.pn-role { position: absolute; left: 50%; bottom: 10px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 5px 12px; border-radius: 999px; background: var(--pn-glass); font-weight: 700; font-size: .85rem; white-space: nowrap; pointer-events: none; max-width: calc(100% - 24px); overflow: hidden; text-overflow: ellipsis; }
.pn-role:empty { display: none; }

/* ---- big messages ---- */
.pn-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.4rem); line-height: 1.15; letter-spacing: .02em; text-shadow: 0 3px 12px rgba(0, 0, 0, .5); background: rgba(10, 18, 12, .55); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.pn-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.pn-banner small { display: block; font-size: .5em; font-weight: 700; letter-spacing: 0; opacity: .92; }
.pn-banner.is-good { background: linear-gradient(135deg, rgba(22, 163, 74, .94), rgba(21, 128, 61, .92)); }
.pn-banner.is-bad { background: linear-gradient(135deg, rgba(220, 38, 38, .92), rgba(153, 27, 27, .9)); }
.pn-banner.is-gold { background: linear-gradient(135deg, rgba(245, 158, 11, .95), rgba(234, 88, 12, .9)); }
.pn-banner.is-cool { background: linear-gradient(135deg, rgba(37, 99, 235, .9), rgba(14, 165, 233, .9)); }

.pn-hint { position: absolute; left: 50%; bottom: 46px; z-index: 2; transform: translateX(-50%); margin: 0; padding: 8px 14px; border-radius: 999px; background: var(--pn-glass); font-weight: 700; font-size: .92rem; white-space: nowrap; pointer-events: none; max-width: calc(100% - 20px); overflow: hidden; text-overflow: ellipsis; }
.pn-hint[hidden] { display: none; }
.pn-hint-icon { display: inline-block; animation: pn-swipe 1.6s ease-in-out infinite; }
@keyframes pn-swipe { 0%, 15% { transform: translateY(6px); opacity: .4; } 60% { transform: translateY(-8px); opacity: 1; } 100% { transform: translateY(-8px); opacity: 0; } }

/* keyboard power gauge */
.pn-gauge { position: absolute; left: 50%; bottom: 84px; z-index: 2; width: min(280px, calc(100% - 40px)); transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 4px; opacity: 0; transition: opacity .25s; pointer-events: none; }
.pn-gauge.is-on { opacity: 1; }
.pn-gauge-bar { position: relative; width: 100%; height: 12px; border-radius: 999px; background: linear-gradient(90deg, rgba(134, 239, 172, .9), rgba(250, 204, 21, .9) 60%, rgba(239, 68, 68, .95)); box-shadow: 0 0 0 2px rgba(0, 0, 0, .25); }
.pn-gauge-mark { position: absolute; top: -6px; width: 6px; height: 24px; margin-left: -3px; border-radius: 3px; background: #fff; box-shadow: 0 0 0 2px rgba(0, 0, 0, .55); left: 0; }
.pn-gauge-txt { padding: 3px 10px; border-radius: 999px; background: var(--pn-glass); font-weight: 800; font-size: .85rem; white-space: nowrap; }
.pn-gauge-txt:empty { display: none; }

.pn-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(#5aa7dd, #2f6f3f); }
.pn-loading[hidden] { display: none; }

/* ---- overlays (setup, cover, pause, game over) ---- */
.pn-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: center; justify-content: center; padding: 14px; background: var(--pn-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; touch-action: manipulation; color: var(--text-color); }
.pn-overlay[hidden] { display: none; }
#pn-cover { background: linear-gradient(160deg, rgba(20, 83, 45, .96), rgba(8, 30, 16, .98)); }
.pn-card { width: 100%; max-width: 390px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 18px 16px; border-radius: 18px; background: var(--pn-card-bg); border: 1px solid var(--pn-card-border); box-shadow: var(--pn-shadow); color: var(--text-color); text-align: center; }
.pn-card h2 { font-weight: 800; font-size: 1.4rem; margin: 0; }
.pn-modes { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.pn-mode { min-height: 64px; padding: 8px 8px; border: 1px solid var(--pn-card-border); border-radius: 12px; background: var(--pn-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; }
.pn-mode > svg, .pn-mode > i { flex: none; width: 1.1em; font-size: 1.05rem; color: var(--pn-accent); }
.pn-mode small { display: block; margin-top: 2px; font-weight: 500; font-size: .74rem; color: var(--pn-muted); }
.pn-mode[aria-checked="true"] { background: var(--pn-accent); border-color: var(--pn-accent); color: var(--pn-on-accent); }
.pn-mode[aria-checked="true"] > svg, .pn-mode[aria-checked="true"] > i { color: inherit; }
.pn-mode[aria-checked="true"] small { color: inherit; opacity: .85; }
.pn-opt { display: flex; flex-direction: column; gap: 6px; }
.pn-opt[hidden] { display: none; }
.pn-label { font-weight: 700; font-size: .9rem; color: var(--pn-muted); }
.pn-chips { display: flex; gap: 6px; justify-content: center; }
.pn-chip { flex: 1; min-height: 44px; padding: 4px 8px; border-radius: 12px; border: 1px solid var(--pn-card-border); background: var(--pn-chip-bg); color: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.pn-chip[aria-checked="true"] { background: var(--pn-accent); border-color: var(--pn-accent); color: var(--pn-on-accent); }
.pn-names { display: grid; gap: 6px; }
.pn-names[hidden], .pn-name[hidden] { display: none; }
.pn-name { display: flex; align-items: center; gap: 8px; margin: 0; }
.pn-name input { flex: 1; min-width: 0; min-height: 44px; padding: 6px 10px; border-radius: 10px; border: 1px solid var(--pn-card-border); background: var(--pn-chip-bg); color: inherit; font-size: 1rem; }
.pn-name input:focus { outline: 2px solid var(--pn-accent); outline-offset: 1px; }
.pn-mode-note { margin: 0; font-size: .85rem; color: var(--pn-muted); line-height: 1.4; }
.pn-mode-note:empty { display: none; }
.pn-mode:focus-visible, .pn-chip:focus-visible, .pn-btn:focus-visible { outline: 2px solid var(--pn-accent); outline-offset: 2px; }

.pn-btn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--pn-card-border); background: var(--pn-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; }
.pn-btn:hover { border-color: var(--pn-accent); }
.pn-btn[hidden] { display: none; }
.pn-btn-primary { background: var(--pn-accent); border-color: var(--pn-accent); color: var(--pn-on-accent); }
.pn-btn-ghost { background: transparent; border-color: transparent; color: var(--pn-muted); }
.pn-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, #15803d); }
.pn-cover-icon { background: linear-gradient(135deg, #22c55e, #2563eb); }
.pn-over-big { margin: 0; font-size: 2.6rem; font-weight: 900; line-height: 1; color: var(--pn-accent); font-variant-numeric: tabular-nums; }
.pn-over-big:empty { display: none; }
.pn-over-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.pn-over-list:empty { display: none; }
.pn-over-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--pn-chip-bg); font-weight: 700; text-align: left; }
.pn-over-list li .pn-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pn-over-list li strong { font-size: 1.15rem; font-variant-numeric: tabular-nums; }
.pn-over-list li.is-win { background: linear-gradient(135deg, rgba(245, 158, 11, .25), rgba(21, 128, 61, .2)); }
.pn-over-sub { margin: 0; color: var(--pn-muted); font-size: .92rem; }
.pn-over-sub:empty { display: none; }

/* ---- the tournament bracket ---- */
.pn-tour { margin: 12px 0 0; padding: 10px 12px 12px; border-radius: 14px; background: var(--pn-card-bg); border: 1px solid var(--pn-card-border); }
.pn-tour[hidden] { display: none; }
.pn-bracket { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 6px; text-align: left; }
.pn-bracket:empty { display: none; }
.pn-bcol { display: flex; flex-direction: column; justify-content: space-around; gap: 6px; min-width: 0; }
.pn-bcol h3 { font-size: .74rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; color: var(--pn-muted); margin: 0; text-align: center; }
.pn-match { border-radius: 10px; background: var(--pn-chip-bg); border: 1px solid var(--pn-card-border); padding: 4px 6px; font-size: .74rem; line-height: 1.3; min-width: 0; }
.pn-match div { display: flex; justify-content: space-between; gap: 4px; white-space: nowrap; overflow: hidden; }
.pn-match span { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pn-match b { font-variant-numeric: tabular-nums; flex: none; }
.pn-match .is-me { color: var(--pn-accent); font-weight: 800; }
.pn-match .is-lost { opacity: .5; text-decoration: line-through; }
.pn-match.is-next { border-color: var(--pn-accent); box-shadow: 0 0 0 1px var(--pn-accent); }

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

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

body.dark-theme .pn-round, body.dark-theme .pn-role, body.dark-theme .pn-hint, body.dark-theme .pn-gauge-txt { box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .16); }
body.dark-theme .pn-row:not(.is-cur) { border-color: rgba(255, 255, 255, .16); }

@media (max-width: 420px) {
    .pn-main { padding-top: 88px; }
    .pn-mode { font-size: .84rem; gap: 6px; padding: 7px 6px; min-height: 60px; }
    .pn-mode small { font-size: .7rem; }
    .pn-row-dots i { width: 12px; height: 12px; }
    .pn-row-dots { gap: 3px; }
    .pn-bracket { gap: 4px; }
    .pn-match { font-size: .7rem; padding: 3px 4px; }
}
@media (max-width: 359.98px) {
    .pn-modes { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) {
    .pn-hint-icon { animation: none; }
    .pn-banner { transition: none; }
}
