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

/* --- Theme Variables (games override --game-primary) --- */
:root {
    --game-primary: #d4a017;
    --game-surface: #16213e;
    --game-bg: #1a1a2e;
    --game-text: #eee;
    --game-text-muted: #aaa;
    --game-danger: #e74c3c;
    --game-success: #27ae60;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #1a1a2e;
    color: #eee;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* --- Common --- */
.screen { display: none; }
.screen.active { display: block; }

h1 { color: var(--game-primary); text-align: center; font-size: 2rem; margin-bottom: 24px; }
h2 { color: var(--game-primary); text-align: center; font-size: 1.5rem; margin-bottom: 20px; }
.subtitle { text-align: center; color: #888; margin-bottom: 20px; font-size: 1.1rem; }

button {
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform 0.1s;
    -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.97); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }

#start-btn, #playagain-btn {
    width: 100%;
    max-width: 400px;
    display: block;
    margin: 20px auto;
    background: var(--game-primary);
    color: #1a1a2e;
}

.player-tag {
    display: inline-block;
    padding: 10px 20px;
    margin: 8px;
    background: var(--game-surface);
    border: 2px solid var(--game-primary);
    border-radius: 8px;
    font-size: 1.1rem;
}
#player-list { text-align: center; margin-bottom: 20px; }
.player-item.disconnected { opacity: 0.45; }
.player-away { margin-left: 6px; font-size: 0.85em; color: #888; font-style: italic; }

/* Timer */
#timer-bar {
    height: 8px;
    background: #333;
    border-radius: 4px;
    margin-bottom: 20px;
    overflow: hidden;
    position: relative;
}
#timer-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--game-danger), var(--game-primary));
    border-radius: 4px;
    width: 100%;
    transition: width 0.1s linear;
}
#timer-text {
    position: absolute;
    right: 0;
    top: -22px;
    color: #e74c3c;
    font-weight: 600;
    font-size: 0.9rem;
}

/* Results */
.result-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--game-surface);
    font-size: 1.1rem;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}
