/* ================================================
   SAMAD BALL Z — TEKKEN 8 ULTIMATE STYLES
   ================================================ */

:root {
    --p1: #0099ff;
    --p1-light: #00ccff;
    --p1-glow: rgba(0,153,255,0.5);
    --p2: #ff3300;
    --p2-light: #ff5533;
    --p2-glow: rgba(255,51,0,0.5);
    --cpu: #ff5500;
    --cpu-light: #ff7733;
    --cpu-glow: rgba(255,85,0,0.5);
    --gold: #ffd700;
    --gold-glow: rgba(255,215,0,0.4);
    --ki: #00ddff;
    --danger: #ff2222;
    --success: #22cc44;
    --bg: #050510;
    --bg-deep: #0a0a1a;
    --bg-overlay: rgba(5,5,18,0.96);
    --surface: #0c0c20;
    --surface-raised: #1a1a38;
    --border: #1a1a3a;
    --border-bright: #333366;
    --text: #ccccee;
    --text-dim: #888899;
    --tekken-scanline: rgba(255,255,255,0.012);
    --tekken-hp-frame: 3px;
    --tekken-hp-height: 22px;
}

/* ================================================
   GLOBAL RESETS
   ================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    background: #000;
    overflow: hidden;
    width: 100vw;
    height: 100vh;
    font-family: 'Segoe UI', 'Arial Black', Arial, sans-serif;
    color: var(--text);
    user-select: none;
    -webkit-user-select: none;
}

.hidden { display: none !important; }

/* ================================================
   GAME CONTAINER
   ================================================ */
#game-container {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--bg) 0%, var(--bg-deep) 50%, #0d0d28 100%);
    overflow: hidden;
}
#game-container, #game-container * { cursor: none !important; }

#gameCanvas {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 1280px;
    max-height: 720px;
    width: 100%;
    height: auto;
    pointer-events: none;
    display: block;
    background: #000;
}

/* ================================================
   CUSTOM CURSOR
   ================================================ */
#custom-cursor {
    position: fixed;
    top: 0; left: 0;
    width: 32px; height: 32px;
    pointer-events: none;
    z-index: 9999;
    background-size: contain;
    background-repeat: no-repeat;
}
#custom-cursor.cursor-normal { background-image: url('./CURSOR/Arrow.png'); }
#custom-cursor.cursor-pointer { background-image: url('./CURSOR/pointer.png'); }

/* ================================================
   SCREEN FLASH
   ================================================ */
#screen-flash {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: #fff;
    opacity: 0;
    pointer-events: none;
    z-index: 20;
    transition: opacity 0.06s;
}

/* ================================================
   RAGE VIGNETTE
   ================================================ */
#rage-vignette {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 7;
    background: radial-gradient(ellipse at center, transparent 50%, rgba(180,0,0,0.35) 100%);
    animation: rage-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes rage-pulse {
    from { opacity: 0.6; }
    to { opacity: 1; }
}

/* ================================================
   MENU PARTICLES CANVAS
   ================================================ */
#menu-particles {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    z-index: 1;
}

/* ================================================
   INTRO VIDEO
   ================================================ */
#intro-video {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    object-fit: contain;
    background: #000;
    z-index: 15;
}

/* ================================================
   OVERLAY BASE
   ================================================ */
.overlay {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--bg-overlay);
    background-image:
        radial-gradient(ellipse at 50% 0%, rgba(0,80,180,0.08) 0%, transparent 60%),
        radial-gradient(ellipse at 50% 100%, rgba(80,0,160,0.06) 0%, transparent 60%);
    z-index: 10;
}

.overlay::before {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        var(--tekken-scanline) 2px,
        var(--tekken-scanline) 4px
    );
    pointer-events: none;
    z-index: 0;
}

.scanline-overlay {
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(
        0deg,
        transparent,
        transparent 2px,
        rgba(255,255,255,0.008) 2px,
        rgba(255,255,255,0.008) 4px
    );
    pointer-events: none;
    z-index: 2;
}

/* ================================================
   GAME TITLE
   ================================================ */
.game-title {
    font-size: clamp(3rem, 10vw, 6rem);
    font-weight: 900;
    letter-spacing: 0.1em;
    color: var(--gold);
    text-shadow:
        0 0 30px var(--gold-glow),
        0 0 80px rgba(255,215,0,0.25),
        0 4px 0 #886600,
        0 6px 0 #664400;
    margin-bottom: 0.1em;
    z-index: 2;
    text-transform: uppercase;
    animation: title-glow 3s ease-in-out infinite alternate;
}

@keyframes title-glow {
    from { text-shadow: 0 0 20px var(--gold-glow), 0 0 60px rgba(255,215,0,0.15), 0 4px 0 #886600; }
    to { text-shadow: 0 0 40px var(--gold-glow), 0 0 100px rgba(255,215,0,0.3), 0 4px 0 #886600; }
}

.game-sub {
    font-size: clamp(0.55rem, 1.2vw, 0.75rem);
    color: var(--text-dim);
    letter-spacing: 0.35em;
    margin-bottom: 2em;
    z-index: 2;
    text-transform: uppercase;
}

.section-title {
    font-size: clamp(1.4rem, 4vw, 2.5rem);
    font-weight: 900;
    letter-spacing: 0.1em;
    color: var(--text);
    margin-bottom: 1.5em;
    z-index: 2;
    text-align: center;
    text-transform: uppercase;
    text-shadow: 0 0 30px rgba(0,153,255,0.2);
}

.pause-title {
    color: var(--text);
    text-shadow: 0 0 40px rgba(0,0,0,0.8);
}

/* ================================================
   BUTTONS — TEKKEN ANGLED STYLE
   ================================================ */
.menu-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
    z-index: 2;
}

.btn-game {
    position: relative;
    padding: 0;
    border: none;
    background: none;
    cursor: pointer;
    overflow: hidden;
    min-width: 260px;
    height: 52px;
    clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
}

.btn-label {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%; height: 100%;
    font-size: 0.85rem;
    font-weight: 800;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    color: #ccc;
    background: linear-gradient(135deg, #1a1a3a 0%, #15152e 100%);
    border: none;
    transition: all 0.15s ease;
    position: relative;
}

.btn-label::before {
    content: '';
    position: absolute;
    inset: 0;
    border: 2px solid #3a3a66;
    clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
    pointer-events: none;
}

.btn-label::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.06), transparent);
    transition: left 0.4s ease;
}

