/* ===== RESET & BASE ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --bg-dark: #0a0a0f;
    --bg-panel: #12121a;
    --bg-card: #1a1a2e;
    --border: #2a2a3e;
    --text: #c8c8d4;
    --text-dim: #6a6a7e;
    --white: #e8e8f0;
    --cyan: #5ce0d8;
    --cyan-glow: rgba(92, 224, 216, 0.4);
    --orange: #e8943a;
    --orange-glow: rgba(232, 148, 58, 0.4);
    --red: #e84040;
    --red-glow: rgba(232, 64, 64, 0.4);
    --green: #40c870;
    --green-glow: rgba(64, 200, 112, 0.4);
    --rune-1: #5ce0d8;
    --rune-2: #e8943a;
    --rune-3: #a86ce8;
    --rune-4: #e84040;
}

html { font-size: 16px; }

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: var(--bg-dark);
    color: var(--text);
    min-height: 100dvh;
    overflow-x: hidden;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

/* ===== SCREENS ===== */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100dvh;
    padding: 2rem 1.5rem;
    text-align: center;
}

.screen.active { display: flex; }

/* ===== LOGIN ===== */
.login-title {
    font-size: 1.6rem;
    color: var(--white);
    margin-bottom: 0.4rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.login-subtitle {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin-bottom: 2.5rem;
    font-style: italic;
}

.login-input {
    width: 100%;
    max-width: 300px;
    padding: 0.9rem 1rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--white);
    font-size: 1rem;
    text-align: center;
    outline: none;
    transition: border-color 0.3s;
}

.login-input:focus {
    border-color: var(--cyan);
    box-shadow: 0 0 12px var(--cyan-glow);
}

.login-input::placeholder { color: var(--text-dim); }

/* ===== BUTTONS ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.85rem 2rem;
    border: 1px solid var(--cyan);
    background: transparent;
    color: var(--cyan);
    font-size: 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    margin-top: 1.2rem;
    min-height: 48px;
}

.btn:active {
    background: var(--cyan);
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--cyan-glow);
}

.btn--orange { border-color: var(--orange); color: var(--orange); }
.btn--orange:active {
    background: var(--orange);
    color: var(--bg-dark);
    box-shadow: 0 0 20px var(--orange-glow);
}

.btn--big {
    width: 100%;
    max-width: 300px;
    padding: 1.2rem;
    font-size: 1.2rem;
    font-weight: 700;
}

.btn--red { border-color: var(--red); color: var(--red); }
.btn--red:active { background: var(--red); color: var(--bg-dark); }

/* ===== HUD ===== */
.game-hud {
    position: fixed;
    top: 0; left: 0; right: 0;
    z-index: 100;
    background: linear-gradient(180deg, var(--bg-dark) 60%, transparent);
    padding: 0.8rem 1.2rem 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.hud-name {
    font-size: 0.85rem;
    color: var(--cyan);
    letter-spacing: 0.05em;
}

.hud-hp { display: flex; align-items: center; gap: 0.5rem; }

.hp-bar-wrap {
    width: 100px; height: 8px;
    background: var(--bg-card);
    border-radius: 4px;
    overflow: hidden;
    border: 1px solid var(--border);
}

.hp-bar {
    height: 100%;
    background: var(--red);
    border-radius: 4px;
    transition: width 0.5s ease;
    box-shadow: 0 0 8px var(--red-glow);
}

.hp-text {
    font-size: 0.8rem;
    color: var(--red);
    min-width: 2.5rem;
    text-align: right;
}

/* ===== STAGE HEADER ===== */
.stage-header { margin-bottom: 1.5rem; text-align: center; }

.stage-label {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.15em;
    margin-bottom: 0.3rem;
}

.stage-title {
    font-size: 1.3rem;
    color: var(--white);
    letter-spacing: 0.05em;
}

.stage-desc {
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-top: 0.5rem;
    line-height: 1.4;
    font-style: italic;
}

/* ===== STAGE 1: PUZZLE ===== */
.puzzle-wrap {
    width: 100%;
    max-width: 320px;
    aspect-ratio: 1;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1rem;
    touch-action: manipulation;
    position: relative;
}

.puzzle-wrap canvas {
    width: 100%;
    height: 100%;
    display: block;
}

.puzzle-hint {
    font-size: 0.75rem;
    color: var(--text-dim);
    margin-bottom: 0.5rem;
}

.angle-slider {
    width: 100%;
    max-width: 300px;
    -webkit-appearance: none;
    appearance: none;
    height: 6px;
    background: var(--bg-card);
    border-radius: 3px;
    outline: none;
    border: 1px solid var(--border);
}

.angle-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 28px; height: 28px;
    border-radius: 50%;
    background: var(--cyan);
    box-shadow: 0 0 12px var(--cyan-glow);
    cursor: pointer;
}

.angle-display {
    font-size: 0.85rem;
    color: var(--text-dim);
    margin: 0.8rem 0 0.5rem;
}

/* ===== STAGE 2: GRAVITY JUMP ===== */
.jump-track-wrap {
    width: 100%;
    max-width: 300px;
    margin-bottom: 1.5rem;
}

.jump-track {
    width: 100%;
    height: 40px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    position: relative;
    overflow: hidden;
}

.jump-zone {
    position: absolute;
    top: 0; height: 100%;
    background: rgba(64, 200, 112, 0.15);
    border-left: 2px solid var(--green);
    border-right: 2px solid var(--green);
}

.jump-cursor {
    position: absolute;
    top: 4px; bottom: 4px;
    width: 4px;
    background: var(--white);
    border-radius: 2px;
    box-shadow: 0 0 8px rgba(255,255,255,0.5);
    transition: none;
}

