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

:root {
    --gold: #c9a84c;
    --gold-dim: #7a6128;
    --cream: #ffefcd;
    --cream-dim: rgba(255, 239, 205, 0.7);
    --bg-deep: #0e1520;
    --bg-surface: rgba(255, 255, 255, 0.04);
    --border: rgba(201, 168, 76, 0.25);
    --font-ui: system-ui, -apple-system, sans-serif;
}

body {
    background: linear-gradient(160deg, #0e1520 0%, #1A2238 40%, #1e2a45 100%);
    color: var(--cream);
    font-family: 'Crimson Text', Georgia, serif;
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    flex-direction: column;
    overscroll-behavior: none;
}

header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    padding: 1.25rem 2.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(to bottom, rgba(14, 21, 32, 0.95), transparent);
}

.nav-logo {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    letter-spacing: 0.3em;
    color: var(--gold);
    text-decoration: none;
    text-transform: uppercase;
}

nav {
    display: flex;
    gap: 2rem;
}

nav a {
    font-family: 'Crimson Text', serif;
    font-size: 1rem;
    color: var(--cream-dim);
    text-decoration: none;
    letter-spacing: 0.08em;
    transition: color 0.3s;
    position: relative;
}

nav a::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--gold);
    transform: scaleX(0);
    transition: transform 0.3s;
}

nav a:hover, nav a.active {
    color: var(--cream);
}

nav a:hover::after, nav a.active::after {
    transform: scaleX(1);
}

.game-page-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 6rem 1rem 2rem;
    width: 100%;
}

.text-center {
    text-align: center;
    margin-bottom: 1rem;
}

.page-title {
    font-size: clamp(2.5rem, 6vw, 4rem);
    margin: 0;
    line-height: 1.1;
    letter-spacing: 0.1em;
    font-family: 'Cinzel', serif;
    color: var(--cream);
    text-shadow: 0 0 30px rgba(201, 168, 76, 0.15), 0 4px 15px rgba(0, 0, 0, 0.8);
}

#game-wrapper {
    position: relative;
    width: 100%;
    max-width: 1152px;
    margin: 3rem auto;
}

#score-container {
    position: absolute;
    top: -3rem;
    right: 0;
    z-index: 10;
    background: var(--bg-surface);
    padding: 0.25rem 1.5rem;
    border: 1px solid var(--border);
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    min-width: 100px;
    text-align: center;
}

#score-value {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
}

#game {
    position: relative;
    background-color: #0e1520;
    width: 100%;
    aspect-ratio: 2 / 1;
    height: auto;
    border: 1px solid var(--border);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    overflow: hidden;
    touch-action: none;
}

#game canvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.mobile-controls {
    display: none;
    width: 100%;
    max-width: 1152px;
    margin: 1rem auto;
    justify-content: space-between;
    padding: 0 1rem;
}

.btn-control {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    background: rgba(26, 34, 56, 0.8);
    border: 1px solid var(--gold-dim);
    color: var(--gold);
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
}

.btn-control:hover {
    background: rgba(42, 53, 84, 0.9);
    border-color: var(--gold);
    color: var(--cream);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0,0,0,0.4);
}

.btn-control:active {
    background: var(--gold);
    color: var(--bg-deep);
}

/* Custom Modal Styles */
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(14, 21, 32, 0.9);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.custom-modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.custom-modal {
    background: var(--bg-deep);
    border: 1px solid var(--gold);
    width: 90%;
    max-width: 600px;
    padding: 3rem;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
    text-align: center;
}

.custom-modal-header {
    margin-bottom: 1rem;
}

.custom-modal-body {
    margin-bottom: 2rem;
}

.custom-modal-title {
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--gold);
    letter-spacing: 0.1em;
}

.modal-badge {
    display: inline-block;
    padding: 1rem 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    font-size: 0.75rem;
    font-family: var(--font-ui);
    color: var(--gold);
    margin-bottom: 1.5rem;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.05em;
}

.modal-question-text {
    font-size: 1.8rem;
    line-height: 1.3;
    color: var(--cream);
    font-family: 'Crimson Text', serif;
    margin-bottom: 2rem;
}

.feedback-status {
    font-family: 'Cinzel', serif;
    font-size: 2rem;
    margin-bottom: 1.5rem;
}

.feedback-status.correct { color: #4ade80; }
.feedback-status.incorrect { color: #f87171; }

.feedback-details {
    text-align: left;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    padding: 1.5rem;
    margin-top: 1.5rem;
}

.feedback-details strong {
    color: var(--gold);
    font-family: 'Cinzel', serif;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 0.5rem;
}

.feedback-text {
    font-style: italic;
    color: var(--cream-dim);
    font-family: var(--font-ui);
    line-height: 1.5;
}

.result-score {
    font-family: 'Cinzel', serif;
    font-size: 4rem;
    color: var(--gold);
    margin: 1.5rem 0;
}

.result-stats {
    display: flex;
    justify-content: center;
    gap: 3rem;
    margin-bottom: 2rem;
}

.stat-item .stat-value {
    display: block;
    font-family: 'Cinzel', serif;
    font-size: 1.5rem;
    color: var(--cream);
}

.stat-item .stat-label {
    font-size: 0.8rem;
    color: var(--cream-dim);
    text-transform: uppercase;
    font-family: var(--font-ui);
}

.btn-start {
    font-family: 'Cinzel', serif;
    font-size: 0.85rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: var(--gold);
    text-decoration: none;
    border: 1px solid var(--gold-dim);
    padding: 1rem 3rem;
    display: inline-block;
    transition: color 0.4s;
    position: relative;
    overflow: hidden;
    background: transparent;
    cursor: pointer;
}

.btn-start::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--gold);
    transform: translateX(-101%);
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.btn-start:hover {
    color: var(--bg-deep);
}

.btn-start:hover::before {
    transform: translateX(0);
}

.btn-start span {
    position: relative;
    z-index: 1;
}

@media (max-width: 1024px) {
    #game-wrapper {
        margin: 2rem auto;
    }

    .game-page-content {
        padding-top: 5rem;
    }
}

@media (max-width: 768px) {
    header {
        padding: 1rem 1.25rem;
    }

    nav {
        gap: 1.25rem;
    }

    .game-page-content {
        padding-top: 5rem;
    }

    #score-value {
        font-size: 1.5rem;
    }

    #score-container {
        min-width: 80px;
        padding: 0.2rem 1rem;
        top: -2.5rem;
    }

    .mobile-controls {
        display: flex;
    }

    .custom-modal {
        padding: 2rem;
    }

    .result-stats {
        gap: 1.5rem;
    }
}

@media (max-width: 480px) {
    header {
        flex-direction: column;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        background: rgba(14, 21, 32, 0.95);
    }

    nav a {
        font-size: 0.8rem;
    }

    nav {
        gap: 0.75rem;
    }

    .custom-modal {
        padding: 1.5rem 1rem;
    }

    .modal-question-text {
        font-size: 1.4rem;
    }

    .result-stats {
        flex-direction: column;
        gap: 1rem;
    }

    .result-score {
        font-size: 3rem;
    }

    .btn-start {
        padding: 0.8rem 2rem;
    }
}
@media (max-height: 500px) and (orientation: landscape) {
    header {
        padding: 0.5rem 1.25rem;
    }

    .game-page-content {
        padding-top: 3.5rem;
    }

    #game-wrapper {
        margin: 1rem auto;
    }

    .page-title {
        font-size: 2rem;
    }
}