:root {
    /* Fonts */
    --font-heading: 'Outfit', sans-serif;
    --font-mono: 'JetBrains Mono', monospace;

    /* Theme: Light (Default) */
    --bg-page: #f1f5f9;
    --bg-grad-1: rgba(2, 132, 199, 0.1);
    --bg-grad-2: rgba(37, 99, 235, 0.08);
    --card-bg: rgba(255, 255, 255, 0.88);
    --card-border: rgba(0, 0, 0, 0.08);
    --card-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);

    --primary-cyan: #0284c7;
    --primary-blue: #2563eb;
    --accent-gold: #d97706;
    --accent-amber: #ea580c;
    --accent-red: #dc2626;
    --accent-green: #059669;

    --heading-grad: linear-gradient(135deg, #0f172a 0%, var(--primary-cyan) 100%);
    --btn-text-color: #ffffff;

    --text-main: #0f172a;
    --text-muted: #64748b;

    --input-bg: rgba(255, 255, 255, 0.95);
    --input-bg-focus: #ffffff;
    --input-border: rgba(0, 0, 0, 0.16);
    --input-text: #0f172a;

    --history-item-bg: rgba(255, 255, 255, 0.92);
    --history-guess-color: #0f172a;
    --badge-bg: rgba(0, 0, 0, 0.06);

    --tag-hit-bg: rgba(2, 132, 199, 0.12);
    --tag-hit-border: rgba(2, 132, 199, 0.35);
    --tag-hit-color: #0284c7;

    --tag-blow-bg: rgba(234, 88, 12, 0.12);
    --tag-blow-border: rgba(234, 88, 12, 0.35);
    --tag-blow-color: #c2410c;

    --modal-overlay-bg: rgba(15, 23, 42, 0.6);
    --modal-card-bg: rgba(255, 255, 255, 0.98);
    --modal-stat-bg: rgba(241, 245, 249, 0.95);
    --modal-glow: 0 10px 40px rgba(0, 0, 0, 0.15);

    --scrollbar-thumb: rgba(0, 0, 0, 0.18);
}

/* Light Theme (Explicit) */
[data-theme="light"] {
    --bg-page: #f1f5f9;
    --bg-grad-1: rgba(2, 132, 199, 0.1);
    --bg-grad-2: rgba(37, 99, 235, 0.08);
    --card-bg: rgba(255, 255, 255, 0.88);
    --card-border: rgba(0, 0, 0, 0.08);
    --card-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);

    --primary-cyan: #0284c7;
    --primary-blue: #2563eb;
    --accent-gold: #d97706;
    --accent-amber: #ea580c;
    --accent-red: #dc2626;
    --accent-green: #059669;

    --heading-grad: linear-gradient(135deg, #0f172a 0%, var(--primary-cyan) 100%);
    --btn-text-color: #ffffff;

    --text-main: #0f172a;
    --text-muted: #64748b;

    --input-bg: rgba(255, 255, 255, 0.95);
    --input-bg-focus: #ffffff;
    --input-border: rgba(0, 0, 0, 0.16);
    --input-text: #0f172a;

    --history-item-bg: rgba(255, 255, 255, 0.92);
    --history-guess-color: #0f172a;
    --badge-bg: rgba(0, 0, 0, 0.06);

    --tag-hit-bg: rgba(2, 132, 199, 0.12);
    --tag-hit-border: rgba(2, 132, 199, 0.35);
    --tag-hit-color: #0284c7;

    --tag-blow-bg: rgba(234, 88, 12, 0.12);
    --tag-blow-border: rgba(234, 88, 12, 0.35);
    --tag-blow-color: #c2410c;

    --modal-overlay-bg: rgba(15, 23, 42, 0.6);
    --modal-card-bg: rgba(255, 255, 255, 0.98);
    --modal-stat-bg: rgba(241, 245, 249, 0.95);
    --modal-glow: 0 10px 40px rgba(0, 0, 0, 0.15);

    --scrollbar-thumb: rgba(0, 0, 0, 0.18);
}

