:root {
    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.2);
    --secondary: #9333ea;
    --accent: #0891b2;
    --bg: #f8fafc;
    --card-bg: rgba(255, 255, 255, 0.9);
    --glass-border: rgba(0, 0, 0, 0.1);
    --gold: #d97706;
}

body.eye-protection {
    --bg: #fffbeb;
    --card-bg: rgba(255, 251, 235, 0.95);
    --primary: #ea580c;
    --primary-glow: rgba(234, 88, 12, 0.2);
    --secondary: #f59e0b;
    --accent: #f97316;
}

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

body {
    font-family: 'Outfit', 'Noto Sans SC', sans-serif;
    background-color: var(--bg);
    color: #1e293b;
    height: 100vh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-app {
    width: 100vw;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

.glass-nav {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px 24px;
    z-index: 50;
    display: flex;
    justify-content: space-between;
    pointer-events: none;
}

.stat-group {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.stat-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    padding: 8px 16px;
    border-radius: 100px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.account-card {
    border-radius: 18px;
    max-width: min(360px, 42vw);
}

.account-status-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

#account-status-main {
    color: #1e293b;
    font-size: 0.9rem;
    font-weight: 800;
    line-height: 1.2;
    white-space: nowrap;
}

#account-status-sub {
    color: #64748b;
    font-size: 0.75rem;
    line-height: 1.2;
    max-width: 290px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gold-icon {
    color: var(--gold);
}

#inventory {
    display: flex;
    gap: 4px;
}

.inv-item {
    font-size: 1.2rem;
    filter: drop-shadow(0 0 5px rgba(255, 255, 255, 0.5));
}

#viewport {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
}

#maze-canvas {
    image-rendering: pixelated;
    transition: transform 0.1s linear;
}

#player-sprite {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 2.8rem;
    z-index: 10;
    pointer-events: none;
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.2));
    animation: floating 2s ease-in-out infinite;
}

@keyframes floating {

    0%,
    100% {
        transform: translate(-50%, -50%) scale(1);
    }

    50% {
        transform: translate(-50%, -55%) scale(1.02);
    }
}

@keyframes hop-anim {
    0% {
        transform: translate(-50%, -50%) scale(1, 1);
    }

    30% {
        transform: translate(-50%, -100%) scale(0.9, 1.2);
    }

    70% {
        transform: translate(-50%, -50%) scale(1.1, 0.8);
    }

    100% {
        transform: translate(-50%, -50%) scale(1, 1);
    }
}

@keyframes hop-anim-right {
    0% {
        transform: translate(-50%, -50%) scaleX(-1) scale(1, 1);
    }

    30% {
        transform: translate(-50%, -100%) scaleX(-1) scale(0.9, 1.2);
    }

    70% {
        transform: translate(-50%, -50%) scaleX(-1) scale(1.1, 0.8);
    }

    100% {
        transform: translate(-50%, -50%) scaleX(-1) scale(1, 1);
    }
}

#player-sprite.hop {
    animation: hop-anim 0.25s ease-out !important;
}

#player-sprite.face-right.hop {
    animation: hop-anim-right 0.25s ease-out !important;
}

#player-sprite.face-right {
    transform: translate(-50%, -50%) scaleX(-1);
}

#ui-layer {
    position: absolute;
    inset: 0;
    z-index: 1000;
    pointer-events: none;
}

.ui-screen {
    position: absolute;
    inset: 0;
    display: none;
    justify-content: center;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(8px);
    padding: 20px;
    pointer-events: auto;
}

body.state-start #screen-start {
    display: flex;
}

body.state-quiz #screen-quiz {
    display: flex;
}

body.state-win #screen-over {
    display: flex;
}

.glass-morphism {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    border: 2px solid var(--glass-border);
    border-radius: 32px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
    width: 100%;
}

.hero-card {
    max-width: min(1100px, calc(100vw - 40px));
}

.glow-text {
    font-size: 3rem;
    background: linear-gradient(to right, #f97316, #fbbf24);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 20px;
    font-weight: 800;
    line-height: 1.2;
}

.settings {
    margin: 25px 0;
    display: flex;
    flex-direction: column;
    gap: 15px;
    align-items: center;
}

.settings label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.1rem;
    color: #1e293b;
}

.checkbox-label {
    cursor: pointer;
    background: rgba(0, 0, 0, 0.05);
    padding: 10px 20px;
    border-radius: 50px;
    transition: 0.3s;
}

.checkbox-label:hover {
    background: rgba(0, 0, 0, 0.1);
}

.checkbox-label input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.primary-btn {
    background: linear-gradient(135deg, #f97316, #fbbf24);
    color: white;
    border: none;
    padding: 18px 48px;
    border-radius: 16px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.3s;
    margin-top: 30px;
    box-shadow: 0 10px 30px rgba(249, 115, 22, 0.3);
}

.primary-btn:hover {
    transform: scale(1.05) translateY(-2px);
    box-shadow: 0 15px 40px rgba(249, 115, 22, 0.4);
}

.secondary-btn {
    background: rgba(255, 255, 255, 0.8);
    color: #334155;
    border: 1px solid var(--glass-border);
    padding: 10px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 700;
    cursor: pointer;
    transition: 0.2s;
}

.secondary-btn:hover {
    background: white;
    border-color: var(--primary);
    color: var(--primary);
}

.danger-btn {
    color: #b91c1c;
}

.compact-btn {
    margin-top: 0;
    padding: 10px 18px;
    border-radius: 12px;
    font-size: 0.95rem;
}

.wordbank-panel {
    margin-top: 18px;
    text-align: left;
}

.wordbank-summary {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    background: rgba(255, 255, 255, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 10px 12px;
}

#wordbank-status {
    color: #475569;
    font-size: 0.95rem;
    line-height: 1.4;
}

.wordbank-editor {
    margin-top: 12px;
}

.wordbank-columns {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
}

.wordbank-column h3 {
    margin: 0 0 8px;
    color: #5b3b28;
    font-size: 1rem;
    line-height: 1.3;
}

#wordbank-prompt,
#wordbank-input {
    width: 100%;
    min-height: 230px;
    resize: vertical;
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 14px;
    font: 0.95rem/1.5 'Outfit', 'Noto Sans SC', sans-serif;
    color: #1e293b;
    background: rgba(255, 255, 255, 0.86);
    outline: none;
    user-select: text;
}

