:root {
    --bg-1: #0d111f;
    --bg-2: #1f2435;
    --ink: #eef5ff;
    --cyan: #69f0ff;
    --amber: #ffc857;
    --mint: #70ffb5;
    --danger: #ff6f91;
    --line: #a4b7da44;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    font-family: "Space Grotesk", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(950px 620px at 0% -15%, #3c446a70, transparent 60%),
        radial-gradient(1000px 700px at 110% 120%, #25515f66, transparent 62%),
        linear-gradient(160deg, var(--bg-1), var(--bg-2));
}

#gameCanvas {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
}

.back-link {
    position: fixed;
    left: 14px;
    top: 14px;
    z-index: 1200;
    color: var(--cyan);
    text-decoration: none;
    font-weight: 700;
    letter-spacing: 0.02em;
    text-shadow: 0 0 14px #6cf0ff70;
}

.back-link:hover,
.back-link:focus-visible {
    color: #c2f8ff;
}

.hud {
    position: fixed;
    top: 14px;
    right: 14px;
    display: flex;
    gap: 8px;
    z-index: 20;
}

.chip {
    min-width: 94px;
    padding: 9px 11px;
    border-radius: 12px;
    border: 1px solid #314770;
    background: #111a30cc;
    box-shadow: 0 8px 18px #00000045;
}

.chip span {
    display: block;
    font-size: 0.62rem;
    letter-spacing: 0.08em;
    opacity: 0.8;
}

.chip strong {
    display: block;
    margin-top: 3px;
    font-size: 1rem;
    font-weight: 700;
}

.energy-wrap {
    position: fixed;
    left: 50%;
    bottom: 20px;
    transform: translateX(-50%);
    width: min(460px, calc(100vw - 24px));
    z-index: 20;
}

.energy-label {
    font-size: 0.68rem;
    letter-spacing: 0.12em;
    margin-bottom: 6px;
    opacity: 0.88;
}

.energy-track {
    width: 100%;
    height: 12px;
    border-radius: 999px;
    border: 1px solid #38517f;
    background: #0a1428;
    overflow: hidden;
}

.energy-fill {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #70ffb5, #ffc857 72%, #ff6f91 100%);
    transform-origin: left center;
    box-shadow: 0 0 22px #70ffb577;
    transition: width 0.08s linear;
}

.overlay {
    position: fixed;
    inset: 0;
    z-index: 30;
    display: grid;
    place-items: center;
    background: linear-gradient(180deg, #060a1480, #060a14cc);
    backdrop-filter: blur(2px);
}

.panel {
    width: min(560px, calc(100vw - 28px));
    border-radius: 20px;
    padding: 26px 22px;
    text-align: center;
    background: linear-gradient(150deg, #111a31ee, #0b1326ef);
    border: 1px solid #3f5a8f;
    box-shadow: 0 22px 52px #00000060;
}

h1,
h2 {
    margin: 0;
    font-family: "Bebas Neue", sans-serif;
    letter-spacing: 0.05em;
    font-weight: 400;
}

h1 {
    font-size: clamp(2.2rem, 10vw, 3.5rem);
    color: #f4f8ff;
    text-shadow: 0 0 20px #9cb4ff7a;
}

h2 {
    font-size: clamp(1.7rem, 8vw, 2.6rem);
    color: #ffd0de;
}

.tag {
    margin: 9px 0 14px;
    color: #d4dcf2;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.best-line {
    margin: 0 0 18px;
    opacity: 0.88;
}

.btn {
    appearance: none;
    border: none;
    cursor: pointer;
    border-radius: 12px;
    padding: 12px 18px;
    font-weight: 700;
    letter-spacing: 0.04em;
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

.btn:hover,
.btn:focus-visible {
    transform: translateY(-1px);
}

.btn-primary {
    color: #091124;
    background: linear-gradient(180deg, #83f6ff, #4dddf0);
    box-shadow: 0 10px 20px #69f0ff58;
}

.btn-secondary {
    color: #e4ecff;
    background: #172545;
    border: 1px solid #395182;
}

.hint {
    margin-top: 12px;
    font-size: 0.9rem;
    opacity: 0.78;
}

.score-block {
    margin-top: 10px;
}

.label {
    font-size: 0.7rem;
    letter-spacing: 0.1em;
    opacity: 0.8;
}

.value {
    font-size: clamp(2.2rem, 10vw, 3.3rem);
    font-weight: 700;
    line-height: 1;
}

.stats {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin: 18px 0;
}

.stats>div {
    border-radius: 12px;
    padding: 10px;
    border: 1px solid #334d7b;
    background: #0f1d3cb0;
}

.stat-value {
    font-size: 1.2rem;
    font-weight: 700;
}

.stat-label {
    font-size: 0.68rem;
    letter-spacing: 0.08em;
    opacity: 0.8;
}

.button-row {
    display: flex;
    justify-content: center;
    gap: 10px;
}

.share-feedback {
    margin-top: 10px;
    color: var(--mint);
    font-weight: 700;
}

.hidden {
    display: none !important;
}

@media (max-width: 720px) {
    .hud {
        top: 58px;
        left: 10px;
        right: 10px;
        justify-content: space-between;
    }

    .chip {
        min-width: auto;
        flex: 1;
        padding: 8px 10px;
    }

    .chip strong {
        font-size: 0.92rem;
    }

    .energy-wrap {
        bottom: calc(16px + env(safe-area-inset-bottom));
    }

    .panel {
        padding: 20px 16px;
    }

    .button-row {
        flex-direction: column;
    }
}