/* Dark Theme Variables */
[data-theme="dark"] {
    --bg-page: #0b0f19;
    --bg-grad-1: rgba(0, 242, 254, 0.08);
    --bg-grad-2: rgba(79, 172, 254, 0.08);
    --card-bg: rgba(22, 31, 51, 0.7);
    --card-border: rgba(255, 255, 255, 0.08);
    --card-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
    
    --primary-cyan: #00f2fe;
    --primary-blue: #4facfe;
    --accent-gold: #ffd700;
    --accent-amber: #ff9f1c;
    --accent-red: #ff0844;
    --accent-green: #00f5d4;

    --heading-grad: linear-gradient(135deg, #ffffff 0%, var(--primary-cyan) 100%);
    --btn-text-color: #050b14;

    --text-main: #f0f4f8;
    --text-muted: #8a99ad;

    --input-bg: rgba(11, 15, 25, 0.8);
    --input-bg-focus: rgba(11, 15, 25, 0.95);
    --input-border: rgba(255, 255, 255, 0.12);
    --input-text: #ffffff;

    --history-item-bg: rgba(11, 15, 25, 0.6);
    --history-guess-color: #ffffff;
    --badge-bg: rgba(255, 255, 255, 0.08);

    --tag-hit-bg: rgba(0, 242, 254, 0.15);
    --tag-hit-border: rgba(0, 242, 254, 0.4);
    --tag-hit-color: var(--primary-cyan);

    --tag-blow-bg: rgba(255, 159, 28, 0.15);
    --tag-blow-border: rgba(255, 159, 28, 0.4);
    --tag-blow-color: var(--accent-amber);

    --modal-overlay-bg: rgba(5, 8, 15, 0.85);
    --modal-card-bg: rgba(22, 31, 51, 0.95);
    --modal-stat-bg: rgba(11, 15, 25, 0.8);
    --modal-glow: 0 0 50px rgba(0, 242, 254, 0.2);

    --scrollbar-thumb: rgba(255, 255, 255, 0.15);
}

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

body {
    font-family: var(--font-heading);
    background-color: var(--bg-page);
    background-image: 
        radial-gradient(circle at 15% 15%, var(--bg-grad-1) 0%, transparent 40%),
        radial-gradient(circle at 85% 85%, var(--bg-grad-2) 0%, transparent 40%);
    color: var(--text-main);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#celebration-canvas {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    pointer-events: none;
    z-index: 999;
}

#app-wrapper {
    width: 92%;
    max-width: 540px;
    margin: 20px auto;
    display: flex;
    flex-direction: column;
    gap: 20px;
    position: relative;
    z-index: 1;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 4px;
}

.logo-area {
    display: flex;
    flex-direction: column;
}

.badge-tag {
    font-family: var(--font-mono);
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary-cyan);
    letter-spacing: 3px;
    text-transform: uppercase;
    transition: color 0.3s ease;
}

h1 {
    font-size: 2rem;
    font-weight: 800;
    background: var(--heading-grad);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-btn {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-main);
    width: 44px;
    height: 44px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.15rem;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.icon-btn:hover {
    border-color: var(--primary-cyan);
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 242, 254, 0.2);
}

.text-icon-btn {
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}

/* Stats Bar */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.stat-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px 8px;
    text-align: center;
    backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.stat-label {
    display: block;
    font-size: 0.65rem;
    font-weight: 700;
    color: var(--text-muted);
    letter-spacing: 1px;
    margin-bottom: 4px;
    transition: color 0.3s ease;
}

.stat-value {
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-cyan);
    transition: color 0.3s ease;
}

.game-subtitle {
    text-align: center;
    font-size: 0.9rem;
    color: var(--text-muted);
    margin-top: -5px;
    transition: color 0.3s ease;
}

/* Card Styling */
.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    padding: 20px;
    backdrop-filter: blur(16px);
    box-shadow: var(--card-shadow);
    transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

/* Input Area */
#input-area {
    display: flex;
    gap: 12px;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

#guess-input {
    width: 100%;
    height: 52px;
    background: var(--input-bg);
    border: 2px solid var(--input-border);
    border-radius: 14px;
    padding: 0 16px;
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--input-text);
    letter-spacing: 8px;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

#guess-input:focus {
    outline: none;
    border-color: var(--primary-cyan);
    box-shadow: 0 0 20px rgba(0, 242, 254, 0.3);
    background: var(--input-bg-focus);
}

#guess-input::placeholder {
    letter-spacing: 2px;
    font-size: 1rem;
    color: var(--text-muted);
    font-weight: 400;
}

.primary-btn {
    background: linear-gradient(135deg, var(--primary-blue) 0%, var(--primary-cyan) 100%);
    color: var(--btn-text-color);
    border: none;
    border-radius: 14px;
    padding: 0 24px;
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.25s ease;
    box-shadow: 0 4px 20px rgba(0, 242, 254, 0.3);
    height: 52px;
    white-space: nowrap;
}

