*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

:root {
    --gold: #e8a030;
    --gold-light: #ffbb50;
    --gold-dark: #c07820;
    --red: #c04020;
    --red-light: #e05030;
    --bg-dark: #1a0e14;
    --bg-card: rgba(30, 15, 25, 0.88);
    --glass: rgba(20, 10, 18, 0.65);
    --glass-border: rgba(255, 140, 50, 0.25);
    --text: #f0dcc8;
    --text-dim: #a08070;
    --safe-bottom: env(safe-area-inset-bottom, 0px);
    --safe-top: env(safe-area-inset-top, 0px);
}

html, body {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--bg-dark);
    color: var(--text);
    font-family: 'Inter', sans-serif;
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    overscroll-behavior: none;
}

/* ═══════════════════════════════════════════
   LOADING SCREEN
   ═══════════════════════════════════════════ */
#loading-screen {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: linear-gradient(180deg, #1a1040 0%, #4a1830 40%, #c04020 75%, #ff8040 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

#loading-screen.fade-out {
    opacity: 0;
    visibility: hidden;
}

.loader-content {
    text-align: center;
    padding: 20px;
}

.loader-avatar-preview {
    width: 200px;
    height: 260px;
    margin: 0 auto 20px;
    position: relative;
}

#loader-canvas {
    width: 200px;
    height: 260px;
    border-radius: 16px;
    animation: pulse-gold 2s ease-in-out infinite;
}

@keyframes pulse-gold {
    0%, 100% { filter: drop-shadow(0 0 8px rgba(212, 168, 71, 0.3)); }
    50% { filter: drop-shadow(0 0 24px rgba(212, 168, 71, 0.7)); }
}

.loader-title {
    font-family: 'Cinzel', serif;
    font-size: 3rem;
    font-weight: 900;
    letter-spacing: 0.3em;
    color: #ffcc70;
    text-shadow: 0 2px 20px rgba(0, 0, 0, 0.4), 0 0 40px rgba(255, 140, 50, 0.5);
}

.loader-subtitle {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.2rem;
    letter-spacing: 0.5em;
    color: rgba(255, 255, 255, 0.7);
    margin-top: 4px;
}

.loader-bar-container {
    width: 300px;
    height: 3px;
    background: rgba(255, 140, 50, 0.15);
    border-radius: 2px;
    margin: 32px auto 12px;
    overflow: hidden;
}

.loader-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #ff6030, #ffaa50);
    border-radius: 2px;
    transition: width 0.3s ease;
}

.loader-percent {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1rem;
    color: #ffaa50;
    letter-spacing: 0.2em;
}

.loader-fact {
    margin-top: 24px;
    font-size: 0.85rem;
    color: rgba(255, 200, 150, 0.5);
    font-style: italic;
    max-width: 400px;
    line-height: 1.5;
    min-height: 2.5em;
    transition: opacity 0.3s ease;
    padding: 0 16px;
}

@keyframes rotateGlow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ═══════════════════════════════════════════
   CANVAS
   ═══════════════════════════════════════════ */
#three-canvas {
    position: fixed;
    inset: 0;
    z-index: 1;
    touch-action: none;
}

/* ═══════════════════════════════════════════
   HEADER
   ═══════════════════════════════════════════ */
#top-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 32px;
    padding-top: calc(16px + var(--safe-top));
    background: linear-gradient(180deg, rgba(20, 10, 18, 0.7) 0%, transparent 100%);
    pointer-events: none;
}

#top-header * {
    pointer-events: auto;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 2px solid var(--gold);
    box-shadow: 0 0 16px rgba(255, 140, 50, 0.4);
}

.header-left h2 {
    font-family: 'Cinzel', serif;
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 0.15em;
    color: var(--gold-light);
    text-shadow: 0 1px 8px rgba(255, 140, 50, 0.3);
}

.header-dates {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.9rem;
    color: var(--text-dim);
    letter-spacing: 0.2em;
}

/* Mobile menu button */
.mobile-menu-btn {
    display: none;
    flex-direction: column;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 8px;
    z-index: 110;
}

.mobile-menu-btn span {
    display: block;
    width: 24px;
    height: 2px;
    background: var(--gold-light);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.mobile-menu-btn.open span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}
