/* ============================================================
   こはだジャンプ～BAKENEKOドリーム～ Styles (REBUILT)
   ============================================================ */

:root {
    --bg-dark: #0f0f1a;
    --text-primary: #f0f0f0;
    --text-secondary: #a0a0b0;
    --accent: #ff6b35;
    --accent-glow: rgba(255, 107, 53, 0.6);
    --gold: #ffd700;
    --danger: #ff4444;
    --success: #44ff88;
    --font-jp: 'Zen Maru Gothic', sans-serif;
    --font-num: 'Orbitron', monospace;
    --ui-bg: rgba(0, 0, 0, 0.6);
    --ui-border: 1px solid rgba(255, 255, 255, 0.15);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    font-family: var(--font-jp);
    color: var(--text-primary);
    touch-action: manipulation;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* ─── Layout Container ─── */
body {
    display: flex;
    flex-direction: column;
}

/* 1. Top Banner (Fixed) */
/* Dummy Ad Banner (Persistent) */
.ad-banner {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 320px;
    height: 50px;
    background: rgba(30, 30, 30, 0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #888;
    font-size: 12px;
    border: 1px dashed #555;
    z-index: 3000;
    /* Above everything */
    pointer-events: none;
    /* Let clicks pass through to game if needed, or auto? Ad should be clickable actually */
    pointer-events: auto;
}

/* 2. Game Area */
#game-container {
    position: relative;
    flex: 1;
    /* Fills remaining space */
    width: 100%;
    overflow: hidden;
}

#game-canvas {
    width: 100%;
    height: 100%;
    display: block;
}

#touch-area {
    position: absolute;
    inset: 0;
    z-index: 10;
    cursor: pointer;
}

/* ─── UI Layers (Clean Split) ─── */

/* TOP UI: Controls (Meter, Angle, Boost) */
#ui-top {
    position: absolute;
    top: 70px;
    /* Shifted down for ad banner */
    left: 0;
    width: 100%;
    pointer-events: none;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

/* Power Meter Container */
#phase-ui {
    width: min(400px, 90vw);
    background: var(--ui-bg);
    backdrop-filter: blur(4px);
    border: var(--ui-border);
    border-radius: 12px;
    padding: 10px 20px;
    text-align: center;
}

.phase-title {
    font-size: 20px;
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    margin-bottom: 5px;
}

.phase-gauge-bg {
    height: 30px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 15px;
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.phase-gauge-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff4444, #ffaa00, #44ff88);
}

.phase-gauge-marker {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #fff;
    left: 0%;
    box-shadow: 0 0 5px #fff;
}

.phase-gauge-sweet {
    position: absolute;
    top: 0;
    bottom: 0;
    background: rgba(68, 255, 136, 0.3);
    border-left: 2px solid var(--success);
    border-right: 2px solid var(--success);
    display: none;
}

.phase-value {
    font-family: var(--font-num);
    font-size: 24px;
    font-weight: 700;
    color: var(--accent);
    margin-top: 5px;
}

.phase-instruction {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Boost Indicator */
#boost-ui {
    margin-top: 10px;
}

.boost-text {
    font-size: 28px;
    font-weight: 900;
    color: #ff4444;
    text-shadow: 0 0 15px rgba(255, 68, 68, 0.8);
    animation: pulse 0.4s infinite alternate;
}

/* BOTTOM UI: Status (Score, Speed) */
#ui-bottom {
    position: absolute;
    bottom: 20px;
    left: 10px;
    right: 10px;
    pointer-events: none;
    z-index: 100;
    display: flex;
    justify-content: center;
    gap: 10px;
}

.hud-panel {
    background: var(--ui-bg);
    backdrop-filter: blur(4px);
    border: var(--ui-border);
    border-radius: 10px;
    padding: 8px 16px;
    text-align: center;
    min-width: 80px;
    flex: 1;
    max-width: 150px;
}

.hud-panel.wide {
    flex: 2;
    max-width: 250px;
}

.hud-label {
    display: block;
    font-size: 10px;
    color: #aaa;
    margin-bottom: 2px;
}

