:root {
    --bg-color: #0f172a;
    --card-bg: rgba(30, 41, 59, 0.7);
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --accent: #6366f1;
    --accent-hover: #4f46e5;
    
    --red: #ef4444;
    --red-rgb: 239, 68, 68;
    --blue: #3b82f6;
    --blue-rgb: 59, 130, 246;
    --green: #10b981;
    --green-rgb: 16, 185, 129;
    --yellow: #f59e0b;
    --yellow-rgb: 245, 158, 11;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    
    --header-height: 80px;
    --screen-padding: 24px;
}

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

body {
    font-family: 'Outfit', 'Poppins', sans-serif;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    color: var(--text-primary);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-x: hidden;
}

#app {
    width: 100%;
    max-width: 1200px;
    padding: var(--screen-padding);
    padding-top: calc(var(--header-height) + 20px);
}

.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
    opacity: 0;
    transform: translateY(10px);
    transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.screen.active {
    display: flex;
    opacity: 1;
    transform: translateY(0);
}

/* Glassmorphism Card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: clamp(16px, 5vw, 24px);
    padding: clamp(20px, 5vw, 40px);
    box-shadow: var(--shadow-xl);
    width: 100%;
}

/* Setup Screen */
.setup-card {
    max-width: 600px;
    text-align: center;
}

.setup-mascot {
    width: clamp(100px, 20vw, 180px);
    height: auto;
    margin-bottom: 20px;
    filter: drop-shadow(0 10px 15px rgba(0,0,0,0.3));
}

h1 {
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    font-weight: 800;
    margin-bottom: 8px;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.subtitle {
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.input-group {
    text-align: left;
    margin-bottom: 20px;
}

.input-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-group input, 
.input-group select {
    width: 100%;
    padding: 14px 20px;
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    background: rgba(15, 23, 42, 0.5);
    color: white;
    font-size: 1rem;
    outline: none;
    transition: all 0.3s;
}

.input-group input:focus {
    border-color: var(--accent);
    background: rgba(15, 23, 42, 0.8);
}

.player-names-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 32px;
}

.player-input {
    display: flex;
    align-items: center;
    background: rgba(15, 23, 42, 0.3);
    padding: 8px 12px;
    border-radius: 12px;
    border: 2px solid transparent;
}

.player-input .dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    margin-right: 10px;
}

.player-input.red .dot { background: var(--red); }
.player-input.blue .dot { background: var(--blue); }
.player-input.green .dot { background: var(--green); }
.player-input.yellow .dot { background: var(--yellow); }

.player-input input {
    background: transparent;
    border: none;
    color: white;
    width: 100%;
    outline: none;
    font-weight: 600;
}

.primary-btn {
    background: var(--accent);
    color: white;
    border: none;
    padding: 16px 32px;
    border-radius: 12px;
    font-size: 1.1rem;
    font-weight: 800;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    width: 100%;
}

.primary-btn:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 20px -5px rgba(99, 102, 241, 0.5);
    background: var(--accent-hover);
}

.primary-btn:active {
    transform: scale(0.95);
}

/* Global Nav Header */
.game-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: var(--header-height);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 40px;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    z-index: 1000;
    transition: all 0.3s ease;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.mini-mascot {
    width: 50px;
    height: auto;
    transition: 0.3s;
}

.game-info h1 {
    font-size: clamp(1rem, 4vw, 1.4rem);
    font-weight: 800;
    margin: 0;
    background: linear-gradient(to right, #818cf8, #c084fc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    line-height: 1.2;
}

.game-info span {
    color: var(--text-secondary);
    font-size: 0.85rem;
    display: block;
}

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

.icon-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-2px);
}

.icon-btn:active {
    transform: scale(0.9);
}

/* Word Board */
.word-board {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: clamp(8px, 2vw, 15px);
    margin-bottom: clamp(20px, 5vw, 40px);
    padding: clamp(10px, 3vw, 20px);
}

