:root {
    --gold: #FFD700;
    --amber: #FF8C00;
    --red: #FF2233;
    --teal: #00E5CC;
    --dark: #080C14;
    --panel: rgba(8, 12, 20, 0.82);
    --border: rgba(255, 215, 0, 0.18);
}

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

body,
html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: var(--dark);
    font-family: 'Rajdhani', sans-serif;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
}

canvas {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ==========================
   PRELOADER
========================== */

#preloader{
    position:fixed;
    inset:0;
    z-index:99999;
    display:flex;
    align-items:center;
    justify-content:center;
    background:
        radial-gradient(circle at center,
        #1d1d1d 0%,
        #0d1117 60%,
        #000 100%);
    transition:opacity .6s ease, visibility .6s ease;
}

#preloader.hide{
    opacity:0;
    visibility:hidden;
    pointer-events:none;
}

.loader-wrap{
    width:320px;
    text-align:center;
}

.loader-rickshaw{
    font-size:70px;
    margin-bottom:25px;
    animation:bounce 1s infinite ease-in-out;
    filter:drop-shadow(0 0 20px rgba(255,215,0,.5));
}

.loader-title{
    font-family:'Orbitron',sans-serif;
    font-size:28px;
    font-weight:900;
    color:#fff;
    letter-spacing:2px;
    margin-bottom:25px;
}

.loader-title span{
    display:block;
    margin-top:6px;
    color:#FFD700;
}

.loader-bar{
    width:100%;
    height:10px;
    background:#222;
    border-radius:50px;
    overflow:hidden;
    border:1px solid rgba(255,215,0,.2);
}

.loader-progress{
    height:100%;
    width:0%;
    border-radius:50px;
    background:linear-gradient(90deg,#FFD700,#ff7b00,#FFD700);
    animation:loading 2.5s linear forwards;
}

.loader-text{
    margin-top:18px;
    color:#aaa;
    font-size:14px;
    letter-spacing:2px;
    animation:blink 1s infinite;
}

@keyframes loading{
    from{width:0%;}
    to{width:100%;}
}

@keyframes bounce{
    0%,100%{
        transform:translateY(0);
    }
    50%{
        transform:translateY(-12px);
    }
}

@keyframes blink{
    50%{
        opacity:.35;
    }
}

/* SCREENS */
.screen {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 20;
}

.screen::after {
    content: '';
    position: absolute;
    inset: 0;
    background: repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(0, 0, 0, 0.05) 2px, rgba(0, 0, 0, 0.05) 4px);
    pointer-events: none;
}

.screen>* {
    position: relative;
    z-index: 1;
}

/* START */
#screen-start {
    background: radial-gradient(ellipse at 50% 30%, rgba(255, 140, 0, 0.13) 0%, transparent 65%), radial-gradient(ellipse at 80% 80%, rgba(0, 229, 204, 0.07) 0%, transparent 55%), var(--dark);
}

.logo-eyebrow {
    font-family: 'Orbitron', monospace;
    font-size: 11px;
    letter-spacing: 6px;
    color: var(--teal);
    text-transform: uppercase;
    margin-bottom: 14px;
    opacity: .85;
}

.logo-main {
    font-family: 'Orbitron', monospace;
    font-size: clamp(2.8rem, 8vw, 5rem);
    font-weight: 900;
    line-height: .9;
    letter-spacing: -1px;
    color: #fff;
    text-align: center;
    margin-bottom: 48px;
}

.logo-main span {
    display: block;
    background: linear-gradient(135deg, var(--gold) 0%, var(--amber) 60%, #FF4500 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    filter: drop-shadow(0 0 24px rgba(255, 140, 0, 0.5));
}

.logo-sub {
    font-family: 'Rajdhani', sans-serif;
    font-size: 13px;
    font-weight: 600;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    -webkit-text-fill-color: unset;
    background: none;
    filter: none;
    margin-top: 10px;
}

.rickshaw-icon {
    width: 72px;
    height: 42px;
    margin: 0 auto 30px;
    filter: drop-shadow(0 0 12px rgba(255, 180, 0, 0.6));
}

.controls-hint {
    display: flex;
    gap: 20px;
    margin-bottom: 40px;
}

.hint-key {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}

.hint-key kbd {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    background: rgba(255, 255, 255, 0.06);
    border: 1.5px solid rgba(255, 255, 255, 0.18);
    border-bottom-width: 3px;
    border-radius: 7px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 16px;
    font-weight: 700;
    color: #fff;
}

.hint-key span {
    font-size: 10px;
    letter-spacing: 2px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
}

.btn-start {
    position: relative;
    padding: 0 52px;
    height: 58px;
    background: linear-gradient(135deg, var(--gold) 0%, var(--amber) 100%);
    border: none;
    border-radius: 3px;
    font-family: 'Orbitron', monospace;
    font-size: 14px;
    font-weight: 700;
    letter-spacing: 3px;
    color: #080C14;
    cursor: pointer;
    clip-path: polygon(12px 0%, 100% 0%, calc(100% - 12px) 100%, 0% 100%);
    box-shadow: 0 0 28px rgba(255, 140, 0, 0.3), 0 4px 16px rgba(0, 0, 0, 0.5);
}

.btn-start:hover {
    filter: brightness(1.1);
}

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

.version-badge {
    position: absolute;
    bottom: 20px;
    font-size: 10px;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.12);
    text-transform: uppercase;
}

