:root {
    --bg-dark: #0a0a14;
    --bg-gradient: radial-gradient(circle at top, #1a1a2e 0%, #0a0a14 100%);

    --primary-color: #00f3ff;
    --secondary-color: #ff00ea;
    --success-color: #00ff66;
    --fire-color: #ff5500;

    --glass-bg: rgba(20, 20, 35, 0.4);
    --glass-border: rgba(255, 255, 255, 0.1);
    --glass-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);

    --font-heading: 'Orbitron', sans-serif;
    --font-body: 'Noto Sans JP', sans-serif;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

body,
html {
    width: 100%;
    height: 100%;
    background: var(--bg-dark);
    font-family: var(--font-body);
    overflow: hidden;
    color: #fff;
}

#game-container {
    position: relative;
    width: 100%;
    height: 100%;
    background: var(--bg-gradient);
    display: flex;
    flex-direction: column;
}

/* Canvas */
#gameCanvas {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    /* Cursor pointer for dragging */
    cursor: crosshair;
}

/* Glassmorphism Utilities */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
}

.glass-inset {
    background: rgba(0, 0, 0, 0.4);
    box-shadow: inset 0 4px 8px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Glow Typography */
.glow-text {
    font-family: var(--font-heading);
    letter-spacing: 2px;
}

.glow-text.primary {
    color: var(--primary-color);
    text-shadow: 0 0 10px var(--primary-color), 0 0 20px var(--primary-color), 0 0 40px var(--primary-color);
}

.glow-text.secondary-text {
    color: var(--secondary-color);
    text-shadow: 0 0 10px rgba(255, 0, 234, 0.7);
}

.glow-text.success {
    color: var(--success-color);
    text-shadow: 0 0 15px var(--success-color), 0 0 30px var(--success-color);
}

.glow-text.fire {
    color: #fff;
    text-shadow: 0 0 5px #fff, 0 0 10px #ffea00, 0 0 20px #ff8800, 0 0 40px var(--fire-color);
    animation: flicker 1.5s infinite alternate;
}

.timer-text {
    font-family: var(--font-heading);
    font-variant-numeric: tabular-nums;
}

/* HUD Header */
.hud {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    padding: 20px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    z-index: 10;
    pointer-events: none;
    transition: opacity 0.3s;
}

.hud.hidden {
    opacity: 0;
    pointer-events: none;
}

.hud-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 20px;
    border-radius: 12px;
}

.hud-panel .label {
    font-size: 0.7rem;
    color: #a0a0b0;
    margin-bottom: 4px;
    letter-spacing: 1px;
    font-weight: 700;
}

.hud-panel .value {
    font-size: 1.5rem;
    font-weight: 900;
}

.timer-panel {
    min-width: 140px;
}

.score-panel {
    min-width: 100px;
}

.combo-container {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 2rem;
    font-weight: 900;
    z-index: 15;
    transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-container.hidden {
    display: none;
}

/* Overlays (Start / Result) */
.overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 50;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(5px);
    transition: opacity 0.4s ease, visibility 0.4s;
}

.overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.modal {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 40px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
    width: 400px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal::-webkit-scrollbar {
    width: 6px;
}

.modal::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.modal::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 3px;
}

.logo {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.subtitle {
    font-family: var(--font-heading);
    color: #a0a0b0;
    font-size: 1rem;
    letter-spacing: 5px;
    margin-bottom: 30px;
    text-transform: uppercase;
}

.instructions {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 40px;
    text-align: left;
    width: 100%;
}

.instruction-item {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.03);
    padding: 12px 20px;
    border-radius: 10px;
}

.instruction-item .icon-wrap {
    font-size: 1.5rem;
}

.instruction-item p {
    font-size: 0.95rem;
    color: #e0e0e0;
}

/* Buttons */
.glow-btn {
    font-family: var(--font-body);
    font-weight: 700;
    font-size: 1.1rem;
    padding: 15px 40px;
    border-radius: 30px;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    letter-spacing: 1px;
    position: relative;
    overflow: hidden;
}

.neon-btn {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 15px rgba(0, 243, 255, 0.4);
}

.neon-btn:hover,
.neon-btn:active {
    transform: scale(1.05);
    box-shadow: 0 0 25px rgba(0, 243, 255, 0.8), 0 0 50px rgba(0, 243, 255, 0.4);
}

.outline-btn {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    margin-top: 15px;
}

.outline-btn:hover,
.outline-btn:active {
    background: rgba(0, 243, 255, 0.1);
    transform: scale(1.05);
}