.letter-slot {
    width: clamp(45px, 12vw, 70px);
    height: clamp(60px, 15vw, 90px);
    background: rgba(255, 255, 255, 0.05);
    border: 3px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: clamp(1.5rem, 6vw, 3rem);
    font-weight: 800;
    color: transparent;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    user-select: none;
}

.letter-slot.revealed {
    transform: scale(1.1);
    background: rgba(255, 255, 255, 0.1);
}

.revealed.p-red { color: var(--red); border-color: var(--red); box-shadow: 0 0 15px rgba(239, 68, 68, 0.3); }
.revealed.p-blue { color: var(--blue); border-color: var(--blue); box-shadow: 0 0 15px rgba(59, 130, 246, 0.3); }
.revealed.p-green { color: var(--green); border-color: var(--green); box-shadow: 0 0 15px rgba(16, 185, 129, 0.3); }
.revealed.p-yellow { color: var(--yellow); border-color: var(--yellow); box-shadow: 0 0 15px rgba(245, 158, 11, 0.3); }

/* Status Message */
.status-message {
    font-size: clamp(1.1rem, 4vw, 1.5rem);
    font-weight: 600;
    margin-bottom: clamp(20px, 4vw, 30px);
    text-align: center;
}

#current-player-name {
    padding: 4px 12px;
    border-radius: 8px;
}

/* Keyboard */
.keyboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(clamp(40px, 10vw, 60px), 1fr));
    gap: 8px;
    width: 100%;
    max-width: 900px;
    margin-bottom: 40px;
}

.key-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: white;
    padding: clamp(10px, 3vw, 15px) 0;
    border-radius: 12px;
    font-size: clamp(1rem, 4vw, 1.2rem);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
}

.key-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-2px);
}

.key-btn:active:not(:disabled) {
    transform: scale(0.9);
}

.key-btn:disabled {
    opacity: 0.3;
}

.key-btn.correct { background: var(--green); border-color: var(--green); }
.key-btn.wrong { background: var(--red); border-color: var(--red); opacity: 0.5 !important; }

/* Scoreboard */
.scoreboard {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: clamp(10px, 2vw, 20px);
    width: 100%;
}

.score-card {
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid transparent;
    padding: clamp(10px, 2vw, 15px) clamp(15px, 4vw, 25px);
    border-radius: 16px;
    text-align: center;
    min-width: clamp(100px, 25vw, 150px);
    transition: all 0.3s;
}

.score-card.active {
    transform: scale(1.05);
}

.score-card .name { font-weight: 800; display: block; margin-bottom: 5px; font-size: 0.9rem; }
.score-card .score { font-size: 1.5rem; font-weight: 800; }

/* Victory Overlay */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1100;
    padding: 20px;
}

.overlay.active { display: flex; }

.victory-card {
    max-width: 500px;
    text-align: center;
}

.victory-mascot {
    width: clamp(120px, 30vw, 200px);
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-15px); }
}

@media (max-width: 768px) {
    :root {
        --header-height: 60px;
        --screen-padding: 16px;
    }
    
    .game-header { padding: 0 20px; }
    .mini-mascot { width: 40px; }
    
    .player-names-grid { grid-template-columns: 1fr; gap: 8px; }
}

/* Landscape Mode Tweak */
@media (max-height: 500px) {
    :root {
        --header-height: 50px;
    }
    
    .game-header { padding: 0 15px; }
    .game-info span { display: none; }
    .mini-mascot { width: 30px; }
    
    .setup-mascot { display: none; }
    .setup-card { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; text-align: left; max-width: 900px; }
    .setup-card h1, .setup-card .subtitle { grid-column: span 2; }
    .setup-card .primary-btn { grid-column: span 2; }
    
    .screen { padding-bottom: 20px; }
}

@media (max-width: 480px) {
    .keyboard { grid-template-columns: repeat(7, 1fr); gap: 4px; }
    .key-btn { padding: 8px 0; font-size: 0.9rem; }
}
