/* =============================================
   TOWERS OF HANOI — NEXUS QUEST
   Premium Dark Gaming Theme
   ============================================= */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;700;900&family=Rajdhani:wght@400;600;700&family=Exo+2:wght@300;400;700&display=swap');

/* ── CSS Variables ── */
:root {
    --bg-deep:      #03010a;
    --bg-mid:       #0d0b1e;
    --bg-panel:     rgba(13, 11, 30, 0.85);
    --neon-purple:  #a855f7;
    --neon-pink:    #ec4899;
    --neon-cyan:    #06b6d4;
    --neon-gold:    #f59e0b;
    --neon-green:   #10b981;
    --text-primary: #f0e6ff;
    --text-muted:   #7c6d9e;
    --border-glow:  rgba(168, 85, 247, 0.4);
    --glass-bg:     rgba(15, 10, 40, 0.75);
    --glass-border: rgba(168, 85, 247, 0.25);
    --shadow-neon:  0 0 30px rgba(168, 85, 247, 0.3);
    --font-game:    'Orbitron', monospace;
    --font-ui:      'Rajdhani', sans-serif;
    --font-body:    'Exo 2', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
}

body {
    font-family: var(--font-body);
    background: var(--bg-deep);
    color: var(--text-primary);
    position: relative;
}

/* ── Starfield Canvas (background) ── */
.starfield-canvas {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
}

/* ── BG Particles ── */
.bg-particles {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-particle {
    position: absolute;
    border-radius: 50%;
    opacity: 0.15;
    animation: floatParticle var(--dur, 15s) ease-in-out infinite;
    animation-delay: var(--delay, 0s);
}

@keyframes floatParticle {
    0%, 100% { transform: translateY(0) rotate(0deg) scale(1); }
    33%       { transform: translateY(-60px) rotate(120deg) scale(1.1); }
    66%       { transform: translateY(30px) rotate(240deg) scale(0.9); }
}

/* ── Glass Card ── */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: blur(20px) saturate(150%);
    -webkit-backdrop-filter: blur(20px) saturate(150%);
    border: 1px solid var(--glass-border);
    border-radius: 20px;
    box-shadow:
        0 8px 32px rgba(0,0,0,0.5),
        inset 0 1px 0 rgba(255,255,255,0.07),
        var(--shadow-neon);
    position: relative;
    overflow: hidden;
}

/* gradient scan-line shimmer on top edge */
.glass-card::before {
    content: '';
    position: absolute;
    top: 0; left: -100%; right: 0;
    height: 2px;
    background: linear-gradient(90deg,
        transparent 0%,
        var(--neon-purple) 40%,
        var(--neon-cyan) 60%,
        transparent 100%);
    animation: scanline 4s linear infinite;
    z-index: 10;
}

@keyframes scanline {
    0%   { left: -100%; }
    100% { left: 100%; }
}

/* ── Modal glow orb ── */
.modal-glow {
    position: absolute;
    top: -80px; left: 50%;
    transform: translateX(-50%);
    width: 300px; height: 300px;
    background: radial-gradient(circle,
        rgba(168, 85, 247, 0.25) 0%,
        transparent 70%);
    pointer-events: none;
    z-index: 0;
    animation: glowPulse 3s ease-in-out infinite;
}

@keyframes glowPulse {
    0%, 100% { opacity: 0.6; transform: translateX(-50%) scale(1);   }
    50%       { opacity: 1;   transform: translateX(-50%) scale(1.15); }
}

/* ── Modals ── */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    background: rgba(3, 1, 10, 0.7);
    backdrop-filter: blur(6px);
}

.modal.modal-active {
    display: flex;
    animation: fadeInModal 0.35s ease;
}

