:root {
    --glass-bg: rgba(15, 22, 36, 0.72);
    --glass-border: rgba(255, 224, 150, 0.22);
    --warm-gold: #ffd166;
    --warm-amber: #f4a261;
    --text-cream: #fff8eb;
    --text-muted: #cbd5e1;
}

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

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: #0b101d;
    color: var(--text-cream);
    font-family: 'Outfit', system-ui, sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.hidden {
    display: none !important;
}

/* HUD */
.hud {
    position: fixed;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    transition: opacity 0.35s ease;
}

.hud.dimmed {
    opacity: 0.25;
}

.hud-left {
    position: absolute;
    top: 16px;
    left: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-stats {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.hud-pill {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-radius: 14px;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
}

.hud-pill.compact {
    padding: 5px 11px;
}

.hud-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--warm-amber);
    font-weight: 700;
}

.hud-value {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text-cream);
}

.bond-bar-wrap {
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    backdrop-filter: blur(12px);
    border-radius: 999px;
    padding: 5px 12px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    width: fit-content;
}

.bond-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--warm-gold);
    font-weight: 700;
}

.bond-track {
    width: 120px;
    height: 8px;
    background: rgba(255, 255, 255, 0.14);
    border-radius: 999px;
    overflow: hidden;
}

.bond-fill {
    height: 100%;
    background: linear-gradient(90deg, #f4a261 0%, #ffd166 100%);
    border-radius: 999px;
    transition: width 0.15s ease;
}

.hud-right {
    position: absolute;
    top: 16px;
    right: 16px;
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border-radius: 12px;
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-cream);
    font-size: 1.15rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    text-decoration: none;
    backdrop-filter: blur(12px);
}

/* Cutscene Captions */
.cutscene-caption {
    position: fixed;
    bottom: 22px;
    left: 50%;
    transform: translateX(-50%);
    width: min(92vw, 720px);
    text-align: center;
    z-index: 20;
    pointer-events: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.cutscene-caption p {
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(1rem, 2.3vw, 1.32rem);
    color: #fff6e0;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.85);
    line-height: 1.4;
}

.skip-btn {
    background: rgba(255, 255, 255, 0.12);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #e2e8f0;
    padding: 5px 14px;
    border-radius: 999px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.78rem;
    font-weight: 600;
    cursor: pointer;
}

/* Overlays */
.overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: radial-gradient(circle at 50% 45%, rgba(15, 23, 42, 0.45), rgba(7, 10, 18, 0.82));
    backdrop-filter: blur(4px);
}

.card {
    width: min(94vw, 540px);
    background: rgba(17, 24, 39, 0.86);
    border: 1px solid rgba(255, 214, 120, 0.28);
    border-radius: 24px;
    padding: 30px 28px;
    text-align: center;
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
}

.badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    padding: 5px 12px;
    border-radius: 999px;
    background: rgba(244, 162, 97, 0.18);
    color: var(--warm-gold);
    margin-bottom: 12px;
}

.badge.danger {
    background: rgba(239, 68, 68, 0.2);
    color: #fca5a5;
}

.card h1, .card h2 {
    font-family: 'Fraunces', Georgia, serif;
    font-size: clamp(2rem, 4.8vw, 2.75rem);
    font-weight: 800;
    background: linear-gradient(135deg, #fff8eb 0%, #ffd166 55%, #f4a261 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 12px;
}

.subtitle {
    color: var(--text-muted);
    font-size: 0.98rem;
    line-height: 1.55;
    margin-bottom: 16px;
}

.rule-note {
    background: rgba(255, 209, 102, 0.08);
    border: 1px solid rgba(255, 209, 102, 0.22);
    border-radius: 12px;
    padding: 10px 14px;
    font-size: 0.88rem;
    color: #fde68a;
    margin-bottom: 18px;
}

.controls-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    text-align: left;
    font-size: 0.84rem;
    color: #cbd5e1;
    margin-bottom: 22px;
}

