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

:root {
    --yellow: #FFE100;
    --black:  #000000;
    --white:  #ffffff;
    --dark:   #111111;
    --dark2:  #1a1a1a;
    --dark3:  #2a2a2a;
    --green:  #2ecc71;
    --green2: #27ae60;
}

html, body {
    height: 100%;
    height: 100dvh;
}

body {
    font-family: 'Nunito', system-ui, sans-serif;
    background: var(--dark);
    color: var(--white);
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ── Screens ── */
.screen { display: none; height: 100dvh; flex-direction: column; }
.screen.active { display: flex; }

/* ── AYG Logo ── */
.ayg-logo {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(2.8rem, 9vw, 5rem);
    color: var(--yellow);
    text-align: center;
    line-height: .95;
    letter-spacing: .04em;
    text-shadow: 3px 3px 0 rgba(0,0,0,.35);
}

/* ────────────────────────────
   Loading
──────────────────────────── */
#screen-loading {
    align-items: center;
    justify-content: center;
    gap: 2rem;
}
.spinner {
    width: 36px; height: 36px;
    border: 4px solid #333;
    border-top-color: var(--yellow);
    border-radius: 50%;
    animation: spin .75s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ────────────────────────────
   Setup
──────────────────────────── */
#screen-setup {
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem 1.5rem;
    gap: 1.75rem;
    overflow-y: auto;
}
.setup-box {
    background: var(--dark3);
    border-radius: 16px;
    padding: 1.5rem;
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.setup-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: .12em;
    color: var(--yellow);
    text-align: center;
}
.count-row {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: .5rem;
}
.count-btn {
    width: 100%; height: 46px;
    border: 2px solid #444;
    background: var(--dark2);
    color: var(--white);
    border-radius: 8px;
    font-size: 1.15rem;
    font-weight: 800;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s;
}
.count-btn.active {
    background: var(--yellow);
    border-color: var(--yellow);
    color: var(--black);
}
.name-inputs { display: flex; flex-direction: column; gap: .5rem; }
.name-input {
    width: 100%;
    padding: .7rem 1rem;
    background: var(--dark2);
    border: 2px solid #444;
    color: var(--white);
    border-radius: 8px;
    font-size: 1rem;
    font-family: 'Nunito', sans-serif;
    font-weight: 700;
    transition: border-color .12s;
}
.name-input::placeholder { color: #555; }
.name-input:focus { outline: none; border-color: var(--yellow); }

/* ── How to Play button ── */
.btn-howtoplay {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.2rem;
    letter-spacing: .1em;
    padding: .65rem 2rem;
    background: transparent;
    color: #888;
    border: 2px solid #444;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
    transition: color .15s, border-color .15s;
}
.btn-howtoplay:hover { color: var(--white); border-color: #777; }

/* ── Modal ── */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.75);
    z-index: 100;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}
.modal-overlay.open { display: flex; }
.modal-box {
    background: var(--dark2);
    border: 2px solid #333;
    border-radius: 16px;
    padding: 2rem 1.75rem;
    width: 100%;
    max-width: 460px;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 1rem; right: 1rem;
    background: none;
    border: none;
    color: #666;
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    padding: .25rem .4rem;
    transition: color .15s;
}
.modal-close:hover { color: var(--white); }
.modal-title {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    letter-spacing: .1em;
    color: var(--yellow);
    margin-bottom: 1.25rem;
}
.modal-steps {
    list-style: none;
    counter-reset: steps;
    display: flex;
    flex-direction: column;
    gap: .85rem;
    padding: 0;
}
.modal-steps li {
    counter-increment: steps;
    display: flex;
    gap: .85rem;
    align-items: flex-start;
    font-size: .95rem;
    line-height: 1.5;
    color: #ccc;
}
.modal-steps li::before {
    content: counter(steps);
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.3rem;
    color: var(--yellow);
    min-width: 22px;
    line-height: 1.2;
}
.modal-steps li strong { color: var(--white); }

