:root {
    --panel: #0b1017;
    --grid: #0f1824;
    --text: #e6f2ff;
    --ship: #22d3ee;
    --flame: #f59e0b;
    --bullet: #f43f5e;
    --rock-light: #84cc16;
    --rock-med: #15803d;
    --rock-blue: #3b82f6;
    --rock-purple: #a855f7;
    --rock-red: #ef4444;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    background: var(--panel);
    overflow: hidden;
    touch-action: none;
    font-family: system-ui, -apple-system, sans-serif;
}

#game-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game {
    display: block;
    background: var(--panel);
}

#hud {
    position: fixed;
    top: 10px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 10;
}

#hud.hidden {
    display: none;
}

.hud-item.clickable {
    cursor: pointer;
    pointer-events: auto;
}

#player-info .label {
    font-size: 10px;
    opacity: 0.6;
    letter-spacing: 1px;
}

#player-name-display {
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

#player-name-display::after {
    content: '⏸';
    font-size: 16px;
    opacity: 0.6;
}

#player-info.paused #player-name-display::after {
    content: '▶';
}

#player-name-input {
    background: transparent;
    border: none;
    border-bottom: 2px solid var(--ship);
    color: var(--text);
    font-size: 24px;
    font-weight: 700;
    text-align: center;
    width: 200px;
    padding: 10px;
    margin-bottom: 20px;
    outline: none;
}

.menu-btn {
    margin-top: 16px;
    background: transparent;
    border: 2px solid var(--ship);
    color: var(--text);
    font-size: 16px;
    padding: 14px 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 2px;
    width: 100%;
    max-width: 240px;
    box-sizing: border-box;
}

.menu-btn:hover {
    background: var(--ship);
    color: var(--panel);
    transform: scale(1.05);
}

.menu-btn:active {
    transform: scale(0.95);
}

#start-screen > .menu-btn {
    max-width: 240px;
}

#customize-design-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 20px;
    max-width: 320px;
    width: 100%;
}

.customize-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 8px;
}

.customize-design-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.05);
    aspect-ratio: 1;
}

.customize-design-item:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.customize-design-item.selected {
    border-color: var(--ship);
    background: rgba(34, 211, 238, 0.1);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.3);
}

.customize-design-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.customize-design-preview svg {
    width: 100%;
    height: 100%;
}

.customize-section-separator {
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: #22d3ee;
    opacity: 0.6;
    padding: 16px 0 8px;
    border-bottom: 1px solid rgba(34, 211, 238, 0.2);
    margin-bottom: 8px;
}

.customize-bullet-item {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    border-radius: 12px;
    border: 2px solid rgba(255, 255, 255, 0.15);
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.05);
    aspect-ratio: 1;
}

.customize-bullet-item:hover {
    border-color: rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.1);
}

.customize-bullet-item.selected {
    border-color: #22d3ee;
    background: rgba(34, 211, 238, 0.1);
    box-shadow: 0 0 16px rgba(34, 211, 238, 0.3);
}

.customize-bullet-preview {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.customize-bullet-preview svg {
    width: 100%;
    height: 100%;
}

#customize-back-btn {
    background: transparent;
    border: 2px solid var(--ship);
    color: var(--text);
    font-size: 16px;
    padding: 14px 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 60px;
}

#customize-back-btn:hover {
    background: var(--ship);
    color: var(--panel);
    transform: scale(1.05);
}

#customize-back-btn:active {
    transform: scale(0.95);
}

#player-name-input:focus {
    border-bottom-color: var(--flame);
}

.hud-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    color: var(--text);
}

.hud-item .label {
    font-size: 10px;
    opacity: 0.6;
    letter-spacing: 1px;
}

.hud-item #score,
.hud-item #high {
    font-size: 24px;
    font-weight: 700;
}

#powerup-indicator {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 16px;
    pointer-events: none;
    z-index: 10;
}

.powerup-icon {
    width: 52px;
    height: 52px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    position: relative;
    border: 2px solid transparent;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.powerup-icon-inner {
    position: relative;
    z-index: 1;
}

.powerup-ring {
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 18px;
    animation: ring-pulse 2s ease-in-out infinite;
}

@keyframes ring-pulse {
    0%, 100% { opacity: 0.6; transform: scale(1); }
    50% { opacity: 0.3; transform: scale(1.05); }
}

@keyframes powerup-activate {
    0% { transform: scale(0.3); opacity: 0; }
    50% { transform: scale(1.15); }
    100% { transform: scale(1); opacity: 1; }
}

.powerup-icon.active {
    animation: powerup-activate 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.powerup-icon.expiring {
    animation: pulse-urgent 0.4s ease-in-out infinite;
}

@keyframes pulse-urgent {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.5; transform: scale(0.95); }
}

#start-screen,
#game-over-screen,
#pause-screen,
#instructions-screen,
#customize-screen,
#leaderboard-screen {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    background: rgba(11, 16, 23, 0.95);
    color: var(--text);
    z-index: 100;
    cursor: pointer;
    padding: 20px;
    min-width: 0;
}

#start-screen,
#instructions-screen,
#customize-screen,
#leaderboard-screen {
    background: transparent;
}

#start-screen > *,
#game-over-screen > *,
#pause-screen > * {
    max-width: 100%;
    min-width: 0;
    flex-shrink: 1;
}

#instructions-screen,
#customize-screen,
#leaderboard-screen {
    cursor: default;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    justify-content: flex-start;
    padding-top: 80px;
    box-sizing: border-box;
}

