/* ================================================================
   Poker Timer — casino theme
   Felt green, gold leaf, card suits, tasteful motion.
   ================================================================ */

* { box-sizing: border-box; margin: 0; padding: 0; }

/* The hidden attribute must always win, even over display:flex rules below —
   without this, .view and .tabpane panels all render stacked together. */
[hidden] { display: none !important; }

:root {
    --felt-light: #1a6b40;
    --felt: #0d4527;
    --felt-dark: #062b17;
    --panel: rgba(6, 32, 18, .75);
    --panel2: #0d3a21;
    --border: rgba(212, 175, 55, .35);
    --gold: #d4af37;
    --gold-light: #f6e27a;
    --gold-dark: #a67c00;
    --text: #f7f3e8;
    --muted: #9dbfab;
    --red: #e5484d;
    --red-suit: #ff6b6b;
    --warn: #e8a33d;
    --font-display: 'Cinzel', 'Times New Roman', serif;
    --font-num: 'Oswald', 'Arial Narrow', sans-serif;
}

body {
    background:
        radial-gradient(ellipse 120% 90% at 50% 25%,
            var(--felt-light) 0%, var(--felt) 48%, var(--felt-dark) 100%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 Helvetica, Arial, sans-serif;
    min-height: 100vh;
}

/* felt vignette */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    pointer-events: none;
    box-shadow: inset 0 0 22vh rgba(0, 0, 0, .55);
    z-index: 1;
}
body > * { position: relative; z-index: 2; }

/* gold gradient text helper */
.goldtext {
    background: linear-gradient(180deg, var(--gold-light) 0%, var(--gold) 55%, var(--gold-dark) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    color: transparent;
}

/* ================= floating suit backdrop ================= */

.suits-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
}
.suits-bg span {
    position: absolute;
    color: rgba(255, 255, 255, .04);
    animation: driftUp linear infinite;
    user-select: none;
}
@keyframes driftUp {
    from { transform: translateY(15vh) rotate(-8deg); }
    to   { transform: translateY(-120vh) rotate(10deg); }
}

/* ---- mood themes: whole palette swaps via the CSS variables ---- */
body.theme-final {   /* final table: red felt */
    --felt-light: #7a1f1f;
    --felt: #4a1010;
    --felt-dark: #2a0707;
    --panel: rgba(40, 8, 8, .75);
    --panel2: #3a0d0d;
}
body.theme-headsup { /* heads-up: blue felt */
    --felt-light: #1f4f7a;
    --felt: #103a5a;
    --felt-dark: #071f33;
    --panel: rgba(8, 24, 40, .75);
    --panel2: #0d2a42;
}

/* ================= big-screen display ================= */

.display-body {
    display: flex;
    flex-direction: column;
    height: 100vh;
    height: 100dvh; /* mobile browsers: exclude URL bar */
    overflow: hidden;
    text-align: center;
}

.display-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 2.2vh 3vw 0;
}
.display-gamename {
    font-family: var(--font-display);
    font-size: min(3.4vh, 5.5vw);
    font-weight: 700;
    letter-spacing: .08em;
}
.display-code {
    font-size: min(2.2vh, 3.6vw);
    color: var(--muted);
    letter-spacing: .18em;
    border: 1px solid var(--border);
    border-radius: 1.2vh;
    padding: 1vh 1.6vw;
    background: var(--panel);
}
.display-code strong {
    color: var(--gold-light);
    font-family: var(--font-num);
    font-size: min(2.8vh, 4.6vw);
    letter-spacing: .25em;
    margin-left: .4vw;
}

.display-middle {
    flex: 1;
    display: flex;
    align-items: stretch;
    min-height: 0;
}
.display-main {
    flex: 1;
    display: flex;
    min-width: 0;
    padding: 0 3vw;
}
.clockwrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: .8vh;
}

