html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    color: rgba(255, 255, 255, 0.87);
    background-color: #0b132b;
    font-family: 'Segoe UI', Arial, Helvetica, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    touch-action: none;
}

#game-container {
    width: 100%;
    height: 100%;
    touch-action: none;
}

#game-container canvas {
    touch-action: none;
}

#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    overflow-y: auto;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 24px 12px;
    box-sizing: border-box;
}

#hud button,
#hud a,
#hud input,
#hud [role="button"],
#hud .interactive {
    pointer-events: auto;
}

.mute-btn {
    position: fixed;
    top: 16px;
    right: 16px;
    z-index: 50;
    background: rgba(11, 19, 43, 0.75);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 50%;
    width: 42px;
    height: 42px;
    font-size: 18px;
    cursor: pointer;
    color: #fff;
}

.pause-btn {
    position: static;
    top: auto;
    right: auto;
    width: 34px;
    height: 34px;
    font-size: 14px;
    flex-shrink: 0;
    margin-left: 8px;
}

.boot-error {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 100;
    text-align: center;
}

.pause-panel {
    text-align: center;
    margin-top: 12vh;
}

.panel {
    background: rgba(15, 23, 51, 0.92);
    border: 1px solid rgba(120, 150, 255, 0.25);
    border-radius: 18px;
    padding: 28px 32px;
    max-width: 640px;
    width: 100%;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
    backdrop-filter: blur(6px);
}

.title {
    font-size: 2rem;
    margin: 0 0 6px 0;
    background: linear-gradient(90deg, #6ee7ff, #a78bfa);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    font-weight: 800;
    text-align: center;
}

.subtitle {
    text-align: center;
    color: rgba(255,255,255,0.6);
    margin: 0 0 20px 0;
    font-size: 0.95rem;
}

.section {
    margin-bottom: 18px;
}

.section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: rgba(255,255,255,0.55);
    margin: 0 0 10px 0;
}

.two-col {
    display: flex;
    gap: 24px;
}
.two-col > div {
    flex: 1;
}

.domain-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
}

.domain-chip {
    border: 2px solid;
    border-radius: 10px;
    padding: 10px 14px;
    font-weight: 700;
    background: transparent;
    cursor: pointer;
    transition: all 0.15s ease;
    font-size: 0.9rem;
}

.pill-row, .preset-row {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.pill {
    padding: 8px 14px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.25);
    background: rgba(255,255,255,0.05);
    color: #fff;
    cursor: pointer;
    font-size: 0.85rem;
}
.pill.active {
    background: #6ee7ff;
    color: #0b132b;
    border-color: #6ee7ff;
    font-weight: 700;
}

.preset-btn {
    padding: 8px 14px;
    border-radius: 10px;
    border: 1px solid rgba(167, 139, 250, 0.4);
    background: rgba(167, 139, 250, 0.12);
    color: #d9c9ff;
    cursor: pointer;
    font-size: 0.85rem;
}
.preset-btn:hover {
    background: rgba(167, 139, 250, 0.25);
}

.upload-label {
    display: inline-block;
    padding: 10px 16px;
    border: 1px dashed rgba(255,255,255,0.35);
    border-radius: 10px;
    cursor: pointer;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.8);
    position: relative;
}
.upload-label input {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}
.upload-name {
    margin: 8px 0 0 0;
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
}
.upload-status {
    margin: 4px 0 0 0;
    font-size: 0.8rem;
    color: #6ee7ff;
}

.start-btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 8px;
    border: none;
    border-radius: 12px;
    background: linear-gradient(90deg, #6ee7ff, #a78bfa);
    color: #0b132b;
    font-size: 1.05rem;
    font-weight: 800;
    cursor: pointer;
    transition: transform 0.15s ease;
}
.start-btn:hover {
    transform: translateY(-2px);
}

.arena {
    max-width: 680px;
    width: 100%;
}

.arena-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: #fff;
    margin-bottom: 8px;
    font-size: 0.9rem;
    gap: 8px;
}

