* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --primary: #6C3CE1;
    --primary-dark: #5128B0;
    --correct: #22C55E;
    --correct-dark: #16A34A;
    --wrong: #EF4444;
    --wrong-dark: #DC2626;
    --skip: #F59E0B;
    --skip-dark: #D97706;
    --bg: #0F0F1A;
    --card-bg: #1A1A2E;
    --surface: #16162A;
    --text: #FFFFFF;
    --text-dim: #A0A0C0;
}

html {
    height: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100dvh;
    overflow: hidden;
    user-select: none;
    -webkit-user-select: none;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

.screen {
    display: none;
    min-height: 100dvh;
    padding: 20px;
}

.screen.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Menu */
.menu-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.game-title {
    font-size: 4rem;
    font-weight: 900;
    letter-spacing: 12px;
    background: linear-gradient(135deg, #6C3CE1, #A855F7, #EC4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 4px;
}

.subtitle {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.settings-box {
    background: var(--surface);
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 24px;
}

.setting-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
}

.setting-row:not(:last-child) {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.setting-row label {
    font-size: 0.95rem;
    color: var(--text-dim);
}

.stepper {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stepper span {
    font-size: 1.2rem;
    font-weight: 700;
    min-width: 36px;
    text-align: center;
}

.stepper-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 2px solid var(--primary);
    background: transparent;
    color: var(--primary);
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.stepper-btn:active {
    background: var(--primary);
    color: white;
    transform: scale(0.9);
}

.btn-primary {
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 2px;
    cursor: pointer;
    transition: transform 0.15s, opacity 0.15s;
}

.btn-primary:active {
    transform: scale(0.97);
    opacity: 0.9;
}

/* Turn Screen */
.turn-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.turn-team-badge {
    display: inline-block;
    padding: 10px 32px;
    border-radius: 50px;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 16px;
    letter-spacing: 1px;
}

.turn-info {
    color: var(--text-dim);
    margin-bottom: 24px;
    font-size: 1rem;
}

/* Scoreboard */
.scoreboard {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

.score-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
}

.score-row:not(:last-child) {
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.score-team-name {
    font-weight: 600;
    font-size: 0.95rem;
}

.score-value {
    font-weight: 800;
    font-size: 1.1rem;
}

/* Game Screen */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0 12px;
}

.team-indicator {
    font-size: 0.85rem;
    font-weight: 700;
    padding: 6px 14px;
    border-radius: 20px;
}

.timer {
    font-size: 2rem;
    font-weight: 900;
    font-variant-numeric: tabular-nums;
}

.timer.warning {
    color: var(--wrong);
    animation: pulse 0.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.score-display {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 2px;
}

.correct-count {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--correct);
}

.skip-count {
    font-size: 0.75rem;
    color: var(--text-dim);
}

/* Card */
.card-area {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 0;
}

#game-screen.active {
    flex-direction: column;
}

.tabu-card {
    width: 100%;
    max-width: 340px;
    background: var(--card-bg);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    border: 2px solid rgba(108, 60, 225, 0.3);
    transition: transform 0.2s;
}

.tabu-card.flip {
    animation: cardFlip 0.3s ease;
}

@keyframes cardFlip {
    0% { transform: scale(0.9); opacity: 0.5; }
    100% { transform: scale(1); opacity: 1; }
}

.main-word {
    font-size: 2rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin-bottom: 16px;
    color: var(--text);
    word-break: break-word;
}

.divider {
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--wrong), transparent);
    margin-bottom: 16px;
}

.taboo-words {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.taboo-words li {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--wrong);
    padding: 6px;
    border-radius: 8px;
    background: rgba(239, 68, 68, 0.08);
}

/* Game Actions */
.game-actions {
    display: flex;
    gap: 10px;
    padding: 12px 0;
    padding-bottom: max(20px, calc(env(safe-area-inset-bottom) + 10px));
    margin-bottom: 10px;
}

.game-actions button {
    flex: 1;
    padding: 14px 8px;
    border: none;
    border-radius: 14px;
    font-size: 0.85rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    transition: transform 0.1s;
    color: white;
}

.game-actions button:active {
    transform: scale(0.93);
}

.btn-icon {
    font-size: 1.4rem;
    font-weight: 900;
}

.btn-correct {
    background: var(--correct);
}

.btn-wrong {
    background: var(--wrong);
}

.btn-skip {
    background: var(--skip);
}

.btn-skip:disabled {
    opacity: 0.4;
    transform: none !important;
}

/* Round End */
.round-end-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.round-team-name {
    font-size: 1.3rem;
    font-weight: 800;
    padding: 8px 24px;
    border-radius: 30px;
    display: inline-block;
    margin-bottom: 20px;
}

.round-stats {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 16px;
}

.stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 20px;
    border-radius: 14px;
    background: var(--surface);
    min-width: 80px;
}