/* final standings (finished game with named players) */
.standings {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 2vh;
    overflow: hidden;
}
.standings-title {
    font-family: var(--font-display);
    font-size: 4.5vh;
    letter-spacing: .3em;
}
.standings ol {
    list-style: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .9vh;
    font-family: var(--font-num);
    font-size: 3.1vh;
    max-height: 62vh;
    overflow: hidden;
}
.standings ol.two-col {
    display: block;
    columns: 2;
    column-gap: 6vw;
    text-align: left;
}
.standings li.st-winner {
    font-size: 6.4vh;
    font-weight: 700;
    color: var(--gold-light);
    text-shadow: 0 0 3vh rgba(246, 226, 122, .4);
}

/* live players panel (item 11) */
.players-panel {
    width: 18vw;
    margin: 1vh 2vw 1vh 0;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1.4vh;
    padding: 1.6vh 1.2vw;
    text-align: left;
    overflow: hidden;
}
.pp-title {
    font-size: 1.9vh;
    letter-spacing: .22em;
    color: var(--muted);
    margin-bottom: 1vh;
}
.players-panel ul {
    list-style: none;
    font-size: 2.2vh;
    line-height: 1.55;
    overflow: hidden;
}
.players-panel .pp-out {
    color: var(--muted);
    text-decoration: line-through;
}

/* confetti (finished) */
.confetti {
    position: fixed;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
    z-index: 3;
}
.confetti span {
    position: absolute;
    top: -4vh;
    border-radius: 25%;
    opacity: .9;
    animation: confFall linear infinite;
}
@keyframes confFall {
    0%   { transform: translateY(0) rotate(0deg); }
    100% { transform: translateY(118vh) rotate(720deg); }
}

.display-level {
    font-family: var(--font-display);
    font-size: min(3.4vh, 4.6vw);
    letter-spacing: .45em;
    color: var(--muted);
    text-transform: uppercase;
}
.display-level::before, .display-level::after {
    content: '—';
    color: var(--gold-dark);
    margin: 0 1.2vw;
}

.display-blinds {
    font-family: var(--font-num);
    font-size: min(15vh, 11vw);
    font-weight: 600;
    line-height: 1.05;
    letter-spacing: .02em;
    filter: drop-shadow(0 .6vh 1.5vh rgba(0, 0, 0, .5));
}
.display-ante {
    font-family: var(--font-num);
    font-size: min(4.2vh, 5.5vw);
    letter-spacing: .3em;
    color: var(--gold-light);
    min-height: 5vh;
}

.display-timer {
    font-family: var(--font-num);
    font-size: min(24vh, 21vw);
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    line-height: 1;
    color: var(--text);
    text-shadow: 0 0 4vh rgba(246, 226, 122, .25), 0 1vh 2vh rgba(0, 0, 0, .6);
    transition: color .4s;
}
.display-timer.urgent {
    color: var(--red);
    text-shadow: 0 0 5vh rgba(229, 72, 77, .5);
    animation: pulse 1s infinite;
}
@keyframes pulse { 50% { opacity: .4; } }

.display-status {
    font-family: var(--font-display);
    font-size: min(3.2vh, 4.4vw);
    letter-spacing: .4em;
    color: var(--warn);
    min-height: 4.2vh;
    animation: blinkSoft 2.4s ease-in-out infinite;
}
@keyframes blinkSoft { 50% { opacity: .35; } }

.progress {
    width: 68vw;
    height: 1.5vh;
    background: rgba(0, 0, 0, .45);
    border: 1px solid var(--border);
    border-radius: 1vh;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    width: 0;
    background: linear-gradient(90deg, var(--gold-dark), var(--gold) 40%, var(--gold-light));
    background-size: 200% 100%;
    animation: shimmer 3s linear infinite;
    transition: width 1s linear;
}
@keyframes shimmer {
    from { background-position: 200% 0; }
    to   { background-position: -200% 0; }
}

.display-next {
    font-size: min(2.9vh, 4.2vw);
    letter-spacing: .12em;
    color: var(--muted);
    margin-top: .6vh;
}
.display-latereg {
    font-size: min(2.4vh, 3.8vw);
    letter-spacing: .18em;
    color: var(--gold-light);
    min-height: 3vh;
}
.display-payouts {
    font-family: var(--font-num);
    font-size: min(3vh, 4.4vw);
    letter-spacing: .08em;
    color: var(--gold-light);
    text-align: center;
    padding: 0 3vw 1.2vh;
    min-height: 3.4vh;
}

