/* ==========================================================================
   Alchemical Cascade - Design tokens & layout (no inline styles)
   ========================================================================== */

:root {
    --color-bg: #0c0d11;
    --color-bg-panel: #1a1c23;
    --color-canvas-bg: #1a1c23;
    --color-text: #d0d0d0;
    --color-cyan: #22d3ee;
    --color-green: #4ade80;
    --color-red: #f87171;
    --color-border-cyan: rgba(34, 211, 238, 0.3);
    --color-border-green: rgba(74, 222, 128, 0.3);
    --color-border-red: rgba(248, 113, 113, 0.3);
    --color-btn-green: #16a34a;
    --color-btn-green-hover: #22c55e;
    --color-btn-blue: #2563eb;
    --color-btn-blue-hover: #3b82f6;
    --font-mono: 'Roboto Mono', monospace;
    --radius-panel: 0.5rem;
    --radius-btn: 0.375rem;
    --shadow-panel: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    --shadow-btn-hover: 0 4px 10px rgba(0, 255, 255, 0.2);
    --transition-fast: 0.2s ease-in-out;
    --z-controller: 50;
}

/* Base
   ========================================================================== */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    padding: 0;
    width: 100vw;
    height: 100vh;
    overflow: hidden;
    font-family: var(--font-mono);
    background-color: var(--color-bg);
    color: var(--color-text);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Game container & canvas
   ========================================================================== */

.game-container {
    position: relative;
    width: 100%;
    height: 100%;
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    background-color: var(--color-canvas-bg);
    cursor: none;
}

/* HUD (top bar)
   ========================================================================== */

.game-hud {
    position: absolute;
    top: 0.125rem;
    left: 0.25rem;
    right: 0.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 700;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #fff;
    text-align: center;
    pointer-events: none;
}

/* Top-left corner: home icon + level (no colon), aligned center */
.game-hud__corner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    pointer-events: all;
    padding: 0.2rem 0.5rem;
    background: rgba(12, 13, 17, 0.75);
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.game-hud__home {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    padding: 0.2rem;
    font-family: var(--font-mono);
    font-weight: 700;
    color: var(--color-text);
    background: none;
    border: none;
    border-radius: 0;
    text-decoration: none;
    cursor: pointer;
    transition: opacity var(--transition-fast);
}

.game-hud__home-icon {
    width: 1.25rem;
    height: 1.25rem;
    flex-shrink: 0;
    color: #c9a227;
}

.game-hud__home:hover {
    opacity: 0.9;
}

.game-hud__home:hover .game-hud__home-icon {
    color: #e6c04a;
}

.game-hud__stat--level {
    margin: 0;
}

.game-hud__stat--level .game-hud__label {
    margin-right: 0.2em;
}

/* Score: pill badges with icons, readable on any background */
.game-hud__stats {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.4rem;
    flex-wrap: wrap;
    pointer-events: none;
}

.game-hud__score {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    background: rgba(12, 13, 17, 0.8);
    border-radius: 9999px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    min-width: 2.5rem;
}

.game-hud__score-icon {
    width: 1rem;
    height: 1rem;
    flex-shrink: 0;
}

.game-hud__score--player {
    color: var(--color-cyan);
    border-color: rgba(34, 211, 238, 0.25);
}

.game-hud__score--player .game-hud__score-icon {
    color: var(--color-cyan);
}

.game-hud__score--ai {
    color: var(--color-red);
    border-color: rgba(248, 113, 113, 0.25);
}

.game-hud__score--ai .game-hud__score-icon {
    color: var(--color-red);
}

.game-hud__score--total {
    color: #fbbf24;
    border-color: rgba(251, 191, 36, 0.35);
}

.game-hud__score-icon--gold {
    color: #fbbf24;
}

.game-hud__label {
    font-weight: 500;
}

@media (min-width: 640px) {
    .game-hud {
        top: 0.25rem;
        left: 0.5rem;
        right: 0.5rem;
        font-size: 1.125rem;
    }
    .game-hud__corner {
        padding: 0.25rem 0.6rem;
    }
    .game-hud__score {
        padding: 0.3rem 0.7rem;
        font-size: 1rem;
    }
    .game-hud__score-icon {
        width: 1.125rem;
        height: 1.125rem;
    }
}

