:root {
    --primary: #00f2ff;
    --secondary: #7000ff;
    --bg-dark: #050505;
    --text: #ffffff;
    --glass: rgba(255, 255, 255, 0.1);
    --glass-border: rgba(255, 255, 255, 0.2);
    --glow: 0 0 10px var(--primary), 0 0 20px var(--primary);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background: var(--bg-dark);
    color: var(--text);
    overflow: hidden;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100vh;
    max-width: 800px;
    background: #000;
    overflow: hidden;
    box-shadow: 0 0 50px rgba(0, 242, 255, 0.2);
    display: flex;
    flex-direction: column;
}

#game-canvas {
    flex-grow: 1;
    /* Take remaining space */
    width: 100%;
    height: 0;
    /* Important for flex container to calculate space properly */
    min-height: 0;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    /* Keeps aspect ratio within the box */
    display: block;
    margin: auto;
}

#ui-overlay {
    width: 100%;
    /* position: absolute; REMOVED */
    pointer-events: none;
    z-index: 10;
    padding: 10px;
    background: rgba(0, 0, 0, 0.8);
    border-bottom: 2px solid var(--primary);
}

#bottom-ui-bar {
    width: 100%;
    /* position: absolute; REMOVED */
    pointer-events: none;
    z-index: 10;
    padding: 10px;
    background: rgba(0, 0, 0, 0.8);
    border-top: 2px solid var(--primary);
    display: flex;
    justify-content: center;
}

.gauge-wrapper.full-width {
    width: 100%;
    max-width: 600px;
}

.glass-panel {
    background: var(--glass);
    backdrop-filter: blur(10px);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    pointer-events: auto;
    transition: all 0.3s ease;
}

#top-bar {
    display: flex;
    justify-content: space-between;
    font-weight: 700;
    letter-spacing: 1px;
    padding: 10px;
}

#gauges-container {
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    margin-top: 5px;
}

.stat span {
    color: var(--primary);
    text-shadow: 0 0 5px var(--primary);
}

.gauge-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--glass);
    backdrop-filter: blur(5px);
    padding: 4px 12px;
    border-radius: 20px;
    border: 1px solid var(--glass-border);
}

.gauge-label {
    font-size: 0.75rem;
    font-weight: 700;
    width: 60px;
    letter-spacing: 1px;
}

.gauge-outer {
    flex-grow: 1;
    height: 10px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 5px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.1);
    position: relative;
    /* For absolute stacking */
}

.gauge-inner {
    height: 100%;
    width: 100%;
    transition: width 0.3s ease;
    border-radius: 5px;
    position: absolute;
    /* Stack on top of each other */
    top: 0;
    left: 0;
}

.life-color {
    background: linear-gradient(90deg, #ff0055, #ff4c8b);
    box-shadow: 0 0 10px rgba(255, 0, 85, 0.5);
    z-index: 2;
}

.max-life-color {
    background: rgba(0, 100, 0, 0.5);
    box-shadow: none;
    z-index: 1;
}

.energy-color {
    background: linear-gradient(90deg, #00f2ff, #0077ff);
    box-shadow: 0 0 10px rgba(0, 242, 255, 0.5);
}

#sidebar {
    width: 250px;
    padding: 20px;
    background: rgba(0, 0, 0, 0.8);
    border-left: 2px solid var(--primary);
    display: flex;
    flex-direction: column;
    height: 100vh;
    justify-content: center;
}

#upgrades-vertical {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gauge-section-title {
    color: var(--primary);
    font-weight: bold;
    font-size: 1.2rem;
    margin-bottom: 10px;
    text-align: center;
    letter-spacing: 2px;
    text-shadow: var(--glow);
}

/* Compact wrapper override for sidebar */
.gauge-wrapper.compact {
    padding: 8px 12px;
    gap: 10px;
    background: rgba(255, 255, 255, 0.05);
}

.gauge-wrapper.compact .gauge-label {
    width: 70px;
    /* Slightly wider for sidebar */
    font-size: 0.8rem;
}

