/* ============================================
   REDDIT FEUD — Apple HIG Dark Theme
   ============================================ */

/* --- Variables --- */
:root {
    --bg-primary:    #1C1C1E;
    --bg-secondary:  #2C2C2E;
    --bg-tertiary:   #3A3A3C;
    --bg-elevated:   #48484A;

    --text-primary:   #FFFFFF;
    --text-secondary: rgba(255,255,255,0.55);
    --text-tertiary:  rgba(255,255,255,0.28);

    --orange: #FF9F0A;
    --green:  #30D158;
    --blue:   #0A84FF;
    --red:    #FF3B30;

    --border: rgba(255,255,255,0.09);

    --r-sm:  8px;
    --r-md:  12px;
    --r-lg:  14px;
    --r-xl:  18px;
    --r-pill: 20px;

    --sp-xs: 4px;
    --sp-sm: 8px;
    --sp-md: 16px;
    --sp-lg: 24px;
    --sp-xl: 32px;

    /* Notion-style max width */
    --max-width: 1120px;
}

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

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    line-height: 1.5;
    min-height: 100vh;
}

button {
    cursor: pointer;
    border: none;
    background: none;
    font-family: inherit;
    color: inherit;
    transition: all 0.18s ease;
}

a { text-decoration: none; color: inherit; }

/* ============================================
   TOP HEADER
   ============================================ */
.top-header {
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border);
    padding: var(--sp-md) var(--sp-xl);
    text-align: center;
}

.title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.3px;
}

/* ============================================
   PAGE WRAPPER & 3-COLUMN LAYOUT
   ============================================ */
.page-wrapper {
    display: flex;
    justify-content: center;
    padding: var(--sp-xl) var(--sp-lg);
}

.content-container {
    width: 100%;
    max-width: var(--max-width);
    display: grid;
    grid-template-columns: 220px 1fr 220px;
    gap: var(--sp-lg);
    align-items: start;
}

/* ============================================
   SHARED SIDEBAR STYLES
   ============================================ */
.question-sidebar,
.player-sidebar {
    background: var(--bg-secondary);
    border-radius: var(--r-xl);
    padding: var(--sp-md);
    position: sticky;
    top: var(--sp-xl);
}

.sidebar-label {
    font-size: 0.78rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-tertiary);
    padding: var(--sp-xs) var(--sp-sm) var(--sp-sm);
}

/* ============================================
   QUESTION LIST (LEFT SIDEBAR)
   ============================================ */
.question-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
}

.question-item {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-sm);
    border-radius: var(--r-md);
    cursor: pointer;
    transition: background 0.15s ease;
}

.question-item:hover { background: rgba(255,255,255,0.07); }
.question-item.active { background: rgba(255,255,255,0.11); }

.question-number {
    width: 26px;
    height: 26px;
    border-radius: var(--r-sm);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.82rem;
    font-weight: 700;
    flex-shrink: 0;
    color: var(--text-secondary);
}

.question-item.active .question-number {
    background: var(--blue);
    color: #fff;
}