.stat-number {
    font-size: 2rem;
    font-weight: 900;
}

.stat.correct .stat-number { color: var(--correct); }
.stat.wrong .stat-number { color: var(--wrong); }
.stat.skipped .stat-number { color: var(--skip); }

.stat-label {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.round-score-change {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 20px;
}

/* End Screen */
.end-container {
    width: 100%;
    max-width: 400px;
    text-align: center;
}

.trophy {
    font-size: 4rem;
    margin-bottom: 8px;
}

.winner-name {
    font-size: 2rem;
    font-weight: 900;
    padding: 8px 24px;
    border-radius: 30px;
    display: inline-block;
}

.winner-label {
    font-size: 1.1rem;
    color: var(--text-dim);
    margin: 8px 0 24px;
}

.final-scoreboard {
    background: var(--surface);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

/* Team Colors */
.team-0 { background: rgba(108, 60, 225, 0.2); color: #A78BFA; }
.team-1 { background: rgba(236, 72, 153, 0.2); color: #F472B6; }
.team-2 { background: rgba(34, 197, 94, 0.2); color: #4ADE80; }
.team-3 { background: rgba(245, 158, 11, 0.2); color: #FBBF24; }

.team-0-solid { background: #6C3CE1; color: white; }
.team-1-solid { background: #EC4899; color: white; }
.team-2-solid { background: #22C55E; color: white; }
.team-3-solid { background: #F59E0B; color: white; }

.team-0-border { border-color: #6C3CE1; }
.team-1-border { border-color: #EC4899; }
.team-2-border { border-color: #22C55E; }
.team-3-border { border-color: #F59E0B; }

/* Install Banner */
.install-banner {
    position: fixed;
    bottom: -200px;
    left: 0;
    right: 0;
    background: var(--surface);
    border-top: 1px solid rgba(108, 60, 225, 0.3);
    padding: 16px 20px;
    padding-bottom: max(16px, env(safe-area-inset-bottom));
    z-index: 1000;
    transition: bottom 0.4s ease;
}

.install-banner.visible {
    bottom: 0;
}

.install-content {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.install-icon {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    font-weight: 900;
    color: white;
    flex-shrink: 0;
}

.install-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.install-text strong {
    font-size: 0.95rem;
    color: var(--text);
}

.install-text span {
    font-size: 0.8rem;
    color: var(--text-dim);
}

.install-actions {
    display: flex;
    gap: 10px;
}

.install-actions button {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 0.9rem;
    cursor: pointer;
}

#install-btn {
    background: linear-gradient(135deg, var(--primary), #A855F7);
    color: white;
}

.install-dismiss {
    background: rgba(255,255,255,0.08);
    color: var(--text-dim);
}

/* Resume Dialog */
.resume-dialog {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.7);
    z-index: 999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.resume-dialog.visible {
    display: flex;
}

.resume-box {
    background: var(--surface);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    max-width: 340px;
    width: 100%;
    border: 1px solid rgba(108, 60, 225, 0.3);
}

.resume-box h3 {
    font-size: 1.3rem;
    margin-bottom: 12px;
}

#resume-info {
    color: var(--text-dim);
    font-size: 0.85rem;
    margin-bottom: 4px;
}

.resume-sub {
    color: var(--text-dim);
    font-size: 0.9rem;
    margin-bottom: 20px;
}

.resume-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.btn-resume {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--primary), #A855F7);
    color: white;
    font-size: 1rem;
    font-weight: 700;
    letter-spacing: 1px;
    cursor: pointer;
}

.btn-newgame {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 12px;
    background: rgba(255,255,255,0.08);
    color: var(--text-dim);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
}

/* Responsive */
@media (max-height: 650px) {
    .main-word { font-size: 1.6rem; }
    .taboo-words li { font-size: 1rem; padding: 4px; }
    .tabu-card { padding: 20px 18px; }
    .game-actions button { padding: 10px 8px; }
}