.speed-color {
    background: linear-gradient(90deg, #00e5ff, #0099ff);
    box-shadow: 0 0 8px rgba(0, 229, 255, 0.4);
}

.shot-color {
    background: linear-gradient(90deg, #ff9100, #ff5e00);
    box-shadow: 0 0 8px rgba(255, 145, 0, 0.4);
}

.power-color {
    background: linear-gradient(90deg, #ff00cc, #ff0066);
    box-shadow: 0 0 8px rgba(255, 0, 204, 0.4);
}

.wide-color {
    background: linear-gradient(90deg, #aa00ff, #6200ea);
    box-shadow: 0 0 8px rgba(170, 0, 255, 0.4);
}

.missile-color {
    background: linear-gradient(90deg, #00ff66, #00cc44);
    box-shadow: 0 0 8px rgba(0, 255, 102, 0.4);
}

.block-color {
    background: linear-gradient(90deg, #ffd500, #ffaa00);
    box-shadow: 0 0 8px rgba(255, 213, 0, 0.4);
}

#start-screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    /* Full screen */
    transform: none;
    /* Remove centering transform */
    padding: 20px;
    /* Reduced padding */
    display: none;
    flex-direction: row;
    /* Horizontal layout */
    justify-content: center;
    /* Center content */
    align-items: center;
    gap: 40px;
    /* Reduced gap */
    /* Space between panels */
    background-image: url('image/tobira.jpg');
    background-size: cover;
    background-position: center;
}

#start-screen.active {
    display: flex;
}

#game-over-screen {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    padding: 40px;
    text-align: center;
    display: none;
    flex-direction: column;
    gap: 20px;
}

#game-over-screen.active {
    display: flex;
}


.start-left-panel {
    padding: 20px;
    text-align: left;
    min-width: 300px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
}

.start-left-panel h2 {
    color: var(--primary);
    margin-bottom: 10px;
    border-bottom: 1px solid var(--glass-border);
    padding-bottom: 5px;
    letter-spacing: 2px;
    font-size: 1.2rem;
}

.start-left-panel ul {
    list-style: none;
    margin-bottom: 15px;
    /* Add spacing before Item header */
}

.start-left-panel li {
    margin-bottom: 8px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.start-left-panel .key {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid var(--primary);
    padding: 2px 8px;
    /* Compact padding */
    border-radius: 4px;
    font-weight: bold;
    color: var(--primary);
    min-width: 50px;
    /* Compact width */
    text-align: center;
    font-size: 0.8rem;
}

.start-left-panel .note {
    font-size: 0.7rem;
    opacity: 0.7;
    margin-left: auto;
}

.item-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px 15px;
    /* Tighter gap */
}

.item-row {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.8rem;
}

.item-icon {
    width: 20px;
    height: 20px;
    border: 1px solid #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 12px;
    color: #000;
    flex-shrink: 0;
}

.item-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    flex-shrink: 0;
}

#visitor-counts {
    margin-top: 30px;
    font-size: 0.9rem;
    color: var(--primary);
    opacity: 0.8;
    text-align: center;
    background: rgba(0, 0, 0, 0.5);
    padding: 10px 20px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
}

#visitor-counts span {
    font-weight: bold;
    color: #fff;
}

.item-speed {
    background: #00e5ff;
}

.item-shot {
    background: #ff9100;
}

.item-way {
    background: #00bfff;
}

.item-power {
    background: #ff00cc;
}

.item-wide {
    background: #aa00ff;
}

.item-missile {
    background: #00ff66;
}

.item-eco {
    background: #76ff03;
}

.item-block {
    background: #8B4513;
    color: #fff;
}

.start-right-panel {
    text-align: center;
    display: flex;
    flex-direction: column;
    gap: 30px;
    align-items: center;
}

h1 {
    font-size: 3rem;
    color: #fff;
    text-shadow:
        0 0 10px var(--primary),
        0 0 20px var(--primary),
        0 0 40px var(--primary),
        0 0 80px var(--primary);
    background: none;
    -webkit-text-fill-color: initial;
    /* Removed background-clip gradient for better visibility against image */
}

.controls-hint {
    font-size: 0.9rem;
    opacity: 0.7;
}

.glow-btn {
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    border: 2px solid var(--primary);
    color: var(--primary);
    padding: 12px 30px;
    font-size: 1.1rem;
    font-weight: 700;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s;
    text-transform: uppercase;
}

.glow-btn:hover {
    background: var(--primary);
    color: #000;
    box-shadow: var(--glow);
}

#mobile-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    pointer-events: none;
    z-index: 20;
}

@media (min-width: 768px) {
    #mobile-controls {
        display: none;
    }
}

.joy-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: #fff;
    font-size: 1.5rem;
    pointer-events: auto;
    backdrop-filter: blur(5px);
}

#fire-btn {
    width: 80px;
    height: 80px;
    background: rgba(255, 0, 0, 0.2);
    border-color: rgba(255, 0, 0, 0.5);
    border-color: rgba(255, 0, 0, 0.5);
    color: #ff4d4d;
}

#ranking-container {
    margin-top: 20px;
    flex-grow: 1;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 10px;
    position: relative;
    display: flex;
    flex-direction: column;
}

#ranking-list {
    list-style: none;
    padding: 0;
    margin: 0;
    position: relative;
    /* top controlled by JS */
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    padding: 2px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#ranking-list li .startRank {
    width: 30px;
    text-align: right;
    margin-right: 10px;
    color: var(--primary);
}

#ranking-list li .name {
    flex-grow: 1;
    text-align: left;
}

#ranking-list li .score {
    text-align: right;
    font-weight: bold;
}

@keyframes blink-anim {
    0% {
        color: #ffff00;
        text-shadow: 0 0 5px #ffff00;
    }

    50% {
        color: #ff0000;
        text-shadow: 0 0 5px #ff0000;
    }

    100% {
        color: #ffff00;
        text-shadow: 0 0 5px #ffff00;
    }
}

.blink {
    animation: blink-anim 1s infinite;
}

#start-ranking-list li {
    display: flex;
    justify-content: space-between;
    font-size: 0.85rem;
    padding: 3px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

#start-ranking-list li:last-child {
    border-bottom: none;
}

#start-ranking-list li .startRank {
    width: 25px;
    text-align: right;
    margin-right: 8px;
    color: var(--primary);
    font-weight: bold;
}

#start-ranking-list li .name {
    flex-grow: 1;
    text-align: left;
    color: #ddd;
}

#start-ranking-list li .score {
    text-align: right;
    font-weight: bold;
    color: #fff;
    font-family: monospace;
    /* For alignment */
}

.saber-color {
    background: #e100ff;
}

.item-saber {
    background: #e100ff;
}