.jump-counter {
    text-align: center;
    margin-top: 0.8rem;
    font-size: 0.9rem;
    color: var(--text-dim);
}

.jump-counter span { color: var(--green); font-weight: 700; }

/* ===== STAGE 3: SIMON SAYS ===== */
.runes-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    max-width: 280px;
    margin-bottom: 1.5rem;
}

.rune-btn {
    aspect-ratio: 1;
    border-radius: 16px;
    border: 2px solid var(--border);
    background: var(--bg-card);
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100px;
}

.rune-btn svg {
    width: 50%; height: 50%;
    opacity: 0.4;
    transition: opacity 0.2s;
}

.rune-btn.lit svg { opacity: 1; }

.rune-btn[data-rune="0"] { --rc: var(--rune-1); }
.rune-btn[data-rune="1"] { --rc: var(--rune-2); }
.rune-btn[data-rune="2"] { --rc: var(--rune-3); }
.rune-btn[data-rune="3"] { --rc: var(--rune-4); }

.rune-btn.lit {
    border-color: var(--rc);
    background: rgba(255,255,255,0.05);
    box-shadow: 0 0 24px color-mix(in srgb, var(--rc) 40%, transparent),
                inset 0 0 16px color-mix(in srgb, var(--rc) 15%, transparent);
}

.rune-btn.lit svg { filter: drop-shadow(0 0 6px var(--rc)); }

.rune-btn svg path,
.rune-btn svg polygon,
.rune-btn svg circle,
.rune-btn svg line {
    stroke: var(--rc);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.simon-info {
    font-size: 0.85rem;
    color: var(--text-dim);
    text-align: center;
    margin-bottom: 0.5rem;
}

.simon-info span { color: var(--orange); font-weight: 700; }

/* ===== RESULT SCREENS ===== */
.result-icon { font-size: 3rem; margin-bottom: 1rem; }

.result-title {
    font-size: 1.5rem;
    color: var(--white);
    margin-bottom: 0.5rem;
}

.result-subtitle {
    font-size: 0.9rem;
    color: var(--text-dim);
    font-style: italic;
}

.result-title.victory {
    color: var(--cyan);
    text-shadow: 0 0 20px var(--cyan-glow);
}

.result-title.defeat {
    color: var(--red);
    text-shadow: 0 0 20px var(--red-glow);
}

/* ===== GATE SCREEN ===== */
.gate-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    color: var(--orange);
    text-shadow: 0 0 16px var(--orange-glow);
}

/* ===== FEEDBACK TOAST ===== */
.feedback {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    padding: 0.7rem 1.5rem;
    border-radius: 8px;
    font-size: 0.85rem;
    z-index: 200;
    opacity: 0;
    transition: opacity 0.3s;
    pointer-events: none;
    white-space: nowrap;
}

.feedback.show { opacity: 1; }

.feedback.success {
    background: rgba(64, 200, 112, 0.15);
    border: 1px solid var(--green);
    color: var(--green);
}

.feedback.error {
    background: rgba(232, 64, 64, 0.15);
    border: 1px solid var(--red);
    color: var(--red);
}

/* ===== ANIMATIONS ===== */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20% { transform: translateX(-8px); }
    40% { transform: translateX(8px); }
    60% { transform: translateX(-6px); }
    80% { transform: translateX(6px); }
}

.shake { animation: shake 0.4s ease-in-out; }

@keyframes glow-pulse {
    0%, 100% { opacity: 0.4; }
    50% { opacity: 1; }
}

.glow-pulse { animation: glow-pulse 1.5s ease-in-out infinite; }

@keyframes fade-in {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fade-in 0.5s ease forwards; }

/* ===== ADMIN PANEL ===== */
.admin-wrap {
    padding: 1.5rem;
    max-width: 600px;
    margin: 0 auto;
}

.admin-title {
    font-size: 1.3rem;
    color: var(--white);
    text-align: center;
    margin-bottom: 0.3rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.admin-subtitle {
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-dim);
    margin-bottom: 1.5rem;
}

.player-table { width: 100%; border-collapse: collapse; }

.player-table th {
    font-size: 0.7rem;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 0.6rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.player-table td {
    padding: 0.7rem 0.5rem;
    font-size: 0.85rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.player-table tr:last-child td { border-bottom: none; }

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.status-badge.stage1 { background: rgba(92,224,216,0.15); color: var(--cyan); }
.status-badge.stage2 { background: rgba(232,148,58,0.15); color: var(--orange); }
.status-badge.stage3 { background: rgba(168,108,232,0.15); color: var(--rune-3); }
.status-badge.victory { background: rgba(64,200,112,0.15); color: var(--green); }
.status-badge.dead { background: rgba(232,64,64,0.15); color: var(--red); }

.btn-reset {
    padding: 0.3rem 0.8rem;
    font-size: 0.7rem;
    border: 1px solid var(--orange);
    background: transparent;
    color: var(--orange);
    border-radius: 4px;
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s;
}

.btn-reset:active { background: var(--orange); color: var(--bg-dark); }

.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--text-dim);
    font-style: italic;
}

.admin-refresh { display: block; margin: 1.5rem auto 0; }

.gate-keys-box {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 1rem 1.2rem;
    margin-bottom: 1.5rem;
}

.gate-keys-box h3 {
    font-size: 0.8rem;
    color: var(--orange);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    margin-bottom: 0.6rem;
}

.gate-keys-box p {
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 0.3rem;
}

.gate-keys-box span {
    color: var(--cyan);
    font-weight: 700;
}