.display-topright {
    display: flex;
    align-items: center;
    gap: 1vw;
}
.sound-btn {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1.2vh;
    cursor: pointer;
    font-size: 2.6vh;
    line-height: 1;
    padding: 1vh 1.2vh;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.sound-btn:active { transform: scale(.94); }

/* level-change entrance */
.swap { animation: swapIn .7s cubic-bezier(.18, .85, .3, 1.15); }
@keyframes swapIn {
    0%   { opacity: 0; transform: translateY(4vh) scale(.9); }
    100% { opacity: 1; transform: none; }
}

/* stats row */
.display-stats {
    display: flex;
    justify-content: center;
    gap: 2.4vw;
    padding: 0 3vw 3vh;
}
.stat {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 1.4vh;
    padding: 1.6vh 2vw;
    min-width: 14vw;
    box-shadow: 0 .8vh 2vh rgba(0, 0, 0, .35);
}
.stat-label {
    font-size: 1.9vh;
    letter-spacing: .22em;
    color: var(--muted);
}
.stat-label .suit { font-size: 2.2vh; margin-right: .4vw; }
.suit.black { color: var(--gold); }
.suit.red   { color: var(--red-suit); }
.stat-value {
    font-family: var(--font-num);
    font-size: 5vh;
    font-weight: 600;
    color: var(--text);
    margin-top: .4vh;
}
.stat-value.pop { animation: statPop .5s ease; }
@keyframes statPop {
    40% { transform: scale(1.22); color: var(--gold-light); }
}

/* ================= director / landing ================= */

.director-body {
    padding: 16px;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)); /* iPhone home bar */
    max-width: 560px;
    margin: 0 auto;
}

.view { display: flex; flex-direction: column; gap: 16px; }

.dir-title {
    font-family: var(--font-display);
    text-align: center;
    font-size: 1.7rem;
    letter-spacing: .06em;
    padding: 10px 0 2px;
}

.logo-chip {
    width: 84px;
    height: 84px;
    margin: 8px auto 0;
    text-decoration: none;
    cursor: pointer;
    transition: transform .15s;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 30%, #17563a, var(--felt-dark) 75%);
    border: 4px solid var(--gold);
    outline: 3px dashed rgba(247, 243, 232, .55);
    outline-offset: -12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.2rem;
    color: var(--gold-light);
    box-shadow: 0 8px 22px rgba(0, 0, 0, .45);
    animation: chipSpin 1s cubic-bezier(.2, .8, .3, 1.1);
}
@keyframes chipSpin {
    from { transform: rotate(-180deg) scale(.3); opacity: 0; }
    to   { transform: none; opacity: 1; }
}
a.logo-chip:active { transform: scale(.92); }

.card {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
    animation: dealIn .5s ease backwards;
}
.card:nth-of-type(2) { animation-delay: .12s; }
.card:nth-of-type(3) { animation-delay: .24s; }
@keyframes dealIn {
    from { opacity: 0; transform: translateY(18px); }
    to   { opacity: 1; transform: none; }
}
.card h2 {
    font-family: var(--font-display);
    font-size: 1.05rem;
    letter-spacing: .04em;
    color: var(--gold-light);
}

form { display: flex; flex-direction: column; gap: 12px; }

label {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: .9rem;
    color: var(--muted);
}
input, select, textarea {
    background: rgba(0, 0, 0, .35);
    border: 1px solid var(--border);
    border-radius: 9px;
    color: var(--text);
    font-size: 16px; /* >=16px stops iOS zooming in on focus */
    padding: 12px;
    width: 100%;
    transition: border-color .2s, box-shadow .2s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--gold);
    box-shadow: 0 0 0 3px rgba(212, 175, 55, .25);
}
textarea { font-family: inherit; resize: vertical; }

