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

html, body, #root {
    width: 100%;
    height: 100%;
    height: 100dvh;
    overflow: hidden;
    background-color: #030712;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    color: #f8fafc;
}

#app {
    position: relative;
    width: 100%;
    height: 100%;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background-color: #020617;
}

#game-stage {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container canvas {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
}

/* HUD Overlay */
.hud-overlay {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 10;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 12px 14px;
    max-width: 580px;
    margin: 0 auto;
}

/* Top Bar */
.hud-topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 8px;
}

.hud-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(56, 189, 248, 0.3);
    border-radius: 10px;
    padding: 6px 10px;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hud-card.left {
    min-width: 90px;
}

.hud-label {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #94a3b8;
}

.lives-row {
    display: flex;
    gap: 4px;
    font-size: 14px;
}

.shield-icon.active {
    opacity: 1;
    filter: drop-shadow(0 0 4px #38bdf8);
}

.shield-icon.depleted {
    opacity: 0.2;
    filter: grayscale(1);
}

.hud-center-card {
    background: rgba(15, 23, 42, 0.9);
    border: 1px solid rgba(245, 158, 11, 0.4);
    border-radius: 10px;
    padding: 6px 12px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    backdrop-filter: blur(8px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    flex: 1;
    max-width: 220px;
}

.level-badge {
    font-size: 11px;
    font-weight: 800;
    color: #f59e0b;
    letter-spacing: 0.12em;
}

.level-name {
    font-size: 11px;
    font-weight: 600;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 190px;
}

.hud-card.right {
    min-width: 100px;
    align-items: flex-end;
}

.sub-stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.hud-value {
    font-size: 13px;
    font-weight: 700;
    color: #ef4444;
}

.score-value {
    font-size: 14px;
    font-weight: 800;
    color: #38bdf8;
    text-shadow: 0 0 6px rgba(56, 189, 248, 0.5);
}

/* Sub-bar: Weapon status & interactive controls */
.hud-subbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    margin-top: 8px;
    pointer-events: auto;
}

.weapon-status-card {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(168, 85, 247, 0.35);
    border-radius: 8px;
    padding: 5px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 140px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.weapon-header {
    display: flex;
    align-items: center;
    gap: 6px;
}

.weapon-icon {
    font-size: 14px;
}

.weapon-title {
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.05em;
    color: #e2e8f0;
}

.weapon-bar-bg {
    width: 100%;
    height: 4px;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 2px;
    overflow: hidden;
}

.weapon-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #38bdf8, #a855f7);
    transition: width 0.1s linear;
}

.hud-btn-group {
    display: flex;
    gap: 8px;
}

.hud-icon-btn {
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(255, 255, 255, 0.25);
    color: #f8fafc;
    width: 38px;
    height: 38px;
    border-radius: 10px;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 3px 8px rgba(0, 0, 0, 0.35);
    transition: transform 0.1s ease, border-color 0.15s ease;
}

.hud-icon-btn:hover {
    border-color: #38bdf8;
    transform: translateY(-1px);
}

.hud-icon-btn:active {
    transform: translateY(1px);
}

/* Modals & Overlays */
.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(2, 6, 23, 0.88);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    padding: 16px;
}

.menu-backdrop {
    background: radial-gradient(circle at center, rgba(30, 27, 75, 0.95), rgba(2, 6, 23, 0.98));
}