.mobile-menu-btn.open span:nth-child(2) {
    opacity: 0;
}
.mobile-menu-btn.open span:nth-child(3) {
    transform: rotate(-45deg) translate(5px, -5px);
}

.header-nav {
    display: flex;
    gap: 4px;
}

.nav-btn {
    background: transparent;
    border: 1px solid transparent;
    color: var(--text-dim);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 8px 20px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.nav-btn:hover {
    color: var(--gold-light);
    border-color: var(--glass-border);
}

.nav-btn.active {
    color: var(--gold);
    border-color: var(--gold);
    background: rgba(255, 140, 50, 0.1);
}

/* ═══════════════════════════════════════════
   SPEECH BUBBLE
   ═══════════════════════════════════════════ */
#speech-bubble {
    position: fixed;
    z-index: 200;
    max-width: 400px;
    transition: opacity 0.4s ease, transform 0.4s ease;
    pointer-events: none;
}

#speech-bubble.hidden {
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    pointer-events: none;
}

.bubble-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4), 0 0 40px rgba(255, 140, 50, 0.06);
}

.bubble-avatar-img {
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    object-position: top;
    border: 2px solid var(--gold);
    box-shadow: 0 0 16px rgba(255, 140, 50, 0.3);
}

.bubble-text {
    font-size: 0.9rem;
    line-height: 1.6;
    color: var(--text);
}

.bubble-tail {
    width: 20px;
    height: 20px;
    margin-left: 30px;
    margin-top: -1px;
    background: var(--glass);
    border-bottom: 1px solid var(--glass-border);
    border-right: 1px solid var(--glass-border);
    transform: rotate(45deg);
    border-radius: 0 0 4px 0;
}

/* ═══════════════════════════════════════════
   TIMELINE OVERLAY
   ═══════════════════════════════════════════ */
#timeline-overlay {
    position: fixed;
    inset: 0;
    z-index: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 10, 15, 0.6);
    backdrop-filter: blur(12px);
    transition: opacity 0.4s ease, visibility 0.4s ease;
}

#timeline-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.overlay-content {
    background: var(--bg-card);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 48px;
    max-width: 500px;
    width: 90%;
    position: relative;
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5), 0 0 60px rgba(255, 100, 30, 0.05);
}

.overlay-close {
    position: absolute;
    top: 16px;
    right: 20px;
    background: none;
    border: none;
    color: var(--text-dim);
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s;
    line-height: 1;
}

.overlay-close:hover {
    color: var(--gold);
}

#overlay-title {
    font-family: 'Cinzel', serif;
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--gold);
    margin-bottom: 8px;
}

.overlay-year {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.1rem;
    letter-spacing: 0.2em;
    color: var(--gold-dark);
    margin-bottom: 20px;
}

.overlay-desc {
    font-size: 0.95rem;
    line-height: 1.7;
    color: var(--text);
}

/* ═══════════════════════════════════════════
   ANIMATION CONTROLS (desktop)
   ═══════════════════════════════════════════ */
#anim-controls {
    position: fixed;
    left: 24px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 100;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.anim-btn {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--text);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.anim-btn:hover {
    background: rgba(255, 140, 50, 0.15);
    border-color: var(--gold);
    transform: scale(1.1);
    box-shadow: 0 0 20px rgba(255, 140, 50, 0.15);
}

.anim-btn.active {
    background: rgba(255, 140, 50, 0.2);
    border-color: var(--gold);
}

/* ═══════════════════════════════════════════
   CHAT CONTAINER
   ═══════════════════════════════════════════ */
#chat-container {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 300;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 24px calc(24px + var(--safe-bottom));
    pointer-events: none;
}

#chat-bar {
    width: 100%;
    max-width: 700px;
    pointer-events: auto;
}

.chat-input-wrap {
    display: flex;
    align-items: center;
    background: var(--glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--glass-border);
    border-radius: 16px;
    padding: 4px 4px 4px 20px;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.chat-input-wrap:focus-within {
    border-color: var(--gold);
    box-shadow: 0 0 30px rgba(255, 140, 50, 0.12);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    outline: none;
    color: var(--text);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    padding: 12px 0;
    min-width: 0;
}

#chat-input::placeholder {
    color: var(--text-dim);
}