.btn-game:hover .btn-label {
    background: linear-gradient(135deg, #1e1e44 0%, #1a1a3a 100%);
    color: var(--p1-light);
    text-shadow: 0 0 12px var(--p1-glow);
}

.btn-game:hover .btn-label::before {
    border-color: var(--p1);
    box-shadow: 0 0 15px var(--p1-glow), inset 0 0 15px rgba(0,153,255,0.05);
}

.btn-game:hover .btn-label::after { left: 100%; }

.btn-game:active .btn-label {
    background: linear-gradient(135deg, #12122a 0%, #0e0e22 100%);
    transform: translateY(1px);
}

/* Secondary button */
.btn-game.btn-secondary .btn-label {
    background: linear-gradient(135deg, #0f1a28 0%, #0c1520 100%);
}
.btn-game.btn-secondary .btn-label::before { border-color: #1a3040; }
.btn-game.btn-secondary:hover .btn-label {
    color: var(--ki);
    text-shadow: 0 0 12px rgba(0,221,255,0.4);
}
.btn-game.btn-secondary:hover .btn-label::before {
    border-color: var(--ki);
    box-shadow: 0 0 15px rgba(0,221,255,0.3);
}

/* Danger button */
.btn-game.btn-danger .btn-label {
    background: linear-gradient(135deg, #20101a 0%, #180c14 100%);
}
.btn-game.btn-danger .btn-label::before { border-color: #3a1a2a; }
.btn-game.btn-danger:hover .btn-label {
    color: var(--danger);
    text-shadow: 0 0 12px rgba(255,34,34,0.4);
}
.btn-game.btn-danger:hover .btn-label::before {
    border-color: var(--danger);
    box-shadow: 0 0 15px rgba(255,34,34,0.3);
}

/* Mode button variant */
.btn-game.btn-mode {
    min-width: 260px;
    height: 52px;
}

/* Confirm fight button */
.btn-game.btn-confirm-fight {
    margin-top: 1em;
    min-width: 260px;
    height: 52px;
}

.btn-confirm-fight .btn-label {
    background: linear-gradient(135deg, #1a1a3a 0%, #15152e 100%);
    border: none;
    color: var(--gold);
    font-size: 1.2rem;
    letter-spacing: 0.22em;
    text-shadow: 0 0 15px var(--gold-glow);
}

.btn-confirm-fight .btn-label::before {
    border-color: var(--gold);
    box-shadow: 0 0 10px rgba(255,215,0,0.15);
}

.btn-confirm-fight:hover .btn-label {
    color: #fff;
    text-shadow: 0 0 20px rgba(255,255,255,0.4);
}

.btn-confirm-fight:hover .btn-label::before {
    border-color: #fff;
    box-shadow: 0 0 20px rgba(255,255,255,0.3);
}

.btn-confirm-fight:active .btn-label { transform: translateY(2px); }

/* Stage random button */
.btn-game.btn-stage-random { margin-bottom: 8px; }

.btn-stage-random .btn-label {
    background: rgba(255,215,0,0.08);
    border: 2px solid var(--gold);
    color: var(--gold);
    font-size: 0.7rem;
}
.btn-stage-random:hover .btn-label {
    background: rgba(255,215,0,0.15);
    color: #fff;
}

/* ================================================
   CONTROLS PANEL
   ================================================ */
.panel {
    margin-top: 15px;
    background: var(--surface);
    border: 1px solid var(--border);
    max-width: 780px;
    width: 90%;
    z-index: 12;
    clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}

.panel-header {
    background: rgba(0,153,255,0.06);
    border-bottom: 1px solid var(--border);
    padding: 6px 12px;
    font-size: 0.6rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    color: var(--p1-light);
    text-align: center;
    text-transform: uppercase;
}

.controls-grid {
    display: flex;
    gap: 14px;
    justify-content: center;
    flex-wrap: wrap;
    padding: 10px;
}

.control-col h3 {
    font-size: 0.55rem;
    color: var(--p1-light);
    margin-bottom: 4px;
    letter-spacing: 0.12em;
    border-bottom: 1px solid rgba(0,153,255,0.12);
    padding-bottom: 2px;
    text-transform: uppercase;
}

.control-col p {
    font-size: 0.6rem;
    margin: 2px 0;
    color: var(--text-dim);
}

kbd {
    display: inline-block;
    padding: 1px 5px;
    font-size: 0.55rem;
    font-family: Consolas, monospace;
    font-weight: 700;
    background: #1a1a33;
    border: 1px solid #3a3a55;
    color: #aabbee;
    min-width: 16px;
    text-align: center;
}

/* ================================================
   MODE SELECT
   ================================================ */
#mode-select {
    background: var(--bg-overlay);
}

#mode-select .section-title {
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-glow), 0 0 50px rgba(255,215,0,0.2);
}

.mode-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    z-index: 2;
}

/* ================================================
   DIFFICULTY SELECT
   ================================================ */
#diff-select {
    background:
        linear-gradient(180deg, rgba(5,5,20,0.97) 0%, rgba(8,5,25,0.98) 100%);
}

#diff-select .section-title {
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-glow), 0 0 50px rgba(255,215,0,0.2);
}

.diff-buttons {
    display: flex;
    gap: 28px;
    z-index: 2;
    justify-content: center;
    align-items: center;
}

.diff-card {
    padding: 24px 50px;
    font-family: inherit;
    cursor: pointer;
    border: 2px solid;
    background: linear-gradient(180deg, var(--surface) 0%, rgba(10,10,26,0.98) 100%);
    transition: all 0.25s;
    min-width: 180px;
    min-height: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    clip-path: polygon(8px 0, 100% 0, calc(100% - 8px) 100%, 0 100%);
    position: relative;
    overflow: hidden;
}

.diff-card::after {
    content: '';
    position: absolute;
    top: 0; left: -100%;
    width: 100%; height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.04), transparent);
    transition: left 0.5s ease;
}
.diff-card:hover::after { left: 100%; }
.diff-card:active { transform: translateY(2px) scale(0.97); }

.diff-name {
    font-size: 1.4rem;
    font-weight: 900;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.diff-desc {
    font-size: 0.7rem;
    opacity: 0.7;
}

.diff-card.easy { border-color: var(--success); color: var(--success); }
.diff-card.easy:hover {
    background: rgba(34,204,68,0.06);
    box-shadow: 0 0 25px rgba(34,204,68,0.3);
    transform: translateY(-3px) scale(1.03);
}

.diff-card.medium { border-color: var(--cpu); color: var(--cpu); }
.diff-card.medium:hover {
    background: rgba(255,85,0,0.06);
    box-shadow: 0 0 25px rgba(255,85,0,0.3);
    transform: translateY(-3px) scale(1.03);
}

.diff-card.hard { border-color: var(--danger); color: var(--danger); }
.diff-card.hard:hover {
    background: rgba(255,34,34,0.06);
    box-shadow: 0 0 25px rgba(255,34,34,0.3);
    transform: translateY(-3px) scale(1.03);
}

.diff-card.easy .diff-name::before { content: '🛡️ '; }
.diff-card.medium .diff-name::before { content: '⚔️ '; }
.diff-card.hard .diff-name::before { content: '💀 '; }

/* ================================================
   CHARACTER SELECT
   ================================================ */
#char-select {
    background:
        linear-gradient(180deg, rgba(5,5,20,0.97) 0%, rgba(8,5,25,0.98) 100%);
}

#char-select .section-title {
    margin-bottom: 0.6em;
    font-size: clamp(1rem, 3vw, 1.6rem);
    letter-spacing: 0.25em;
    color: var(--gold);
    text-shadow: 0 0 20px var(--gold-glow), 0 0 50px rgba(255,215,0,0.2);
    text-transform: uppercase;
}

.char-select-layout {
    display: flex;
    align-items: stretch;
    justify-content: center;
    gap: 16px;
    z-index: 2;
    width: min(1100px, 95vw);
    min-height: 420px;
}

