/* ==========================================================================
   omfg.cards — phone / player view (Unholy Ritual)
   Card faces come from cards.css; palette from theme.css.
   ========================================================================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    /* Canvas from theme.css; keep the phone padding. */
    font-family: var(--font-body);
    color: var(--text);
    min-height: 100vh;
    padding: 10px;
}

.container { max-width: 520px; margin: 0 auto; }

header { position: relative; text-align: center; margin-bottom: 22px; padding: 18px 0 6px; }
header .sound-toggle { position: absolute; top: 10px; right: 4px; }
header h1 {
    font-family: var(--font-display);
    font-size: 2.4em; letter-spacing: 0.03em;
    background: linear-gradient(92deg, var(--oxblood), var(--ember) 55%, var(--gold));
    -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
#room-info {
    background: rgba(32, 24, 38, 0.7);
    border: 1px solid rgba(201, 162, 39, 0.3);
    border-radius: 10px; padding: 8px 18px; margin-top: 12px; color: var(--text-dim);
}
.room-code { font-weight: 700; font-size: 1.1em; color: var(--gold); letter-spacing: 0.1em; }

.screen { display: none; }
.screen.active { display: block; }

/* ---- Surfaces (forms, lobby, game) ------------------------------------- */
.join-card, .lobby-info, .game-content, .error-card {
    background: linear-gradient(180deg, var(--ink-2), var(--ink));
    border: 1px solid var(--ink-line);
    border-radius: var(--radius);
    padding: 26px; margin-bottom: 18px;
    box-shadow: var(--shadow-card);
}
.join-card { text-align: center; }

.form-group { margin-bottom: 18px; text-align: left; }
.form-group label { display: block; margin-bottom: 8px; font-weight: 700; color: var(--text-dim); }
.form-group input {
    width: 100%; padding: 15px;
    background: rgba(13, 11, 15, 0.8);
    border: 1px solid rgba(239, 230, 211, 0.14);
    border-radius: 8px; font-size: 16px; color: var(--text);
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}
.form-group input::placeholder { color: var(--text-faint); }
.form-group input:focus { outline: none; border-color: var(--ember); box-shadow: var(--glow-ember); }
#room-code-input { text-transform: uppercase; text-align: center; font-weight: 700; letter-spacing: 0.2em; font-size: 1.5em; color: var(--gold); }