@keyframes fadeInModal {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-content {
    text-align: center;
    padding: 48px 44px;
    position: relative;
    z-index: 1;
    animation: popUp 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.name-modal   { width: 90%; max-width: 460px; }
.config-modal { width: 90%; max-width: 560px; }

@keyframes popUp {
    from { opacity: 0; transform: scale(0.7) translateY(40px); }
    to   { opacity: 1; transform: scale(1) translateY(0);       }
}

/* ── Title Icon ── */
.title-icon-wrap {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.title-icon-wrap.small .title-icon {
    font-size: 40px;
}

.title-icon {
    font-size: 64px;
    line-height: 1;
    animation: iconFloat 3s ease-in-out infinite;
    position: relative;
    z-index: 2;
    filter: drop-shadow(0 0 20px var(--neon-purple));
}

.title-icon-rings {
    position: absolute;
    width: 90px; height: 90px;
    border-radius: 50%;
    border: 2px solid rgba(168, 85, 247, 0.4);
    animation: ringPulse 2.5s ease-in-out infinite;
}

.title-icon-rings::before,
.title-icon-rings::after {
    content: '';
    position: absolute;
    inset: -15px;
    border-radius: 50%;
    border: 1px solid rgba(168, 85, 247 , 0.2);
    animation: ringPulse 2.5s ease-in-out infinite reverse;
}

.title-icon-rings::after { inset: -28px; animation-delay: 0.5s; }

@keyframes ringPulse {
    0%, 100% { transform: scale(1); opacity: 0.6; }
    50%       { transform: scale(1.1); opacity: 1; }
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50%       { transform: translateY(-12px); }
}

/* ── Game Title ── */
.game-title {
    font-family: var(--font-game);
    font-size: clamp(26px, 5vw, 42px);
    font-weight: 900;
    line-height: 1.1;
    letter-spacing: 4px;
    background: linear-gradient(135deg, #c084fc 0%, #e879f9 40%, #67e8f9 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 8px;
    text-shadow: none;
    filter: drop-shadow(0 0 20px rgba(168,85,247,0.5));
}

.title-accent {
    background: linear-gradient(135deg, #f59e0b, #ef4444, #ec4899);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.game-subtitle {
    font-family: var(--font-ui);
    font-size: 14px;
    letter-spacing: 6px;
    color: var(--neon-cyan);
    margin-bottom: 10px;
    text-transform: uppercase;
    opacity: 0.9;
}

.modal-subtitle {
    font-family: var(--font-ui);
    font-size: 16px;
    color: var(--text-muted);
    margin-bottom: 24px;
    letter-spacing: 1px;
}

.section-title {
    font-family: var(--font-game);
    font-size: clamp(18px, 3vw, 26px);
    font-weight: 700;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 24px;
}

/* ── Neon Input ── */
.input-wrap {
    position: relative;
    margin-bottom: 24px;
}

.neon-input {
    width: 100%;
    padding: 14px 18px;
    font-size: 16px;
    font-family: var(--font-ui);
    font-weight: 600;
    letter-spacing: 1px;
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.3);
    border-radius: 12px;
    color: var(--text-primary);
    transition: all 0.3s ease;
    outline: none;
}

.neon-input::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.neon-input:focus {
    border-color: var(--neon-purple);
    background: rgba(168, 85, 247, 0.15);
    box-shadow: 0 0 0 3px rgba(168, 85, 247, 0.15),
                0 0 20px rgba(168, 85, 247, 0.25);
}

/* ── Config Group ── */
.config-group {
    margin: 20px 0;
    padding: 20px 22px;
    background: rgba(168, 85, 247, 0.06);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 14px;
    text-align: left;
}

.config-group label {
    display: block;
    font-family: var(--font-ui);
    font-size: 15px;
    font-weight: 600;
    color: var(--neon-cyan);
    letter-spacing: 1px;
    margin-bottom: 14px;
    text-transform: uppercase;
}

/* ── Neon Slider ── */
.neon-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    border-radius: 6px;
    background: linear-gradient(90deg,
        var(--neon-purple) 0%,
        var(--neon-pink)   50%,
        var(--neon-cyan)   100%);
    outline: none;
    cursor: pointer;
    margin-bottom: 12px;
}

.neon-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px; height: 22px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 0 12px var(--neon-purple), 0 0 24px rgba(168,85,247,0.4);
    border: 2px solid var(--neon-purple);
    transition: transform 0.2s, box-shadow 0.2s;
}

.neon-slider::-webkit-slider-thumb:hover {
    transform: scale(1.3);
    box-shadow: 0 0 20px var(--neon-purple), 0 0 40px rgba(168,85,247,0.5);
}

.neon-slider::-moz-range-thumb {
    width: 22px; height: 22px;
    border-radius: 50%;
    background: white;
    cursor: pointer;
    box-shadow: 0 0 12px var(--neon-purple);
    border: 2px solid var(--neon-purple);
}

.config-display { text-align: center; }

.value-badge {
    display: inline-block;
    padding: 6px 20px;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
    border-radius: 30px;
    font-family: var(--font-game);
    font-size: 20px;
    font-weight: 700;
    color: white;
    box-shadow: 0 0 16px rgba(168,85,247,0.5);
    animation: badgePulse 1.8s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% { box-shadow: 0 0 16px rgba(168,85,247,0.5); transform: scale(1); }
    50%       { box-shadow: 0 0 28px rgba(168,85,247,0.8); transform: scale(1.05); }
}

.config-actions {
    display: flex;
    gap: 14px;
    margin-top: 28px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Buttons ── */
.btn-primary,
.btn-secondary,
.btn-control {
    position: relative;
    font-family: var(--font-game);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 2px;
    text-transform: uppercase;
    padding: 14px 32px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.25s ease;
    overflow: hidden;
    z-index: 1;
}

.btn-primary {
    background: linear-gradient(135deg, #7c3aed, #a855f7, #ec4899);
    color: white;
    box-shadow: 0 4px 20px rgba(168,85,247,0.4), 0 0 0 1px rgba(168,85,247,0.3);
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-3px) scale(1.03);
    box-shadow: 0 8px 30px rgba(168,85,247,0.6), 0 0 0 1px rgba(168,85,247,0.5);
}

.btn-glow {
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent, rgba(255,255,255,0.15), transparent);
    transform: translateX(-100%);
    transition: transform 0.5s ease;
}

.btn-primary:hover .btn-glow {
    transform: translateX(100%);
}

.btn-secondary {
    background: rgba(168, 85, 247, 0.1);
    color: var(--neon-purple);
    border: 1px solid rgba(168, 85, 247, 0.35);
}

.btn-secondary:hover:not(:disabled) {
    background: rgba(168, 85, 247, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(168,85,247,0.25);
}

.btn-control {
    background: rgba(6, 182, 212, 0.1);
    color: var(--neon-cyan);
    border: 1px solid rgba(6, 182, 212, 0.3);
    font-size: 12px;
    padding: 12px 22px;
    transition: all 0.25s;
}

.btn-control:hover:not(:disabled) {
    background: rgba(6, 182, 212, 0.22);
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(6, 182, 212, 0.25);
    border-color: var(--neon-cyan);
}

button:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.icon-btn {
    background: rgba(168,85,247,0.1);
    border: 1px solid rgba(168,85,247,0.3);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 20px;
    width: 44px; height: 44px;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: rgba(168,85,247,0.25);
    transform: scale(1.1);
}

/* ── Game Screen ── */
.game-screen {
    display: none;
    flex-direction: column;
    width: 100%;
    height: 100vh;
    padding: 14px 18px;
    gap: 12px;
    position: relative;
    z-index: 1;
}

/* ── Game Header ── */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
    padding: 12px 20px;
    background: var(--glass-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    box-shadow: var(--shadow-neon);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-icon {
    font-size: 32px;
    filter: drop-shadow(0 0 10px var(--neon-purple));
    animation: iconFloat 4s ease-in-out infinite;
}

.header-title {
    font-family: var(--font-game);
    font-size: clamp(14px, 2.5vw, 22px);
    font-weight: 900;
    letter-spacing: 3px;
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.1;
}

.player-name {
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--neon-gold);
    font-weight: 600;
    letter-spacing: 1px;
    margin-top: 2px;
}

.game-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.stat-card {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.2);
    border-radius: 12px;
    transition: border-color 0.3s;
}

.stat-card.updated {
    border-color: var(--neon-cyan);
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.3);
}

.stat-icon {
    font-size: 20px;
}

.stat-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
}