.char-select-side {
    display: flex;
    flex-direction: column;
    flex: 1;
    max-width: 420px;
}

.char-side-label {
    font-size: 0.85rem;
    font-weight: 900;
    letter-spacing: 0.25em;
    text-align: center;
    padding: 8px 0;
    margin-bottom: 10px;
    border-bottom: 3px solid;
    text-transform: uppercase;
}

.p1-label, #p1-side-label.p1-label {
    color: var(--p1-light);
    border-color: var(--p1);
    background: rgba(0,153,255,0.08);
    text-shadow: 0 0 20px var(--p1-glow), 0 0 40px rgba(0,153,255,0.15);
}

.p2-label, #p2-side-label.p2-label {
    color: var(--cpu-light);
    border-color: var(--p2);
    background: rgba(255,85,0,0.08);
    text-shadow: 0 0 20px var(--p2-glow), 0 0 40px rgba(255,85,0,0.15);
}

.char-cards-vertical {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    flex: 1;
}

.char-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 10px 10px;
    border: 2px solid var(--border);
    background: linear-gradient(180deg, rgba(12,12,32,0.95) 0%, rgba(8,8,24,0.98) 100%);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
    overflow: hidden;
    min-height: 180px;
    clip-path: polygon(0 0, calc(100% - 6px) 0, 100% 6px, 100% 100%, 6px 100%, 0 calc(100% - 6px));
}

.char-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(180deg, rgba(255,255,255,0.015) 0%, transparent 100%);
    pointer-events: none;
}

.char-card:hover {
    border-color: #444477;
    transform: translateY(-2px);
    background: rgba(15,15,40,0.95);
    box-shadow: 0 0 20px rgba(255,255,255,0.06), 0 0 40px rgba(255,255,255,0.03);
}

.char-card.selected {
    transform: translateY(-4px) scale(1.05);
    z-index: 3;
}

/* P1 side char cards */
.p1-side .char-card:hover { border-color: var(--p1); }
.p1-side .char-card.selected {
    border-color: var(--p1);
    box-shadow:
        0 0 30px rgba(0,153,255,0.5),
        0 0 60px rgba(0,153,255,0.2),
        inset 0 0 30px rgba(0,153,255,0.08);
    background: linear-gradient(180deg, rgba(0,20,60,0.6) 0%, rgba(0,10,40,0.7) 100%);
}

/* P2 side char cards */
.p2-side .char-card:hover { border-color: var(--p2); }
.p2-side .char-card.selected {
    border-color: var(--p2);
    box-shadow:
        0 0 30px rgba(255,51,0,0.5),
        0 0 60px rgba(255,51,0,0.2),
        inset 0 0 30px rgba(255,51,0,0.08);
    background: linear-gradient(180deg, rgba(60,10,0,0.6) 0%, rgba(40,5,0,0.7) 100%);
}

.char-card-portrait {
    width: 100%;
    height: 120px;
    overflow: hidden;
    margin-bottom: 8px;
    background: rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.03);
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.char-card-portrait img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    object-position: center bottom;
    transition: transform 0.2s ease;
}

.char-card:hover .char-card-portrait img { transform: scale(1.08); }
.char-card.selected .char-card-portrait img { transform: scale(1.1); }

.char-card-info {
    width: 100%;
    text-align: center;
    margin-top: 4px;
}

.char-name {
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.14em;
    margin-bottom: 4px;
    color: var(--gold);
    text-transform: uppercase;
    text-shadow: 0 0 10px var(--gold-glow);
}

.char-card.selected .char-name {
    color: var(--gold);
    text-shadow: 0 0 15px var(--gold-glow);
}

.p1-side .char-card.selected .char-name {
    color: var(--p1-light);
    text-shadow: 0 0 10px var(--p1-glow);
}

.p2-side .char-card.selected .char-name {
    color: var(--cpu-light);
    text-shadow: 0 0 10px var(--cpu-glow);
}

.char-stats { width: 100%; padding: 0 4px; }
.stat { display: flex; align-items: center; gap: 3px; margin: 2px 0; }
.stat-label {
    font-size: 0.4rem;
    color: #4a5577;
    width: 20px;
    text-align: right;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}
.stat-bar {
    flex: 1;
    height: 3px;
    background: rgba(255,255,255,0.04);
    overflow: hidden;
}
.stat-fill {
    height: 100%;
    background: #334;
    transition: background 0.2s, box-shadow 0.3s;
}
.char-card.selected .stat-fill { animation: stat-pulse 0.6s ease-in-out; }
@keyframes stat-pulse {
    0% { filter: brightness(1); }
    50% { filter: brightness(1.8); }
    100% { filter: brightness(1); }
}

.p1-side .char-card.selected .stat-fill { background: var(--p1); box-shadow: 0 0 6px var(--p1-glow); }
.p2-side .char-card.selected .stat-fill { background: var(--p2); box-shadow: 0 0 6px var(--p2-glow); }

/* VS DIVIDER */
.char-select-vs {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 80px;
    flex-shrink: 0;
    position: relative;
}

.char-select-vs::before {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: 50%;
    width: 2px;
    background: linear-gradient(180deg,
        transparent 0%,
        var(--p1) 15%,
        var(--gold) 50%,
        var(--p2) 85%,
        transparent 100%);
    box-shadow: 0 0 12px rgba(255,215,0,0.3);
}

.vs-text {
    position: relative;
    z-index: 1;
    font-size: 2.8rem;
    font-weight: 900;
    color: var(--gold);
    letter-spacing: 0.1em;
    background: linear-gradient(180deg, rgba(12,12,32,0.98) 0%, rgba(8,8,24,0.99) 100%);
    padding: 14px 10px;
    border: 2px solid var(--gold);
    text-shadow:
        0 0 20px var(--gold-glow),
        0 0 50px rgba(255,215,0,0.3);
    writing-mode: vertical-lr;
    text-orientation: upright;
    box-shadow:
        0 0 20px rgba(255,215,0,0.25),
        inset 0 0 20px rgba(255,215,0,0.06);
    animation: vs-glow 1.5s ease-in-out infinite alternate;
}

@keyframes vs-glow {
    from { box-shadow: 0 0 15px rgba(255,215,0,0.2), inset 0 0 15px rgba(255,215,0,0.04); }
    to { box-shadow: 0 0 30px rgba(255,215,0,0.4), inset 0 0 25px rgba(255,215,0,0.08); }
}

/* RANDOM CARD */
.char-card.card-random {
    border-style: dashed !important;
    border-color: #333 !important;
}

.char-card.card-random .char-card-portrait {
    background: rgba(255,215,0,0.02);
}

.random-icon {
    font-size: 2rem;
    font-weight: 900;
    color: var(--gold);
    opacity: 0.4;
    transition: all 0.2s;
    text-shadow: none;
}

.card-random:hover .random-icon {
    opacity: 0.9;
    text-shadow: 0 0 15px var(--gold-glow);
}

.card-random.selected .random-icon {
    opacity: 1;
    animation: rand-spin 0.5s ease-in-out;
    text-shadow: 0 0 20px var(--gold-glow);
}

@keyframes rand-spin {
    0% { transform: rotateY(0); }
    50% { transform: rotateY(180deg); }
    100% { transform: rotateY(360deg); }
}

