:root {
    --bg: #07111f;
    --border: rgba(255,255,255,.10);
    --text: #f4f7fb;
    --muted: #9baabd;
    --blue: #4da3ff;
    --cyan: #39d9ff;
    --green: #45e6a3;
    --purple: #9270ff;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    min-height: 100vh;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at 50% -10%, rgba(57,217,255,.14), transparent 35%),
        radial-gradient(circle at 90% 20%, rgba(146,112,255,.08), transparent 30%),
        var(--bg);
    line-height: 1.5;
}

button, a { font: inherit; }
button { color: inherit; }
a { color: inherit; text-decoration: none; }

.app-shell { max-width: 1320px; margin: auto; padding: 0 22px 40px; }

.topbar {
    min-height: 76px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-bottom: 1px solid rgba(255,255,255,.06);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-size: 19px;
    font-weight: 850;
}
.brand > span:last-child > span { color: var(--cyan); }

.brand-mark {
    width: 35px; height: 35px; display: grid; place-items: center;
    border-radius: 11px;
    background: linear-gradient(135deg, var(--cyan), var(--blue), var(--purple));
    box-shadow: 0 8px 30px rgba(57,217,255,.18);
}

.top-actions { display: flex; gap: 9px; align-items: center; }

.icon-button, .back-link {
    min-height: 40px;
    border: 1px solid var(--border);
    border-radius: 11px;
    background: rgba(255,255,255,.04);
}

.icon-button { width: 42px; cursor: pointer; }
.back-link { display: inline-flex; align-items: center; padding: 0 14px; color: var(--muted); font-size: 13px; }

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 300px;
    gap: 22px;
    padding-top: 32px;
}

.game-panel, .info-card {
    border: 1px solid var(--border);
    background: linear-gradient(180deg, rgba(255,255,255,.052), rgba(255,255,255,.025));
}

.game-panel { padding: 26px; border-radius: 24px; }

.title-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    gap: 18px;
    margin-bottom: 22px;
}

.eyebrow { color: #91f3c7; font-size: 11px; font-weight: 800; letter-spacing: .9px; margin-bottom: 5px; }
h1 { font-size: clamp(34px, 5vw, 55px); line-height: 1; letter-spacing: -2px; }
.subtitle { margin-top: 10px; max-width: 560px; color: var(--muted); font-size: 14px; }

.scoreboard { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; min-width: 230px; }
.score-box {
    padding: 9px 12px; border: 1px solid var(--border);
    border-radius: 12px; background: rgba(255,255,255,.035);
}
.score-box span { display: block; color: var(--muted); font-size: 9px; text-transform: uppercase; letter-spacing: .6px; }
.score-box strong { display: block; margin-top: 1px; font-size: 20px; }

.game-frame {
    position: relative;
    overflow: hidden;
    width: 100%;
    aspect-ratio: 16 / 10;
    border: 1px solid rgba(57,217,255,.15);
    border-radius: 20px;
    background: #06101c;
    box-shadow: inset 0 0 60px rgba(57,217,255,.03), 0 18px 60px rgba(0,0,0,.24);
}

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

.overlay {
    position: absolute; inset: 0; display: grid; place-items: center;
    padding: 25px; background: rgba(3,10,18,.66);
    backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px);
}

.hidden { display: none !important; }

.overlay-card {
    width: min(410px, 100%); padding: 30px;
    border: 1px solid rgba(255,255,255,.10);
    border-radius: 22px; background: rgba(7,17,31,.94);
    text-align: center; box-shadow: 0 20px 80px rgba(0,0,0,.35);
}

.overlay-card.compact { max-width: 330px; }
.overlay-icon { font-size: 42px; margin-bottom: 10px; }
.overlay-card h2 { font-size: 29px; letter-spacing: -1px; }
.overlay-card p { margin-top: 8px; color: var(--muted); }

.primary-button, .secondary-button {
    width: 100%; margin-top: 18px; padding: 13px 18px;
    border-radius: 12px; cursor: pointer; font-weight: 850;
}
.primary-button {
    border: 0; background: linear-gradient(135deg, #6beaff, #4da3ff);
    color: #03101c; box-shadow: 0 10px 35px rgba(77,163,255,.22);
}
.secondary-button { border: 1px solid var(--border); background: rgba(255,255,255,.05); }

.highscore-message { color: #91f3c7 !important; font-weight: 800; }

.side-panel { display: flex; flex-direction: column; gap: 15px; }
.info-card { padding: 21px; border-radius: 18px; }
.info-card h2 { margin-bottom: 8px; font-size: 17px; }
.info-card p { color: var(--muted); font-size: 13px; }

.key-grid { display: grid; grid-template-columns: 82px 1fr; gap: 7px 12px; font-size: 12px; }
.key-grid span:nth-child(odd) {
    padding: 4px 7px; border: 1px solid var(--border); border-radius: 7px;
    background: rgba(255,255,255,.04); text-align: center;
}
.key-grid span:nth-child(even) { display: flex; align-items: center; color: var(--muted); }

.mobile-controls {
    display: none; grid-template-columns: repeat(2, 90px);
    justify-content: center; gap: 12px; margin-top: 16px;
}
.control-button {
    min-height: 54px; border: 1px solid var(--border);
    border-radius: 14px; background: rgba(255,255,255,.055);
    font-size: 22px; cursor: pointer; touch-action: none;
}

.status-row {
    display: flex; justify-content: space-between; gap: 15px;
    margin-top: 14px; color: var(--muted); font-size: 11px;
}
#saveStatus { color: #91f3c7; }

@media (max-width: 1000px) {
    .game-layout { grid-template-columns: 1fr; }
    .side-panel { display: grid; grid-template-columns: repeat(2,1fr); }
}

@media (max-width: 720px) {
    .app-shell { padding-left: 12px; padding-right: 12px; }
    .topbar { min-height: 64px; }
    .brand { font-size: 16px; }
    .brand-mark { width: 31px; height: 31px; }
    .back-link { display: none; }
    .game-panel { padding: 14px; border-radius: 18px; }
    .title-row { flex-direction: column; align-items: stretch; }
    .scoreboard { min-width: 0; width: 100%; grid-template-columns: repeat(4, 1fr); }
    .score-box { padding: 7px 8px; }
    .score-box strong { font-size: 17px; }
    .mobile-controls { display: grid; }
    .side-panel { grid-template-columns: 1fr; }
}