#leaderboard-screen {
    justify-content: center;
    padding-top: 20px;
    gap: 24px;
}

#start-screen h1,
#game-over-screen h1,
#pause-screen h1 {
    font-size: clamp(36px, 10vw, 64px);
    letter-spacing: clamp(2px, 1vw, 8px);
    margin-bottom: 20px;
    text-shadow: 0 0 30px var(--ship);
    word-wrap: break-word;
    max-width: 100%;
}

#start-screen p,
#game-over-screen p,
#pause-screen p {
    font-size: clamp(14px, 4vw, 18px);
    opacity: 0.8;
}

#instructions-screen {
    cursor: default;
}

#start-screen h1,
#start-screen p {
    cursor: pointer;
}

#instructions-screen h1,
#customize-screen h1,
#leaderboard-screen h1 {
    font-size: clamp(24px, 7vw, 36px);
    letter-spacing: clamp(2px, 0.5vw, 4px);
    margin-bottom: 0;
    margin-top: 0;
    text-shadow: 0 0 30px var(--ship);
    flex-shrink: 0;
}

.instructions-controls {
    text-align: center;
    margin-bottom: 50px;
    padding: 0 20px;
}

.instructions-controls p {
    font-size: 20px;
    opacity: 0.85;
    margin: 12px 0;
    font-weight: 500;
}

.instructions-powerups {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 15px;
    margin-bottom: 50px;
    padding: 0 20px;
    max-width: 600px;
    width: 100%;
}

.powerup-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.powerup-icon-only {
    width: 56px;
    height: 56px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.powerup-label {
    font-size: 11px;
    opacity: 0.9;
    text-align: center;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

#instructions-back-btn {
    background: transparent;
    border: 2px solid var(--ship);
    color: var(--text);
    font-size: 18px;
    padding: 12px 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

#instructions-back-btn:hover {
    background: var(--ship);
    color: var(--panel);
    transform: scale(1.05);
}

#instructions-back-btn:active {
    transform: scale(0.95);
}

#leaderboard-back-btn {
    background: transparent;
    border: 2px solid var(--ship);
    color: var(--text);
    font-size: 18px;
    padding: 12px 40px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    margin-top: 0;
    margin-bottom: 0;
}

#leaderboard-back-btn:hover {
    background: var(--ship);
    color: var(--panel);
    transform: scale(1.05);
}

#leaderboard-back-btn:active {
    transform: scale(0.95);
}

#game-over-screen h1 {
    color: var(--bullet);
    text-shadow: 0 0 30px var(--bullet);
    text-align: center;
    width: 100%;
}

#pause-screen h1 {
    color: var(--flame);
    text-shadow: 0 0 30px var(--flame);
}

#final-score {
    font-size: 24px;
    margin-bottom: 30px;
}

.hidden {
    display: none !important;
}

.menu-btn {
    margin-top: 16px;
    background: transparent;
    border: 2px solid var(--ship);
    color: var(--text);
    font-size: 16px;
    padding: 14px 36px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    text-transform: uppercase;
    letter-spacing: 2px;
    width: 100%;
    max-width: 240px;
    box-sizing: border-box;
}

#design-list {
    display: none;
    flex-direction: column;
    gap: 8px;
    margin-top: 16px;
    padding: 16px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    min-width: 180px;
}

#design-list.open {
    display: flex;
}

.design-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.03);
}

.design-option:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.2);
}

.design-option.selected {
    border-color: var(--ship);
    background: rgba(34, 211, 238, 0.1);
}

.design-option .design-color {
    width: 20px;
    height: 20px;
    border-radius: 4px;
    flex-shrink: 0;
}

.design-option .design-name {
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.lb-tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 0;
}

.lb-tab {
    background: transparent;
    border: 2px solid rgba(255, 255, 255, 0.2);
    color: var(--text);
    padding: 8px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    transition: all 0.2s;
}

.lb-tab.active {
    border-color: var(--ship);
    background: rgba(34, 211, 238, 0.15);
    color: var(--ship);
}

.lb-tab-content {
    width: 100%;
    max-width: 360px;
    max-height: 50vh;
    flex-grow: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.lb-list {
    width: 100%;
}

.lb-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    border-radius: 6px;
    margin-bottom: 4px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.06);
}

.lb-row.current {
    border-color: var(--flame);
    background: rgba(245, 158, 11, 0.12);
}

.lb-row .lb-rank {
    width: 28px;
    text-align: center;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.5);
    flex-shrink: 0;
}

.lb-row .lb-ship {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lb-row .lb-ship svg {
    width: 100%;
    height: 100%;
}

.lb-row .lb-name {
    flex: 1;
    text-align: left;
    margin-left: 8px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.lb-row .lb-score {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    margin-left: 12px;
    flex-shrink: 0;
}

.lb-empty {
    text-align: center;
    padding: 24px;
    opacity: 0.5;
    font-size: 14px;
}

.lb-loading {
    text-align: center;
    padding: 24px;
    opacity: 0.6;
    font-size: 14px;
}

#gameover-leaderboard {
    width: 100%;
    max-width: 320px;
    margin: 12px 0;
    max-height: 35vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#gameover-leaderboard h3 {
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin: 12px 0 8px;
    opacity: 0.7;
    color: var(--ship);
}

#gameover-leaderboard .lb-row {
    padding: 6px 10px;
    font-size: 13px;
}