/* Nu te supăra, frate! — a 3D board (js/nu-te-supara.js). Theme-aware like the other game pages: tokens on :root,
   redefined under body.dark-theme. The board itself is painted wood in both themes; the room behind it, the cards,
   the HUD and the player list follow the theme. */
:root {
    --ns-accent: #b45309;
    --ns-accent-2: #be123c;
    --ns-page-bg: #fbf6ee;
    --ns-card-bg: #ffffff;
    --ns-card-border: #eadfcd;
    --ns-muted: #6b6257;
    --ns-shadow: 0 10px 30px rgba(68, 40, 12, .14);
    --ns-stage-bg: radial-gradient(120% 90% at 50% 40%, #f6ead6 0%, #e7d3b3 55%, #cdb18a 100%);
    --ns-overlay: rgba(40, 24, 8, .45);
    --ns-hud: rgba(28, 18, 8, .66);
    --ns-on-accent: #ffffff;
    --ns-cur: #fff7ea;
}

body.dark-theme {
    --ns-accent: #f59e0b;
    --ns-accent-2: #fb7185;
    --ns-page-bg: #0f0d0b;
    --ns-card-bg: #1d1915;
    --ns-card-border: #3a3129;
    --ns-muted: #b3a797;
    --ns-shadow: 0 10px 30px rgba(0, 0, 0, .5);
    --ns-stage-bg: radial-gradient(120% 90% at 50% 40%, #2d241c 0%, #1a1511 55%, #0c0a08 100%);
    --ns-overlay: rgba(6, 4, 2, .6);
    --ns-hud: rgba(10, 8, 6, .7);
    --ns-on-accent: #1a1209;
    --ns-cur: #2a2219;
}

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

/* ---- hero ---- */
.ns-hero { text-align: center; padding: 4px 0 12px; }
.ns-hero h1 { font-weight: 800; font-size: clamp(1.5rem, 5.4vw, 2.3rem); margin: 0 0 6px; display: inline-flex; align-items: center; gap: 12px; }
.ns-hero-icon { width: 46px; height: 46px; flex: none; border-radius: 14px; display: inline-grid; place-items: center; font-size: 22px; color: #fff; background: linear-gradient(135deg, #dc2626 0%, #f59e0b 35%, #16a34a 68%, #2563eb 100%); box-shadow: var(--ns-shadow); }
.ns-lead { max-width: 620px; margin: 0 auto; color: var(--ns-muted); font-size: 1rem; line-height: 1.55; }

/* ---- the stage: the 3D board fills it ---- */
.ns-stage {
    --ns-h: clamp(460px, calc(100vh - 150px), 780px);
    position: relative;
    height: var(--ns-h);
    width: 100%;
    margin: 0 auto;
    background: var(--ns-stage-bg);
    border-radius: 18px;
    overflow: hidden;
    box-shadow: var(--ns-shadow);
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
    -webkit-tap-highlight-color: transparent;
    outline: none;
}
@supports (height: 100svh) {
    .ns-stage { --ns-h: clamp(460px, calc(100svh - 150px), 780px); }
}
/* a portrait phone: the board is square, so a taller stage would only add empty space */
@media (max-width: 575.98px) and (orientation: portrait) {
    .ns-stage { height: min(var(--ns-h), calc(100vw * 1.3 + 40px)); }
    .ns-stage.is-max, .ns-stage:fullscreen { height: 100%; }
}
.ns-stage:focus-visible { box-shadow: 0 0 0 3px var(--ns-accent), var(--ns-shadow); }
@media (max-width: 575.98px) {
    .ns-stage { width: calc(100% + 24px); margin: 0 -12px; border-radius: 0; }
}
.ns-canvas, .ns-canvas2d { position: absolute; inset: 0; display: block; width: 100%; height: 100%; touch-action: none; }
.ns-stage[data-phase="holding"] .ns-canvas { cursor: grab; }
.ns-stage[data-phase="choosing"] .ns-canvas, .ns-stage[data-phase="choosing"] .ns-canvas2d { cursor: pointer; }

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

/* ---- HUD: whose turn (top left), tools (top right) ---- */
.ns-turn { position: absolute; left: 10px; top: 10px; z-index: 2; display: flex; align-items: center; gap: 9px; padding: 7px 10px 7px 9px; border-radius: 16px; background: var(--ns-hud); color: #fff; max-width: calc(100% - 82px); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); pointer-events: none; }
.ns-turn[hidden] { display: none; }
.ns-turn-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.ns-turn-text strong { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-turn-text small { font-size: .8rem; opacity: .88; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-dot { width: 20px; height: 20px; flex: none; border-radius: 50%; background: radial-gradient(circle at 35% 30%, rgba(255, 255, 255, .75), transparent 46%), var(--c, #b45309); box-shadow: 0 1px 3px rgba(0, 0, 0, .45), inset 0 -2px 3px rgba(0, 0, 0, .25); }
.ns-die-chip { flex: none; width: 30px; height: 30px; border-radius: 8px; background: #fbf8f0; color: #1c1917; display: grid; place-items: center; font-weight: 900; font-size: 1.05rem; box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .15), 0 1px 3px rgba(0, 0, 0, .4); }
.ns-die-chip[hidden] { display: none; }

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

/* ---- big messages and the throw button ---- */
.ns-banner { position: absolute; left: 50%; top: 40%; z-index: 2; transform: translate(-50%, -50%) scale(.92); margin: 0; padding: 10px 22px; border-radius: 18px; max-width: 90%; text-align: center; color: #fff; font-weight: 900; font-size: clamp(1.3rem, 6.4vw, 2.3rem); line-height: 1.15; text-shadow: 0 2px 10px rgba(0, 0, 0, .5); background: rgba(28, 18, 8, .62); opacity: 0; pointer-events: none; transition: opacity .25s, transform .25s; }
.ns-banner.is-on { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.ns-banner small { display: block; font-size: .52em; font-weight: 700; opacity: .92; margin-top: 2px; }
.ns-banner.is-six { background: linear-gradient(135deg, rgba(180, 83, 9, .92), rgba(190, 18, 60, .9)); }
.ns-banner.is-cap { background: linear-gradient(135deg, rgba(190, 18, 60, .92), rgba(124, 45, 18, .92)); }

.ns-bottom { position: absolute; left: 0; right: 0; bottom: 14px; z-index: 3; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; padding: 0 12px; }
.ns-hint { margin: 0; padding: 6px 14px; border-radius: 999px; background: var(--ns-hud); color: #fff; font-weight: 700; font-size: .92rem; text-align: center; max-width: 100%; }
.ns-hint[hidden] { display: none; }
.ns-roll { pointer-events: auto; min-height: 54px; min-width: 210px; padding: 10px 24px; border: 0; border-radius: 999px; background: linear-gradient(135deg, #b45309, #be123c); color: #fff; font-weight: 800; font-size: 1.1rem; display: inline-flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 6px 18px rgba(124, 45, 18, .45); cursor: pointer; touch-action: manipulation; }
.ns-roll:hover { filter: brightness(1.07); }
.ns-roll:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
.ns-roll[hidden] { display: none; }
.ns-loading { position: absolute; inset: 0; z-index: 1; display: grid; place-items: center; margin: 0; padding: 20px; text-align: center; color: var(--ns-muted); font-weight: 700; }
.ns-loading[hidden] { display: none; }

/* ---- overlays (setup, game over) ---- */
.ns-overlay { position: absolute; inset: 0; z-index: 5; display: flex; align-items: flex-start; justify-content: center; padding: 12px; background: var(--ns-overlay); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); overflow-y: auto; overscroll-behavior: contain; touch-action: pan-y; }
.ns-overlay[hidden] { display: none; }
.ns-card { width: 100%; max-width: 400px; margin: auto; display: flex; flex-direction: column; gap: 10px; padding: 16px 14px; border-radius: 18px; background: var(--ns-card-bg); border: 1px solid var(--ns-card-border); box-shadow: var(--ns-shadow); color: var(--text-color); text-align: center; }
.ns-card h2 { font-weight: 800; font-size: 1.35rem; margin: 0; }
.ns-card-sub { margin: -4px 0 0; color: var(--ns-muted); font-size: .9rem; }
.ns-seats { display: grid; grid-template-columns: minmax(0, 1fr); gap: 7px; }
.ns-seat { min-width: 0; display: flex; align-items: center; gap: 7px; padding: 6px; border-radius: 14px; background: var(--ns-page-bg); border: 1px solid var(--ns-card-border); }
.ns-seat.is-off { opacity: .62; }
.ns-seat .ns-dot { width: 22px; height: 22px; }
.ns-seat input { flex: 1 1 auto; width: 0; min-width: 0; min-height: 44px; padding: 6px 9px; border-radius: 10px; border: 1px solid var(--ns-card-border); background: var(--ns-card-bg); color: inherit; font-size: 1rem; }
.ns-seat input:disabled { background: transparent; border-color: transparent; color: var(--ns-muted); -webkit-text-fill-color: var(--ns-muted); opacity: 1; }
.ns-seat input:focus { outline: 2px solid var(--ns-accent); outline-offset: 1px; }
.ns-seg { flex: none; display: flex; gap: 2px; padding: 2px; border-radius: 11px; background: var(--ns-card-bg); border: 1px solid var(--ns-card-border); }
.ns-seg button { min-height: 40px; min-width: 40px; padding: 4px 8px; border: 0; border-radius: 9px; background: transparent; color: inherit; font-weight: 700; font-size: .84rem; cursor: pointer; touch-action: manipulation; display: inline-flex; align-items: center; justify-content: center; gap: 4px; }
.ns-seg button[aria-checked="true"] { background: var(--ns-accent); color: var(--ns-on-accent); }
.ns-warn { margin: 0; color: var(--ns-accent-2); font-weight: 700; font-size: .9rem; }
.ns-warn[hidden] { display: none; }
.ns-opt { display: flex; flex-direction: column; gap: 6px; }
.ns-opt[hidden] { display: none; }
.ns-label { font-weight: 700; font-size: .9rem; color: var(--ns-muted); }
.ns-chips { display: flex; gap: 6px; justify-content: center; }
.ns-chip { flex: 1; min-height: 44px; border-radius: 12px; border: 1px solid var(--ns-card-border); background: var(--ns-page-bg); color: inherit; font-weight: 700; cursor: pointer; touch-action: manipulation; }
.ns-chip[aria-checked="true"] { background: var(--ns-accent); border-color: var(--ns-accent); color: var(--ns-on-accent); }
.ns-rules-opt { text-align: left; border-radius: 12px; border: 1px solid var(--ns-card-border); padding: 4px 10px; }
.ns-rules-opt summary { font-weight: 700; min-height: 40px; display: flex; align-items: center; gap: 8px; cursor: pointer; color: var(--ns-muted); }
.ns-rules-opt summary::-webkit-details-marker { display: none; }
.ns-rules-opt summary::after { content: "▾"; margin-left: auto; font-size: .8rem; }
.ns-rules-opt[open] summary::after { content: "▴"; }
.ns-switch { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: .92rem; cursor: pointer; }
.ns-switch input { appearance: none; -webkit-appearance: none; flex: none; width: 42px; height: 24px; border-radius: 999px; background: var(--ns-card-border); position: relative; cursor: pointer; transition: background .2s; margin: 0; }
.ns-switch input::after { content: ""; position: absolute; left: 3px; top: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .3); transition: transform .2s; }
.ns-switch input:checked { background: var(--ns-accent); }
.ns-switch input:checked::after { transform: translateX(18px); }
.ns-switch input:focus-visible { outline: 2px solid var(--ns-accent); outline-offset: 2px; }
.ns-seg button:focus-visible, .ns-chip:focus-visible, .ns-btn:focus-visible { outline: 2px solid var(--ns-accent); outline-offset: 2px; }

.ns-btn { min-height: 48px; padding: 8px 14px; border-radius: 12px; border: 1px solid var(--ns-card-border); background: var(--ns-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; }
.ns-btn:hover { border-color: var(--ns-accent); }
.ns-btn[hidden] { display: none; }
.ns-btn:disabled { opacity: .5; cursor: not-allowed; }
.ns-btn-primary { background: var(--ns-accent); border-color: var(--ns-accent); color: var(--ns-on-accent); }
.ns-btn-ghost { background: transparent; border-color: transparent; color: var(--ns-muted); }
.ns-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, #be123c); }
.ns-over-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.ns-over-list li { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border-radius: 12px; background: var(--ns-page-bg); font-weight: 700; text-align: left; }
.ns-over-list li .ns-n { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ns-over-list li small { color: var(--ns-muted); font-weight: 600; }
.ns-over-list li.is-win { background: linear-gradient(135deg, rgba(245, 158, 11, .25), rgba(190, 18, 60, .16)); }
.ns-over-sub { margin: 0; color: var(--ns-muted); font-size: .92rem; }
.ns-over-sub:empty { display: none; }

/* ---- the players under the board ---- */
.ns-players { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: 8px; margin-top: 12px; }
.ns-player { display: flex; align-items: center; gap: 9px; padding: 9px 11px; border-radius: 14px; background: var(--ns-card-bg); border: 1px solid var(--ns-card-border); min-width: 0; }
.ns-player.is-cur { border-color: var(--c); box-shadow: 0 0 0 1px var(--c); background: var(--ns-cur); }
.ns-player-text { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.ns-player-text strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-player-text small { color: var(--ns-muted); font-size: .76rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ns-pips { display: flex; gap: 3px; flex: none; }
.ns-pip { width: 11px; height: 11px; border-radius: 50%; box-shadow: inset 0 0 0 2px var(--c); opacity: .5; }
.ns-pip.is-track { opacity: 1; background: linear-gradient(90deg, var(--c) 50%, transparent 50%); }
.ns-pip.is-home { opacity: 1; background: var(--c); }

.ns-actions { display: flex; justify-content: center; gap: 8px; margin: 14px 0 8px; }
.ns-actions .ns-btn-icon { width: 48px; min-width: 48px; padding: 0; }
.ns-btn-icon span[hidden] { display: none; }
.ns-actions .ns-btn { min-width: 180px; }
.ns-record { margin: 6px 0 0; text-align: center; color: var(--ns-muted); font-size: .9rem; }
.ns-record:empty { display: none; }
.ns-reset-wrap { text-align: center; margin: 2px 0 12px; }
.ns-reset-wrap[hidden] { display: none; }
.ns-link { border: 0; background: none; padding: 6px; color: var(--ns-muted); font-size: .85rem; text-decoration: underline; cursor: pointer; }

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

@media (max-width: 420px) {
    .ns-main { padding-top: 88px; }
    .ns-seg button { padding: 4px 6px; font-size: .8rem; }
    .ns-seat input { padding: 6px 7px; }
    .ns-players { grid-template-columns: 1fr 1fr; }
    .ns-player { padding: 8px 9px; gap: 7px; }
    .ns-pip { width: 9px; height: 9px; }
}
@media (prefers-reduced-motion: reduce) {
    .ns-banner { transition: none; }
}