.hud-value {
    display: block;
    font-family: var(--font-num);
    font-size: 20px;
    font-weight: 700;
    color: var(--gold);
}

.hud-panel.wide .hud-value {
    font-size: 28px;
    color: #fff;
}

.hud-unit {
    font-size: 11px;
    color: #888;
}


/* ─── Overlays (Title, Result) ─── */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(15, 15, 26, 0.8);
    z-index: 2000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

.screen.active {
    opacity: 1;
    pointer-events: auto;
}

/* Title */
#title-screen {
    background: linear-gradient(135deg, #1a1a2e, #0f3460);
}

.title-content {
    text-align: center;
    padding-top: 70px;
    /* Adjusted for ad banner space */
}

.title-cat {
    margin-bottom: 10px;
    animation: bounce 2s infinite;
}

.title-main {
    font-family: var(--font-main);
    font-size: 56px;
    font-weight: 900;
    margin: 0;
    /* Gold Gradient */
    background: linear-gradient(to bottom, #fff 0%, #ffd700 50%, #ff8c00 100%);
    background-clip: text;
    -webkit-background-clip: text;
    color: transparent;
    filter: drop-shadow(0 4px 0 #000);
    letter-spacing: 2px;
}

.title-sub {
    color: #ffd700;
    font-size: 18px;
    margin-top: -5px;
    margin-bottom: 20px;
    letter-spacing: 4px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.title-desc {
    color: #fff;
    font-size: 14px;
    margin-bottom: 30px;
    line-height: 1.6;
    text-shadow: 0 2px 2px #000;
}

.nickname-container {
    margin: 20px 0;
}

.nickname-label {
    display: block;
    color: #ff8c00;
    font-weight: bold;
    font-size: 14px;
    margin-bottom: 5px;
    text-shadow: 0 1px 2px #000;
}

.btn-start {
    background: linear-gradient(135deg, #ff6b35, #ff8c00);
    color: #fff;
    border: none;
    padding: 15px 50px;
    font-size: 24px;
    border-radius: 50px;
    font-family: var(--font-main);
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 5px 0 #b33e00, 0 10px 20px rgba(255, 100, 50, 0.4);
    transition: transform 0.1s;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.2);
    margin-top: 20px;
}

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

/* Result */
.result-content {
    background: rgba(20, 20, 35, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 30px;
    border-radius: 20px;
    text-align: center;
    max-width: 90%;
}

/* Ranking Modal */
.ranking-content {
    background: rgba(20, 20, 35, 0.95);
    padding: 20px;
    border-radius: 15px;
    width: 95%;
    max-width: 500px;
    max-height: 60vh;
    display: flex;
    flex-direction: column;
}

.rank-row {
    display: flex;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    font-size: 14px;
}

.rank-pos {
    width: 30px;
    color: var(--gold);
    font-weight: bold;
    flex-shrink: 0;
}

.rank-icon {
    width: 30px;
    text-align: center;
    flex-shrink: 0;
}

.rank-name {
    flex: 1;
    color: #fff;
    text-align: left;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    /* Important for flex shrinking */
    margin-right: 5px;
}

.rank-dist {
    width: 70px;
    text-align: right;
    font-family: var(--font-num);
    color: var(--accent);
    flex-shrink: 0;
}

.rank-date {
    display: block;
    width: 70px;
    text-align: right;
    font-size: 11px;
    color: #888;
    flex-shrink: 0;
}

.result-val {
    font-family: var(--font-num);
    font-size: 60px;
    color: var(--gold);
}

/* Milestone Popup (Center Screen) */
#milestone-popup {
    position: absolute;
    top: 40%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 500;
    text-align: center;
}

.milestone-text {
    font-size: 80px;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 20px #ff6b35, 4px 4px 0 #000;
    white-space: nowrap;
    animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

/* Utility */
.hidden {
    display: none !important;
}

/* Animations */
@keyframes pulse {
    to {
        transform: scale(1.1);
    }
}

@keyframes bounce {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-20px);
    }
}

@keyframes popIn {
    from {
        transform: scale(0);
    }

    to {
        transform: scale(1);
    }
}