:root {
    --bg-1: #06101a;
    --bg-2: #0d2231;
    --ink: #e8f6ff;
    --cyan: #3ce7ff;
    --amber: #ffb347;
    --mint: #5affbe;
    --danger: #ff4f63;
}

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

html,
body {
    margin: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    touch-action: none;
    font-family: "Manrope", sans-serif;
    color: var(--ink);
    background:
        radial-gradient(1200px 700px at 20% -20%, #18405b66, transparent 60%),
        radial-gradient(1000px 700px at 120% 120%, #1d3f3a70, transparent 60%),
        linear-gradient(165deg, 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: 800;
    letter-spacing: 0.02em;
    text-shadow: 0 0 14px #3ce7ff70;
}

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

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

.chip {
    min-width: 94px;
    padding: 9px 11px;
    border-radius: 12px;
    background: #04111fcc;
    border: 1px solid #1f425680;
    box-shadow: 0 10px 18px #00000040;
}

.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: 800;
}

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

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

.meter-track {
    width: 100%;
    height: 12px;
    border-radius: 99px;
    border: 1px solid #2e5365;
    background: #051520;
    overflow: hidden;
}

.meter-fill {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, var(--amber), #ffd88a);
    box-shadow: 0 0 18px #ffb34799;
    transition: width 0.12s linear;
}

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

.panel {
    width: min(560px, calc(100vw - 28px));
    border-radius: 20px;
    border: 1px solid #376177;
    background: linear-gradient(165deg, #082031ee, #061421ef);
    box-shadow: 0 22px 52px #00000060;
    padding: 26px 22px;
    text-align: center;
}

h1,
h2 {
    margin: 0;
    font-family: "Russo One", sans-serif;
    font-weight: 400;
    letter-spacing: 0.06em;
}

h1 {
    font-size: clamp(2rem, 9vw, 3.1rem);
    color: #dbf7ff;
    text-shadow: 0 0 22px #3ce7ff7a;
}

h2 {
    font-size: clamp(1.5rem, 8vw, 2.4rem);
    color: #ffd7a1;
}

.tag {
    margin: 8px 0 14px;
    font-weight: 700;
    letter-spacing: 0.06em;
    color: #b9ecff;
}

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

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

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

.btn-primary {
    background: linear-gradient(180deg, #4ceeff, #24c8ea);
    color: #032233;
    box-shadow: 0 10px 18px #3ce7ff52;
}

.btn-secondary {
    background: #0c2e40;
    color: #d9f3ff;
    border: 1px solid #2d5a72;
}

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

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

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

.score-block .value {
    font-size: clamp(2.2rem, 10vw, 3.3rem);
    font-weight: 800;
    line-height: 1;
    color: #edfbff;
}

.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 #2b4f63;
    background: #051826b0;
}

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

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

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

.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;
    }

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

    .panel {
        padding: 20px 16px;
    }

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