/* ================================================
   STAGE SELECT
   ================================================ */
.stage-preview-area {
    position: relative;
    width: min(520px, 75vw);
    height: 150px;
    margin-bottom: 0.6em;
    border: 1px solid var(--border);
    overflow: hidden;
    z-index: 2;
}

.stage-preview-img {
    width: 100%; height: 100%;
    object-fit: cover;
    filter: brightness(0.5) saturate(1.2);
}

.stage-preview-name {
    position: absolute;
    bottom: 8px; left: 12px;
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    font-weight: 900;
    letter-spacing: 0.12em;
    color: var(--gold);
    text-shadow:
        0 0 15px var(--gold-glow),
        0 2px 4px rgba(0,0,0,0.9);
    z-index: 2;
    text-transform: uppercase;
}

.stage-carousel {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 1.2em;
    z-index: 2;
}

.carousel-arrow {
    width: 36px; height: 36px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-dim);
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    clip-path: polygon(4px 0, 100% 0, calc(100% - 4px) 100%, 0 100%);
}

.carousel-arrow:hover {
    border-color: var(--p1);
    color: var(--p1-light);
    box-shadow: 0 0 12px var(--p1-glow);
}

.stage-cards {
    display: flex;
    gap: 6px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    padding: 6px 0;
    max-width: 70vw;
}
.stage-cards::-webkit-scrollbar { display: none; }

.stage-card {
    flex-shrink: 0;
    width: 110px;
    scroll-snap-align: center;
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}

.stage-card-inner {
    border: 2px solid var(--border);
    overflow: hidden;
    transition: all 0.2s;
}

.stage-card-img,
.stage-card-inner img {
    width: 100%;
    height: 70px;
    object-fit: cover;
    display: block;
    filter: brightness(0.4) saturate(0.8);
    transition: all 0.2s;
}

.stage-card:hover .stage-card-inner {
    border-color: var(--p1);
    transform: translateY(-2px);
    box-shadow: 0 0 15px var(--p1-glow);
}
.stage-card:hover .stage-card-inner img,
.stage-card:hover .stage-card-img {
    filter: brightness(0.7) saturate(1.1);
}

.stage-card.active .stage-card-inner,
.stage-card.selected .stage-card-inner {
    border-color: var(--gold);
    transform: translateY(-2px);
    box-shadow: 0 0 20px var(--gold-glow);
}
.stage-card.active .stage-card-inner img,
.stage-card.active .stage-card-img,
.stage-card.selected .stage-card-inner img,
.stage-card.selected .stage-card-img {
    filter: brightness(0.9) saturate(1.3);
}
.stage-card.active .stage-name,
.stage-card.selected .stage-name {
    color: var(--gold);
    text-shadow: 0 0 10px var(--gold-glow);
}

.stage-name,
.stage-card-name {
    display: block;
    margin-top: 4px;
    font-size: 0.5rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--text-dim);
    text-transform: uppercase;
}

/* ================================================
   LOADING SCREEN
   ================================================ */
#loading-screen { z-index: 50; }

.loading-inner {
    text-align: center;
    z-index: 2;
}

.loading-bar-outer {
    width: min(400px, 80vw);
    height: 6px;
    background: rgba(255,255,255,0.04);
    border: 1px solid var(--border);
    overflow: hidden;
    margin: 0 auto 12px;
    clip-path: polygon(3px 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

.loading-bar-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--gold) 0%, #ffee88 100%);
    transition: width 0.15s;
    box-shadow: 0 0 8px var(--gold-glow);
    position: relative;
}

.loading-bar-fill::after {
    content: '';
    position: absolute;
    right: 0; top: -2px; bottom: -2px;
    width: 20px;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4));
    animation: loading-shine 1s ease-in-out infinite;
}

@keyframes loading-shine {
    0%, 100% { opacity: 0; }
    50% { opacity: 1; }
}

.loading-text {
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ================================================
   IN-GAME HUD — TEKKEN 8 STYLE
   ================================================ */
#in-game-hud {
    position: absolute;
    top: 0; left: 0;
    width: 100%;
    z-index: 8;
    pointer-events: none;
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    padding: 4px 6px 0;
}

.hud-side {
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    width: min(40vw, 520px);
}

.hud-left { align-items: flex-start; }
.hud-right { align-items: flex-end; }

.hud-top-row {
    display: flex;
    align-items: flex-start;
    gap: 5px;
    width: 100%;
}
.hud-right .hud-top-row { flex-direction: row-reverse; }

.hud-portrait-frame {
    position: relative;
    width: clamp(48px, 6vw, 64px);
    height: clamp(48px, 6vw, 64px);
    flex-shrink: 0;
    border: 3px solid var(--p1);
    overflow: hidden;
    clip-path: polygon(0 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%);
    box-shadow: 0 0 15px var(--p1-glow);
    animation: portrait-glow-p1 2s ease-in-out infinite alternate;
}

.hud-right .hud-portrait-frame {
    border-color: var(--p2);
    clip-path: polygon(0 0, 100% 0, 100% 100%, 8px 100%, 0 calc(100% - 8px));
    box-shadow: 0 0 15px var(--p2-glow);
    animation: portrait-glow-p2 2s ease-in-out infinite alternate;
}

@keyframes portrait-glow-p1 {
    from { box-shadow: 0 0 10px var(--p1-glow); }
    to { box-shadow: 0 0 20px var(--p1-glow), 0 0 40px rgba(0,153,255,0.15); }
}

@keyframes portrait-glow-p2 {
    from { box-shadow: 0 0 10px var(--p2-glow); }
    to { box-shadow: 0 0 20px var(--p2-glow), 0 0 40px rgba(255,51,0,0.15); }
}

.hud-portrait {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: top center;
    display: block;
}