@media (min-width: 1024px) {
    .game-hud {
        font-size: 1.25rem;
    }
}

@media (max-width: 480px) {
    .game-hud {
        font-size: 0.75rem;
        flex-wrap: wrap;
        gap: 0.2rem;
    }
    .game-hud__corner {
        gap: 0.35rem;
    }
    .game-hud__home {
        padding: 0.2rem;
    }
    .game-hud__home-icon {
        width: 1rem;
        height: 1rem;
    }
    .game-hud__stats .game-hud__score {
        padding: 0.2rem 0.5rem;
        font-size: 0.8rem;
    }
    .game-hud__score-icon {
        width: 0.9rem;
        height: 0.9rem;
    }
}

/* UI screens (overlays)
   ========================================================================== */

.ui-screen {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: rgba(12, 13, 17, 0.9);
    backdrop-filter: blur(10px);
    pointer-events: all;
}

.ui-screen--start {
    pointer-events: all;
    background: radial-gradient(ellipse 80% 70% at 50% 50%, rgba(26, 28, 35, 0.97) 0%, rgba(12, 13, 17, 0.98) 100%);
    backdrop-filter: blur(12px);
}

.ui-screen--modal.hidden {
    display: none;
}

.ui-screen--start.hidden {
    display: none;
}

/* Start panel — game-themed pop-up
   ========================================================================== */

.start-panel {
    position: relative;
    width: 100%;
    max-width: 36rem;
    margin: 0 0.75rem;
}

.start-panel__glow {
    position: absolute;
    inset: -1px;
    background: linear-gradient(135deg, rgba(201, 162, 39, 0.15) 0%, transparent 40%, transparent 60%, rgba(34, 211, 238, 0.08) 100%);
    border-radius: 0.75rem;
    filter: blur(8px);
    pointer-events: none;
}

.start-panel__inner {
    position: relative;
    padding: 1.5rem 1.25rem;
    background: linear-gradient(180deg, rgba(28, 30, 38, 0.98) 0%, rgba(18, 19, 24, 0.99) 100%);
    border: 1px solid rgba(201, 162, 39, 0.25);
    border-radius: 0.75rem;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.4) inset,
        0 24px 48px -12px rgba(0, 0, 0, 0.6),
        0 0 40px -8px rgba(201, 162, 39, 0.2);
    text-align: center;
}

.start-panel__header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.start-panel__accent {
    width: 1.5rem;
    height: 2px;
    background: linear-gradient(90deg, transparent, rgba(201, 162, 39, 0.6));
    border-radius: 1px;
}

.start-panel__accent--right {
    background: linear-gradient(90deg, rgba(201, 162, 39, 0.6), transparent);
}

.start-panel__title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.2;
    color: #e8e0d0;
    text-shadow:
        0 0 20px rgba(201, 162, 39, 0.4),
        0 2px 4px rgba(0, 0, 0, 0.5);
}

.start-panel__subtitle {
    margin: 0 0 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: rgba(201, 162, 39, 0.9);
}

.start-panel__divider {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.start-panel__divider-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: rgba(201, 162, 39, 0.5);
}

.start-panel__desc {
    margin: 0 0 1.25rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(212, 212, 212, 0.92);
}

.start-panel__controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
}

.start-panel__key {
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    color: rgba(212, 212, 212, 0.95);
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 0.375rem;
}

.start-panel__key-hint {
    font-size: 0.7rem;
    color: rgba(107, 114, 128, 1);
    margin-left: 0.25rem;
}

.start-panel__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #0c0d11;
    background: linear-gradient(180deg, #e6c04a 0%, #c9a227 50%, #a8841f 100%);
    border: 1px solid rgba(201, 162, 39, 0.5);
    border-radius: 0.5rem;
    cursor: pointer;
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.35),
        0 0 24px -4px rgba(201, 162, 39, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    touch-action: manipulation;
}