#chat-send {
    width: 44px;
    height: 44px;
    border-radius: 12px;
    background: linear-gradient(135deg, var(--gold-dark), var(--gold));
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

#chat-send svg {
    width: 18px;
    height: 18px;
    color: #1a0e14;
}

#chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 140, 50, 0.4);
}

#chat-send:active {
    transform: scale(0.95);
}

/* ═══════════════════════════════════════════
   TYPING INDICATOR
   ═══════════════════════════════════════════ */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-indicator span {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--gold);
    animation: typingBounce 1.4s ease-in-out infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ═══════════════════════════════════════════
   FIGHT BUTTON
   ═══════════════════════════════════════════ */
.fight-btn {
    color: #ff4040 !important;
    border-color: #ff4040 !important;
    text-shadow: 0 0 10px rgba(255, 60, 60, 0.5);
    animation: fightPulse 2s ease-in-out infinite;
}
.fight-btn:hover {
    background: rgba(255, 40, 40, 0.15) !important;
    color: #ff6060 !important;
}
@keyframes fightPulse {
    0%, 100% { box-shadow: 0 0 5px rgba(255, 40, 40, 0.2); }
    50% { box-shadow: 0 0 20px rgba(255, 40, 40, 0.5); }
}

/* ═══════════════════════════════════════════
   FIGHT HUD
   ═══════════════════════════════════════════ */
#fight-hud {
    position: fixed;
    inset: 0;
    z-index: 600;
    pointer-events: none;
}
#fight-hud.hidden { display: none; }

.fight-top-bar {
    position: absolute;
    top: 0; left: 0; right: 0;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 20px 30px 0;
    padding-top: calc(20px + var(--safe-top));
    gap: 16px;
    background: linear-gradient(180deg, rgba(0,0,0,0.7) 0%, transparent 100%);
}

.fighter-info {
    flex: 1;
    max-width: 380px;
}
.fighter-info.right { text-align: right; }
.fighter-info.right .hp-bar-wrap { direction: rtl; }
.fighter-info.right .hp-bar-fill { transform-origin: right; }
.fighter-info.right .round-dots { justify-content: flex-end; }

.fighter-name {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.4rem;
    letter-spacing: 0.2em;
    color: #fff;
    text-shadow: 0 0 10px rgba(255,100,50,0.5);
    margin-bottom: 6px;
}

.hp-bar-wrap {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.hp-bar-bg {
    height: 18px;
    background: rgba(0,0,0,0.6);
    border: 2px solid rgba(255,200,100,0.4);
    border-radius: 2px;
    overflow: hidden;
    position: relative;
}
.hp-bar-bg::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.15) 0%, transparent 50%);
    pointer-events: none;
}