.hud-bars-group {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.hud-name-row {
    display: flex;
    align-items: center;
}

.hud-name {
    font-size: clamp(0.45rem, 0.8vw, 0.6rem);
    font-weight: 900;
    letter-spacing: 0.14em;
    text-transform: uppercase;
    padding: 1px 8px;
    min-width: 60px;
    text-align: center;
    background: rgba(0,0,0,0.5);
}

.hud-left .hud-name {
    color: var(--p1-light);
    border-left: 2px solid var(--p1);
    text-shadow: 0 0 8px var(--p1-glow);
}

.hud-right .hud-name {
    color: var(--cpu-light);
    border-right: 2px solid var(--cpu);
    border-left: none;
    text-shadow: 0 0 8px var(--cpu-glow);
}

/* HP BAR */
.hud-bar {
    width: 100%;
    position: relative;
    overflow: hidden;
}

.hud-hp-bar {
    width: 100%;
    height: var(--tekken-hp-height);
    background: #080814;
    position: relative;
    overflow: hidden;
    border: var(--tekken-hp-frame) solid #1a1a44;
    clip-path: polygon(0 0, 100% 0, calc(100% - 6px) 100%, 0 100%);
}

.hud-right .hud-hp-bar {
    clip-path: polygon(6px 0, 100% 0, 100% 100%, 0 100%);
}

.hud-hp-bar::after {
    content: '';
    position: absolute;
    inset: 0;
    border: 1px solid rgba(255,255,255,0.06);
    pointer-events: none;
    z-index: 3;
}

.hud-hp-fill {
    height: 100%; width: 100%;
    transition: width 0.3s ease-out;
    position: relative;
    z-index: 2;
}

.player-hp {
    background: linear-gradient(90deg, #003366 0%, #0066aa 30%, var(--p1) 70%, var(--p1-light) 100%);
    box-shadow: 0 0 12px var(--p1-glow), inset 0 1px 0 rgba(255,255,255,0.15);
}

.hud-right .player-hp {
    background: linear-gradient(270deg, #330000 0%, #660000 30%, #cc2200 70%, #ff4422 100%);
    box-shadow: 0 0 12px var(--p2-glow), inset 0 1px 0 rgba(255,255,255,0.15);
}

.cpu-hp {
    background: linear-gradient(270deg, #993300 0%, #cc3300 60%, #ff5533 100%);
    box-shadow: 0 0 10px var(--cpu-glow);
}

.hud-right .hud-hp-fill { float: right; }

.hud-hp-fill.low {
    animation: hp-critical 0.3s ease-in-out infinite alternate;
}

@keyframes hp-critical {
    from { filter: brightness(1); }
    to { filter: brightness(1.5); }
}

/* RAGE INDICATOR */
.rage-indicator {
    position: absolute;
    inset: -2px;
    border: 2px solid var(--danger);
    box-shadow: 0 0 15px rgba(255,34,34,0.5), inset 0 0 15px rgba(255,34,34,0.15);
    animation: rage-glow-pulse 0.6s ease-in-out infinite alternate;
    pointer-events: none;
    z-index: 5;
}

@keyframes rage-glow-pulse {
    from { opacity: 0.5; box-shadow: 0 0 10px rgba(255,34,34,0.3), inset 0 0 10px rgba(255,34,34,0.1); }
    to { opacity: 1; box-shadow: 0 0 20px rgba(255,34,34,0.6), inset 0 0 20px rgba(255,34,34,0.2); }
}

.hud-hp-damage {
    position: absolute;
    top: 0; height: 100%;
    width: 100%;
    background: rgba(255,255,255,0.25);
    z-index: 1;
    transition: width 0.6s ease-out 0.2s;
}

.hud-left .hud-hp-damage { left: 0; }
.hud-right .hud-hp-damage { right: 0; }

/* KI BAR */
.hud-ki-bar {
    width: 100%;
    height: clamp(5px, 0.8vw, 7px);
    background: #080814;
    position: relative;
    overflow: hidden;
    border: 1px solid #1a1a44;
    clip-path: polygon(0 0, 100% 0, calc(100% - 3px) 100%, 0 100%);
}

.hud-right .hud-ki-bar {
    clip-path: polygon(3px 0, 100% 0, 100% 100%, 0 100%);
}

.hud-ki-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #004466 0%, #0088aa 40%, var(--ki) 100%);
    transition: width 0.15s;
    box-shadow: 0 0 8px rgba(0,221,255,0.4);
}

.hud-right .hud-ki-fill {
    float: right;
    background: linear-gradient(270deg, #004466 0%, #0088aa 40%, var(--ki) 100%);
}

.hud-ki-fill.full {
    background: linear-gradient(90deg, var(--ki) 0%, var(--gold) 100%) !important;
    animation: ki-full 0.5s ease-in-out infinite alternate;
    box-shadow: 0 0 12px var(--gold-glow);
}

.hud-right .hud-ki-fill.full {
    background: linear-gradient(270deg, var(--ki) 0%, var(--gold) 100%) !important;
}

@keyframes ki-full {
    from { filter: brightness(1); }
    to { filter: brightness(1.4); }
}

/* STUN BAR */
.hud-stun-bar {
    height: 3px;
    background: rgba(255,255,255,0.08);
    overflow: hidden;
    margin-top: 1px;
}

.hud-stun-fill {
    height: 100%; width: 0%;
    background: linear-gradient(90deg, #aa44ff, #ff44ff);
    transition: width 0.15s ease-out;
}

.hud-stun-fill.full {
    background: linear-gradient(90deg, #ff00ff, #ff0044);
    box-shadow: 0 0 8px rgba(255,0,255,0.6);
    animation: stun-pulse 0.3s ease-in-out infinite alternate;
}

@keyframes stun-pulse {
    from { opacity: 0.7; }
    to { opacity: 1; }
}

/* WIN MARKERS */
.hud-win-markers {
    display: flex;
    align-items: center;
    gap: 4px;
    margin: 1px 0;
}

.win-marker {
    display: inline-block;
    width: 10px; height: 10px;
    background: #1a1a3a;
    border: 1px solid #333;
    transform: rotate(45deg);
    transition: all 0.3s ease;
}

.win-marker.won {
    background: var(--gold);
    border-color: var(--gold);
    box-shadow: 0 0 8px var(--gold-glow);
}

.win-marker.lost {
    background: #1a1a3a;
    border-color: #333;
}

/* FINISHER LABEL */
.hud-finisher-label {
    font-size: clamp(0.3rem, 0.6vw, 0.42rem);
    font-weight: 900;
    letter-spacing: 0.14em;
    color: var(--gold);
    animation: f-blink 0.5s ease-in-out infinite alternate;
    text-shadow: 0 0 8px var(--gold-glow);
}

@keyframes f-blink {
    from { opacity: 0.2; }
    to { opacity: 1; }
}

/* TIMER */
.hud-center {
    position: absolute;
    top: 2px; left: 50%;
    transform: translateX(-50%);
    z-index: 9;
}

.hud-timer {
    background: linear-gradient(180deg, #0c0c20 0%, #080818 100%);
    border: 3px solid var(--border-bright);
    padding: 2px 18px 4px;
    min-width: 70px;
    text-align: center;
    clip-path: polygon(8px 0, calc(100% - 8px) 0, 100% 50%, calc(100% - 8px) 100%, 8px 100%, 0 50%);
    box-shadow: 0 0 12px rgba(0,100,200,0.2), inset 0 0 10px rgba(0,0,0,0.5);
}

.hud-timer-text {
    font-size: clamp(1.2rem, 2.8vw, 1.8rem);
    font-weight: 900;
    color: #fff;
    font-family: 'Arial Black', sans-serif;
    line-height: 1.2;
    text-shadow: 0 0 10px rgba(0,150,255,0.3);
}

.hud-timer-text.timer-urgent {
    color: var(--danger);
    animation: timer-flash 0.4s ease-in-out infinite alternate;
    text-shadow: 0 0 15px rgba(255,34,34,0.5);
}

@keyframes timer-flash {
    from { color: var(--danger); text-shadow: 0 0 15px rgba(255,34,34,0.5); }
    to { color: var(--gold); text-shadow: 0 0 20px var(--gold-glow); }
}

/* FINISHER TEXT (center screen) */
.hud-finisher-text {
    position: absolute;
    top: 35%; left: 50%;
    transform: translateX(-50%);
    font-size: clamp(0.8rem, 1.5vw, 1.1rem);
    font-weight: 900;
    color: var(--gold);
    letter-spacing: 0.22em;
    animation: slam 0.3s ease-out;
    white-space: nowrap;
    z-index: 9;
    text-shadow:
        0 0 25px var(--gold-glow),
        0 0 50px rgba(255,215,0,0.3),
        0 2px 0 #886600;
}

@keyframes slam {
    0% { transform: translateX(-50%) scale(2.5); opacity: 0; }
    60% { transform: translateX(-50%) scale(0.92); }
    100% { transform: translateX(-50%) scale(1); opacity: 1; }
}

/* ================================================
   COUNTER HIT TEXT
   ================================================ */
.counter-hit-text {
    position: absolute;
    top: 30%; left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-family: 'Impact', 'Arial Black', sans-serif;
    font-size: 3.5rem;
    font-weight: 900;
    color: #ff4400;
    text-shadow: 0 0 20px #ff4400, 0 0 40px #ff2200, 2px 2px 0 #000;
    letter-spacing: 0.15em;
    z-index: 20;
    pointer-events: none;
    transition: transform 0.08s ease-out, opacity 0.3s ease-out;
}

.counter-hit-text.show {
    transform: translate(-50%, -50%) scale(1.2);
    opacity: 1;
}

.counter-hit-text.hide {
    transform: translate(-50%, -50%) scale(0.8);
    opacity: 0;
}

/* ================================================
   RESULT SCREENS
   ================================================ */
.result-character-portrait {
    position: relative;
    width: clamp(120px, 18vw, 200px);
    height: clamp(120px, 18vw, 200px);
    margin-bottom: 0.4em;
    z-index: 2;
    border: 4px solid var(--p1);
    overflow: hidden;
    clip-path: polygon(0 0, calc(100% - 16px) 0, 100% 16px, 100% 100%, 16px 100%, 0 calc(100% - 16px));
    box-shadow: 0 0 40px var(--p1-glow), 0 0 80px rgba(0,153,255,0.15);
}

.result-character-portrait img {
    width: 100%; height: 100%;
    object-fit: cover;
    object-position: top center;
}

.result-title {
    font-size: clamp(3rem, 10vw, 7rem);
    font-weight: 900;
    margin-bottom: 0.08em;
    letter-spacing: 0.08em;
    z-index: 2;
    position: relative;
    animation: r-slam 0.5s ease-out;
    text-transform: uppercase;
}

.victory-title {
    color: var(--p1-light);
    text-shadow:
        0 0 40px var(--p1-glow),
        0 0 80px rgba(0,153,255,0.3),
        0 4px 0 #003366;
}

.defeat-title {
    color: var(--p2);
    text-shadow:
        0 0 40px var(--p2-glow),
        0 0 80px rgba(255,51,0,0.3),
        0 4px 0 #330000;
}

@keyframes r-slam {
    0% { transform: scale(3.5); opacity: 0; filter: blur(8px); }
    55% { transform: scale(0.92); filter: blur(0); }
    100% { transform: scale(1); opacity: 1; filter: blur(0); }
}

.result-subtitle {
    font-size: clamp(0.9rem, 2.2vw, 1.5rem);
    font-weight: 700;
    margin-bottom: 1em;
    letter-spacing: 0.1em;
    z-index: 2;
    position: relative;
    color: var(--text-dim);
    text-transform: uppercase;
}

/* ROUND RESULT */
#round-result-screen {
    z-index: 12;
}

.round-result-title {
    font-size: clamp(2rem, 6vw, 4rem);
    font-weight: 900;
    color: var(--gold);
    margin-bottom: 0.3em;
    animation: r-slam 0.5s ease-out;
    text-shadow:
        0 0 30px var(--gold-glow),
        0 0 60px rgba(255,215,0,0.2);
    text-transform: uppercase;
}

.round-result-sub {
    font-size: clamp(1rem, 2.5vw, 1.5rem);
    font-weight: 700;
    color: var(--text-dim);
    margin-bottom: 1.5em;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

/* MATCH RESULT */
.match-result-title {
    font-size: clamp(1.5rem, 5vw, 3rem);
    font-weight: 900;
    color: var(--gold);
    margin-bottom: 0.3em;
    animation: r-slam 0.5s ease-out;
    text-shadow:
        0 0 25px var(--gold-glow),
        0 0 50px rgba(255,215,0,0.2);
    text-transform: uppercase;
}

.match-result-score {
    font-size: clamp(2rem, 5vw, 3.5rem);
    font-weight: 900;
    color: var(--text);
    margin-bottom: 1em;
    letter-spacing: 0.14em;
    text-shadow: 0 0 15px rgba(255,255,255,0.15);
}

/* ================================================
   PAUSE MENU
   ================================================ */
#pause-menu {
    background: rgba(5,5,18,0.96);
}

/* ================================================
   CONTROL GUIDE (in-game)
   ================================================ */
#control-guide {
    position: absolute;
    top: 50%; left: 4px;
    transform: translateY(-50%);
    z-index: 5;
}

#guide-toggle {
    background: rgba(5,5,18,0.85);
    border: 1px solid var(--border);
    color: var(--text-dim);
    font-size: 8px;
    font-weight: 800;
    padding: 3px 6px;
    cursor: pointer;
    margin-bottom: 2px;
    display: block;
    font-family: inherit;
}

#guide-toggle:hover {
    color: var(--p1-light);
    border-color: var(--p1);
}

#guide-content {
    background: rgba(5,5,18,0.85);
    border: 1px solid var(--border);
    padding: 4px 6px;
    display: none;
    min-width: 130px;
}

#control-guide.expanded #guide-content { display: block; }

.guide-section { margin-bottom: 2px; }
.guide-section:last-child { margin-bottom: 0; }

.guide-section h4 {
    font-size: 6px;
    color: var(--p1-light);
    letter-spacing: 0.12em;
    margin-bottom: 1px;
    border-bottom: 1px solid rgba(0,153,255,0.1);
    padding-bottom: 1px;
    text-transform: uppercase;
}

.guide-section p {
    font-size: 7px;
    color: #556688;
    margin: 1px 0;
    line-height: 1.3;
}

.guide-section kbd {
    font-size: 6px;
    padding: 0 3px;
    min-width: 12px;
}

/* ================================================
   MENU KEYBOARD HINTS
   ================================================ */
.menu-keyhints {
    display: flex;
    gap: 26px;
    align-items: center;
    justify-content: center;
    margin-top: 1.4em;
    z-index: 2;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.14em;
    color: var(--text-dim);
    text-transform: uppercase;
}

.menu-keyhints kbd {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.14);
    color: #aabbee;
    margin: 0 1px;
}

.char-keyhints {
    gap: 40px;
    margin-top: 0.8em;
}

.kh-p1 b { color: var(--p1-light); }
.kh-p2 b { color: var(--cpu-light); }

/* ================================================
   KEYBOARD NAVIGATION
   ================================================ */
.kb-active {
    position: relative;
}

.kb-active::after {
    content: '';
    position: absolute;
    inset: -4px;
    border: 2px solid var(--gold);
    box-shadow: 0 0 14px var(--gold-glow), inset 0 0 10px rgba(255,215,0,0.08);
    pointer-events: none;
    animation: kb-pulse 0.9s ease-in-out infinite alternate;
}

.diff-card.kb-active::after { inset: -6px; }

/* Keyboard nav cursors for char select */
.char-card.kb-nav-p1,
.char-card.kb-nav-p2 {
    transform: translateY(-3px);
}

.char-card.kb-nav-p1::after,
.char-card.kb-nav-p2::after {
    content: '▼';
    position: absolute;
    top: -20px; left: 50%;
    transform: translateX(-50%);
    font-size: 0.7rem;
    line-height: 1;
    pointer-events: none;
    animation: kb-bounce 0.7s ease-in-out infinite alternate;
}

.char-card.kb-nav-p1::after {
    color: var(--p1-light);
    text-shadow: 0 0 10px var(--p1-glow);
}

.char-card.kb-nav-p2::after {
    color: var(--cpu-light);
    text-shadow: 0 0 10px var(--cpu-glow);
}

@keyframes kb-pulse {
    from { opacity: 0.55; }
    to { opacity: 1; }
}

@keyframes kb-bounce {
    from { transform: translateX(-50%) translateY(0); }
    to { transform: translateX(-50%) translateY(4px); }
}

/* ================================================
   GAMEPAD HINT
   ================================================ */
.gamepad-hint {
    position: absolute;
    bottom: 30px; left: 50%;
    transform: translateX(-50%);
    z-index: 11;
    font-size: 0.65rem;
    color: var(--text-dim);
    letter-spacing: 0.1em;
    animation: gp-pulse 1.5s ease-in-out infinite alternate;
}

.gamepad-hint kbd {
    background: rgba(0,153,255,0.1);
    border-color: rgba(0,153,255,0.3);
    color: var(--p1-light);
}

@keyframes gp-pulse {
    from { opacity: 0.3; }
    to { opacity: 1; }
}

/* ================================================
   COMBO DISPLAY
   ================================================ */
#combo-display {
    position: absolute;
    bottom: 18%; left: 50%;
    transform: translateX(-50%);
    z-index: 15;
    pointer-events: none;
    text-align: center;
    transition: transform 0.1s ease-out, opacity 0.3s;
}