.start-panel__btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 32px -4px rgba(201, 162, 39, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    filter: brightness(1.05);
}

.start-panel__btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) inset;
}

.start-panel__btn-text {
    color: inherit;
}

.start-panel__btn-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: inherit;
}

@media (min-width: 640px) {
    .start-panel {
        max-width: 40rem;
    }
    .start-panel__inner {
        padding: 2rem 2rem;
    }
    .start-panel__title {
        font-size: 2.25rem;
    }
    .start-panel__subtitle {
        font-size: 0.85rem;
    }
    .start-panel__desc {
        font-size: 0.95rem;
        margin-bottom: 1.5rem;
    }
    .start-panel__controls {
        margin-bottom: 1.75rem;
    }
    .start-panel__btn {
        padding: 0.85rem 2rem;
        font-size: 1.2rem;
        width: auto;
        min-width: 14rem;
    }
}

@media (min-width: 1024px) {
    .start-panel__title {
        font-size: 2.75rem;
    }
}

@media (max-width: 480px) {
    .start-panel__inner {
        padding: 1.25rem 1rem;
    }
    .start-panel__title {
        font-size: 1.5rem;
        letter-spacing: 0.05em;
    }
    .start-panel__subtitle {
        font-size: 0.7rem;
    }
    .start-panel__desc {
        font-size: 0.8rem;
        margin-bottom: 1rem;
    }
    .start-panel__btn {
        padding: 0.65rem 1.25rem;
        font-size: 1rem;
    }
}

/* Result panel (Win/Lose) — same style as start panel, themed
   ========================================================================== */

.ui-screen--modal {
    background: radial-gradient(ellipse 80% 70% at 50% 50%, rgba(26, 28, 35, 0.97) 0%, rgba(12, 13, 17, 0.98) 100%);
    backdrop-filter: blur(12px);
}

.result-panel {
    position: relative;
    width: 100%;
    max-width: 36rem;
    margin: 0 0.75rem;
}

.result-panel__glow {
    position: absolute;
    inset: -1px;
    border-radius: 0.75rem;
    filter: blur(8px);
    pointer-events: none;
}

.result-panel--win .result-panel__glow {
    background: linear-gradient(135deg, rgba(74, 222, 128, 0.2) 0%, transparent 40%, transparent 60%, rgba(201, 162, 39, 0.12) 100%);
}

.result-panel--lose .result-panel__glow {
    background: linear-gradient(135deg, rgba(248, 113, 113, 0.18) 0%, transparent 40%, transparent 60%, rgba(251, 146, 60, 0.1) 100%);
}

.result-panel__inner {
    position: relative;
    padding: 1.5rem 1.25rem;
    background: linear-gradient(180deg, rgba(28, 30, 38, 0.98) 0%, rgba(18, 19, 24, 0.99) 100%);
    border-radius: 0.75rem;
    text-align: center;
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.4) inset,
        0 24px 48px -12px rgba(0, 0, 0, 0.6);
}

.result-panel--win .result-panel__inner {
    border: 1px solid rgba(74, 222, 128, 0.3);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.4) inset,
        0 24px 48px -12px rgba(0, 0, 0, 0.6),
        0 0 40px -8px rgba(74, 222, 128, 0.2);
}

.result-panel--lose .result-panel__inner {
    border: 1px solid rgba(248, 113, 113, 0.3);
    box-shadow:
        0 0 0 1px rgba(0, 0, 0, 0.4) inset,
        0 24px 48px -12px rgba(0, 0, 0, 0.6),
        0 0 40px -8px rgba(248, 113, 113, 0.2);
}

.result-panel__header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    margin-bottom: 0.35rem;
}

.result-panel__accent {
    width: 1.5rem;
    height: 2px;
    border-radius: 1px;
}

.result-panel--win .result-panel__accent--left {
    background: linear-gradient(90deg, transparent, rgba(74, 222, 128, 0.7));
}

.result-panel--win .result-panel__accent--right {
    background: linear-gradient(90deg, rgba(74, 222, 128, 0.7), transparent);
}

