/* CSS Variables & Design System */
:root {
    --bg-dark: #070b19;
    --bg-card: rgba(15, 23, 42, 0.75);
    --gold-primary: #d4af37;
    --gold-light: #f9e076;
    --gold-dark: #997a15;
    --rose-gold: #e8a598;
    --cyan-crystal: #4cc9f0;
    --purple-magic: #7209b7;
    --text-light: #f8fafc;
    --text-muted: #94a3b8;
    --border-gold: rgba(212, 175, 55, 0.35);
    --shadow-glow: 0 0 25px rgba(212, 175, 55, 0.25);
    --font-heading: 'Cinzel', 'Outfit', serif;
    --font-body: 'Inter', system-ui, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-light);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow-x: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    padding: 15px;
}

/* Background Stars and Ambient Orbs */
.stars-bg {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: radial-gradient(ellipse at bottom, #1b2735 0%, #090a0f 100%);
    z-index: -2;
}

.clock-glow-orb {
    position: fixed;
    border-radius: 50%;
    filter: blur(100px);
    z-index: -1;
    pointer-events: none;
    opacity: 0.4;
    animation: orbPulse 8s infinite alternate ease-in-out;
}

.orb-1 {
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, #d4af37 0%, transparent 70%);
    top: 10%;
    left: 15%;
}

.orb-2 {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, #7209b7 0%, transparent 70%);
    bottom: 10%;
    right: 15%;
    animation-delay: 4s;
}

@keyframes orbPulse {
    0% { transform: scale(1) translate(0, 0); opacity: 0.3; }
    100% { transform: scale(1.2) translate(30px, -20px); opacity: 0.5; }
}

/* Typography Helpers */
.gold-text {
    background: linear-gradient(135deg, #fff2a3 0%, #d4af37 50%, #aa7c11 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.cyan-text {
    background: linear-gradient(135deg, #a5f3fc 0%, #38bdf8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.rose-text {
    background: linear-gradient(135deg, #fecdd3 0%, #e8a598 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* App Main Container */
.app-container {
    width: 100%;
    max-width: 800px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    margin: 0 auto;
}

/* Header */
.game-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 12px 20px;
    box-shadow: var(--shadow-glow);
}

.back-link {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--gold-light);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    transition: all 0.2s ease;
    padding: 6px 12px;
    border-radius: 8px;
    background: rgba(212, 175, 55, 0.1);
}

.back-link:hover {
    background: rgba(212, 175, 55, 0.25);
    transform: translateX(-2px);
}

.game-title-group {
    text-align: center;
}

.game-title {
    font-family: var(--font-heading);
    font-size: 22px;
    font-weight: 700;
    letter-spacing: 2px;
}

.game-subtitle {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 1px;
}

.icon-btn {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-gold);
    color: var(--gold-light);
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: rgba(212, 175, 55, 0.2);
}

/* Dashboard Panel */
.dashboard-panel {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.stat-box {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 10px 14px;
    display: flex;
    flex-direction: column;
    align-items: center;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
}

.stat-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-value {
    font-family: var(--font-heading);
    font-size: 24px;
    font-weight: 700;
    margin-top: 2px;
}

/* Game Main Area */
.game-main {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
}

.canvas-wrapper {
    position: relative;
    width: 100%;
    max-width: 720px;
    aspect-ratio: 1 / 1;
    background: rgba(10, 15, 30, 0.85);
    border: 2px solid var(--border-gold);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.15), inset 0 0 30px rgba(0, 0, 0, 0.8);
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

/* Overlay Modals */
.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(7, 11, 25, 0.88);
    backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10;
    padding: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-card {
    background: rgba(20, 27, 45, 0.95);
    border: 1px solid var(--gold-primary);
    box-shadow: 0 0 40px rgba(212, 175, 55, 0.3);
    border-radius: 20px;
    padding: 28px 24px;
    text-align: center;
    max-width: 440px;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
}

.clockwork-emblem {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 3px double var(--gold-primary);
    background: radial-gradient(circle, rgba(212, 175, 55, 0.2) 0%, transparent 70%);
    position: relative;
    animation: spinClock 20s linear infinite;
}

.clockwork-emblem::after {
    content: '⚙️';
    font-size: 32px;
    line-height: 60px;
}

@keyframes spinClock {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.modal-title {
    font-family: var(--font-heading);
    font-size: 26px;
    color: var(--gold-light);
    letter-spacing: 2px;
}

.modal-desc {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.6;
}

.key-hints {
    display: flex;
    flex-direction: column;
    gap: 8px;
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 10px 14px;
}

.hint-item {
    font-size: 12px;
    color: var(--text-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.key {
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--border-gold);
    color: var(--gold-light);
    padding: 3px 8px;
    border-radius: 6px;
    font-family: monospace;
    font-size: 11px;
}

.btn {
    border: none;
    border-radius: 12px;
    padding: 12px 28px;
    font-family: var(--font-heading);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 1px;
}

.btn-gold {
    background: linear-gradient(135deg, #f9e076 0%, #d4af37 100%);
    color: #070b19;
    box-shadow: 0 4px 20px rgba(212, 175, 55, 0.4);
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(212, 175, 55, 0.6);
}

/* Ability Controls Panel */
.ability-panel {
    width: 100%;
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    backdrop-filter: blur(12px);
    border-radius: 16px;
    padding: 14px 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: var(--shadow-glow);
}

.energy-bar-container {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.energy-label {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gold-light);
    font-weight: 600;
}

.energy-track {
    width: 100%;
    height: 10px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 6px;
    overflow: hidden;
    border: 1px solid rgba(212, 175, 55, 0.2);
}

.energy-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #38bdf8 0%, #4cc9f0 50%, #f9e076 100%);
    box-shadow: 0 0 10px #4cc9f0;
    transition: width 0.3s ease;
}

.btn-ability {
    background: linear-gradient(135deg, rgba(76, 201, 240, 0.15) 0%, rgba(212, 175, 55, 0.2) 100%);
    border: 1px solid var(--gold-primary);
    color: var(--gold-light);
    border-radius: 12px;
    padding: 12px;
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-ability:not(:disabled):hover {
    background: linear-gradient(135deg, rgba(76, 201, 240, 0.35) 0%, rgba(212, 175, 55, 0.4) 100%);
    box-shadow: 0 0 20px rgba(76, 201, 240, 0.5);
    transform: scale(1.02);
}

.btn-ability:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    border-color: rgba(255, 255, 255, 0.1);
}

/* Mobile Controls */
.mobile-controls {
    display: none;
    width: 100%;
    justify-content: space-between;
    align-items: center;
    gap: 15px;
    padding: 10px 0;
}

.dpad {
    position: relative;
    width: 130px;
    height: 130px;
}

.dpad-btn {
    position: absolute;
    width: 42px;
    height: 42px;
    background: rgba(212, 175, 55, 0.15);
    border: 1px solid var(--border-gold);
    color: var(--gold-light);
    border-radius: 10px;
    font-size: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    touch-action: manipulation;
}

.dpad-btn:active {
    background: rgba(212, 175, 55, 0.4);
}

.dpad-up { top: 0; left: 44px; }
.dpad-left { top: 44px; left: 0; }
.dpad-right { top: 44px; right: 0; }
.dpad-down { bottom: 0; left: 44px; }

.mobile-chrono-btn {
    flex: 1;
    height: 70px;
    background: linear-gradient(135deg, rgba(76, 201, 240, 0.2) 0%, rgba(212, 175, 55, 0.2) 100%);
    border: 1px solid var(--gold-primary);
    border-radius: 16px;
    color: var(--gold-light);
    font-family: var(--font-heading);
    font-size: 14px;
    font-weight: 700;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 4px;
    touch-action: manipulation;
}

.mobile-chrono-btn:active {
    background: rgba(76, 201, 240, 0.4);
    transform: scale(0.97);
}

/* Footer Guide */
.game-footer {
    width: 100%;
}

.guide-card {
    background: var(--bg-card);
    border: 1px solid var(--border-gold);
    border-radius: 16px;
    padding: 16px 20px;
    backdrop-filter: blur(10px);
}

.guide-card h3 {
    font-size: 14px;
    color: var(--gold-light);
    margin-bottom: 10px;
}

.guide-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    font-size: 12px;
    color: var(--text-muted);
    line-height: 1.5;
}

.guide-list code {
    background: rgba(212, 175, 55, 0.15);
    color: var(--gold-light);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* Responsive Media Queries */
@media (max-width: 640px) {
    body {
        padding: 8px;
    }

    .game-header {
        padding: 10px 14px;
    }

    .game-title {
        font-size: 18px;
    }

    .stat-value {
        font-size: 20px;
    }

    .mobile-controls {
        display: flex;
    }

    .ability-panel .btn-ability {
        display: none; /* Mobile uses dedicated mobile-chrono-btn */
    }
}