.hp-bar-fill {
    height: 100%;
    width: 100%;
    transition: width 0.2s ease;
    position: relative;
}
.hp-bar-fill.chuck-fill {
    background: linear-gradient(90deg, #ff3030, #ff8020, #ffcc00);
}
.hp-bar-fill.bruce-fill {
    background: linear-gradient(90deg, #30ff30, #20c0ff, #6060ff);
}
.hp-bar-fill.critical {
    animation: hpFlash 0.3s ease infinite;
}
@keyframes hpFlash {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.round-dots {
    display: flex;
    gap: 6px;
}
.round-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid rgba(255,200,100,0.5);
    background: transparent;
    transition: all 0.3s ease;
}
.round-dot.won {
    background: #ffcc00;
    border-color: #ffcc00;
    box-shadow: 0 0 10px rgba(255,200,0,0.6);
}

.fight-vs {
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2rem;
    color: #ff4040;
    text-shadow: 0 0 20px rgba(255,40,40,0.7), 0 0 40px rgba(255,40,40,0.3);
    letter-spacing: 0.1em;
    padding-top: 8px;
}

.fight-controls-hint {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 20px;
    pointer-events: none;
    opacity: 0.6;
}
.fight-controls-hint span {
    font-size: 0.65rem;
    color: #ccc;
    letter-spacing: 0.05em;
    white-space: nowrap;
}
.fight-controls-hint b {
    color: #ffcc00;
}

/* ═══════════════════════════════════════════
   MOBILE FIGHT TOUCH CONTROLS
   ═══════════════════════════════════════════ */
.fight-touch-controls {
    position: absolute;
    bottom: 20px;
    left: 0;
    right: 0;
    padding: 0 16px;
    padding-bottom: var(--safe-bottom);
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    pointer-events: none;
}

.fight-touch-left {
    display: flex;
    gap: 12px;
    pointer-events: auto;
}

.fight-touch-right {
    display: flex;
    gap: 10px;
    pointer-events: auto;
}

.fight-touch-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    border: 2px solid rgba(255,200,100,0.5);
    background: rgba(0,0,0,0.5);
    backdrop-filter: blur(8px);
    color: #fff;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    -webkit-user-select: none;
    user-select: none;
}

.fight-touch-btn:active {
    transform: scale(0.9);
    background: rgba(255,140,50,0.3);
    border-color: var(--gold);
}

.fight-touch-btn svg {
    width: 28px;
    height: 28px;
    fill: none;
    stroke: #fff;
    stroke-width: 2.5;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.fight-btn-punch {
    background: rgba(255,60,30,0.35);
    border-color: #ff4040;
    width: 72px;
    height: 72px;
    font-size: 0.8rem;
}
.fight-btn-kick {
    background: rgba(255,140,30,0.3);
    border-color: #ffaa30;
    font-size: 0.75rem;
}
.fight-btn-block {
    background: rgba(60,120,255,0.3);
    border-color: #60a0ff;
    font-size: 0.7rem;
}

/* Fight Announcements */
.fight-announce {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.5);
    z-index: 700;
    font-family: 'Bebas Neue', sans-serif;
    text-align: center;
    pointer-events: none;
    animation: announceSlam 0.5s cubic-bezier(0.2, 1.5, 0.4, 1) forwards;
}
.fight-announce.hidden { display: none; }

.round-text {
    font-size: 4rem;
    color: #fff;
    text-shadow: 0 0 30px rgba(255,200,100,0.6), 0 4px 20px rgba(0,0,0,0.8);
    letter-spacing: 0.2em;
}
.fight-text {
    font-size: 7rem;
    color: #ff4040;
    text-shadow: 0 0 60px rgba(255,40,40,0.8), 0 0 120px rgba(255,40,40,0.4), 0 4px 20px rgba(0,0,0,0.8);
    letter-spacing: 0.15em;
}
.ko-text {
    font-size: 10rem;
    color: #ff2020;
    text-shadow: 0 0 80px rgba(255,20,20,0.9), 0 0 160px rgba(255,20,20,0.5), 0 8px 30px rgba(0,0,0,0.9);
    letter-spacing: 0.1em;
}
.win-text {
    font-size: 4rem;
    color: #ffcc00;
    text-shadow: 0 0 40px rgba(255,200,0,0.7), 0 0 80px rgba(255,200,0,0.3), 0 4px 20px rgba(0,0,0,0.8);
    letter-spacing: 0.15em;
}

@keyframes announceSlam {
    0% { transform: translate(-50%, -50%) scale(3); opacity: 0; }
    60% { transform: translate(-50%, -50%) scale(0.9); opacity: 1; }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* Combo Text */
.combo-text {
    position: fixed;
    top: 40%;
    right: 10%;
    z-index: 650;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 2.5rem;
    color: #ffcc00;
    text-shadow: 0 0 20px rgba(255,200,0,0.7), 0 2px 10px rgba(0,0,0,0.8);
    letter-spacing: 0.1em;
    pointer-events: none;
}
.combo-text.hidden { display: none; }
.combo-text.pop {
    animation: comboPop 0.3s cubic-bezier(0.2, 1.5, 0.4, 1);
}
@keyframes comboPop {
    0% { transform: scale(0.5) rotate(-5deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Damage Numbers */
.damage-number {
    position: fixed;
    z-index: 660;
    font-family: 'Bebas Neue', sans-serif;
    font-size: 1.8rem;
    color: #ff3030;
    text-shadow: 0 0 10px rgba(255,30,30,0.7), 0 2px 6px rgba(0,0,0,0.9);
    pointer-events: none;
    animation: dmgFloat 0.8s ease-out forwards;
    letter-spacing: 0.05em;
}
.damage-number.blocked {
    color: #60a0ff;
    font-size: 1.2rem;
}
@keyframes dmgFloat {
    0% { transform: translateY(0) scale(1.3); opacity: 1; }
    100% { transform: translateY(-60px) scale(0.8); opacity: 0; }
}

/* Earthquake effect */
@keyframes earthquakeShake {
    0%, 100% { transform: translate(0, 0); }
    10% { transform: translate(-4px, 3px); }
    20% { transform: translate(5px, -4px); }
    30% { transform: translate(-6px, 2px); }
    40% { transform: translate(3px, -5px); }
    50% { transform: translate(-3px, 4px); }
    60% { transform: translate(6px, -2px); }
    70% { transform: translate(-4px, 5px); }
    80% { transform: translate(5px, -3px); }
    90% { transform: translate(-2px, 4px); }
}
#three-canvas.earthquake {
    animation: earthquakeShake 0.15s ease infinite;
}

/* ═══════════════════════════════════════════
   CONTROLS HINT (desktop)
   ═══════════════════════════════════════════ */
#controls-hint {
    position: fixed;
    right: 24px;
    bottom: 100px;
    z-index: 100;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    pointer-events: none;
    opacity: 0.7;
    transition: opacity 0.3s ease;
}

#controls-hint:hover {
    opacity: 1;
}

.controls-keys {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
}

.key-row {
    display: flex;
    gap: 4px;
}

kbd {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: var(--glass);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    color: var(--gold-light);
    font-family: 'Inter', sans-serif;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.controls-labels {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.controls-labels span {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.05em;
}

.controls-labels b {
    color: var(--gold-light);
    font-weight: 600;
}

/* ═══════════════════════════════════════════
   MOBILE TOUCH JOYSTICK
   ═══════════════════════════════════════════ */
#touch-joystick {
    position: fixed;
    bottom: 80px;
    left: 24px;
    z-index: 400;
    pointer-events: auto;
    padding-bottom: var(--safe-bottom);
}

.joystick-base {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.3);
    border: 2px solid rgba(255, 140, 50, 0.3);
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    touch-action: none;
}

.joystick-knob {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 180, 80, 0.6), rgba(255, 140, 50, 0.3));
    border: 2px solid var(--gold);
    box-shadow: 0 0 16px rgba(255, 140, 50, 0.3);
    position: absolute;
    transition: none;
    pointer-events: none;
}