.result-panel--lose .result-panel__accent--left {
    background: linear-gradient(90deg, transparent, rgba(248, 113, 113, 0.7));
}

.result-panel--lose .result-panel__accent--right {
    background: linear-gradient(90deg, rgba(248, 113, 113, 0.7), transparent);
}

.result-panel__title {
    margin: 0;
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    line-height: 1.2;
    color: #e8e0d0;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.result-panel--win .result-panel__title {
    color: #86efac;
    text-shadow: 0 0 20px rgba(74, 222, 128, 0.4), 0 2px 4px rgba(0, 0, 0, 0.5);
}

.result-panel--lose .result-panel__title {
    color: #fca5a5;
    text-shadow: 0 0 20px rgba(248, 113, 113, 0.4), 0 2px 4px rgba(0, 0, 0, 0.5);
}

.result-panel__subtitle {
    margin: 0 0 1rem;
    font-size: 0.8rem;
    font-weight: 600;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.result-panel--win .result-panel__subtitle {
    color: rgba(74, 222, 128, 0.95);
}

.result-panel--lose .result-panel__subtitle {
    color: rgba(248, 113, 113, 0.95);
}

.result-panel__divider {
    display: flex;
    justify-content: center;
    margin-bottom: 1rem;
}

.result-panel--win .result-panel__divider-icon {
    color: rgba(74, 222, 128, 0.5);
}

.result-panel--lose .result-panel__divider-icon {
    color: rgba(248, 113, 113, 0.5);
}

.result-panel__divider-icon {
    width: 1.25rem;
    height: 1.25rem;
}

.result-panel__desc {
    margin: 0 0 1.5rem;
    font-size: 0.875rem;
    line-height: 1.5;
    color: rgba(212, 212, 212, 0.92);
}

.result-panel__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    font-family: var(--font-mono);
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #0c0d11;
    border-radius: 0.5rem;
    cursor: pointer;
    border: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
    touch-action: manipulation;
}

.result-panel--win .result-panel__btn {
    background: linear-gradient(180deg, #4ade80 0%, #22c55e 50%, #16a34a 100%);
    border: 1px solid rgba(74, 222, 128, 0.5);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.35),
        0 0 24px -4px rgba(74, 222, 128, 0.4),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
}

.result-panel--win .result-panel__btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 32px -4px rgba(74, 222, 128, 0.5),
        inset 0 1px 0 rgba(255, 255, 255, 0.3);
    filter: brightness(1.05);
}

.result-panel--lose .result-panel__btn {
    background: linear-gradient(180deg, #f87171 0%, #ef4444 50%, #dc2626 100%);
    border: 1px solid rgba(248, 113, 113, 0.5);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.35),
        0 0 24px -4px rgba(248, 113, 113, 0.35),
        inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.result-panel--lose .result-panel__btn:hover {
    transform: translateY(-2px);
    box-shadow:
        0 6px 20px rgba(0, 0, 0, 0.4),
        0 0 32px -4px rgba(248, 113, 113, 0.45),
        inset 0 1px 0 rgba(255, 255, 255, 0.25);
    filter: brightness(1.05);
}

.result-panel__btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) inset;
}

.result-panel__btn-text {
    color: inherit;
}

.result-panel__btn-icon {
    width: 1.25rem;
    height: 1.25rem;
    color: inherit;
}

@media (min-width: 640px) {
    .result-panel {
        max-width: 40rem;
    }
    .result-panel__inner {
        padding: 2rem 2rem;
    }
    .result-panel__title {
        font-size: 2.25rem;
    }
    .result-panel__subtitle {
        font-size: 0.85rem;
    }
    .result-panel__desc {
        font-size: 0.95rem;
        margin-bottom: 1.75rem;
    }
    .result-panel__btn {
        padding: 0.85rem 2rem;
        font-size: 1.2rem;
        width: auto;
        min-width: 14rem;
    }
}

@media (min-width: 1024px) {
    .result-panel__title {
        font-size: 2.75rem;
    }
}