#wordbank-prompt {
    color: #2f4f32;
}

#wordbank-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-glow);
}

.wordbank-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

.wordbank-note {
    margin-top: 8px;
    color: #64748b;
    font-size: 0.85rem;
    line-height: 1.4;
}

.hint {
    margin-top: 15px;
    font-size: 0.9rem;
    opacity: 0.7;
}

.quiz-header #q-word {
    font-size: 1.5rem;
    margin: 15px 0;
    color: var(--primary);
    font-weight: 800;
    line-height: 1.6;
}

.translation-hint {
    font-size: 1rem;
    opacity: 0.8;
    margin-bottom: 20px;
}

.options-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 30px 0;
}

.option-btn {
    background: #ffffff;
    border: 2px solid #e2e8f0;
    color: #334155;
    padding: 22px 10px;
    border-radius: 18px;
    cursor: pointer;
    font-size: 1.2rem;
    font-weight: 600;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.option-btn:hover {
    background: #f8fafc;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.option-btn.correct {
    background: #10b981;
    color: white;
    border-color: #059669;
    pointer-events: none;
}

.option-btn.wrong {
    background: #ef4444;
    color: white;
    border-color: #dc2626;
    pointer-events: none;
    animation: shake 0.4s;
}

#confetti-canvas {
    position: absolute;
    inset: 0;
    z-index: 2000;
    pointer-events: none;
}

@keyframes shake {

    0%,
    100% {
        transform: translateX(0);
    }

    25% {
        transform: translateX(-5px);
    }

    75% {
        transform: translateX(5px);
    }
}

.quiz-footer {
    margin-top: 20px;
    border-top: 1px solid var(--glass-border);
    padding-top: 20px;
}

.props-bar {
    display: flex;
    justify-content: center;
    gap: 15px;
    flex-wrap: wrap;
}

.prop-btn {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 10px 20px;
    border-radius: 12px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 600;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.prop-btn:hover:not(:disabled) {
    background: #e2e8f0;
    transform: translateY(-2px);
}

.prop-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    filter: grayscale(1);
}

.prop-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: white;
}

#dpad-container {
    position: absolute;
    bottom: 50px;
    right: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    z-index: 100;
    pointer-events: auto;
}

.dpad-mid {
    display: flex;
    align-items: center;
    gap: 10px;
}

.dpad-center {
    width: 70px;
    height: 70px;
    border-radius: 16px;
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 2px solid var(--glass-border);
    font-size: 1.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s;
}

.dpad-center:not(:disabled):hover {
    transform: scale(1.05);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 20px var(--primary-glow);
}

.dpad-center:not(:disabled):active {
    transform: scale(0.95);
}

.dpad-center:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.dpad-btn {
    width: 70px;
    height: 70px;
    border-radius: 16px;
    border: 2px solid var(--glass-border);
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    color: var(--primary);
    font-size: 1.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.dpad-btn:active,
.dpad-btn.active {
    transform: scale(0.9);
    background: var(--primary);
    color: white;
    box-shadow: 0 0 20px var(--primary-glow);
}

#toast-container {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 2000;
}

.toast {
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--primary);
    padding: 12px 24px;
    border-radius: 100px;
    color: white;
    margin-top: 10px;
    animation: fadeInOut 2s forwards;
}

@keyframes fadeInOut {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }

    15% {
        opacity: 1;
        transform: translateY(0);
    }

    85% {
        opacity: 1;
    }

    100% {
        opacity: 0;
    }
}

.result-card {
    background: var(--card-bg);
    backdrop-filter: blur(24px);
    border: 2px solid var(--glass-border);
    border-radius: 32px;
    padding: 40px;
    text-align: center;
    max-width: 500px;
}

.congrats {
    font-size: 2.5rem;
    margin-bottom: 20px;
    background: linear-gradient(to right, #f97316, #fbbf24);
    background-clip: text;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    font-weight: 800;
    animation: celebrate 1s ease-out;
}

@keyframes celebrate {
    0% {
        transform: scale(0.5);
        opacity: 0;
    }

    50% {
        transform: scale(1.1);
    }

    100% {
        transform: scale(1);
        opacity: 1;
    }
}

.scroll-stats {
    margin: 30px 0;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid var(--glass-border);
    font-size: 1.2rem;
}

.stat-line span:last-child {
    font-weight: 700;
    color: #f97316;
}

.hidden {
    display: none;
}

@media (max-width: 600px) {
    .glass-nav {
        padding: 12px;
        align-items: flex-start;
    }

    .stat-group {
        gap: 8px;
        flex-wrap: wrap;
    }

    .account-card {
        order: 3;
        width: calc(100vw - 24px);
        max-width: none;
    }

    #account-status-sub {
        max-width: calc(100vw - 92px);
    }

    .glow-text {
        font-size: 2rem;
    }

    .options-grid {
        grid-template-columns: 1fr;
    }

    .glass-morphism {
        padding: 30px 20px;
    }

    .wordbank-columns {
        grid-template-columns: 1fr;
    }
}