.controls-grid span {
    background: rgba(255, 255, 255, 0.1);
    padding: 2px 7px;
    border-radius: 6px;
    color: #fff;
    font-weight: 700;
}

.summary-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 14px;
    padding: 12px 8px;
}

.stat-num {
    display: block;
    font-size: 1.45rem;
    font-weight: 800;
    color: var(--warm-gold);
}

.stat-lbl {
    font-size: 0.74rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.milestones-line {
    font-size: 0.88rem;
    color: #e2e8f0;
    margin-bottom: 20px;
}

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

.cta-btn {
    width: 100%;
    border: none;
    border-radius: 14px;
    padding: 14px 22px;
    font-family: 'Outfit', sans-serif;
    font-size: 1.05rem;
    font-weight: 800;
    color: #1a1410;
    background: linear-gradient(135deg, #ffd166 0%, #f4a261 100%);
    box-shadow: 0 10px 24px rgba(244, 162, 97, 0.35);
    cursor: pointer;
    transition: transform 0.15s ease;
}

.cta-btn:active {
    transform: scale(0.98);
}

.sec-btn {
    width: 100%;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    padding: 11px 18px;
    font-family: 'Outfit', sans-serif;
    font-size: 0.94rem;
    font-weight: 700;
    color: #f1f5f9;
    background: rgba(255, 255, 255, 0.07);
    cursor: pointer;
}

.back-link {
    display: inline-block;
    margin-top: 14px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.88rem;
    font-weight: 600;
}

/* Mobile & Tablet Touch Controls */
.touch-controls {
    display: none;
    position: fixed;
    left: 16px;
    right: 16px;
    bottom: 18px;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
}

.touch-cluster {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.joystick-pad {
    position: relative;
    width: 138px;
    height: 138px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 224, 150, 0.3);
    background: rgba(15, 22, 36, 0.48);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    touch-action: none;
    box-shadow: inset 0 0 24px rgba(0, 0, 0, 0.32);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.joystick-pad.active {
    border-color: rgba(255, 209, 102, 0.65);
    background: rgba(15, 22, 36, 0.62);
}

.joystick-knob {
    width: 54px;
    height: 54px;
    border-radius: 50%;
    background: radial-gradient(circle at 35% 35%, #ffe699 0%, #f4a261 100%);
    border: 2px solid rgba(255, 255, 255, 0.65);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.4);
    pointer-events: none;
    transform: translate(0px, 0px);
    transition: transform 0.08s ease-out;
}

.joystick-pad.active .joystick-knob {
    transition: none;
}

.joy-hint {
    position: absolute;
    font-size: 0.72rem;
    color: rgba(255, 248, 235, 0.35);
    pointer-events: none;
}

.joy-hint.left { left: 10px; }
.joy-hint.right { right: 10px; }
.joy-hint.down { bottom: 8px; }

.touch-btn {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    border: 1.5px solid rgba(255, 255, 255, 0.25);
    background: rgba(15, 22, 36, 0.56);
    backdrop-filter: blur(8px);
    color: #fff8eb;
    font-size: 1.25rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.touch-btn.primary {
    width: 68px;
    height: 68px;
    background: rgba(244, 162, 97, 0.42);
    border-color: rgba(255, 209, 102, 0.6);
}

.touch-btn.accent.ready {
    background: rgba(255, 209, 102, 0.52);
    border-color: #ffd166;
    box-shadow: 0 0 16px rgba(255, 209, 102, 0.55);
}

.touch-btn.pressed {
    transform: scale(0.92);
    background: rgba(255, 255, 255, 0.28);
}

@media (pointer: coarse), (max-width: 1024px) {
    .touch-controls {
        display: flex;
    }
    .controls-grid {
        grid-template-columns: 1fr;
    }
    .cutscene-caption {
        bottom: 148px;
    }
}