@media (max-width: 480px) {
    .result-panel__inner {
        padding: 1.25rem 1rem;
    }
    .result-panel__title {
        font-size: 1.5rem;
        letter-spacing: 0.05em;
    }
    .result-panel__subtitle {
        font-size: 0.7rem;
    }
    .result-panel__desc {
        font-size: 0.8rem;
        margin-bottom: 1.25rem;
    }
    .result-panel__btn {
        padding: 0.65rem 1.25rem;
        font-size: 1rem;
    }
}

/* Panels (cards inside screens) — legacy, kept for any other usage
   ========================================================================== */

.ui-panel {
    width: 100%;
    max-width: 42rem;
    margin: 0 0.5rem;
    padding: 0.75rem;
    text-align: center;
    background-color: var(--color-bg-panel);
    border-radius: var(--radius-panel);
    box-shadow: var(--shadow-panel);
}

.ui-panel--start {
    border: 1px solid var(--color-border-cyan);
}

.ui-panel--win {
    border: 1px solid var(--color-border-green);
}

.ui-panel--lose {
    border: 1px solid var(--color-border-red);
}

.ui-panel__title {
    margin: 0 0 0.5rem;
    font-size: 1.875rem;
    font-weight: 700;
    line-height: 1.2;
}

.ui-panel__title--cyan {
    color: var(--color-cyan);
}

.ui-panel__title--green {
    color: var(--color-green);
}

.ui-panel__title--red {
    color: var(--color-red);
}

.ui-panel__desc {
    margin: 0 0 1rem;
    font-size: 0.875rem;
    color: rgba(212, 212, 212, 0.9);
}

.ui-panel__controls {
    margin: 0 0 1.5rem;
    font-size: 0.875rem;
    font-weight: 700;
}

.ui-panel__controls-hint {
    font-size: 0.75rem;
    color: rgba(107, 114, 128, 1);
}

@media (min-width: 640px) {
    .ui-panel {
        padding: 1.25rem;
    }
    .ui-panel__title {
        font-size: 2.25rem;
    }
    .ui-panel__desc,
    .ui-panel__controls {
        font-size: 1rem;
    }
    .ui-panel__desc {
        margin-bottom: 1.5rem;
    }
    .ui-panel__controls {
        margin-bottom: 2rem;
    }
}

@media (min-width: 1024px) {
    .ui-panel {
        padding: 1.5rem;
    }
    .ui-panel__title {
        font-size: 3rem;
    }
}

@media (max-width: 768px) {
    .ui-panel__title {
        font-size: 2.5rem;
    }
    .ui-panel__desc {
        margin-bottom: 1rem;
    }
    .ui-panel__controls {
        margin-bottom: 1.5rem;
    }
}

@media (max-width: 480px) {
    .ui-panel {
        padding: 0.75rem;
    }
    .ui-panel__title {
        font-size: 2rem;
    }
    .ui-panel__desc {
        margin-bottom: 0.75rem;
    }
    .ui-panel__controls {
        margin-bottom: 1rem;
        font-size: 0.875rem;
    }
}

/* Buttons
   ========================================================================== */

.btn {
    display: inline-block;
    font-family: var(--font-mono);
    font-weight: 700;
    text-align: center;
    border: none;
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: transform var(--transition-fast), box-shadow var(--transition-fast);
    touch-action: manipulation;
    pointer-events: all;
}

.btn--primary {
    padding: 0.5rem 2rem;
    font-size: 1.125rem;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-btn-hover);
}

.btn:active {
    transform: translateY(0);
}