.menu-card {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(56, 189, 248, 0.4);
    box-shadow: 0 0 32px rgba(56, 189, 248, 0.25);
    border-radius: 16px;
    padding: 24px 20px;
    max-width: 440px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.game-logo-badge {
    background: linear-gradient(90deg, #f59e0b, #ef4444);
    color: #ffffff;
    font-size: 12px;
    font-weight: 900;
    letter-spacing: 0.16em;
    padding: 4px 14px;
    border-radius: 20px;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}

.game-title {
    font-size: 38px;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: #ffffff;
    text-shadow: 0 0 16px rgba(56, 189, 248, 0.8), 0 0 32px rgba(56, 189, 248, 0.4);
    line-height: 1;
}

.game-subtitle {
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    color: #94a3b8;
}

.how-to-play-box {
    background: rgba(2, 6, 23, 0.7);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 14px;
    width: 100%;
    text-align: left;
}

.section-heading {
    font-size: 12px;
    font-weight: 800;
    color: #38bdf8;
    letter-spacing: 0.1em;
    margin-bottom: 10px;
    text-align: center;
}

.guide-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.guide-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.guide-icon {
    font-size: 18px;
    line-height: 1.2;
    flex-shrink: 0;
}

.guide-text {
    font-size: 12px;
    line-height: 1.45;
    color: #cbd5e1;
}

.guide-text strong {
    color: #f8fafc;
}

.action-btn {
    border: none;
    border-radius: 10px;
    padding: 12px 24px;
    font-size: 15px;
    font-weight: 800;
    letter-spacing: 0.06em;
    cursor: pointer;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    transition: transform 0.1s ease, filter 0.15s ease;
    width: 100%;
}

.action-btn:hover {
    filter: brightness(1.15);
    transform: translateY(-2px);
}

.action-btn:active {
    transform: translateY(1px);
}

.start-btn {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(56, 189, 248, 0.5);
}

.play-again-btn {
    background: linear-gradient(135deg, #22c55e, #15803d);
    color: #ffffff;
    box-shadow: 0 0 20px rgba(34, 197, 94, 0.5);
}

.result-card {
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid rgba(239, 68, 68, 0.4);
    border-radius: 16px;
    padding: 24px 20px;
    max-width: 380px;
    width: 100%;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    box-shadow: 0 0 32px rgba(239, 68, 68, 0.3);
}

.pause-card {
    border-color: rgba(56, 189, 248, 0.4);
    box-shadow: 0 0 32px rgba(56, 189, 248, 0.25);
}

.modal-title {
    font-size: 26px;
    font-weight: 900;
    color: #ffffff;
}

.modal-desc {
    font-size: 14px;
    color: #cbd5e1;
}

.modal-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 8px;
}

.resume-btn {
    background: linear-gradient(135deg, #38bdf8, #2563eb);
    color: #ffffff;
}

.restart-btn {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.mute-btn {
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

.card-badge {
    background: rgba(239, 68, 68, 0.2);
    border: 1px solid #ef4444;
    color: #ef4444;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.12em;
    padding: 3px 10px;
    border-radius: 12px;
}

.game-over-title {
    font-size: 28px;
    font-weight: 900;
    color: #ffffff;
    text-shadow: 0 0 16px rgba(239, 68, 68, 0.6);
}

.card-subtitle {
    font-size: 12px;
    color: #94a3b8;
    line-height: 1.4;
}

.score-summary-grid {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
    width: 100%;
    background: rgba(2, 6, 23, 0.7);
    border-radius: 12px;
    padding: 12px 6px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.summary-stat {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.stat-label {
    font-size: 9px;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 0.05em;
}

.stat-val {
    font-size: 16px;
    font-weight: 800;
    color: #ffffff;
}

.stat-val.primary {
    color: #38bdf8;
}

.stat-val.highlight {
    color: #facc15;
}

.new-high-score-tag {
    background: linear-gradient(90deg, #f59e0b, #eab308);
    color: #000000;
    font-size: 11px;
    font-weight: 900;
    letter-spacing: 0.06em;
    padding: 6px 14px;
    border-radius: 16px;
    box-shadow: 0 0 14px rgba(245, 158, 11, 0.6);
}

/* Sector Cleared Banner */
.sector-clear-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    justify-content: center;
    align-items: center;
    pointer-events: none;
    z-index: 40;
}

.sector-clear-banner {
    background: rgba(15, 23, 42, 0.95);
    border: 2px solid #38bdf8;
    border-radius: 16px;
    padding: 20px 32px;
    text-align: center;
    box-shadow: 0 0 36px rgba(56, 189, 248, 0.5);
    animation: bannerPop 0.4s ease-out;
}

@keyframes bannerPop {
    0% { transform: scale(0.7); opacity: 0; }
    100% { transform: scale(1); opacity: 1; }
}

.clear-sparkle {
    font-size: 28px;
    display: block;
    margin-bottom: 4px;
}

.clear-title {
    font-size: 28px;
    font-weight: 900;
    letter-spacing: 0.08em;
    color: #38bdf8;
    text-shadow: 0 0 12px rgba(56, 189, 248, 0.8);
}

.clear-bonus {
    font-size: 14px;
    font-weight: 700;
    color: #facc15;
    margin-top: 4px;
}

.clear-sub {
    font-size: 12px;
    color: #94a3b8;
    margin-top: 2px;
}