.question-text {
    font-size: 0.88rem;
    line-height: 1.3;
    color: var(--text-secondary);
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.question-item.active .question-text { color: var(--text-primary); }

/* ============================================
   GAME BOARD (CENTER)
   ============================================ */
.game-board { min-width: 0; }

.game-header { margin-bottom: var(--sp-lg); }

/* Clickable question title */
.question-title-link {
    display: inline-flex;
    align-items: flex-start;
    gap: var(--sp-xs);
    margin-bottom: var(--sp-sm);
    border-radius: var(--r-sm);
    transition: opacity 0.15s ease;
}

.question-title-link:hover { opacity: 0.75; }

.question-title {
    font-size: 1.6rem;
    font-weight: 700;
    letter-spacing: -0.4px;
    line-height: 1.25;
}

.link-arrow {
    font-size: 1rem;
    color: var(--text-tertiary);
    margin-top: 6px;
    flex-shrink: 0;
    transition: color 0.15s ease;
}

.question-title-link:hover .link-arrow { color: var(--text-secondary); }

.game-meta-row {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    flex-wrap: wrap;
}

.subreddit-badge {
    display: inline-block;
    padding: 3px var(--sp-sm);
    background: var(--bg-tertiary);
    border-radius: var(--r-sm);
    font-size: 0.82rem;
    color: var(--text-secondary);
}

/* Segmented Control */
.segmented-control {
    display: inline-flex;
    background: var(--bg-secondary);
    border-radius: var(--r-md);
    padding: 2px;
    gap: 2px;
}

.seg-btn {
    padding: 5px var(--sp-md);
    border-radius: calc(var(--r-md) - 2px);
    font-size: 0.88rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.seg-btn:hover { color: var(--text-primary); }
.seg-btn.active {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

/* ============================================
   ANSWER CARDS — Pill Row Design
   ============================================ */
.answer-grid {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}

.answer-card {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    background: var(--bg-secondary);
    border-radius: var(--r-pill);
    padding: var(--sp-sm) var(--sp-sm);
    cursor: pointer;
    transition: background 0.18s ease, opacity 0.3s ease, filter 0.3s ease;
    min-height: 56px;
}

.answer-card:hover { background: var(--bg-tertiary); }

.answer-card.claimed {
    opacity: 0.38;
    filter: grayscale(55%);
    cursor: default;
}

.answer-card.claimed:hover { background: var(--bg-secondary); }

/* Rank badge — orange rounded square */
.answer-rank {
    width: 40px;
    height: 40px;
    border-radius: var(--r-md);
    background: var(--orange);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

/* Answer text */
.answer-text {
    flex: 1;
    font-size: 0.97rem;
    line-height: 1.35;
    color: var(--text-primary);
    padding: 0 var(--sp-xs);
}

/* Points badge — grey rounded square */
.answer-points {
    min-width: 48px;
    height: 40px;
    border-radius: var(--r-md);
    background: var(--bg-tertiary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1rem;
    color: var(--text-primary);
    flex-shrink: 0;
    padding: 0 var(--sp-sm);
}

/* Claimed-by indicator inside card */
.claimed-by {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    font-size: 0.78rem;
    color: var(--text-secondary);
    flex-shrink: 0;
    padding-right: var(--sp-xs);
}

.claimed-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

/* ============================================
   PLAYER SIDEBAR (RIGHT)
   ============================================ */
.player-list {
    display: flex;
    flex-direction: column;
    gap: var(--sp-xs);
}

/* Player card — same pill design as answer cards */
.player-card {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    background: var(--bg-tertiary);
    border-radius: var(--r-pill);
    padding: var(--sp-sm) var(--sp-sm);
    min-height: 52px;
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.player-card.disabled {
    opacity: 0.35;
    filter: grayscale(70%);
}

/* Avatar badge — colored rounded square */
.player-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    color: #fff;
    flex-shrink: 0;
}

.adam-bg   { background: var(--orange); }
.mariah-bg { background: var(--green); }
.david-bg  { background: var(--blue); }

.player-name {
    flex: 1;
    font-weight: 600;
    font-size: 1rem;
}

/* Right side of player card: strikes text + wrong button */
.player-right {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    flex-shrink: 0;
}

/* Strike x characters (shown as red text) */
.player-strikes {
    font-size: 1rem;
    font-weight: 700;
    color: rgba(255, 59, 48, 0.65);
    letter-spacing: 2px;
    min-width: 0;
}

/* Wrong answer button — red rounded square badge */
.wrong-btn {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    background: var(--red);
    color: #fff;
    font-size: 1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.15s ease, transform 0.1s ease;
}

.wrong-btn:hover { background: #ff6259; }
.wrong-btn:active { transform: scale(0.93); }

/* Score row below each player card */
.player-score-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--sp-xs) calc(var(--sp-sm) + 2px);
    margin-bottom: var(--sp-sm);
}

.score-label {
    font-size: 0.78rem;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.player-score {
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: -0.3px;
    transition: transform 0.15s ease;
}

/* ============================================
   PLAYER SELECTION MODAL
   ============================================ */
.modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    margin: 0;
    background: rgba(28, 28, 30, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border);
    border-radius: var(--r-xl);
    padding: var(--sp-xl);
    max-width: 480px;
    width: 90vw;
    color: var(--text-primary);
}

.modal::backdrop {
    background: rgba(0,0,0,0.55);
}

.modal-content {
    display: flex;
    flex-direction: column;
    gap: var(--sp-md);
}

.modal-header {
    font-size: 1.3rem;
    font-weight: 700;
    text-align: center;
}

.modal-answer-text {
    text-align: center;
    color: var(--text-secondary);
    font-size: 1rem;
    padding: var(--sp-md);
    background: rgba(255,255,255,0.05);
    border-radius: var(--r-lg);
    line-height: 1.4;
}

.player-buttons {
    display: flex;
    flex-direction: column;
    gap: var(--sp-sm);
}

/* Player select buttons use the same pill design */
.player-select-btn {
    display: flex;
    align-items: center;
    gap: var(--sp-md);
    background: var(--bg-tertiary);
    border-radius: var(--r-pill);
    padding: var(--sp-sm) var(--sp-sm);
    min-height: 52px;
    transition: background 0.15s ease, opacity 0.15s ease;
    text-align: left;
}

.player-select-btn:hover { background: var(--bg-elevated); }

.player-select-btn.disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.player-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--r-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
}

.player-select-btn strong {
    font-size: 1rem;
    font-weight: 600;
}

.modal-cancel-btn {
    padding: var(--sp-sm) var(--sp-md);
    border-radius: var(--r-lg);
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    text-align: center;
    width: 100%;
    margin-top: var(--sp-xs);
}

.modal-cancel-btn:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}

/* ============================================
   LOADING OVERLAY
   ============================================ */
.loading-overlay {
    position: fixed;
    inset: 0;
    background: rgba(28,28,30,0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

.loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

@keyframes spin { to { transform: rotate(360deg); } }

.loading-overlay svg circle {
    stroke: var(--blue);
    stroke-dasharray: 180;
    stroke-linecap: round;
    animation: spin 1s linear infinite;
    transform-origin: center;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .content-container {
        grid-template-columns: 1fr;
    }

    .question-sidebar,
    .player-sidebar {
        position: static;
    }
}
