:root {
    --bg-primary: #0a0e17;
    --accent-gold: #f0c850;
    --accent-gold-dim: #a88b30;
    --accent-teal: #2dd4bf;
    --accent-rose: #fb7185;
    --accent-violet: #a78bfa;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    --glass-bg: rgba(15, 23, 42, 0.8);
    --glass-border: rgba(255,255,255,0.1);
    --font-ui: 'Outfit', 'Segoe UI', sans-serif;
    --radius: 12px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
    font-family: var(--font-ui);
    background: var(--bg-primary);
    color: var(--text-primary);
    -webkit-font-smoothing: antialiased;
}

/* Phaser canvas container - absolutely at the bottom of the layer stack */
#game-container {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

/* === DOM HUD === */
#hud-layer {
    position: absolute;
    top: 0; left: 0; right: 0;
    z-index: 100;
    pointer-events: none;
    padding: 14px 18px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.hud-cluster {
    pointer-events: auto;
    display: flex;
    gap: 8px;
    align-items: center;
}

.hud-chip {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
}

.hud-chip .label {
    color: var(--text-secondary);
    font-weight: 400;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.hud-chip .value {
    font-size: 20px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.value.gold { color: var(--accent-gold); }
.value.teal { color: var(--accent-teal); }
.value.rose { color: var(--accent-rose); }

.hud-stage {
    background: linear-gradient(135deg, rgba(45, 212, 191, 0.12), rgba(167, 139, 250, 0.08));
    border: 1px solid rgba(45, 212, 191, 0.2);
}

.hud-stage .stage-name {
    font-size: 15px;
    font-weight: 700;
    background: linear-gradient(135deg, var(--accent-teal), var(--accent-violet));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* === Bottom Action Bar === */
#action-bar {
    position: absolute;
    bottom: 0; left: 0; right: 0;
    z-index: 100;
    pointer-events: none;
    padding: 14px 18px;
    display: flex;
    justify-content: center;
    gap: 8px;
}

.action-btn {
    pointer-events: auto;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 12px 24px;
    color: var(--text-primary);
    font-family: var(--font-ui);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
}

.action-btn:hover {
    background: rgba(30, 41, 59, 0.95);
    border-color: rgba(255,255,255,0.2);
    transform: translateY(-2px);
}
.action-btn:active { transform: translateY(0); }
.action-btn .icon { font-size: 16px; }
.action-btn.hint:hover { border-color: rgba(45, 212, 191, 0.5); }
.action-btn.shuffle:hover { border-color: rgba(251, 113, 133, 0.5); }
.action-btn.undo:hover { border-color: rgba(167, 139, 250, 0.5); }

/* === Stage Select Overlay === */
#stage-overlay {
    position: absolute;
    inset: 0;
    z-index: 9999;
    background: rgba(5, 7, 12, 0.97);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transition: opacity 0.4s ease;
}

#stage-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.title-area { text-align: center; margin-bottom: 36px; }

.title-area h1 {
    font-size: 48px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold) 0%, #fff5cc 40%, var(--accent-gold) 60%, #e8a800 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -1px;
}

.title-area .subtitle {
    font-size: 14px;
    color: var(--text-muted);
    letter-spacing: 5px;
    text-transform: uppercase;
    margin-top: 6px;
}

#btn-start-game {
    padding: 18px 48px;
    font-size: 22px;
    font-family: var(--font-ui);
    font-weight: 700;
    border-radius: 30px;
    background: linear-gradient(135deg, var(--accent-gold), #e8a800);
    color: #111;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 15px rgba(240, 200, 80, 0.3);
}

#btn-start-game:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(240, 200, 80, 0.5);
    filter: brightness(1.1);
}

#btn-start-game:active {
    transform: translateY(0);
}

.rules-area {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius);
    padding: 20px 28px;
    margin-bottom: 32px;
    width: 320px;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.rule-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--accent-gold);
    margin-bottom: 16px;
    text-align: center;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.rule-list {
    list-style: none;
    font-size: 14px;
    color: var(--text-primary);
}

.rule-list li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.rule-list li:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.rule-list .plus { color: var(--accent-teal); font-weight: 600; font-variant-numeric: tabular-nums; }
.rule-list .minus { color: var(--accent-rose); font-weight: 600; font-variant-numeric: tabular-nums; }

.rule-note {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 16px;
    text-align: center;
}

/* === Toast === */
#toast {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.85);
    z-index: 10000;
    background: var(--glass-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    padding: 28px 44px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

#toast.visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#toast .toast-title {
    font-size: 38px;
    font-weight: 800;
    background: linear-gradient(135deg, var(--accent-gold), #fff5cc);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#toast .toast-sub {
    font-size: 15px;
    color: var(--text-secondary);
    margin-top: 6px;
}

/* === Combo === */
#combo-display {
    position: absolute;
    top: 90px;
    left: 50%;
    transform: translateX(-50%) scale(0.9);
    z-index: 200;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    background: var(--glass-bg);
    padding: 12px 24px;
    border-radius: 20px;
    border: 1px solid var(--accent-gold);
    box-shadow: 0 4px 20px rgba(240, 200, 80, 0.2);
}

#combo-display.visible { 
    opacity: 1; 
    transform: translateX(-50%) scale(1);
}

.combo-info {
    display: flex;
    align-items: baseline;
    gap: 8px;
}

#combo-display .combo-num {
    font-size: 36px;
    font-weight: 800;
    color: var(--accent-gold);
    text-shadow: 0 0 10px rgba(240, 200, 80, 0.6);
    line-height: 1;
}

#combo-display .combo-label {
    font-size: 16px;
    font-weight: 700;
    color: #fff;
    letter-spacing: 2px;
}

#combo-display .combo-bonus {
    font-size: 15px;
    font-weight: 800;
    color: var(--accent-rose);
    margin-top: -4px;
    margin-bottom: 4px;
    letter-spacing: 1px;
}

.combo-gauge-bg {
    width: 200px;
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.combo-gauge-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, var(--accent-rose), var(--accent-gold));
    border-radius: 4px;
    transform-origin: left center;
}

@keyframes comboGaugeDeplete {
    0% { transform: scaleX(1); }
    100% { transform: scaleX(0); }
}

/* === Responsive === */
@media (max-width: 768px) {
    .title-area h1 { font-size: 36px; }
    .hud-chip { padding: 10px 14px; }
    .hud-chip .value { font-size: 18px; }
    .hud-chip .label { font-size: 12px; }
    .hud-stage .stage-name { font-size: 18px; }
    
    .action-btn { padding: 12px 18px; font-size: 15px; }
    .action-btn .icon { font-size: 20px; }
    #combo-display .combo-num { font-size: 34px; }
}

@media (max-width: 480px) {
    .title-area h1 { font-size: 30px; }
    .hud-layer { padding: 10px 12px; }
    .hud-chip { padding: 8px 12px; }
    .hud-chip .value { font-size: 16px; }
    /* Hide top label text (e.g. "점수") to save vertical/horizontal space, but keep the value large */
    .hud-chip .label { display: none; }
    
    /* Keep action button text visible, but slightly squeeze padding to ensure they fit */
    .action-btn { padding: 10px 14px; font-size: 14px; }
    .action-btn .icon { font-size: 18px; }
}