#combo-display .combo-number,
.combo-number {
    display: block;
    font-size: clamp(3rem, 8vw, 5rem);
    font-weight: 900;
    font-family: 'Arial Black', sans-serif;
    line-height: 1;
    color: #fff;
    text-shadow:
        0 0 20px rgba(255,255,255,0.5),
        0 4px 0 rgba(0,0,0,0.6);
    transition: color 0.2s;
}

#combo-display .combo-label,
.combo-label {
    display: block;
    font-size: clamp(0.8rem, 2vw, 1.2rem);
    font-weight: 900;
    letter-spacing: 0.3em;
    color: var(--gold);
    text-shadow: 0 0 15px var(--gold-glow);
}

#combo-display .combo-sub,
.combo-sub {
    display: block;
    font-size: clamp(0.5rem, 1.2vw, 0.7rem);
    font-weight: 700;
    letter-spacing: 0.2em;
    color: var(--text-dim);
}

/* Combo color escalation */
#combo-display.combo-white .combo-number {
    color: #fff;
    text-shadow: 0 0 20px rgba(255,255,255,0.5), 0 4px 0 rgba(0,0,0,0.6);
}

#combo-display.combo-yellow .combo-number {
    color: #ffcc00;
    text-shadow: 0 0 20px rgba(255,204,0,0.5), 0 4px 0 rgba(0,0,0,0.6);
}