/* Result Screen Specific */
.result-time-box {
    margin: 30px 0;
    padding: 20px;
    border-radius: 15px;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.result-time-box .label {
    font-size: 0.8rem;
    color: #a0a0b0;
    margin-bottom: 5px;
}

.result-time-box .value {
    font-size: 2.8rem;
}

.stats-box {
    width: 100%;
    margin-bottom: 30px;
}

.stat-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-row:last-child {
    border-bottom: none;
}

.stat-label {
    color: #a0a0b0;
    font-size: 0.9rem;
}

.stat-val {
    font-weight: bold;
    font-family: var(--font-heading);
}

.action-buttons {
    width: 100%;
}

/* Animations */
@keyframes flicker {

    0%,
    19%,
    21%,
    23%,
    25%,
    54%,
    56%,
    100% {
        text-shadow: 0 0 5px #fff, 0 0 10px #ffea00, 0 0 20px #ff8800, 0 0 40px var(--fire-color);
        opacity: 1;
    }

    20%,
    24%,
    55% {
        text-shadow: none;
        opacity: 0.8;
    }
}

.fade-in-up {
    animation: fadeInUp 0.5s ease forwards;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.scale-in {
    animation: scaleIn 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.275) forwards;
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Responsive */
@media (max-height: 600px) {
    .modal {
        padding: 25px;
    }

    .logo {
        font-size: 2rem;
    }

    .subtitle {
        margin-bottom: 15px;
    }

    .instructions {
        margin-bottom: 20px;
    }

    .result-time-box .value {
        font-size: 2.2rem;
    }

    .result-time-box {
        margin: 15px 0;
    }
}

/* --- Added Integrations (Portal & Ofuse) --- */
.back-to-portal-game {
    position: absolute;
    top: 20px;
    left: 20px;
    color: var(--primary-color);
    font-size: 0.8rem;
    text-decoration: none;
    font-weight: bold;
    letter-spacing: 1px;
    border: 1px solid var(--primary-color);
    padding: 8px 15px;
    border-radius: 8px;
    z-index: 1000;
    transition: 0.3s;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(5px);
    font-family: var(--font-body);
}

.back-to-portal-game:hover {
    background: var(--primary-color);
    color: #000;
    box-shadow: 0 0 10px var(--primary-color);
}

.ofuse-floating-btn-game {
    position: absolute;
    bottom: 25px;
    right: 25px;
    background: linear-gradient(135deg, #ff4b6b, #ff718a);
    color: #fff;
    font-weight: bold;
    font-family: var(--font-body);
    font-size: 0.85rem;
    text-decoration: none;
    padding: 8px 16px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 15px rgba(255, 75, 107, 0.4);
    z-index: 1000;
    transition: transform 0.2s, box-shadow 0.2s, opacity 0.3s, visibility 0.3s;
}

.ofuse-floating-btn-game:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(255, 75, 107, 0.6);
}

.ofuse-floating-btn-game.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

/* --- Illustrations --- */
.title-illustration {
    width: 150px;
    height: 150px;
    margin-bottom: 10px;
    object-fit: contain;
    filter: drop-shadow(0 0 15px rgba(0, 240, 255, 0.4));
}

.result-illustration {
    width: 120px;
    height: 120px;
    margin-bottom: 5px;
    object-fit: contain;
    filter: drop-shadow(0 0 20px rgba(0, 255, 136, 0.4));
}

.bounce-anim {
    animation: bounceObj 3s infinite ease-in-out;
}

@keyframes bounceObj {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

.pulse-anim {
    animation: pulseObj 2s infinite ease-in-out;
}

@keyframes pulseObj {
    0% {
        transform: scale(1);
        filter: brightness(1) drop-shadow(0 0 10px rgba(0, 255, 136, 0.3));
    }

    50% {
        transform: scale(1.05);
        filter: brightness(1.2) drop-shadow(0 0 25px rgba(0, 255, 136, 0.7));
    }

    100% {
        transform: scale(1);
        filter: brightness(1) drop-shadow(0 0 10px rgba(0, 255, 136, 0.3));
    }
}

@media (max-width: 600px) {
    .back-to-portal-game {
        top: 10px;
        left: 10px;
        font-size: 0.7rem;
        padding: 6px 10px;
    }

    .ofuse-floating-btn-game {
        bottom: 15px;
        right: 15px;
        padding: 10px 20px;
        font-size: 0.9rem;
    }
}