.btn {
    background: var(--panel2);
    border: 1px solid var(--border);
    border-radius: 11px;
    color: var(--text);
    cursor: pointer;
    font-size: 1rem;
    min-height: 48px; /* comfortable touch target */
    padding: 13px 16px;
    text-align: center;
    text-decoration: none;
    /* <a> and <button> render identically: text centred both axes */
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: manipulation; /* no double-tap zoom delay */
    user-select: none;
    -webkit-user-select: none;
    transition: transform .12s, box-shadow .2s, filter .2s;
    -webkit-tap-highlight-color: transparent;
}
.btn:hover { filter: brightness(1.12); }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .45; cursor: default; }

.btn-primary {
    background: linear-gradient(180deg, var(--gold-light), var(--gold) 55%, var(--gold-dark));
    border-color: var(--gold-dark);
    color: #241a00;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(212, 175, 55, .3);
}
.btn-danger { background: transparent; border-color: var(--red); color: var(--red); }
.btn-warn {
    background: linear-gradient(180deg, #f3bd63, var(--warn));
    border-color: #a86f1c;
    color: #241400;
    font-weight: 700;
}
.btn-big   { font-size: 1.2rem; padding: 16px; flex: 1; }
.btn-small { padding: 8px 14px; font-size: .85rem; min-height: 40px; }
.btn-block { display: flex; width: 100%; }

.btnrow { display: flex; gap: 10px; }
.btnrow .btn { flex: 1; }
/* small buttons keep their natural size instead of stretching to fill */
.btnrow .btn-small { flex: 0 1 auto; }

.msg { min-height: 1.2em; text-align: center; color: #7fe0a7; font-size: .95rem; }
.msg.error { color: var(--red-suit); }
.hint { color: var(--muted); font-size: .85rem; }
.hint-inline { color: var(--muted); font-size: .8rem; font-family: inherit; font-weight: 400; }
.hint-link { color: var(--muted); }
.hint-link:active { color: var(--gold-light); }

/* setup "is it set?" status lines */
.setline { color: var(--muted); font-size: .85rem; }
.setline.set { color: #7fe0a7; font-weight: 600; }

.acct-games { display: flex; flex-direction: column; gap: 8px; }
.btn-mygame { text-align: left; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 5-tab row: tighter so all fit on a phone */
.tabs-5 .tab { padding: 11px 4px; font-size: .9rem; min-height: 44px; }

/* clock nudge buttons */
.nudgerow {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 10px;
}
.nudgerow .btn-mini { min-width: 56px; font-variant-numeric: tabular-nums; }

/* registration name picker */
.reg-picker {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}
.reg-picker .btn-mini { flex: 0 1 auto; }

/* history view */
.hist-list { display: flex; flex-direction: column; }
.hist-row {
    background: none;
    border: none;
    border-bottom: 1px solid rgba(212, 175, 55, .15);
    color: var(--text);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 12px 4px;
    text-align: left;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
.hist-row:last-child { border-bottom: none; }
.hist-row:active { background: rgba(212, 175, 55, .08); }
.hist-top { font-weight: 600; }
.hist-bottom { color: var(--muted); font-size: .85rem; }

/* player roster */
#anon-controls { display: flex; flex-direction: column; gap: 12px; }
.roster-list { display: flex; flex-direction: column; }
.roster-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 8px;
    padding: 8px 2px;
    border-bottom: 1px solid rgba(212, 175, 55, .15);
}
.roster-row:last-child { border-bottom: none; }
.roster-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.roster-out .roster-name { color: var(--muted); text-decoration: line-through; }
.roster-btns { display: flex; gap: 6px; flex-shrink: 0; }
.btn-mini { min-height: 40px; padding: 8px 12px; font-size: .85rem; }
#form-roster input { flex: 1; }
#form-roster .btn { flex: 0 0 auto; }

/* control header */
.dir-header { display: flex; justify-content: space-between; align-items: center; }
.dir-gamename { font-family: var(--font-display); font-size: 1.2rem; font-weight: 700; }
.dir-code { color: var(--muted); font-size: .9rem; }
.dir-code strong { color: var(--gold-light); letter-spacing: .12em; }
.dir-code a { color: #7fe0a7; }

/* tabs */
.tabs { display: flex; gap: 8px; }
.tab {
    flex: 1;
    background: var(--panel);
    border: 1px solid var(--border);
    border-bottom-width: 3px;
    border-radius: 11px;
    color: var(--muted);
    cursor: pointer;
    font-size: 1rem;
    min-height: 48px;
    padding: 12px;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: color .2s, border-color .2s;
}
.tab.active {
    color: var(--gold-light);
    border-color: var(--gold);
    background: var(--panel2);
}

.tabpane { display: flex; flex-direction: column; gap: 14px; animation: dealIn .35s ease; }

/* timer tab */
.c-timerbox {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 14px;
    padding: 22px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(0, 0, 0, .3);
}
.c-level {
    font-family: var(--font-display);
    color: var(--muted);
    letter-spacing: .2em;
    font-size: .85rem;
    text-transform: uppercase;
}
.c-blinds {
    font-family: var(--font-num);
    font-size: 2rem;
    font-weight: 600;
    margin: 6px 0;
}
.c-clock {
    font-family: var(--font-num);
    font-size: 4rem;
    font-weight: 600;
    font-variant-numeric: tabular-nums;
    text-shadow: 0 0 24px rgba(246, 226, 122, .25);
}
.c-status {
    color: var(--warn);
    letter-spacing: .3em;
    font-size: .8rem;
    min-height: 1.1em;
    animation: blinkSoft 2.4s ease-in-out infinite;
}

/* levels editor */
.levels-table-wrap { overflow-x: auto; }
.levels-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.levels-table th {
    color: var(--gold-light);
    font-weight: 600;
    text-align: left;
    padding: 6px 4px;
    border-bottom: 1px solid var(--border);
    letter-spacing: .06em;
}
.levels-table td { padding: 4px 3px; border-bottom: 1px solid rgba(212, 175, 55, .15); }
.levels-table input { padding: 10px 6px; font-size: 16px; min-width: 62px; }
.levels-table .lvl-num { color: var(--muted); width: 24px; text-align: center; }
.levels-table .td-break { text-align: center; width: 30px; }
.row-break td { background: rgba(212, 175, 55, .08); }
.btn-del {
    background: none;
    border: none;
    color: var(--red);
    cursor: pointer;
    font-size: 1.1rem;
    padding: 12px 8px; /* bigger touch target */
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

/* ---- phones / portrait: stacked header, 2x2 stat grid ---- */
@media (orientation: portrait), (max-width: 700px) {
    .display-body {
        height: auto;
        min-height: 100dvh;
        overflow-y: auto; /* never trap content off-screen on small phones */
    }
    .display-top {
        flex-direction: column;
        gap: 1vh;
        padding-top: 1.6vh;
    }
    .display-code { padding: .8vh 4vw; }
    .clockwrap { gap: .5vh; }
    .display-middle { flex-direction: column; }
    .players-panel {
        width: auto;
        margin: 0 3vw 1vh;
        max-height: 24vh;
    }
    .players-panel ul { columns: 2; column-gap: 6vw; }
    .display-blinds { font-size: min(11vh, 14vw); }
    .display-ante { font-size: min(3.6vh, 5.5vw); min-height: 4vh; }
    .display-timer { font-size: min(17vh, 26vw); }
    .progress { width: 88vw; height: 1.2vh; }
    .display-stats {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 2.4vw;
        padding: 0 3vw 2vh;
    }
    .stat { min-width: 0; padding: 1.3vh 2vw; }
    .stat:last-child:nth-child(odd) { grid-column: span 2; } /* 5th stat full width */
    .stat-label { font-size: min(1.9vh, 3.4vw); letter-spacing: .14em; }
    .stat-value { font-size: min(4.4vh, 7vw); }
    .display-payouts { font-size: min(2.6vh, 4.6vw); }
}

/* very short landscape phones: trim vertical chrome */
@media (max-height: 450px) {
    .display-top { padding-top: 1vh; }
    .display-stats { padding-bottom: 1.2vh; }
    .stat { padding: .8vh 2vw; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after { animation: none !important; transition: none !important; }
}