#combo-display.combo-orange .combo-number {
    color: #ff8800;
    text-shadow: 0 0 25px rgba(255,136,0,0.5), 0 4px 0 rgba(0,0,0,0.6);
}

#combo-display.combo-red .combo-number {
    color: #ff2222;
    text-shadow: 0 0 30px rgba(255,34,34,0.6), 0 4px 0 rgba(0,0,0,0.6);
}

/* ================================================
   KI MESSAGE
   ================================================ */
#ki-message {
    position: absolute;
    top: 45%; left: 50%;
    transform: translate(-50%, -50%);
    font-size: clamp(1rem, 2.5vw, 1.6rem);
    font-weight: 900;
    letter-spacing: 0.2em;
    color: var(--danger);
    text-shadow: 0 0 20px rgba(255,34,34,0.5), 0 2px 0 #330000;
    z-index: 15;
    animation: ki-msg-slam 0.3s ease-out;
    text-transform: uppercase;
}

@keyframes ki-msg-slam {
    0% { transform: translate(-50%, -50%) scale(2); opacity: 0; }
    60% { transform: translate(-50%, -50%) scale(0.95); }
    100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

/* ================================================
   HINTS
   ================================================ */
#hints {
    position: absolute;
    bottom: 25px; left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    font-size: 0.65rem;
    color: rgba(255,255,255,0.2);
    pointer-events: none;
    white-space: nowrap;
}

#hints kbd {
    background: rgba(255,255,255,0.05);
    border-color: rgba(255,255,255,0.1);
}

/* ================================================
   TOUCH CONTROLS
   ================================================ */
#touch-controls {
    position: absolute;
    inset: 0;
    z-index: 30;
    pointer-events: none;
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    padding: 0 12px calc(14px + env(safe-area-inset-bottom, 0px));
}

#touch-controls.hidden { display: none !important; }

.tc-btn {
    pointer-events: auto;
    touch-action: none;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
    border: 2px solid rgba(255,255,255,0.28);
    background: rgba(8,8,26,0.5);
    color: #eef2ff;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-family: inherit;
    cursor: pointer;
    backdrop-filter: blur(2px);
    transition: transform 0.06s, background 0.06s, border-color 0.06s;
}

.tc-btn span {
    font-size: 0.62rem;
    font-weight: 900;
    letter-spacing: 0.04em;
    line-height: 1;
}

.tc-btn small {
    font-size: 0.3rem;
    font-weight: 700;
    letter-spacing: 0.1em;
    color: #9db2d9;
    margin-top: 2px;
}

.tc-btn.tc-active {
    background: rgba(255,215,0,0.32) !important;
    border-color: var(--gold) !important;
    transform: scale(0.92);
}

/* D-PAD */
.tc-left {
    display: grid;
    grid-template-columns: repeat(3, var(--tc, 52px));
    grid-template-rows: repeat(3, var(--tc, 52px));
    gap: 5px;
}

.tc-dir {
    background: rgba(10,10,32,0.55);
    font-size: 0.9rem;
    color: #cdd8f2;
}

.tc-dup { grid-column: 2; grid-row: 1; }
.tc-dleft { grid-column: 1; grid-row: 2; }
.tc-dright { grid-column: 3; grid-row: 2; }
.tc-ddown { grid-column: 2; grid-row: 3; }

/* ACTION CLUSTER */
.tc-right {
    display: flex;
    flex-direction: column;
    gap: 7px;
    align-items: flex-end;
}

.tc-row {
    display: flex;
    gap: 7px;
}

.tc-row-main {
    display: flex;
    gap: 7px;
}

.tc-atk {
    width: var(--tc, 52px);
    height: var(--tc, 52px);
    background: rgba(0,50,110,0.55);
    border-color: rgba(0,153,255,0.55);
}