.btn--start {
    width: 100%;
    background-color: var(--color-btn-green);
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.btn--start:hover {
    background-color: var(--color-btn-green-hover);
}

.btn--next,
.btn--retry {
    width: 100%;
    background-color: var(--color-btn-blue);
    color: #fff;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.2);
}

.btn--next:hover,
.btn--retry:hover {
    background-color: var(--color-btn-blue-hover);
}

@media (min-width: 640px) {
    .btn--primary {
        padding: 0.75rem 3rem;
        font-size: 1.25rem;
    }
    .btn--start,
    .btn--next,
    .btn--retry {
        width: auto;
    }
}

@media (min-width: 1024px) {
    .btn--primary {
        font-size: 1.5rem;
    }
}

@media (max-width: 480px) {
    .btn--primary {
        padding: 0.5rem 1.5rem;
        font-size: 1.125rem;
    }
}

/* Utility: hide
   ========================================================================== */

.hidden {
    display: none !important;
}

/* Mobile controller
   ========================================================================== */

.mobile-controller {
    display: none;
    position: absolute;
    bottom: 2rem;
    left: 2rem;
    z-index: var(--z-controller);
}

@media (max-width: 768px) {
    .mobile-controller {
        display: block;
    }
}

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

.controller-container {
    position: relative;
    width: 120px;
    height: 120px;
    pointer-events: none;
}

.controller-outer {
    position: absolute;
    width: 120px;
    height: 120px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(52, 152, 219, 0.3) 0%, rgba(52, 152, 219, 0.1) 50%, rgba(52, 152, 219, 0.05) 100%);
    border: 3px solid rgba(52, 152, 219, 0.4);
    box-shadow:
        0 0 20px rgba(52, 152, 219, 0.3),
        inset 0 0 20px rgba(52, 152, 219, 0.1),
        0 4px 15px rgba(0, 0, 0, 0.3);
    backdrop-filter: blur(10px);
    pointer-events: all;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.controller-outer:active {
    transform: scale(1.05);
    box-shadow:
        0 0 25px rgba(52, 152, 219, 0.5),
        inset 0 0 25px rgba(52, 152, 219, 0.2),
        0 6px 20px rgba(0, 0, 0, 0.4);
}

.controller-outer.active {
    background: radial-gradient(circle, rgba(52, 152, 219, 0.4) 0%, rgba(52, 152, 219, 0.2) 50%, rgba(52, 152, 219, 0.1) 100%);
    border-color: rgba(52, 152, 219, 0.6);
    box-shadow:
        0 0 25px rgba(52, 152, 219, 0.4),
        inset 0 0 25px rgba(52, 152, 219, 0.15),
        0 4px 15px rgba(0, 0, 0, 0.3);
}

.controller-inner {
    --knob-dx: 0px;
    --knob-dy: 0px;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0.7) 100%);
    border: 2px solid rgba(52, 152, 219, 0.8);
    box-shadow:
        0 0 15px rgba(52, 152, 219, 0.4),
        inset 0 2px 5px rgba(255, 255, 255, 0.8),
        inset 0 -2px 5px rgba(0, 0, 0, 0.1);
    transform: translate(var(--knob-dx), var(--knob-dy));
    transition: box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

.controller-inner:active {
    cursor: grabbing;
    transform: translate(var(--knob-dx), var(--knob-dy)) scale(1.1);
    box-shadow:
        0 0 20px rgba(52, 152, 219, 0.6),
        inset 0 2px 5px rgba(255, 255, 255, 0.9),
        inset 0 -2px 5px rgba(0, 0, 0, 0.2);
}

.controller-inner.dragging {
    transform: translate(var(--knob-dx), var(--knob-dy)) scale(1.15);
    box-shadow:
        0 0 25px rgba(52, 152, 219, 0.7),
        inset 0 2px 5px rgba(255, 255, 255, 0.9),
        inset 0 -2px 5px rgba(0, 0, 0, 0.2);
}

.controller-center {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 12px;
    height: 12px;
    margin: -6px 0 0 -6px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(52, 152, 219, 1) 0%, rgba(52, 152, 219, 0.8) 100%);
    box-shadow:
        0 0 8px rgba(52, 152, 219, 0.6),
        inset 0 1px 2px rgba(255, 255, 255, 0.3);
}

@media (max-width: 480px) {
    .controller-container {
        width: 100px;
        height: 100px;
    }
    .controller-outer {
        width: 100px;
        height: 100px;
    }
    .controller-inner {
        width: 42px;
        height: 42px;
        margin: -21px 0 0 -21px;
    }
    .controller-center {
        width: 10px;
        height: 10px;
        margin: -5px 0 0 -5px;
    }
}