/* ═══════════════════════════════════════════
   MOBILE TOUCH ACTION BUTTONS
   ═══════════════════════════════════════════ */
#touch-actions {
    position: fixed;
    bottom: 80px;
    right: 24px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: auto;
    padding-bottom: var(--safe-bottom);
}

.touch-action-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.4);
    border: 2px solid var(--glass-border);
    color: var(--gold-light);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.15s ease;
    backdrop-filter: blur(8px);
    -webkit-user-select: none;
    user-select: none;
}

.touch-action-btn:active {
    transform: scale(0.9);
    background: rgba(255, 140, 50, 0.25);
    border-color: var(--gold);
}

.touch-action-btn svg {
    width: 24px;
    height: 24px;
    fill: var(--gold-light);
}

/* ═══════════════════════════════════════════
   DESKTOP / MOBILE VISIBILITY
   ═══════════════════════════════════════════ */
.mobile-only {
    display: none;
}

.desktop-only {
    display: flex;
}

/* ═══════════════════════════════════════════
   RESPONSIVE — MOBILE
   ═══════════════════════════════════════════ */
@media (max-width: 768px), (hover: none) and (pointer: coarse) {
    .mobile-only { display: flex; }
    .desktop-only { display: none !important; }

    /* Loading screen */
    .loader-avatar-preview { width: 140px; height: 180px; }
    #loader-canvas { width: 140px; height: 180px; }
    .loader-title { font-size: 2rem; letter-spacing: 0.2em; }
    .loader-subtitle { font-size: 0.9rem; letter-spacing: 0.3em; }
    .loader-bar-container { width: 220px; }

    /* Header */
    #top-header {
        padding: 10px 16px;
        padding-top: calc(10px + var(--safe-top));
    }
    .header-logo { width: 32px; height: 32px; }
    .header-left h2 { font-size: 1rem; letter-spacing: 0.1em; }
    .header-dates { display: none; }

    .mobile-menu-btn { display: flex; }

    .header-nav {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        width: 200px;
        background: rgba(20, 10, 18, 0.95);
        backdrop-filter: blur(20px);
        -webkit-backdrop-filter: blur(20px);
        flex-direction: column;
        padding: calc(80px + var(--safe-top)) 20px 40px;
        gap: 8px;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 105;
        border-left: 1px solid var(--glass-border);
    }

    .header-nav.open {
        transform: translateX(0);
    }

    .nav-btn {
        padding: 14px 16px;
        font-size: 0.85rem;
        text-align: left;
        border-radius: 8px;
    }

    /* Speech bubble */
    #speech-bubble {
        max-width: calc(100vw - 32px);
        left: 16px !important;
        top: auto !important;
        bottom: 80px;
    }

    /* Chat */
    #chat-container {
        padding: 0 12px calc(12px + var(--safe-bottom));
    }
    #chat-bar { max-width: 100%; }
    .chat-input-wrap { padding: 2px 2px 2px 14px; border-radius: 12px; }
    #chat-input { font-size: 16px; padding: 10px 0; }
    #chat-send { width: 40px; height: 40px; border-radius: 10px; }

    /* Overlay */
    .overlay-content { padding: 28px 20px; }
    #overlay-title { font-size: 1.3rem; }
    .overlay-desc { font-size: 0.85rem; }

    /* Fight HUD */
    .fight-top-bar {
        padding: 10px 12px 0;
        padding-top: calc(10px + var(--safe-top));
        gap: 8px;
    }
    .fighter-name { font-size: 0.85rem; letter-spacing: 0.1em; margin-bottom: 3px; }
    .hp-bar-bg { height: 12px; }
    .fight-vs { font-size: 1.2rem; padding-top: 4px; }
    .round-dot { width: 8px; height: 8px; }

    /* Fight announcements */
    .round-text { font-size: 2.5rem; }
    .fight-text { font-size: 4rem; }
    .ko-text { font-size: 5rem; }
    .win-text { font-size: 2.5rem; }
    .combo-text { font-size: 1.8rem; right: 5%; }
    .damage-number { font-size: 1.4rem; }
    .damage-number.blocked { font-size: 1rem; }

    /* Touch joystick */
    #touch-joystick { bottom: 60px; left: 16px; }
    .joystick-base { width: 110px; height: 110px; }
    .joystick-knob { width: 44px; height: 44px; }

    /* Touch actions */
    #touch-actions { bottom: 60px; right: 16px; }
    .touch-action-btn { width: 50px; height: 50px; font-size: 1.1rem; }

    /* Fight touch controls */
    .fight-touch-controls { bottom: 16px; padding: 0 12px; }
    .fight-touch-btn { width: 58px; height: 58px; font-size: 0.65rem; }
    .fight-btn-punch { width: 66px; height: 66px; font-size: 0.75rem; }
}