.tc-ki {
    width: calc(var(--tc, 52px) - 8px);
    height: calc(var(--tc, 52px) - 8px);
    background: rgba(0,70,80,0.55);
    border-color: rgba(0,221,255,0.45);
}

.tc-extra {
    width: calc(var(--tc, 52px) - 16px);
    height: calc(var(--tc, 52px) - 16px);
    background: rgba(70,40,0,0.5);
    border-color: rgba(255,160,0,0.45);
}

.tc-extra span,
.tc-ki span {
    font-size: 0.5rem;
}

.tc-pause {
    position: absolute;
    top: 52px; right: 10px;
    width: 38px; height: 38px;
    font-size: 0.8rem;
    font-weight: 900;
    background: rgba(8,8,26,0.6);
}

/* ================================================
   ROTATE DEVICE HINT
   ================================================ */
#rotate-hint {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9998;
    background: rgba(3,3,14,0.97);
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 14px;
    text-align: center;
}

#rotate-hint .rh-icon {
    font-size: 3.2rem;
    color: var(--gold);
    text-shadow: 0 0 25px var(--gold-glow);
    animation: rh-turn 2.2s ease-in-out infinite;
}

#rotate-hint .rh-text {
    font-size: 0.8rem;
    font-weight: 900;
    letter-spacing: 0.18em;
    color: var(--text);
    text-transform: uppercase;
    line-height: 1.7;
}

#rotate-hint .rh-text span {
    font-size: 0.55rem;
    font-weight: 700;
    color: var(--text-dim);
    letter-spacing: 0.14em;
}

@keyframes rh-turn {
    0%, 25% { transform: rotate(0deg); }
    60%, 100% { transform: rotate(90deg); }
}

/* ================================================
   SCREEN TRANSITIONS
   ================================================ */
.screen-fade-out {
    animation: screen-fadeout 0.3s ease-in forwards;
}

.screen-fade-in {
    animation: screen-fadein 0.3s ease-out forwards;
}

@keyframes screen-fadeout {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes screen-fadein {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ================================================
   KEYFRAME ANIMATIONS
   ================================================ */
@keyframes glow-pulse-gold {
    0%, 100% { box-shadow: 0 0 10px var(--gold-glow); }
    50% { box-shadow: 0 0 30px var(--gold-glow), 0 0 60px rgba(255,215,0,0.15); }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    10%, 30%, 50%, 70%, 90% { transform: translateX(-3px); }
    20%, 40%, 60%, 80% { transform: translateX(3px); }
}

@keyframes pulse-glow {
    0%, 100% { box-shadow: 0 0 10px currentColor; }
    50% { box-shadow: 0 0 25px currentColor, 0 0 50px currentColor; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

@keyframes slide-up {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes slide-down {
    from { transform: translateY(-20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* ================================================
   DIZZY OVERLAY (JS-applied)
   ================================================ */
.dizzy-overlay {
    position: absolute;
    pointer-events: none;
    z-index: 10;
}

/* ================================================
   TOUCH MODE OVERRIDES
   ================================================ */
body.touch-mode .menu-keyhints { display: none; }
body.touch-mode #custom-cursor { display: none !important; }
body.touch-mode #game-container,
body.touch-mode #game-container * { cursor: auto !important; }

/* ================================================
   RESPONSIVE — TABLETS & SMALL LAPTOPS
   ================================================ */
@media (max-width: 980px) {
    .stage-cards { max-width: 82vw; }
    .char-select-layout { width: min(980px, 96vw); }
    .char-select-side { max-width: 360px; }
    .char-select-vs { width: 56px; }
}

/* ================================================
   RESPONSIVE — MOBILE
   ================================================ */
@media (max-width: 700px) {
    .char-select-layout {
        flex-direction: column;
        align-items: center;
        min-height: auto;
    }
    .char-select-side { max-width: 100%; width: 100%; }
    .char-select-vs {
        width: 100%;
        flex-direction: row;
        padding: 4px 0;
    }
    .char-select-vs::before {
        background: linear-gradient(90deg, transparent, var(--gold), transparent);
        width: 100%; height: 2px;
    }
    .vs-text {
        writing-mode: horizontal-tb;
        font-size: 1.2rem;
        padding: 4px 12px;
    }
    .char-cards-vertical { grid-template-columns: repeat(4, 1fr); gap: 4px; }
    .char-card { padding: 4px; }
    .char-card-portrait { max-height: 70px; }
    .char-name { font-size: 0.5rem; }
    .char-stats { display: none; }
    .diff-buttons { flex-direction: column; gap: 6px; }
    .controls-grid { flex-direction: column; gap: 6px; }
    #control-guide { display: none; }
    #combo-count { font-size: 1.8rem; }
    .hud-side { width: min(42vw, 320px); }
    .hud-name { font-size: 0.38rem; }
    .hud-hp-bar { height: 10px; }
    .hud-ki-bar { height: 3px; }
    .hud-timer-text { font-size: 0.85rem; }
    #key-guide-panel { width: 180px; }
    .stage-card { width: 90px; }
    .stage-card-inner img,
    .stage-card-img { height: 55px; }
    .hud-portrait-frame { width: 30px; height: 30px; }
    .stage-preview-area { height: 100px; }

    .btn-game { min-width: 200px; height: 40px; }
    .btn-label { font-size: 0.75rem; }
    .game-title { letter-spacing: 0.04em; }
    .result-title { letter-spacing: 0.03em; }

    .hud-left .hud-hp-bar { clip-path: polygon(0 0, 100% 0, calc(100% - 3px) 100%, 0 100%); }
    .hud-right .hud-hp-bar { clip-path: polygon(3px 0, 100% 0, 100% 100%, 0 100%); }
}

/* ================================================
   RESPONSIVE — SHORT LANDSCAPE
   ================================================ */
@media (max-height: 500px) and (orientation: landscape) {
    .game-title { font-size: clamp(1.6rem, 6vh, 2.6rem); margin-bottom: 0.1em; }
    .game-sub { margin-bottom: 1em; }
    .section-title { font-size: clamp(1rem, 4.5vh, 1.5rem); margin-bottom: 0.7em; }
    .menu-buttons { gap: 7px; }
    .mode-buttons { gap: 8px; }
    .btn-game { height: 38px; min-width: 220px; }
    .diff-card { padding: 8px 26px; min-width: 110px; }
    .diff-name { font-size: 0.9rem; }
    .char-select-layout { min-height: 300px; }
    .char-card-portrait { max-height: 78px; }
    .stage-preview-area { height: 100px; width: min(400px, 60vw); }
    .stage-card-inner img,
    .stage-card-img { height: 56px; }
    .result-title { font-size: clamp(1.8rem, 9vh, 3.4rem); }
    .menu-keyhints { margin-top: 0.8em; }
}

/* ================================================
   TOUCH DEVICE MEDIA QUERIES
   ================================================ */
@media (max-width: 860px) {
    #touch-controls { --tc: 46px; }
}

@media (max-height: 420px) {
    #touch-controls { --tc: 42px; }
    .tc-pause { width: 32px; height: 32px; top: 42px; }
}

@media (orientation: portrait) and (max-width: 860px) {
    body.touch-mode #rotate-hint { display: flex; }
}