/* ---- Buttons ------------------------------------------------------------ */
.primary-btn, .secondary-btn, .action-btn {
    color: var(--bone); border: 1px solid transparent;
    padding: 15px 30px; border-radius: 8px; font-size: 16px; font-weight: 700;
    cursor: pointer; transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.14s ease;
    margin: 8px; width: 100%; max-width: 320px;
}
.primary-btn { background: linear-gradient(180deg, var(--oxblood), var(--oxblood-deep)); border-color: rgba(224,75,47,0.5); }
.primary-btn:hover, .action-btn:hover { transform: translateY(-2px); box-shadow: var(--glow-ember); }
.secondary-btn { background: linear-gradient(180deg, var(--gold), var(--gold-dim)); color: #1a130a; }
.secondary-btn:hover { transform: translateY(-2px); box-shadow: var(--glow-gold); }
.action-btn { background: linear-gradient(180deg, #2a2030, var(--ink-3)); border-color: rgba(201,162,39,0.35); margin: 5px; width: 100%; max-width: none; }
.action-btn:hover { border-color: var(--gold); }
.action-btn:disabled { background: #1a1620; color: var(--text-faint); border-color: transparent; cursor: not-allowed; transform: none; box-shadow: none; }

/* ---- Lobby / game text -------------------------------------------------- */
.lobby-info h2, .game-info h3, .scoreboard h4 { color: var(--gold); margin-bottom: 12px; }
.players-section { margin-top: 26px; }
.players-section h3 { color: var(--text-dim); margin-bottom: 12px; }
#players-list { list-style: none; display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; margin-top: 12px; }
.player-item {
    background: rgba(32, 24, 38, 0.7); padding: 12px; border-radius: 8px;
    border-left: 3px solid var(--oxblood); font-size: 0.9em; text-align: center; color: var(--text);
}
.player-item.current-player { border-left-color: var(--gold); color: var(--gold); }

.game-info { margin-bottom: 18px; }
.game-status { background: rgba(21, 17, 27, 0.7); padding: 14px; border-radius: 8px; border-left: 3px solid var(--gold); font-size: 0.9em; color: var(--text-dim); }
.game-message { background: rgba(139, 30, 45, 0.14); padding: 18px; border-radius: 10px; text-align: center; margin-bottom: 18px; font-size: 1.1em; border-left: 3px solid var(--ember); }
.player-area { background: rgba(13, 11, 15, 0.4); padding: 18px; border-radius: 10px; margin-bottom: 18px; min-height: 100px; }
.game-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin-bottom: 18px; }

/* ---- Scoreboard --------------------------------------------------------- */
.scoreboard { background: rgba(21, 17, 27, 0.6); padding: 18px; border-radius: 10px; border: 1px solid var(--ink-line); }
.scoreboard h4 { text-align: center; letter-spacing: 0.08em; text-transform: uppercase; }
#scores-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 10px; }
.score-item { background: rgba(32, 24, 38, 0.7); padding: 10px; border-radius: 8px; text-align: center; border-left: 3px solid var(--oxblood); }
.score-item .player-name { font-weight: 700; font-size: 0.9em; color: var(--text); }
.score-item .score { font-size: 1.4em; font-weight: 800; color: var(--gold); margin-top: 4px; }

.error-card { text-align: center; color: var(--ember); }

/* ---- Connection chip ---------------------------------------------------- */
.connection-status {
    position: fixed; bottom: 16px; right: 16px;
    background: rgba(21, 17, 27, 0.92); padding: 9px 14px; border-radius: 999px;
    font-size: 0.8em; color: var(--text-dim); border: 1px solid var(--ink-line);
    box-shadow: 0 4px 15px rgba(0,0,0,0.5); display: flex; align-items: center;
}
.status-indicator { width: 8px; height: 8px; border-radius: 50%; background: #6aa84f; margin-right: 8px; animation: pulse 2s infinite; }
.status-indicator.disconnected { background: var(--ember); animation: none; }
.status-indicator.connecting { background: var(--gold); }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.5; } }

/* ---- MadLad hand / board ------------------------------------------------ */
/* Judge's "pick the winner" submission grid (anonymous cards, not a hand). */
.madlad-hand { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 12px; }
.madlad-banner { background: rgba(139, 30, 45, 0.18); color: var(--bone); border: 1px solid rgba(224,75,47,0.3); border-radius: 10px; padding: 14px; font-weight: 700; text-align: center; margin: 10px 0; font-size: 1.1em; }
.madlad-note { text-align: center; color: var(--text-dim); margin: 10px 0; font-size: 1em; }

/* One free swap per round: corner control that replaces (not plays) the card.
   Sits top-left so it clears the flag control (top-right); doesn't affect the
   fixed 168px card height since the wrapper stays sized by the card. */
.madlad-card-wrap { position: relative; }
.madlad-discard {
    position: absolute; top: 4px; left: 4px; z-index: 2;
    border: none; background: rgba(0, 0, 0, 0.35); border-radius: 6px;
    font-size: 14px; line-height: 1; padding: 2px 4px; cursor: pointer;
    opacity: 0.75;
}
.madlad-discard:hover { opacity: 1; }

/* ---- Played state: obvious, can't be confused with "still choosing" ---- */
.hand-played__card-wrap { position: relative; max-width: 160px; margin: 14px auto 0; }
.card--played { opacity: 0.55; filter: grayscale(0.2); }
.hand-played__badge {
    position: absolute; top: -10px; right: -10px;
    background: var(--gold); color: #1a130a; font-weight: 800; font-size: 0.75em;
    padding: 4px 9px; border-radius: 999px; box-shadow: var(--shadow-card);
}

@media (max-width: 480px) {
    body { padding: 6px; }
    .container { max-width: 100%; }
    header h1 { font-size: 2em; }
    .join-card, .lobby-info, .game-content, .error-card { padding: 18px; margin-bottom: 14px; }
    .primary-btn, .secondary-btn, .action-btn { padding: 13px 20px; font-size: 15px; }
    .game-actions { grid-template-columns: 1fr; }
    .action-btn { width: 100%; max-width: none; margin: 5px 0; }
}

/* Phone refinement: reserve the screen for the prompt and the hand. */
body { padding: 0 16px max(20px, env(safe-area-inset-bottom)); }
header { text-align: left; padding: 22px 0 0; margin-bottom: 22px; }
header h1.wordmark { font-size: 28px; letter-spacing: -.04em; background: none; -webkit-text-fill-color: var(--bone); padding-right: 48px; }
header .brand-mark { width: 26px; height: 32px; font-size: 20px; }
header .sound-toggle { top: 20px; right: 0; width: 44px; height: 44px; }
#room-info { background: none; border: 0; border-bottom: 1px solid var(--ink-line); border-radius: 0; padding: 14px 0; margin-top: 6px; }
.room-code { font-size: 12px; font-weight: 500; color: var(--text-dim); letter-spacing: .06em; }
#current-room-code { color: var(--gold); font-weight: 700; margin-left: 6px; }
.join-card, .lobby-info, .error-card { padding: 24px; box-shadow: none; background: var(--ink-2); }
.join-card { text-align: left; }
.join-card h2, .lobby-info h2 { font-family: var(--font-display); font-size: 30px; font-weight: 500; color: var(--bone); }
.join-description { color: var(--text-dim); font-size: 14px; margin: 10px 0 28px; }
.form-group label { font-size: 13px; font-weight: 500; }
.primary-btn, .secondary-btn, .action-btn { margin: 0; max-width: none; min-height: 48px; }
.primary-btn { background: var(--bone); border-color: var(--bone); color: var(--ink); }
.primary-btn:hover { background: #fff8e9; box-shadow: none; transform: none; }
.game-info { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.game-info h3 { font-size: 13px; margin: 0; color: var(--text-dim); font-weight: 500; }
.game-status { background: none; border: 0; padding: 0; font-size: 12px; text-align: right; }
.game-content { padding: 0; border: 0; background: none; box-shadow: none; }
.game-message { padding: 0; background: none; border: 0; margin-bottom: 18px; }
.card--phone.card--prompt { padding: 24px 22px; font-size: 24px; min-height: 132px; box-shadow: none; }
.player-area { padding: 0; background: none; margin-bottom: 20px; }
.madlad-banner { font-size: 14px; font-weight: 600; padding: 12px; }
.madlad-note { font-size: 13px; line-height: 1.5; margin: 12px 0; }
.madlad-hand { gap: 12px; grid-template-columns: repeat(2, minmax(0, 1fr)); }
.card--hand.card--answer { height: 184px; padding: 38px 15px 18px; font-size: 15px; border-radius: 10px; box-shadow: 0 4px 12px rgba(0,0,0,.18); background: var(--bone); }
.card--hand.card--answer .card__inner { justify-content: flex-start; }
.madlad-flag, .madlad-discard { min-width: 32px; min-height: 32px; }
.player-item, .score-item .player-name { overflow-wrap: anywhere; }
.scoreboard { padding: 16px; background: none; }
.scoreboard h4 { text-align: left; font-size: 10px; letter-spacing: .12em; color: var(--text-dim); }
.score-item { border: 0; background: var(--ink-2); }
.connection-status { position: static; justify-content: center; width: fit-content; margin: 20px auto 0; padding: 6px 10px; font-size: 11px; border: 0; background: none; box-shadow: none; }
.status-indicator { width: 6px; height: 6px; animation: none; }
@media (max-width: 360px) {
    body { padding-left: 12px; padding-right: 12px; }
    header h1.wordmark { font-size: 25px; }
    .join-card, .lobby-info { padding: 20px; }
}

.lobby-guidance { color: var(--text-dim); font-size: 13px; line-height: 1.6; margin-top: 12px; }
.how-to-play { border-top: 1px solid var(--ink-line); margin-top: 22px; padding-top: 16px; font-size: 13px; line-height: 1.6; }
.how-to-play summary { cursor: pointer; color: var(--bone); font-weight: 600; min-height: 32px; }
.how-to-play ol { color: var(--text-dim); padding-left: 20px; }
.how-to-play li + li { margin-top: 8px; }

.score-item .player-name, .score-item .score { display: block; }
.game-actions:empty { display: none; }

/* Let long answers grow instead of clipping the copy. */
.card--hand.card--answer { min-height: 184px; height: 100%; }
.card--hand.card--answer .card__text { display: block; overflow: visible; }

header .brand-logo { width: 220px; margin: 0; }