.primary-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 242, 254, 0.5);
    filter: brightness(1.08);
}

.primary-btn:active {
    transform: translateY(0);
}

.primary-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.message-area {
    min-height: 24px;
    margin-top: 12px;
    font-size: 0.85rem;
    color: var(--accent-red);
    text-align: center;
    font-weight: 600;
    transition: color 0.3s ease;
}

/* History Section */
.section-title {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 14px;
}

.section-title h2 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    transition: color 0.3s ease;
}

.badge {
    background: var(--badge-bg);
    color: var(--text-muted);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-family: var(--font-mono);
    transition: background 0.3s ease, color 0.3s ease;
}

#history-scroll-container {
    max-height: 260px;
    overflow-y: auto;
    padding-right: 4px;
}

#history-scroll-container::-webkit-scrollbar {
    width: 6px;
}

#history-scroll-container::-webkit-scrollbar-thumb {
    background: var(--scrollbar-thumb);
    border-radius: 3px;
}

#history-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

#history-list li {
    background: var(--history-item-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    animation: slideIn 0.3s cubic-bezier(0, 0, 0.2, 1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: background 0.3s ease, border-color 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.history-turn {
    font-family: var(--font-mono);
    font-size: 0.8rem;
    color: var(--text-muted);
    width: 50px;
    transition: color 0.3s ease;
}

.history-guess {
    font-family: var(--font-mono);
    font-size: 1.3rem;
    font-weight: 700;
    letter-spacing: 6px;
    color: var(--history-guess-color);
    transition: color 0.3s ease;
}

.history-result {
    display: flex;
    gap: 8px;
}

.tag-hit {
    background: var(--tag-hit-bg);
    border: 1px solid var(--tag-hit-border);
    color: var(--tag-hit-color);
    padding: 4px 10px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.tag-blow {
    background: var(--tag-blow-bg);
    border: 1px solid var(--tag-blow-border);
    color: var(--tag-blow-color);
    padding: 4px 10px;
    border-radius: 8px;
    font-family: var(--font-mono);
    font-weight: 700;
    font-size: 0.85rem;
    transition: all 0.3s ease;
}

.empty-state {
    text-align: center;
    padding: 30px 10px;
    color: var(--text-muted);
    font-size: 0.9rem;
    transition: color 0.3s ease;
}

/* Victory Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--modal-overlay-bg);
    backdrop-filter: blur(12px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.4s ease;
    transition: background 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: var(--modal-card-bg);
    border: 1px solid rgba(0, 242, 254, 0.3);
    box-shadow: var(--modal-glow);
    border-radius: 24px;
    padding: 32px 24px;
    width: 90%;
    max-width: 440px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    animation: popIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: background 0.3s ease, box-shadow 0.3s ease;
}

@keyframes popIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.celebration-badge {
    background: linear-gradient(135deg, var(--accent-gold) 0%, var(--accent-amber) 100%);
    color: #000000;
    font-family: var(--font-mono);
    font-weight: 800;
    font-size: 0.75rem;
    padding: 4px 14px;
    border-radius: 20px;
    letter-spacing: 2px;
    text-transform: uppercase;
}

.modal-card h2 {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
}

.modal-body-text {
    font-size: 1.05rem;
    line-height: 1.6;
    color: var(--text-main);
}

.modal-stats {
    display: flex;
    gap: 16px;
    width: 100%;
    margin: 8px 0;
}

.modal-stat-item {
    flex: 1;
    background: var(--modal-stat-bg);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: background 0.3s ease, border-color 0.3s ease;
}

.modal-stat-label {
    font-size: 0.7rem;
    color: var(--text-muted);
    transition: color 0.3s ease;
}

.modal-stat-val {
    font-family: var(--font-mono);
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--primary-cyan);
    transition: color 0.3s ease;
}

.secret-code {
    letter-spacing: 4px;
    color: var(--accent-green);
}

.reset-btn {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
}

.hidden {
    display: none !important;
}

/* Responsive */
@media (max-width: 480px) {
    #input-area {
        flex-direction: column;
    }
    
    .primary-btn {
        width: 100%;
        justify-content: center;
    }
    
    h1 {
        font-size: 1.6rem;
    }
    
    .history-guess {
        font-size: 1.1rem;
        letter-spacing: 4px;
    }

    .header-actions {
        gap: 6px;
    }

    .icon-btn {
        width: 38px;
        height: 38px;
        font-size: 1rem;
    }
}
