:root {
    --bg: #0f172a;
    --bg-panel: #1e293b;
    --border: #334155;
    --text: #f8fafc;
    --text-dim: #94a3b8;
    --accent: #ef4444;
    --accent-2: #10b981;
    --accent-blue: #38bdf8;
    --accent-purple: #a855f7;
    --accent-gold: #f59e0b;
    --kbd-bg: #1e2433;
}

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 16px 12px 48px;
    background: var(--bg);
    background-image: radial-gradient(circle at 50% 10%, #1e293b 0, var(--bg) 80%);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
}

.page {
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
}

/* Top Navigation Bar ------------------------------------------------------ */
.top-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 14px;
    margin-bottom: 14px;
    background: rgba(30, 41, 59, 0.7);
    border: 1px solid var(--border);
    border-radius: 9999px;
    backdrop-filter: blur(10px);
}

.back-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--accent-blue);
    font-size: 13px;
    font-weight: 600;
    text-decoration: none;
    padding: 5px 12px;
    background: rgba(56, 189, 248, 0.1);
    border: 1px solid rgba(56, 189, 248, 0.25);
    border-radius: 9999px;
    transition: all 0.2s;
}

.back-btn:hover {
    background: #0284c7;
    color: #fff;
}

.nav-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.nav-btn {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--border);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    transition: all 0.2s;
}

.nav-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* Header ------------------------------------------------------------------ */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    margin-bottom: 12px;
}

.header-title-wrap {
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header h1 {
    margin: 0;
    font-size: 26px;
    line-height: 1.1;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.page-header strong {
    color: var(--accent);
}

.edition-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 2px 8px;
    background: linear-gradient(135deg, #f59e0b, #ef4444);
    color: #fff;
    border-radius: 9999px;
    margin-left: 6px;
    vertical-align: middle;
}

.html5 {
    flex: none;
    display: block;
    width: 44px;
    height: 44px;
    background: url('../img/html5.png') no-repeat center / contain;
}

.html5 span {
    display: none;
}

/* Game canvas ------------------------------------------------------------- */
#game {
    line-height: 0;
    position: relative;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 12px 35px rgba(0, 0, 0, 0.65), 0 0 20px rgba(56, 189, 248, 0.15);
    border: 2px solid var(--border);
    background: #000;
}

#canvas {
    display: block;
    width: 100%;
    height: auto;
    image-rendering: -webkit-optimize-contrast;
}

