:root {
    --bg-color: #050505;
    --neon-blue: #00f3ff;
    --neon-pink: #ff00ba;
    --neon-green: #39ff14;
    --neon-red: #ff073a;
    --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

body {
    background-color: var(--bg-color);
    color: white;
    font-family: var(--font-main);
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    touch-action: none;
    /* スマホでのスクロールを無効化 */
}

#game-container {
    position: relative;
    width: 100%;
    max-width: 600px;
    height: 100%;
    max-height: 800px;
    background: #000;
    box-shadow: 0 0 20px rgba(0, 243, 255, 0.1);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* HUD */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 15px;
    z-index: 10;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0.8), transparent);
    font-weight: bold;
    letter-spacing: 1px;
}

.hud-item {
    text-shadow: 0 0 5px var(--neon-blue);
}

.time-alert {
    color: var(--neon-pink);
    text-shadow: 0 0 5px var(--neon-pink);
}

/* Screens */
.screen {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background: rgba(5, 5, 5, 0.85);
    backdrop-filter: blur(4px);
    z-index: 20;
    padding: 20px;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Typography & Buttons */
.neon-text {
    font-size: 3rem;
    color: #fff;
    text-shadow:
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--neon-pink),
        0 0 40px var(--neon-pink),
        0 0 80px var(--neon-pink);
    margin-bottom: 20px;
}

.neon-text.error {
    text-shadow:
        0 0 5px #fff,
        0 0 10px #fff,
        0 0 20px var(--neon-red),
        0 0 40px var(--neon-red),
        0 0 80px var(--neon-red);
}

p {
    margin-bottom: 10px;
    color: #ccc;
}

.instruction {
    font-size: 0.9rem;
    color: var(--neon-blue);
    margin-bottom: 30px;
}

.highlight {
    color: var(--neon-green);
    font-weight: bold;
    font-size: 1.2rem;
    text-shadow: 0 0 10px var(--neon-green);
    margin: 15px 0;
    animation: pulse 1s infinite alternate;
}

.neon-button {
    background: transparent;
    color: var(--neon-blue);
    font-size: 1.2rem;
    font-weight: bold;
    padding: 15px 40px;
    border: 2px solid var(--neon-blue);
    border-radius: 5px;
    cursor: pointer;
    box-shadow: 0 0 10px var(--neon-blue) inset, 0 0 10px var(--neon-blue);
    transition: all 0.2s;
    margin-top: 20px;
}

/* Ranking Board UI */
#ranking-board {
    margin: 20px auto;
    padding: 15px;
    background: rgba(0, 0, 0, 0.6);
    border: 2px solid var(--neon-cyan);
    border-radius: 10px;
    box-shadow: 0 0 10px var(--neon-cyan) inset, 0 0 15px var(--neon-cyan);
    width: 80%;
    max-width: 400px;
}

.ranking-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    border-bottom: 2px solid rgba(0, 243, 255, 0.5);
    padding-bottom: 10px;
}

.ranking-title {
    font-size: 1.2rem;
    color: var(--neon-cyan);
    text-shadow: 0 0 5px var(--neon-cyan);
    margin: 0;
}

.ranking-tabs {
    display: flex;
    gap: 10px;
}

.ranking-tab {
    background: transparent;
    color: #888;
    border: 1px solid #888;
    padding: 5px 10px;
    border-radius: 3px;
    font-size: 0.8rem;
    font-weight: bold;
    cursor: pointer;
    transition: 0.3s;
}

.ranking-tab.active {
    color: var(--neon-cyan);
    border-color: var(--neon-cyan);
    box-shadow: 0 0 5px var(--neon-cyan) inset;
    text-shadow: 0 0 5px var(--neon-cyan);
}

#ranking-list li {
    display: flex;
    justify-content: space-between;
    margin-bottom: 5px;
    font-family: 'Courier New', Courier, monospace;
    font-size: 1.2rem;
    color: #fff;
    border-bottom: 1px solid rgba(0, 243, 255, 0.3);
    padding-bottom: 3px;
    list-style: none;
}

#ranking-list li.no-records {
    justify-content: center;
    border-bottom: none;
    color: #aaa;
    font-style: italic;
}

.neon-button:hover {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 20px var(--neon-blue) inset, 0 0 20px var(--neon-blue);
}

@keyframes pulse {
    0% {
        opacity: 0.8;
        transform: scale(1);
    }

    100% {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* ダメージフラッシュ演出 */
#game-container.damage-flash {
    animation: flashRed 0.2s;
}

@keyframes flashRed {
    0% {
        box-shadow: inset 0 0 100px rgba(255, 7, 58, 0.8), 0 0 20px rgba(255, 7, 58, 0.4);
    }

    100% {
        box-shadow: 0 0 20px rgba(0, 243, 255, 0.1);
    }
}

/* Back to Portal Button */
.back-to-portal {
    position: absolute;
    top: 15px;
    left: 15px;
    color: var(--neon-blue);
    font-size: 0.9rem;
    text-decoration: none;
    font-weight: bold;
    letter-spacing: 1px;
    border: 1px solid var(--neon-blue);
    padding: 8px 15px;
    border-radius: 5px;
    z-index: 1000;
    transition: 0.3s;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    text-shadow: 0 0 5px var(--neon-blue);
    box-shadow: 0 0 5px rgba(0, 243, 255, 0.2);
}

.back-to-portal:hover {
    background: var(--neon-blue);
    color: #000;
    box-shadow: 0 0 15px var(--neon-blue);
    text-shadow: none;
}

/* Ofuse Button Hover Effect */
.ofuse-button:hover {
    background: linear-gradient(135deg, #ff79b0, #ff4081) !important;
    box-shadow: 0 0 20px rgba(255, 64, 129, 0.8) !important;
    color: white !important;
    transform: scale(1.05);
}

/* Ofuse Floating Button */
.ofuse-floating-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: linear-gradient(135deg, #ff4081, #ff79b0);
    color: white;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 50px;
    font-weight: bold;
    font-size: 0.85rem;
    box-shadow: 0 4px 15px rgba(255, 64, 129, 0.4);
    display: flex;
    align-items: center;
    gap: 8px;
    z-index: 9999;
    transition: all 0.3s ease;
    font-family: 'Noto Sans JP', sans-serif;
}

.ofuse-floating-btn:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 25px rgba(255, 64, 129, 0.6);
    color: white;
}

.ofuse-icon {
    font-size: 1.2rem;
}

/* --- Mobile Responsive Rules --- */
@media (max-width: 600px) {
    #hud {
        padding-top: 50px;
        /* back-to-portalボタンとの被り防止 */
        padding-left: 10px;
        padding-right: 10px;
        flex-wrap: wrap;
    }

    .hud-item {
        font-size: 1.1rem;
        /* スマホで見やすく拡大 */
        margin-bottom: 5px;
    }

    .hud-item span:first-child {
        font-size: 0.6rem;
        /* ラベル部分は少し小さめ */
    }

    .hud-value {
        font-size: 1.2rem;
        /* 数値部分は大きく */
    }

    .time-alert {
        font-size: 1.3rem;
        /* タイマーはさらに目立たせる */
    }

    .neon-text {
        font-size: 2rem;
        /* タイトルのサイズダウン */
    }

    #memory-timer {
        font-size: 3rem !important;
    }

    .back-to-portal {
        top: 10px;
        left: 10px;
        font-size: 0.75rem;
        padding: 6px 10px;
    }
}