.corner {
    position: absolute;
    width: 18px;
    height: 18px;
    border-color: rgba(255, 215, 0, 0.35);
    border-style: solid;
    opacity: .6;
}

.corner-tl {
    top: 8px;
    left: 8px;
    border-width: 2px 0 0 2px;
}

.corner-tr {
    top: 8px;
    right: 8px;
    border-width: 2px 2px 0 0;
}

.corner-bl {
    bottom: 8px;
    left: 8px;
    border-width: 0 0 2px 2px;
}

.corner-br {
    bottom: 8px;
    right: 8px;
    border-width: 0 2px 2px 0;
}

/* HUD — no backdrop-filter (GPU killer) */
#hud {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    display: none;
    padding: 14px 18px;
    pointer-events: none;
    z-index: 10;
}

.hud-inner {
    display: flex;
    align-items: stretch;
    justify-content: space-between;
    gap: 10px;
    max-width: 660px;
    margin: 0 auto;
}

.hud-panel {
    flex: 1;
    background: rgba(6, 9, 16, 0.88);
    border: 1px solid var(--border);
    border-radius: 2px;
    clip-path: polygon(8px 0%, 100% 0%, calc(100% - 8px) 100%, 0% 100%);
    padding: 9px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.hud-label {
    font-family: 'Orbitron', monospace;
    font-size: 8px;
    letter-spacing: 3px;
    color: rgba(255, 255, 255, 0.3);
    text-transform: uppercase;
    margin-bottom: 2px;
}

.hud-value {
    font-family: 'Orbitron', monospace;
    font-size: 25px;
    font-weight: 700;
    color: var(--gold);
    line-height: 1;
}

.hud-value.teal {
    color: var(--teal);
}

.lives-row {
    display: flex;
    gap: 5px;
    align-items: center;
    margin-top: 2px;
}

.heart {
    width: 17px;
    height: 17px;
    transition: opacity .3s;
}

.heart.dead {
    opacity: .15;
    filter: grayscale(1);
}

.speed-bar-track {
    width: 100%;
    height: 3px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 2px;
    margin-top: 5px;
    overflow: hidden;
}

.speed-bar-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--teal), var(--gold));
    border-radius: 2px;
    transition: width .3s ease;
    will-change: width;
}

/* DAMAGE FLASH */
#damage-flash {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 35%, rgba(255, 0, 30, 0.65) 100%);
    pointer-events: none;
    opacity: 0;
    z-index: 15;
}

/* MOBILE CONTROLS */
#mobile-controls {
    display: none;
    position: absolute;
    bottom: 26px;
    left: 0;
    right: 0;
    justify-content: space-between;
    padding: 0 26px;
    z-index: 10;
}

.ctrl-btn {
    width: 86px;
    height: 86px;
    background: rgba(6, 9, 16, 0.75);
    border: 2px solid rgba(255, 215, 0, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ctrl-btn:active {
    background: rgba(255, 215, 0, 0.15);
    border-color: var(--gold);
}

@media(min-width:769px) {
    #mobile-controls {
        display: none !important;
    }
}

/* GAME OVER */
#screen-gameover {
    display: none;
    background: rgba(6, 9, 16, 0.96);
}

.go-skull {
    font-size: 60px;
    margin-bottom: 10px;
    filter: drop-shadow(0 0 16px rgba(255, 30, 30, 0.6));
}

.go-title {
    font-family: 'Orbitron', monospace;
    font-size: clamp(2.4rem, 10vw, 4.2rem);
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 36px rgba(255, 30, 30, 0.55);
    margin-bottom: 6px;
}

.go-title em {
    font-style: normal;
    color: var(--red);
}

.go-subtitle {
    font-size: 12px;
    letter-spacing: 5px;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    margin-bottom: 32px;
}

.score-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border);
    border-radius: 3px;
    padding: 22px 44px;
    text-align: center;
    margin-bottom: 32px;
}

.score-card-label {
    font-size: 10px;
    letter-spacing: 4px;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    margin-bottom: 5px;
}

.score-card-value {
    font-family: 'Orbitron', monospace;
    font-size: clamp(2rem, 7vw, 3.2rem);
    font-weight: 900;
    color: var(--gold);
    text-shadow: 0 0 24px rgba(255, 215, 0, 0.45);
}

.rank-badge {
    font-size: 11px;
    letter-spacing: 3px;
    text-transform: uppercase;
    color: var(--teal);
    margin-top: 7px;
}

.btn-restart {
    padding: 0 44px;
    height: 54px;
    background: transparent;
    border: 2px solid var(--gold);
    border-radius: 2px;
    font-family: 'Orbitron', monospace;
    font-size: 13px;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--gold);
    cursor: pointer;
    clip-path: polygon(10px 0%, 100% 0%, calc(100% - 10px) 100%, 0% 100%);
}

.btn-restart:hover {
    background: rgba(255, 215, 0, 0.12);
}

.btn-restart:active {
    transform: scale(0.97);
}

/* COMBO */
#combo-popup {
    position: absolute;
    top: 45%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0);
    font-family: 'Orbitron', monospace;
    font-size: 2.2rem;
    font-weight: 900;
    color: #fff;
    text-shadow: 0 0 24px var(--teal);
    pointer-events: none;
    z-index: 30;
    opacity: 0;
}

/* Edge glow */
#edge-glow {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 8;
    background: linear-gradient(180deg, rgba(255, 140, 0, 0.05) 0%, transparent 12%), linear-gradient(0deg, rgba(0, 229, 204, 0.03) 0%, transparent 10%);
}