.stat-label {
    font-family: var(--font-ui);
    font-size: 9px;
    letter-spacing: 2px;
    color: var(--text-muted);
    text-transform: uppercase;
}

.stat-value {
    font-family: var(--font-game);
    font-size: clamp(16px, 2vw, 22px);
    font-weight: 700;
    color: var(--text-primary);
    transition: color 0.3s;
}

.header-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ── Instruction Bar ── */
.instruction-bar {
    padding: 8px 18px;
    background: rgba(6, 182, 212, 0.08);
    border: 1px solid rgba(6, 182, 212, 0.2);
    border-radius: 10px;
    text-align: center;
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--neon-cyan);
    letter-spacing: 0.5px;
    transition: all 0.3s;
}

/* ── Game Canvas ── */
.game-canvas {
    flex: 1;
    background: transparent;
    border: 1px solid var(--glass-border);
    border-radius: 18px;
    position: relative;
    overflow: hidden;
    box-shadow:
        0 0 40px rgba(168,85,247,0.1),
        inset 0 0 60px rgba(3,1,10,0.5);
    min-height: 300px;
    cursor: crosshair;
}

.game-canvas canvas {
    display: block;
    border-radius: 17px;
}

/* ── Game Controls ── */
.game-controls {
    display: flex;
    gap: 10px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Win Popup ── */
.win-popup {
    display: none;
    position: fixed;
    inset: 0;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    background: rgba(3, 1, 10, 0.85);
    backdrop-filter: blur(10px);
    animation: fadeInModal 0.3s ease;
}

.win-particles-canvas {
    position: absolute;
    inset: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 0;
}

.win-content {
    text-align: center;
    padding: 50px 44px;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1;
    animation: popUp 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* rotating light rays */
.win-rays {
    position: absolute;
    width: 500px; height: 500px;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: conic-gradient(
        from 0deg,
        transparent 0deg,
        rgba(168,85,247,0.08) 10deg,
        transparent 20deg,
        rgba(236,72,153,0.06) 30deg,
        transparent 40deg,
        rgba(6,182,212,0.08) 50deg,
        transparent 60deg
    );
    animation: raysRotate 8s linear infinite;
    z-index: -1;
    border-radius: 50%;
}

@keyframes raysRotate {
    from { transform: translate(-50%, -50%) rotate(0deg); }
    to   { transform: translate(-50%, -50%) rotate(360deg); }
}

.win-icon {
    font-size: 80px;
    animation: iconFloat 2s ease-in-out infinite;
    filter: drop-shadow(0 0 20px var(--neon-gold));
    margin-bottom: 10px;
    display: block;
}

.win-title {
    font-family: var(--font-game);
    font-size: clamp(36px, 8vw, 64px);
    font-weight: 900;
    letter-spacing: 6px;
    background: linear-gradient(135deg, var(--neon-gold), var(--neon-pink), var(--neon-purple));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titlePulse 1.5s ease-in-out infinite;
    margin-bottom: 12px;
}

@keyframes titlePulse {
    0%, 100% { filter: brightness(1); }
    50%       { filter: brightness(1.25); }
}

.win-message {
    font-family: var(--font-ui);
    font-size: clamp(16px, 3vw, 22px);
    color: var(--text-muted);
    margin-bottom: 28px;
    font-weight: 600;
}

.winner-highlight {
    color: var(--neon-cyan);
    font-weight: 700;
}

.win-stats {
    margin-bottom: 22px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.win-stat-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: rgba(168, 85, 247, 0.08);
    border: 1px solid rgba(168, 85, 247, 0.18);
    border-radius: 12px;
}

.win-stat-label {
    font-family: var(--font-ui);
    font-size: 14px;
    color: var(--text-muted);
    font-weight: 600;
    letter-spacing: 1px;
}

.win-stat-val {
    font-family: var(--font-game);
    font-size: 20px;
    font-weight: 700;
    color: var(--neon-cyan);
}

.efficiency-badge {
    display: inline-block;
    padding: 10px 28px;
    border-radius: 30px;
    font-family: var(--font-game);
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 2px;
    margin-bottom: 24px;
    animation: badgePulse 1.5s infinite;
}

.efficiency-badge.perfect {
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: white;
    box-shadow: 0 0 24px rgba(245,158,11,0.6);
}

.efficiency-badge.great {
    background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
    color: white;
    box-shadow: 0 0 24px rgba(168,85,247,0.5);
}

.efficiency-badge.good {
    background: linear-gradient(135deg, var(--neon-green), var(--neon-cyan));
    color: white;
    box-shadow: 0 0 24px rgba(16,185,129,0.5);
}

.efficiency-badge.ok {
    background: linear-gradient(135deg, #374151, #4b5563);
    color: var(--text-primary);
    box-shadow: none;
}

.win-actions {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-mid); }
::-webkit-scrollbar-thumb {
    background: var(--neon-purple);
    border-radius: 6px;
}

/* ── Responsive ── */
@media (max-width: 768px) {
    .game-screen { padding: 10px 12px; gap: 8px; }
    .game-header { flex-direction: column; gap: 8px; }
    .modal-content { padding: 30px 24px; }
    .game-stats { justify-content: center; }
    .win-content { padding: 30px 22px; }
    .btn-primary, .btn-secondary { padding: 12px 22px; font-size: 12px; }
}

@media (max-width: 480px) {
    .header-title { letter-spacing: 1px; }
    .stat-card { padding: 8px 12px; }
    .btn-control { padding: 10px 14px; font-size: 11px; }
}