.badge {
    font-weight: 700;
    font-size: 0.8rem;
    padding: 4px 10px;
    border: 1px solid currentColor;
    border-radius: 20px;
}

.score-block {
    font-size: 0.9rem;
}
.streak {
    color: #ffb703;
    margin-left: 6px;
}

.timer {
    font-weight: 700;
    font-size: 1rem;
    padding: 4px 10px;
    border-radius: 8px;
    background: rgba(255,255,255,0.08);
}
.timer.urgent {
    color: #ff4d6d;
    background: rgba(255, 77, 109, 0.15);
    animation: pulse 0.8s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
}
.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #6ee7ff, #a78bfa);
    transition: width 0.3s ease;
}
.progress-label {
    text-align: right;
    font-size: 0.75rem;
    color: rgba(255,255,255,0.5);
    margin: 0 0 12px 0;
}

.question-card {
    background: rgba(15, 23, 51, 0.92);
    border: 1px solid rgba(120, 150, 255, 0.25);
    border-radius: 18px;
    padding: 24px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}

.question-text {
    font-size: 1.15rem;
    font-weight: 600;
    color: #fff;
    margin: 0 0 20px 0;
    line-height: 1.5;
}

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

.option {
    text-align: left;
    padding: 14px 16px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.2);
    background: rgba(255,255,255,0.04);
    color: #fff;
    cursor: pointer;
    font-size: 0.95rem;
    transition: all 0.15s ease;
}
.option:hover:not(:disabled) {
    border-color: #6ee7ff;
    background: rgba(110, 231, 255, 0.08);
}
.option.selected {
    border-color: #6ee7ff;
    background: rgba(110, 231, 255, 0.15);
}
.option.correct {
    border-color: #4ade80;
    background: rgba(74, 222, 128, 0.18);
}
.option.wrong {
    border-color: #ff4d6d;
    background: rgba(255, 77, 109, 0.18);
}
.option:disabled {
    cursor: default;
}

.hint-btn {
    margin-top: 14px;
    background: none;
    border: none;
    color: #ffb703;
    cursor: pointer;
    font-size: 0.85rem;
    padding: 0;
}
.hint-text {
    margin-top: 8px;
    font-size: 0.85rem;
    color: rgba(255,255,255,0.65);
    font-style: italic;
}

.feedback {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.1);
}
.explanation {
    font-size: 0.88rem;
    color: rgba(255,255,255,0.75);
    margin: 0 0 14px 0;
    line-height: 1.5;
}
.next-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(90deg, #6ee7ff, #a78bfa);
    color: #0b132b;
    font-weight: 700;
    cursor: pointer;
    font-size: 0.9rem;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin: 16px 0 24px 0;
}
.summary-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: rgba(255,255,255,0.05);
    border-radius: 12px;
    padding: 12px 6px;
}
.stat-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: #6ee7ff;
}
.stat-label {
    font-size: 0.7rem;
    color: rgba(255,255,255,0.55);
    text-align: center;
    margin-top: 4px;
}

.domain-breakdown {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}
.domain-row {
    display: flex;
    align-items: center;
    gap: 10px;
}
.domain-name {
    width: 90px;
    font-weight: 700;
    font-size: 0.85rem;
    flex-shrink: 0;
}
.domain-bar-track {
    flex: 1;
    height: 10px;
    background: rgba(255,255,255,0.1);
    border-radius: 6px;
    overflow: hidden;
}
.domain-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.4s ease;
}
.domain-pct {
    font-size: 0.75rem;
    color: rgba(255,255,255,0.6);
    width: 90px;
    flex-shrink: 0;
    text-align: right;
}

@media (max-width: 600px) {
    .panel, .arena, .question-card {
        padding: 16px;
    }
    .domain-grid {
        grid-template-columns: 1fr;
    }
    .two-col {
        flex-direction: column;
        gap: 12px;
    }
    .summary-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}