.result-correct { border-left: 4px solid #27ae60; }
.result-wrong { border-left: 4px solid #e74c3c; }

.correct-banner {
    background: #1a4a2e;
    border: 2px solid #27ae60;
    padding: 16px;
    border-radius: 8px;
    text-align: center;
    font-size: 1.3rem;
    margin: 20px auto;
    color: #27ae60;
    max-width: 600px;
}

.final-score-row {
    display: flex;
    justify-content: space-between;
    padding: 16px;
    margin-bottom: 8px;
    border-radius: 8px;
    background: var(--game-surface);
    font-size: 1.2rem;
    max-width: 500px;
    margin-left: auto;
    margin-right: auto;
}
.final-score-row.winner { border: 2px solid var(--game-primary); }

/* Player feedback */
.feedback {
    text-align: center;
    font-size: 1.8rem;
    font-weight: 700;
    padding: 24px;
    border-radius: 12px;
    margin-bottom: 16px;
}
.feedback.correct { background: #1a4a2e; color: #27ae60; }
.feedback.wrong { background: #4a1a1a; color: #e74c3c; }
.feedback.timeout { background: #4a3a1a; color: #d4a017; }

/* Bonus breakdown */
.bonus-line {
    text-align: center;
    font-size: 1.1rem;
    padding: 6px 0;
    color: #d4a017;
    font-weight: 600;
}

.my-score {
    text-align: center;
    font-size: 1.5rem;
    color: #d4a017;
    padding: 20px;
    background: #16213e;
    border-radius: 8px;
    font-weight: 600;
    margin-top: 12px;
}

/* Text input */
input[type="text"] {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    border: 2px solid var(--game-primary);
    border-radius: 8px;
    background: var(--game-surface);
    color: #eee;
    margin-bottom: 16px;
    outline: none;
}

/* --- Shared Component Styles --- */

.final-score-row .rank {
    color: var(--game-primary);
    font-weight: 700;
    margin-right: 12px;
}

.final-score-row .player-score {
    color: var(--game-primary);
    font-weight: 600;
}

/* Action buttons */
.action-btn {
    width: 100%;
    padding: 16px;
    font-size: 1.1rem;
    font-weight: 600;
    background: var(--game-primary);
    color: #fff;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 10px;
}

.action-btn-secondary {
    background: transparent;
    border: 2px solid var(--game-primary);
    color: var(--game-primary);
}

.action-btn-danger {
    background: var(--game-danger);
}

.action-btn-success {
    background: var(--game-success);
}

/* Display vote cards (TV view) */
.display-vote-card {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
    margin-bottom: 12px;
    border-radius: 10px;
    background: var(--game-surface);
    border: 2px solid #333;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    font-size: 1.3rem;
}

.display-vote-card .vote-label {
    background: var(--game-primary);
    color: #fff;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Display result rows (TV view) — absolute-positioned vote bar overlay */
.display-result-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    margin-bottom: 10px;
    border-radius: 10px;
    background: var(--game-surface);
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
    font-size: 1.2rem;
    position: relative;
    overflow: hidden;
}

.display-result-row.winner {
    border: 2px solid var(--game-primary);
}

.display-result-row .result-text {
    flex: 1;
    z-index: 1;
}

.display-result-row .vote-bar {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    background: var(--game-primary);
    opacity: 0.15;
    transition: width 0.5s ease;
}

.display-result-row .vote-count {
    color: var(--game-primary);
    font-weight: 600;
    z-index: 1;
    white-space: nowrap;
}

/* Player result rows */
.result-row .result-votes {
    color: var(--game-primary);
    font-weight: 600;
    white-space: nowrap;
    margin-left: 12px;
}

/* Score tags (display view) */
.score-tag {
    padding: 8px 20px;
    background: var(--game-surface);
    border: 2px solid var(--game-primary);
    border-radius: 8px;
    font-size: 1.1rem;
    color: var(--game-primary);
    font-weight: 600;
}

/* Player bar (display bottom bar) */
.player-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    padding: 12px;
    margin-top: 10px;
}

.player-bar-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    background: var(--game-surface);
    border: 1px solid #333;
    border-radius: 8px;
    font-size: 0.95rem;
}

.player-bar-item.active-player {
    border-color: var(--game-primary);
    box-shadow: 0 0 6px rgba(255, 255, 255, 0.2);
}

/* Display prompt card */
.display-prompt-card {
    background: var(--game-surface);
    border: 2px solid #444;
    border-radius: 16px;
    padding: 40px;
    margin: 30px auto;
    max-width: 700px;
    text-align: center;
}

.display-prompt-card p {
    font-size: 1.6rem;
    line-height: 1.6;
}

/* Score rows */
.score-row {
    display: flex;
    justify-content: space-between;
    padding: 10px 16px;
    margin-bottom: 6px;
    border-radius: 8px;
    background: var(--game-surface);
    font-size: 1.05rem;
}

.score-row span:last-child {
    color: var(--game-primary);
    font-weight: 600;
}

/* Player item (lobby tags) */
.player-item {
    display: inline-block;
    padding: 10px 20px;
    margin: 8px;
    background: var(--game-surface);
    border: 2px solid var(--game-primary);
    border-radius: 8px;
    font-size: 1.1rem;
}

/* --- Landscape Enforcement --- */
#rotate-prompt {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: #1a1a2e;
    align-items: center;
    justify-content: center;
    flex-direction: column;
}

body.landscape-enforced #rotate-prompt {
    display: flex;
}

/* Only show overlay on touch devices in portrait */
@media (orientation: landscape), (pointer: fine) {
    body.landscape-enforced #rotate-prompt {
        display: none;
    }
}

.rotate-prompt-content {
    text-align: center;
    color: #eee;
}

.rotate-prompt-icon {
    margin-bottom: 24px;
    animation: rotate-phone 2s ease-in-out infinite;
}

@keyframes rotate-phone {
    0%, 100% { transform: rotate(0deg); }
    25%, 75% { transform: rotate(90deg); }
}

.rotate-prompt-text {
    font-size: 1.3rem;
    color: #d4a017;
    font-weight: 600;
}

/* Landscape game screen sizing */
body.landscape-enforced .screen.active {
    width: 100dvw;
    height: 100dvh;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Override per-game max-width constraints in landscape */
body.landscape-enforced .player-mode #app {
    max-width: none !important;
}