/* Live HUD Strip ---------------------------------------------------------- */
.hud-strip {
    margin-top: 10px;
    padding: 10px 14px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hud-campaign-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
    padding-bottom: 6px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-level {
    border-color: rgba(251, 191, 36, 0.45);
    background: rgba(251, 191, 36, 0.12);
}

.stat-theme {
    border-color: rgba(56, 189, 248, 0.4);
    background: rgba(56, 189, 248, 0.1);
}

.stat-score {
    border-color: rgba(250, 204, 21, 0.4);
    background: rgba(250, 204, 21, 0.1);
}

.hud-main-stats {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px;
}

.stat-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    font-weight: 700;
    background: rgba(0, 0, 0, 0.25);
    padding: 4px 10px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-item i {
    font-size: 13px;
}

.stat-item strong {
    font-size: 14px;
    color: #fff;
}

.badge-curse {
    display: none;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: rgba(220, 38, 38, 0.25);
    border: 1px solid #ef4444;
    color: #fca5a5;
    font-size: 11px;
    font-weight: 800;
    border-radius: 9999px;
    animation: cursePulse 1s infinite alternate;
}

@keyframes cursePulse {
    from { transform: scale(1); filter: drop-shadow(0 0 4px #ef4444); }
    to { transform: scale(1.05); filter: drop-shadow(0 0 10px #ef4444); }
}

.hud-abilities {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    padding-top: 6px;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.badge-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #64748b;
    transition: all 0.2s;
    user-select: none;
}

.badge-item.active {
    background: rgba(56, 189, 248, 0.18);
    border-color: #38bdf8;
    color: #fff;
    box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
    font-weight: 700;
}

/* Mobile Virtual Gamepad -------------------------------------------------- */
.virtual-gamepad {
    display: none;
    margin-top: 12px;
    padding: 6px 4px;
    justify-content: space-between;
    align-items: center;
    user-select: none;
    -webkit-user-select: none;
    touch-action: none;
}

.dpad {
    display: grid;
    grid-template-columns: repeat(3, 44px);
    grid-template-rows: repeat(3, 44px);
    gap: 4px;
}

.dpad-btn {
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
}

.dpad-btn:active, .dpad-btn.pressed {
    background: #38bdf8;
    color: #000;
}

.btn-dpad-up { grid-column: 2; grid-row: 1; }
.btn-dpad-left { grid-column: 1; grid-row: 2; }
.btn-dpad-down { grid-column: 2; grid-row: 3; }
.btn-dpad-right { grid-column: 3; grid-row: 2; }

.action-cluster {
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
}

.action-row {
    display: flex;
    gap: 8px;
}

.act-btn {
    border-radius: 50%;
    width: 52px;
    height: 52px;
    border: 2px solid rgba(255, 255, 255, 0.25);
    color: #fff;
    font-size: 11px;
    font-weight: 800;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    transition: transform 0.08s;
}

.act-btn i {
    font-size: 16px;
    margin-bottom: 2px;
}

.act-btn:active, .act-btn.pressed {
    transform: scale(0.92);
}

.btn-act-bomb {
    background: #ef4444;
    border-color: #fca5a5;
    width: 58px;
    height: 58px;
}

.btn-act-detonate {
    background: #8b5cf6;
    border-color: #d8b4fe;
}

.btn-act-throw {
    background: #ec4899;
    border-color: #fbcfe8;
}

@media (max-width: 820px), (pointer: coarse) {
    .virtual-gamepad {
        display: flex;
    }
}

/* Panels ------------------------------------------------------------------ */
.panel {
    margin-top: 14px;
    padding: 16px 18px;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: 8px;
}

.panel h2 {
    margin: 0 0 12px;
    font-size: 13px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--accent-blue);
    display: flex;
    align-items: center;
    gap: 8px;
}

.controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.control-group h3 {
    margin: 0 0 8px;
    font-size: 13px;
    font-weight: 700;
}

.control-group:first-child h3 {
    color: var(--accent-blue);
}

.control-group:last-child h3 {
    color: var(--accent-2);
}

.control-group ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

.control-group li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    color: var(--text-dim);
    font-size: 12px;
}

.keys {
    flex: none;
    display: inline-flex;
    gap: 3px;
}

kbd {
    display: inline-block;
    min-width: 22px;
    padding: 2px 6px;
    background: var(--kbd-bg);
    border: 1px solid var(--border);
    border-bottom-width: 2px;
    border-radius: 4px;
    color: var(--text);
    font: 700 11px/1.4 monospace;
    text-align: center;
}

.shortcuts {
    display: flex;
    flex-wrap: wrap;
    gap: 6px 16px;
    margin: 14px 0 0;
    padding: 12px 0 0;
    border-top: 1px solid var(--border);
    list-style: none;
    color: var(--text-dim);
    font-size: 12px;
}

.shortcuts li {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Power-Ups Guide Grid ---------------------------------------------------- */
.powerups-guide {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-top: 10px;
}

.guide-category {
    background: rgba(15, 23, 42, 0.6);
    border: 1px solid var(--border);
    border-radius: 6px;
    padding: 10px;
}

.guide-category h4 {
    margin: 0 0 8px;
    font-size: 12px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 6px;
}

.cat-offensive h4 { color: #f87171; }
.cat-utility h4 { color: #38bdf8; }
.cat-defensive h4 { color: #fbbf24; }
.cat-chaos h4 { color: #c084fc; }
.cat-hazards h4 { color: #34d399; }
.cat-hazards { grid-column: 1 / -1; }

.guide-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--text-dim);
}

.guide-item strong {
    color: #fff;
    display: block;
}

.guide-icon {
    flex: none;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    background: rgba(255, 255, 255, 0.08);
}

/* Footer ------------------------------------------------------------------ */
.footer {
    margin-top: 18px;
    color: var(--text-dim);
    font-size: 12px;
    text-align: center;
}

.footer a {
    color: var(--accent-blue);
    text-decoration: none;
}

.footer a:hover {
    text-decoration: underline;
}

@media (max-width: 520px) {
    .powerups-guide {
        grid-template-columns: 1fr;
    }
    .controls {
        grid-template-columns: 1fr;
    }
}