/* Extra small phones */
@media (max-width: 380px) {
    .loader-title { font-size: 1.6rem; }
    .loader-avatar-preview { width: 120px; height: 150px; }
    #loader-canvas { width: 120px; height: 150px; }
    .joystick-base { width: 90px; height: 90px; }
    .joystick-knob { width: 36px; height: 36px; }
    .fight-touch-btn { width: 50px; height: 50px; font-size: 0.55rem; }
    .fight-btn-punch { width: 56px; height: 56px; }
    .touch-action-btn { width: 44px; height: 44px; }
}

/* Landscape mobile */
@media (max-height: 500px) and (orientation: landscape) {
    #touch-joystick { bottom: 10px; left: 10px; }
    .joystick-base { width: 80px; height: 80px; }
    .joystick-knob { width: 32px; height: 32px; }
    #touch-actions { bottom: 10px; right: 10px; gap: 6px; }
    .touch-action-btn { width: 40px; height: 40px; }
    #chat-container { display: none; }
    .fight-touch-controls { bottom: 8px; }
    .fight-touch-btn { width: 48px; height: 48px; }
    .fight-btn-punch { width: 54px; height: 54px; }
    .fight-top-bar { padding-top: 6px; }
    .fighter-name { font-size: 0.7rem; }
    .hp-bar-bg { height: 8px; }
}