/* ── Custom Cards ── */
.custom-cards-wrap {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.custom-cards-body {
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.custom-input-row {
    display: flex;
    gap: .5rem;
}
.custom-input-row .name-input { flex: 1; }
.btn-add-custom {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    letter-spacing: .05em;
    padding: .7rem 1rem;
    background: var(--yellow);
    color: var(--black);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    white-space: nowrap;
    transition: opacity .12s;
    flex-shrink: 0;
}
.btn-add-custom:hover { opacity: .85; }
.custom-card-list {
    display: flex;
    flex-direction: column;
    gap: .35rem;
    max-height: 160px;
    overflow-y: auto;
}
.custom-card-item {
    display: flex;
    align-items: center;
    gap: .5rem;
    background: var(--dark);
    border-radius: 6px;
    padding: .45rem .65rem;
    font-size: .85rem;
    color: #ccc;
}
.custom-card-text {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.custom-card-remove {
    background: none;
    border: none;
    color: #555;
    cursor: pointer;
    font-size: .85rem;
    padding: 0 .2rem;
    transition: color .12s;
    flex-shrink: 0;
}
.custom-card-remove:hover { color: #e74c3c; }

/* ── Deal button ── */
.btn-deal {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.6rem;
    letter-spacing: .1em;
    padding: .8rem 2rem;
    background: var(--yellow);
    color: var(--black);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
    transition: opacity .12s, transform .1s;
}
.btn-deal:hover  { opacity: .9; }
.btn-deal:active { transform: scale(.97); }

/* ── YouTube link ── */
.site-links {
    display: inline-flex;
    flex-direction: column;
    align-items: flex-start;
    margin-top: auto;
    padding-bottom: 1.25rem;
    gap: .5rem;
}
.yt-link {
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #555;
    text-decoration: none;
    font-size: .78rem;
    font-weight: 700;
    letter-spacing: .04em;
    transition: color .15s;
}
.yt-link:hover { color: #888; }

/* ────────────────────────────
   Solo Screen
──────────────────────────── */
#screen-solo {
    align-items: center;
    justify-content: flex-start;
    padding-top: 4rem;
    overflow-y: auto;
}
.solo-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 2rem;
    text-align: center;
}
.solo-eyebrow {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    color: #666;
    letter-spacing: .03em;
    text-align: center;
    width: 100%;
}
.solo-verdict {
    font-family: 'Bebas Neue', sans-serif;
    font-size: clamp(4rem, 18vw, 9rem);
    color: var(--yellow);
    line-height: .95;
    text-shadow: 4px 4px 0 rgba(0,0,0,.35);
    text-align: center;
    width: 100%;
}
.solo-back {
    max-width: 220px;
    font-size: 1.2rem;
    background: var(--dark3);
    color: var(--white);
    margin-top: .5rem;
}
.solo-back:hover { opacity: .8; }

/* ────────────────────────────
   Score Bar
──────────────────────────── */
.scorebar {
    background: var(--dark2);
    border-bottom: 1px solid #2a2a2a;
    padding: .45rem 1rem;
    display: flex;
    gap: .6rem;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    flex-shrink: 0;
    min-height: 42px;
}
.score-chip {
    font-size: .82rem;
    font-weight: 800;
    background: var(--dark3);
    border-radius: 20px;
    padding: .2rem .7rem;
    white-space: nowrap;
}
.score-chip .pts {
    color: var(--yellow);
    margin-left: .35rem;
}

/* ────────────────────────────
   Game Screen
──────────────────────────── */
#screen-game { overflow: hidden; }

.game-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 1rem 1.25rem;
    gap: .85rem;
    overflow-y: auto;
}

/* ── Card ── */
.card-face {
    background: var(--yellow);
    border-radius: 20px;
    width: 100%;
    max-width: 480px;
    padding: 1.1rem 1.25rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .6rem;
    box-shadow: 0 10px 36px rgba(0,0,0,.55);
    flex-shrink: 0;
    transition: transform .25s ease, opacity .25s ease;
}
.card-face.out {
    transform: scale(.88);
    opacity: 0;
    pointer-events: none;
}
.card-branding {
    font-family: 'Bebas Neue', sans-serif;
    font-size: .8rem;
    letter-spacing: .22em;
    color: rgba(0,0,0,.35);
    align-self: flex-start;
}
.card-circle {
    width: min(76%, 280px);
    aspect-ratio: 1 / 1;
    background: var(--white);
    border: 4px solid var(--black);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 13%;
    text-align: center;
}
.card-question {
    font-family: 'Nunito', sans-serif;
    font-weight: 900;
    color: var(--black);
    line-height: 1.3;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
    /* font-size set by JS based on text length */
    font-size: 1.2rem;
}
.card-footer {
    font-family: 'Bebas Neue', sans-serif;
    font-size: .78rem;
    letter-spacing: .18em;
    color: rgba(0,0,0,.35);
    align-self: flex-end;
}

/* ── Vote Section ── */
.vote-section {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: .6rem;
}
.vote-label {
    font-family: 'Bebas Neue', sans-serif;
    font-size: .88rem;
    letter-spacing: .1em;
    color: #666;
    text-align: center;
}
.player-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: .5rem;
}
.player-btn {
    padding: .8rem .5rem;
    background: var(--dark3);
    border: 2px solid #3a3a3a;
    color: var(--white);
    border-radius: 10px;
    font-family: 'Nunito', sans-serif;
    font-size: .95rem;
    font-weight: 800;
    cursor: pointer;
    transition: background .12s, border-color .12s, color .12s, transform .1s;
    text-align: center;
    min-height: 54px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.player-btn:active { transform: scale(.95); }
.player-btn.voted {
    background: var(--green);
    border-color: var(--green2);
    color: var(--black);
}
.player-btn.voted::before {
    content: '✓ ';
    font-size: 1rem;
}

/* ── Next Button ── */
.btn-next {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.5rem;
    letter-spacing: .1em;
    padding: .8rem;
    background: var(--yellow);
    color: var(--black);
    border: none;
    border-radius: 10px;
    cursor: pointer;
    width: 100%;
    transition: opacity .12s, transform .1s;
}
.btn-next:hover  { opacity: .9; }
.btn-next:active { transform: scale(.97); }

/* ────────────────────────────
   End Screen
──────────────────────────── */
#screen-end {
    align-items: center;
    justify-content: flex-start;
    padding: 2rem 1rem;
    gap: 1.25rem;
    overflow-y: auto;
}
.end-wrap {
    width: 100%;
    max-width: 460px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}
.end-subtitle {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.6rem;
    letter-spacing: .15em;
    color: #666;
}
.tie-message {
    font-family: 'Nunito', sans-serif;
    font-weight: 800;
    font-style: italic;
    font-size: clamp(1rem, 3.5vw, 1.3rem);
    color: var(--yellow);
    text-align: center;
    width: 100%;
}
.leaderboard {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: .5rem;
}
.lb-row {
    display: flex;
    align-items: center;
    gap: .85rem;
    background: var(--dark3);
    border-radius: 10px;
    padding: .8rem 1.1rem;
}
.lb-row.winner {
    background: var(--yellow);
    color: var(--black);
}
.lb-rank {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    color: #555;
    min-width: 26px;
}
.lb-row.winner .lb-rank { color: rgba(0,0,0,.35); }
.lb-name { flex: 1; font-weight: 800; font-size: 1.05rem; }
.lb-score {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    color: var(--yellow);
}
.lb-row.winner .lb-score { color: var(--black); }
.lb-tag {
    font-size: .7rem;
    font-weight: 800;
    padding: .2rem .55rem;
    border-radius: 4px;
    background: rgba(0,0,0,.15);
    color: var(--black);
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}

/* ── Responsive ── */
@media (min-width: 520px) {
    .player-grid { grid-template-columns: repeat(4, 1fr); }
}
@media (orientation: landscape) and (max-height: 520px) {
    .ayg-logo     { font-size: 2rem; }
    .card-circle  { width: min(60%, 200px); }
    .game-wrap    { gap: .5rem; padding: .5rem .75rem; }
}
