:root {
    color-scheme: dark;
    --ink: #17191f;
    --paper: #f4f1e8;
    --muted: rgba(244, 241, 232, 0.7);
    --line: rgba(244, 241, 232, 0.18);
    --panel: rgba(23, 25, 31, 0.76);
    --gold: #f0b94f;
    --mint: #50d7a0;
    --rose: #ff6b6b;
    --blue: #73b7ff;
    --shadow: rgba(0, 0, 0, 0.42);
}

* {
    box-sizing: border-box;
}

html,
body {
    width: 100%;
    height: 100%;
    margin: 0;
    overflow: hidden;
    background: var(--ink);
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    letter-spacing: 0;
}

body {
    display: grid;
    place-items: center;
}

button {
    border: 0;
    font: inherit;
}

.game-shell {
    position: relative;
    width: min(100vw, 177.78vh);
    height: min(100vh, 56.25vw);
    min-width: 320px;
    min-height: 180px;
    overflow: hidden;
    background: #1b1e24;
    box-shadow: 0 24px 84px rgba(0, 0, 0, 0.48);
}

#gameCanvas {
    display: block;
    width: 100%;
    height: 100%;
    touch-action: none;
}

.hud {
    position: absolute;
    inset: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) auto max(12px, env(safe-area-inset-left));
    display: flex;
    align-items: center;
    gap: 10px;
    pointer-events: none;
}

.hud-item {
    min-width: 82px;
    height: 52px;
    display: grid;
    align-content: center;
    gap: 2px;
    padding: 8px 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--paper);
    background: rgba(18, 20, 25, 0.58);
    box-shadow: 0 16px 38px var(--shadow);
    backdrop-filter: blur(12px);
}

.hud-item span {
    color: var(--muted);
    font-size: clamp(0.62rem, 1.2vw, 0.74rem);
    line-height: 1;
    text-transform: uppercase;
}

.hud-item strong {
    min-width: 44px;
    color: var(--paper);
    font-size: clamp(0.95rem, 1.8vw, 1.14rem);
    line-height: 1.05;
}

.icon-button {
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    margin-left: auto;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--paper);
    background: rgba(18, 20, 25, 0.6);
    box-shadow: 0 16px 38px var(--shadow);
    pointer-events: auto;
    cursor: pointer;
    backdrop-filter: blur(12px);
    font-weight: 900;
}

.menu-panel {
    position: absolute;
    left: clamp(18px, 6vw, 70px);
    bottom: clamp(20px, 6vw, 68px);
    width: min(430px, calc(100% - 36px));
    padding: clamp(18px, 4vw, 30px);
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--paper);
    background: linear-gradient(145deg, rgba(23, 25, 31, 0.92), rgba(39, 43, 51, 0.74));
    box-shadow: 0 26px 80px rgba(0, 0, 0, 0.48);
    backdrop-filter: blur(16px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.menu-panel.is-hidden {
    opacity: 0;
    transform: translateY(16px);
    pointer-events: none;
}

.eyebrow {
    margin: 0 0 8px;
    color: var(--mint);
    font-size: clamp(0.7rem, 1.2vw, 0.82rem);
    font-weight: 800;
    line-height: 1;
    text-transform: uppercase;
}

h1 {
    margin: 0;
    color: var(--paper);
    font-size: clamp(2.15rem, 7.4vw, 4.85rem);
    line-height: 0.94;
    letter-spacing: 0;
}

#panelMeta {
    margin: 14px 0 18px;
    color: var(--muted);
    font-size: clamp(0.96rem, 2vw, 1.08rem);
}

.primary-button {
    min-width: 120px;
    min-height: 48px;
    padding: 0 18px;
    border-radius: 8px;
    color: #151617;
    background: var(--gold);
    font-weight: 900;
    cursor: pointer;
    box-shadow: 0 12px 30px rgba(240, 185, 79, 0.23);
}

.primary-button:focus-visible,
.icon-button:focus-visible,
.control-button:focus-visible {
    outline: 3px solid var(--blue);
    outline-offset: 3px;
}

.touch-controls {
    position: absolute;
    right: max(14px, env(safe-area-inset-right));
    bottom: max(14px, env(safe-area-inset-bottom));
    display: flex;
    align-items: end;
    gap: 10px;
}

.move-pad {
    display: grid;
    grid-template-columns: repeat(2, 58px);
    gap: 8px;
}

.control-button {
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border: 1px solid var(--line);
    border-radius: 8px;
    color: var(--paper);
    background: rgba(18, 20, 25, 0.62);
    box-shadow: 0 16px 38px rgba(0, 0, 0, 0.34);
    cursor: pointer;
    backdrop-filter: blur(12px);
    font-size: 1.55rem;
    font-weight: 900;
    line-height: 1;
}

.primary-control {
    width: 68px;
    height: 68px;
    color: #151617;
    background: var(--mint);
}

.attack-control {
    color: #151617;
    background: var(--rose);
}

@media (hover: hover) and (pointer: fine) {
    .control-button:hover,
    .icon-button:hover,
    .primary-button:hover {
        filter: brightness(1.08);
    }
}

@media (max-width: 680px) {
    .hud {
        gap: 5px;
    }

    .hud-item {
        min-width: 58px;
        height: 46px;
        padding: 7px 8px;
    }

    .icon-button {
        width: 46px;
        height: 46px;
    }

    .touch-controls {
        left: 0;
        right: 0;
        width: auto;
        height: 104px;
        display: block;
    }

    .move-pad {
        position: absolute;
        left: max(14px, env(safe-area-inset-left));
        bottom: 0;
        grid-template-columns: repeat(2, 44px);
        gap: 4px;
    }

    .attack-control {
        position: absolute;
        left: 164px;
        bottom: 0;
        margin-left: 0;
    }

    #dashButton {
        position: absolute;
        left: 218px;
        bottom: 0;
    }

    .control-button {
        width: 44px;
        height: 44px;
    }

    .primary-control {
        position: absolute;
        left: 272px;
        bottom: 54px;
        width: 48px;
        height: 48px;
    }
}
