/* ── Reset & Base ── */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body,
html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: #0b071e;
    font-family: 'Rajdhani', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    touch-action: none;
    -webkit-font-smoothing: antialiased;
}

.hidden {
    display: none !important;
}

/* ── Device Blocker (Desktop only overlay) ── */
.device-blocker {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    pointer-events: auto;
}

.device-blocker__backdrop {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at 50% 10%, rgba(168, 85, 247, 0.22) 0%, rgba(0, 0, 0, 0.78) 55%, rgba(0, 0, 0, 0.92) 100%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.device-blocker__panel {
    position: relative;
    width: min(520px, calc(100% - 24px));
    padding: 22px 20px 18px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(22, 14, 48, 0.98) 0%, rgba(10, 8, 26, 0.99) 100%);
    border: 1px solid rgba(168, 85, 247, 0.45);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.05) inset,
        0 24px 70px rgba(0, 0, 0, 0.75);
    color: #f3f0fa;
    text-align: center;
}

.device-blocker__title {
    margin: 0 0 8px;
    font-family: 'Orbitron', sans-serif;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    font-size: clamp(1.35rem, 4.5vw, 1.9rem);
    background: linear-gradient(180deg, #ffffff 0%, #fde047 55%, #c4b5fd 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 2px 12px rgba(168, 85, 247, 0.35));
}

.device-blocker__text {
    margin: 0 auto 14px;
    max-width: 46ch;
    font-size: 0.92rem;
    font-weight: 600;
    line-height: 1.5;
    color: #e7e2f2;
}

.device-blocker__actions {
    display: flex;
    justify-content: center;
    margin: 0 0 10px;
}

.device-blocker__actions .btn-game {
    width: min(360px, 100%);
    border-radius: 12px;
}

.device-blocker__hint {
    margin: 0;
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(196, 181, 253, 0.85);
}

/* ── Canvas ── */
#game-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

/* ── UI Layer ── */
.ui-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-height: 100dvh;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── HUD layout (scales with viewport via .hud font-size) ── */
.hud-panel-group {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.75em;
}

.hud-panel--bridge {
    min-width: 9.375em;
    border-color: rgba(168, 85, 247, 0.25);
}

.bridge-need-row {
    display: flex;
    align-items: baseline;
    gap: 0.375em;
}

.bridge-need-label {
    color: #c4b5fd;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.bridge-need--danger {
    border-color: rgba(239, 68, 68, 0.45);
    box-shadow: 0 0 20px rgba(239, 68, 68, 0.2);
}

.bridge-need--danger .hud-value--white {
    color: #f87171;
}

.label-warning--low {
    color: #fb923c;
}

.label-warning--rescue {
    color: #facc15;
    animation: rescue-pulse 0.6s ease-in-out infinite alternate;
}

@keyframes rescue-pulse {
    from {
        opacity: 0.7;
        transform: scale(1);
    }

    to {
        opacity: 1;
        transform: scale(1.04);
    }
}

.hud-label--speed {
    color: #a78bfa;
    margin-top: 0.5em;
    margin-bottom: 0.125em;
}

.hud-value--speed {
    font-size: 1.25em;
    color: #c4b5fd;
}

.legend-dot--speed {
    background-color: #a855f7;
    border-radius: 2px;
    box-shadow: 0 0 10px rgba(168, 85, 247, 0.8);
}

/* ── Shared Panels ── */
.glass-panel {
    background: rgba(10, 8, 28, 0.5);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.text-glow-yellow {
    text-shadow: 0 0 15px rgba(250, 204, 21, 0.8);
}

.text-glow-purple {
    text-shadow: 0 0 15px rgba(168, 85, 247, 0.8);
}

.label-sm {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.label-warning {
    font-size: 9px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 900;
    color: #f87171;
    margin-top: 4px;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ── HUD ── */
.hud {
    width: 100%;
    padding: var(--hud-pad);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: start;
    gap: var(--hud-gap);
    color: #fff;
    pointer-events: auto;
    font-size: clamp(9px, 2.2vmin, 16px);
}

.hud-home-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    width: clamp(32px, 7.5vmin, 42px);
    height: clamp(32px, 7.5vmin, 42px);
    padding: 0;
    border-radius: clamp(10px, 2.4vmin, 14px);
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(10, 8, 28, 0.55);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    color: #ffffff;
    cursor: pointer;
    pointer-events: auto;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 10px 24px rgba(0, 0, 0, 0.35);
    transition: transform 0.18s cubic-bezier(0.16, 1, 0.3, 1), background 0.18s ease, border-color 0.18s ease;
    -webkit-tap-highlight-color: transparent;
    align-self: start;
    flex-shrink: 0;
}

.hud-home-btn:hover {
    transform: translateY(-1px);
    background: rgba(18, 12, 40, 0.65);
    border-color: rgba(250, 204, 21, 0.22);
}

.hud-home-btn:active {
    transform: translateY(1px);
}

.hud-home-btn:focus-visible {
    outline: 2px solid #fde047;
    outline-offset: 3px;
}

.hud-home-btn__icon {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
}

.hud-home-btn svg {
    width: clamp(14px, 3.2vmin, 18px);
    height: clamp(14px, 3.2vmin, 18px);
    display: block;
}

.hud-panel.hud-panel--top-center {
    justify-self: center;
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 1em;
    min-height: 3.5em;
    padding: 0.5em 0.875em;
    border-color: rgba(255, 255, 255, 0.12);
    align-self: start;
}

.hud-stat {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.125em;
    min-width: 6.875em;
}

.hud-stat--speed {
    min-width: 5.9375em;
}

.hud-panel-group {
    justify-self: end;
    align-items: stretch;
    align-self: start;
}

.hud-panel {
    min-height: 3.5em;
    justify-content: center;
    padding: 0.75em 1.5em;
    border-radius: 1em;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* (legacy) .hud-panel--journey replaced by .hud-panel--top-center */

.hud-panel--stack {
    min-width: 9.375em;
    border-color: rgba(234, 179, 8, 0.2);
}

.hud .label-sm {
    font-size: 0.625em;
}

.hud-label--purple {
    color: #d8b4fe;
    margin-bottom: 0.25em;
}

.hud-label--yellow {
    color: #fde047;
    margin-bottom: 0.25em;
}

.hud-value {
    font-size: 1.875em;
    font-weight: 900;
    letter-spacing: -0.025em;
    line-height: 1.1;
}

.hud-value--white {
    color: #fff;
}

.hud-value--yellow {
    color: #facc15;
}

.hud-stack-row {
    display: flex;
    align-items: center;
    gap: 0.75em;
}

.hud-stack-count {
    display: flex;
    align-items: baseline;
    gap: 0.25em;
}

.hud-stack-max {
    color: #6b7280;
    font-size: 0.875em;
}

.hud .label-warning {
    font-size: 0.5625em;
    margin-top: 0.25em;
}

/* ── Stack Indicator ── */
.stack-indicator {
    width: 1em;
    height: 1em;
    border-radius: 50%;
    border: 1px solid #fff;
    transition: all 0.3s ease;
}

.stack-indicator--normal {
    background-color: #facc15;
    box-shadow: 0 0 15px rgba(250, 204, 21, 0.9);
}

.stack-indicator--low {
    background-color: #f97316;
    box-shadow: 0 0 18px rgba(249, 115, 22, 0.95);
    animation: stack-pulse 0.8s ease-in-out infinite alternate;
}

@keyframes stack-pulse {
    from {
        transform: scale(1);
    }

    to {
        transform: scale(1.15);
    }
}

.stack-indicator--max {
    background-color: #ef4444;
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.9);
}

.stack-indicator--flash {
    transform: scale(1.5);
}

/* ── Screens (Start / Game Over) ── */
.screen {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: 100%;
    padding:
        max(10px, env(safe-area-inset-top, 0px)) max(12px, env(safe-area-inset-right, 0px)) max(10px, env(safe-area-inset-bottom, 0px)) max(12px, env(safe-area-inset-left, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.screen--start {
    background: radial-gradient(ellipse at 50% 0%, rgba(88, 28, 135, 0.35) 0%, transparent 55%),
        radial-gradient(ellipse at 80% 80%, rgba(234, 88, 12, 0.12) 0%, transparent 45%),
        rgba(5, 3, 18, 0.72);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.screen--gameover {
    background: rgba(3, 2, 12, 0.88);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}

/* ── Screen Background Effects ── */
.screen-bg {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: hidden;
}

.screen-bg--dark .screen-bg__aurora {
    display: none;
}

.screen-bg__vignette {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, transparent 30%, rgba(0, 0, 0, 0.65) 100%);
}

.screen-bg__aurora {
    position: absolute;
    top: -20%;
    left: 50%;
    width: 140%;
    height: 60%;
    transform: translateX(-50%);
    background: linear-gradient(180deg,
            rgba(168, 85, 247, 0.25) 0%,
            rgba(99, 102, 241, 0.12) 40%,
            transparent 100%);
    animation: aurora-drift 8s ease-in-out infinite alternate;
}

.screen-bg__stars {
    position: absolute;
    inset: 0;
    background-image:
        radial-gradient(1px 1px at 10% 20%, rgba(255, 255, 255, 0.7) 50%, transparent 50%),
        radial-gradient(1px 1px at 30% 65%, rgba(255, 255, 255, 0.5) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 55% 15%, rgba(250, 204, 21, 0.8) 50%, transparent 50%),
        radial-gradient(1px 1px at 70% 45%, rgba(255, 255, 255, 0.6) 50%, transparent 50%),
        radial-gradient(1px 1px at 85% 75%, rgba(255, 255, 255, 0.4) 50%, transparent 50%),
        radial-gradient(1.5px 1.5px at 15% 85%, rgba(168, 85, 247, 0.7) 50%, transparent 50%),
        radial-gradient(1px 1px at 45% 40%, rgba(255, 255, 255, 0.5) 50%, transparent 50%),
        radial-gradient(1px 1px at 92% 30%, rgba(255, 255, 255, 0.6) 50%, transparent 50%),
        radial-gradient(1px 1px at 60% 90%, rgba(255, 255, 255, 0.45) 50%, transparent 50%),
        radial-gradient(2px 2px at 25% 35%, rgba(250, 204, 21, 0.6) 50%, transparent 50%);
    animation: stars-twinkle 4s ease-in-out infinite alternate;
}

@keyframes aurora-drift {
    from {
        transform: translateX(-50%) scaleX(1);
        opacity: 0.8;
    }

    to {
        transform: translateX(-48%) scaleX(1.08);
        opacity: 1;
    }
}

@keyframes stars-twinkle {
    from {
        opacity: 0.6;
    }

    to {
        opacity: 1;
    }
}

/* ── Game Modal Card ── */
.game-modal {
    position: relative;
    width: 100%;
    max-width: min(460px, 100%);
    max-height: min(calc(100dvh - 20px), 100%);
    flex-shrink: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    margin: auto 0;
    overflow: hidden;
    animation: modal-enter 0.7s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.game-modal--gameover {
    max-width: min(400px, 100%);
    animation: modal-enter 0.5s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.game-modal__glow {
    position: absolute;
    inset: 0;
    background: radial-gradient(ellipse at center, rgba(168, 85, 247, 0.35) 0%, transparent 70%);
    pointer-events: none;
    animation: glow-pulse 3s ease-in-out infinite alternate;
}

.game-modal__glow--red {
    background: radial-gradient(ellipse at center, rgba(239, 68, 68, 0.3) 0%, transparent 70%);
}

.game-modal--start {
    max-width: min(520px, 100%);
}

.game-modal__frame {
    position: relative;
    display: flex;
    flex-direction: column;
    min-height: 0;
    max-height: min(calc(100dvh - 20px), 100%);
    padding: 0;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(22, 14, 48, 0.97) 0%, rgba(10, 8, 26, 0.98) 100%);
    border: 1px solid rgba(168, 85, 247, 0.4);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.06) inset,
        0 20px 50px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    overflow: hidden;
}

.start-card {
    animation: modal-enter 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* ── Start Screen Layout ── */
.start-header {
    flex-shrink: 0;
    text-align: center;
    padding: clamp(12px, 3vmin, 20px) clamp(14px, 4vmin, 20px) clamp(10px, 2.5vmin, 16px);
    background: linear-gradient(180deg, rgba(168, 85, 247, 0.15) 0%, transparent 100%);
    border-bottom: 1px solid rgba(168, 85, 247, 0.2);
}

.start-header__brand {
    margin: 0;
    line-height: 0;
}

.start-header__logo {
    display: block;
    width: clamp(130px, 58vw, 280px);
    max-width: 100%;
    height: auto;
    margin: 0 auto;
    object-fit: contain;
    filter: drop-shadow(0 4px 18px rgba(0, 0, 0, 0.35));
}

.start-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
    padding: 16px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    color: #ece8f4;
}

.section-label {
    display: block;
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.18em;
    text-transform: uppercase;
    color: #a78bfa;
    margin-bottom: 8px;
}

.mission-box {
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(168, 85, 247, 0.12);
    border: 1px solid rgba(168, 85, 247, 0.28);
}

.mission-box p {
    margin: 0;
    font-size: 0.88rem;
    font-weight: 600;
    line-height: 1.45;
    color: #f3f0fa;
}

.guide-section {
    flex-shrink: 0;
}

.guide-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.guide-card {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 10px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    min-width: 0;
}

.guide-card--amber {
    border-left: 3px solid #facc15;
}

.guide-card--red {
    border-left: 3px solid #ef4444;
}

.guide-card--purple {
    border-left: 3px solid #a855f7;
}

.guide-card--speed {
    border-left: 3px solid #818cf8;
}

.guide-card .legend-dot {
    margin-top: 3px;
    flex-shrink: 0;
}

.guide-card__body {
    flex: 1;
    min-width: 0;
}

.guide-card__title {
    margin: 0 0 2px;
    font-family: 'Rajdhani', sans-serif;
    font-size: 0.8rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    color: #ffffff;
    text-transform: uppercase;
    line-height: 1.2;
}

.guide-card__text {
    margin: 0;
    font-size: 0.72rem;
    line-height: 1.35;
    color: #d4cfe0;
}

.guide-card__text strong {
    color: #fde047;
    font-weight: 700;
}

.controls-box {
    flex-shrink: 0;
    padding: 12px 14px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(250, 204, 21, 0.2);
}

.controls-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.control-group {
    flex: 1;
    min-width: 0;
}

.control-group__label {
    display: block;
    font-size: 0.6rem;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: #9ca3af;
    margin-bottom: 6px;
}

.control-keys {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}

.control-chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
    padding: 4px 8px;
    border-radius: 6px;
    font-family: 'Orbitron', sans-serif;
    font-size: 0.65rem;
    font-weight: 700;
    color: #1a0a2e;
    background: linear-gradient(180deg, #fde047 0%, #facc15 100%);
    border: 1px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 2px 0 rgba(0, 0, 0, 0.25);
}

.control-divider {
    width: 1px;
    align-self: stretch;
    min-height: 36px;
    background: rgba(255, 255, 255, 0.12);
    flex-shrink: 0;
}

.start-card .btn-game {
    margin: 0 16px 16px;
    width: calc(100% - 32px);
    border-radius: 12px;
}

.game-modal__frame--compact {
    padding: 24px 22px 20px;
    border-color: rgba(239, 68, 68, 0.3);
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.04) inset,
        0 16px 40px rgba(0, 0, 0, 0.6),
        0 0 50px rgba(239, 68, 68, 0.12);
}

@keyframes modal-enter {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes glow-pulse {
    from {
        opacity: 0.6;
        transform: scale(0.98);
    }

    to {
        opacity: 1;
        transform: scale(1.02);
    }
}

/* ── Corner Accents ── */
.corner-accent {
    position: absolute;
    width: 24px;
    height: 24px;
    pointer-events: none;
}

.corner-accent::before,
.corner-accent::after {
    content: '';
    position: absolute;
    background: linear-gradient(90deg, #facc15, #a855f7);
}

.corner-accent--tl {
    top: 10px;
    left: 10px;
}

.corner-accent--tl::before {
    top: 0;
    left: 0;
    width: 24px;
    height: 2px;
}

.corner-accent--tl::after {
    top: 0;
    left: 0;
    width: 2px;
    height: 24px;
}

.corner-accent--tr {
    top: 10px;
    right: 10px;
}

.corner-accent--tr::before {
    top: 0;
    right: 0;
    width: 24px;
    height: 2px;
}

.corner-accent--tr::after {
    top: 0;
    right: 0;
    width: 2px;
    height: 24px;
}

.corner-accent--bl {
    bottom: 10px;
    left: 10px;
}

.corner-accent--bl::before {
    bottom: 0;
    left: 0;
    width: 24px;
    height: 2px;
}

.corner-accent--bl::after {
    bottom: 0;
    left: 0;
    width: 2px;
    height: 24px;
}

.corner-accent--br {
    bottom: 10px;
    right: 10px;
}

.corner-accent--br::before {
    bottom: 0;
    right: 0;
    width: 24px;
    height: 2px;
}

.corner-accent--br::after {
    bottom: 0;
    right: 0;
    width: 2px;
    height: 24px;
}

.corner-accent--red::before,
.corner-accent--red::after {
    background: linear-gradient(90deg, #f87171, #db2777);
}

/* ── Title Block ── */
.screen-title {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(1.85rem, 7vw, 3rem);
    font-weight: 900;
    margin: 0 0 4px;
    letter-spacing: 0.06em;
    text-align: center;
    line-height: 1.1;
}

.screen-subtitle {
    color: #facc15;
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.62rem;
    margin: 0 0 10px;
}

.screen-subtitle--death {
    color: #fca5a5;
    letter-spacing: 0.15em;
    margin-bottom: 14px;
    font-size: 0.62rem;
    flex-shrink: 0;
}

.screen-title--death {
    font-size: clamp(1.5rem, 6vw, 2.25rem);
    margin-bottom: 4px;
    letter-spacing: 0.08em;
    flex-shrink: 0;
}

.screen-title--death {
    background-image: linear-gradient(to right, #fca5a5, #f87171, #db2777);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    filter: drop-shadow(0 0 24px rgba(239, 68, 68, 0.45));
    animation: none;
}

@media (min-width: 768px) {
    .screen-title {
        font-size: 3rem;
    }

    .screen-title--death {
        font-size: 2.25rem;
    }

    .game-modal__frame--compact {
        padding: 28px 26px 24px;
    }

    .start-header__logo {
        width: min(280px, 100%);
    }
}

.legend-dot {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    border: 1px solid #fff;
    flex-shrink: 0;
    margin-top: 2px;
}

.legend-dot--amber {
    background-color: #facc15;
    box-shadow: 0 0 10px rgba(250, 204, 21, 0.8);
}

.legend-dot--red {
    background-color: #ef4444;
    box-shadow: 0 0 10px rgba(239, 68, 68, 0.8);
}

.legend-dot--purple {
    background-color: #a855f7;
    border-radius: 2px;
}

/* ── Score Panel (Game Over) ── */
.score-panel {
    border-radius: 14px;
    padding: 18px 22px;
    margin-bottom: 16px;
    text-align: center;
    border-color: rgba(239, 68, 68, 0.2);
    background: rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.score-label {
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.15em;
    font-size: 0.65rem;
    font-weight: 700;
    margin: 0 0 6px;
}

.score-value {
    font-family: 'Orbitron', sans-serif;
    font-size: clamp(2.5rem, 12vw, 3.25rem);
    font-weight: 900;
    color: #fff;
    letter-spacing: 0.02em;
    margin: 0;
    text-shadow: 0 0 30px rgba(255, 255, 255, 0.25);
}

/* ── Game Buttons ── */
.btn-game {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 0;
    border: none;
    border-radius: 14px;
    cursor: pointer;
    overflow: hidden;
    font-family: 'Orbitron', sans-serif;
    font-weight: 800;
    font-size: 0.9rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    transition: transform 0.2s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.2s ease;
    -webkit-tap-highlight-color: transparent;
    flex-shrink: 0;
}

.btn-game__bg {
    position: absolute;
    inset: 0;
    border-radius: inherit;
    transition: opacity 0.2s ease;
}

.btn-game--primary .btn-game__bg {
    background: linear-gradient(135deg, #facc15 0%, #f97316 35%, #9333ea 100%);
}

.btn-game--restart .btn-game__bg {
    background: linear-gradient(135deg, #fde047 0%, #f97316 50%, #ea580c 100%);
}

.btn-game__shine {
    position: absolute;
    top: 0;
    left: -100%;
    width: 60%;
    height: 100%;
    background: linear-gradient(90deg,
            transparent,
            rgba(255, 255, 255, 0.35),
            transparent);
    transform: skewX(-20deg);
    animation: btn-shine 3s ease-in-out infinite;
}

@keyframes btn-shine {

    0%,
    70%,
    100% {
        left: -100%;
    }

    85% {
        left: 150%;
    }
}

.btn-game__content {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    width: 100%;
}

.btn-game__text {
    color: #fff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.btn-game--restart .btn-game__text {
    color: #1a0a2e;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}

.btn-game__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.2);
    color: inherit;
    transition: transform 0.2s ease, background 0.2s ease;
}

.btn-game--primary .btn-game__icon {
    color: #fff;
}

.btn-game--restart .btn-game__icon {
    color: #1a0a2e;
    background: rgba(255, 255, 255, 0.25);
}

.btn-game--primary {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.15) inset,
        0 4px 0 #6b21a8,
        0 8px 24px rgba(168, 85, 247, 0.45),
        0 0 40px rgba(250, 204, 21, 0.2);
}

.btn-game--restart {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.2) inset,
        0 4px 0 #c2410c,
        0 8px 24px rgba(249, 115, 22, 0.4);
}

.btn-game:hover {
    transform: translateY(-2px);
}

.btn-game--primary:hover {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.2) inset,
        0 6px 0 #6b21a8,
        0 12px 32px rgba(168, 85, 247, 0.55),
        0 0 50px rgba(250, 204, 21, 0.3);
}

.btn-game--restart:hover {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.25) inset,
        0 6px 0 #c2410c,
        0 12px 32px rgba(249, 115, 22, 0.5);
}

.btn-game:hover .btn-game__icon {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.3);
}

.btn-game--restart:hover .btn-game__icon {
    background: rgba(255, 255, 255, 0.35);
}

.btn-game:active {
    transform: translateY(3px);
}

.btn-game--primary:active {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 1px 0 #6b21a8,
        0 4px 16px rgba(168, 85, 247, 0.35);
}

.btn-game--restart:active {
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, 0.15) inset,
        0 1px 0 #c2410c,
        0 4px 16px rgba(249, 115, 22, 0.35);
}

.btn-game:focus-visible {
    outline: 2px solid #facc15;
    outline-offset: 3px;
}

/* ── Small / Short Screens ── */
@media (max-height: 680px) {
    .start-header {
        padding: 12px 14px 10px;
    }

    .start-header__logo {
        width: clamp(115px, 55vw, 220px);
    }

    .start-body {
        padding: 12px 14px 10px;
        gap: 10px;
    }

    .mission-box,
    .controls-box {
        padding: 10px 12px;
    }

    .mission-box p {
        font-size: 0.8rem;
    }

    .guide-grid {
        gap: 6px;
    }

    .guide-card {
        padding: 8px 9px;
    }

    .guide-card__title {
        font-size: 0.75rem;
    }

    .guide-card__text {
        font-size: 0.68rem;
    }

    .start-card .btn-game {
        margin-bottom: 12px;
    }

    .btn-game__content {
        padding: 12px 20px;
    }
}

@media (max-width: 380px) {
    .screen {
        padding-left: 8px;
        padding-right: 8px;
    }

    .guide-grid {
        grid-template-columns: 1fr;
    }

    .controls-row {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .control-divider {
        width: 100%;
        height: 1px;
        min-height: 0;
    }

    .start-card .btn-game {
        margin-left: 12px;
        margin-right: 12px;
        width: calc(100% - 24px);
    }

    .btn-game__content {
        padding: 12px 16px;
        font-size: 0.82rem;
    }
}

/* ── Responsive HUD (scales with viewport / iframe size) ── */
:root {
    --hud-pad: clamp(6px, 1.6vmin, 14px);
    --hud-gap: clamp(6px, 1.6vmin, 14px);
}

.hud {
    padding: var(--hud-pad);
}

.hud-panel-group {
    gap: var(--hud-gap);
}

/* Compact embedded / short viewports */
@media (max-height: 520px) {
    .hud {
        font-size: clamp(8px, 2vmin, 13px);
    }
}

@media (max-width: 480px), (max-height: 400px) {
    .hud {
        font-size: clamp(7.5px, 1.9vmin, 12px);
    }

    .hud-panel.hud-panel--top-center {
        gap: 0.65em;
        padding: 0.4em 0.65em;
    }

    .hud-stat {
        min-width: 5.5em;
    }

    .hud-stat--speed {
        min-width: 4.75em;
    }

    .hud-panel--stack,
    .hud-panel--bridge {
        min-width: 8em;
    }
}

/* Landscape mobile */
@media (max-height: 480px) and (orientation: landscape) {
    .hud {
        font-size: clamp(7px, 1.8vmin, 11px);
    }
}