:root {
    color-scheme: light;
    --ink: #182540;
    --muted: #52627c;
    --primary: #254fce;
    --primary-dark: #1e3fa5;
    --primary-soft: #e8efff;
    --line: #d9e2f0;
    --surface: #edf2f9;
    --panel: #fff;
    --accent: #a75a06;
    --green: #176c58;
    --radius-md: 10px;
    --radius-lg: 14px;
    --shadow-md: 0 14px 40px rgb(27 49 88 / 12%);
    --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'Cascadia Mono', Consolas, monospace;
    --gradient-primary: linear-gradient(140deg, #254fce, #217997);
    --gray-50: #f8faff;
    --gray-100: #eff3f9;
    --gray-200: #e4eaf3;
    --gray-500: #63738b;
    --gray-600: #53637a;
    --gray-700: #3b4e69;
    --gray-800: #24344f;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
    margin: 0;
    background: var(--surface);
    color: var(--ink);
    font-family: var(--font);
}
h1, h2, h3, p, dl, dd { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; }
button, summary, a { cursor: pointer; }
:focus-visible { outline: 3px solid #805cf5; outline-offset: 2px; }
button:disabled { opacity: 0.5; cursor: default; }

.app-shell {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    gap: 10px;
    width: min(100%, 1760px);
    height: 100vh;
    height: 100dvh;
    margin-inline: auto;
    padding: 10px 14px 6px;
}
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
    min-width: 0;
    min-height: 50px;
    padding: 5px 10px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--panel);
}
.brand {
    display: flex;
    align-items: center;
    min-width: 0;
    gap: 8px;
    text-decoration: none;
}
.logo-img { width: 34px; height: 34px; flex: none; border-radius: 8px; }
.brand-copy { display: grid; gap: 1px; }
.brand-copy strong { color: #1e346b; font-size: 17px; line-height: 1.05; }
.brand-copy span { color: var(--muted); font-size: 12px; line-height: 1.15; }
.top-actions { display: flex; gap: 5px; }
.ghost-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    min-height: 34px;
    padding: 0 10px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    color: #293b5d;
    font-size: 13px;
    font-weight: 650;
    text-decoration: none;
    white-space: nowrap;
}
.ghost-link:hover:not(:disabled) { border-color: #a9bce5; background: var(--gray-50); }
.top-actions .ghost-link { background: #f8faff; }

.game-layout {
    display: grid;
    grid-template-columns: clamp(230px, 22vw, 290px) minmax(0, 1fr) clamp(196px, 17vw, 244px);
    grid-template-areas: 'editor board modes';
    align-items: stretch;
    gap: 10px;
    min-height: 0;
}
.editor-panel, .play-panel, .mode-panel {
    min-width: 0;
    min-height: 0;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
}
.editor-panel {
    grid-area: editor;
    display: flex;
    flex-direction: column;
    gap: 11px;
    padding: 11px;
}
.equation-composer { display: grid; gap: 5px; min-width: 0; }
.section-label { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.section-label label, .panel-heading { color: #233d71; font-size: 14px; font-weight: 750; }
.section-label span { color: var(--muted); font-size: 11px; }
.equation-input-wrap { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 5px; }
.eq-field {
    min-width: 0;
    width: 100%;
    height: 42px;
    padding: 0 9px;
    border: 1px solid #b9c9e6;
    border-radius: 8px;
    background: #f8faff;
    color: var(--ink);
    font-family: var(--font-mono);
    font-size: 15px;
}
.btn-add, .btn-launch, .primary-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 42px;
    padding: 0 13px;
    border: 1px solid transparent;
    border-radius: 8px;
    background: var(--primary);
    color: white;
    font-size: 14px;
    font-weight: 750;
    text-decoration: none;
    white-space: pre;
}
.btn-add:hover, .btn-launch:hover, .primary-link:hover { background: var(--primary-dark); }
.btn-cancel-edit {
    justify-self: start;
    padding: 0;
    border: 0;
    background: none;
    color: var(--primary-dark);
    font-size: 12px;
    text-decoration: underline;
}
.editor-tools { display: flex; gap: 4px; flex-wrap: wrap; }
.editor-tools .ghost-link { min-height: 29px; padding-inline: 6px; font-size: 12px; }

.track-panel { display: flex; flex-direction: column; gap: 5px; min-height: 0; }
.track-heading { display: flex; flex-direction: column; gap: 6px; }
.track-title { display: flex; justify-content: space-between; align-items: center; gap: 5px; }
.track-heading span {
    min-width: 20px;
    padding: 2px 4px;
    border-radius: 6px;
    background: var(--primary-soft);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
    text-align: center;
}

.keyboard-box {
    --key-height: clamp(30px, 5.2vh, 43px);
    --key-columns: 6;
    --key-rows: 4;
    flex: none;
    min-width: 0;
    padding: 6px;
    border: 1px solid #dce5f4;
    border-radius: 10px;
    background: #f0f5ff;
}
.math-keyboard { display: grid; gap: 5px; min-width: 0; }
.math-preview {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 34px;
    min-width: 0;
    padding-inline: 5px;
    overflow: hidden;
    border: 1px solid #e0e8f7;
    border-radius: 6px;
    background: #fbfdff;
    font-family: var(--font-mono);
    font-size: 13px;
}
.preview-placeholder { color: var(--muted); font: 12px var(--font); }
.keyboard-tabs, .keyboard-actions {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 4px;
    min-width: 0;
}
.keyboard-actions { grid-template-columns: repeat(3, minmax(0, 1fr)) repeat(2, minmax(0, 1.4fr)); }
.keyboard-tab, .keyboard-key, .keyboard-action {
    min-width: 0;
    padding: 0 2px;
    border: 1px solid #d7e1f1;
    border-radius: 6px;
    background: #fff;
    color: #243959;
    font-size: 12px;
    font-weight: 650;
    line-height: 1;
}
.keyboard-tab, .keyboard-action { min-height: 30px; }
.keyboard-tab.active { border-color: #a2b8ee; background: #dbe7ff; color: #16378f; }
.keyboard-key {
    font-family: var(--font-mono);
    font-size: clamp(10px, 1.2vw, 13px);
}
.keyboard-key.long-label { font-size: 9px; letter-spacing: -0.025em; }
.keyboard-key.key-operator, .keyboard-key.key-template, .keyboard-key.key-function { background: #e9f0ff; color: #244c9b; }
.keyboard-key.key-variable, .keyboard-key.key-constant { background: #e7f5ef; color: #196650; }
.keyboard-key:hover, .keyboard-action:hover, .keyboard-tab:hover { border-color: #92a7d1; }
.keyboard-action.action-submit { background: #dbe7ff; color: #16378f; }
.keyboard-panel { display: none; }
.keyboard-panel.active {
    display: grid;
    grid-template-columns: repeat(var(--key-columns), minmax(0, 1fr));
    grid-template-rows: repeat(var(--key-rows), var(--key-height));
    gap: 4px;
}

.play-panel {
    grid-area: board;
    display: flex;
    flex-direction: column;
    padding: 6px;
}
.graph-toolbar {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: space-between;
    gap: 7px;
    padding: 10px;
    border: 1px solid #dce6f8;
    border-radius: 10px;
    background: linear-gradient(140deg, #f6f9ff, #ebf2ff);
}
.mission-summary { min-width: 0; }
.mission-summary h1 {
    color: #203a74;
    font-size: clamp(19px, 1.8vw, 25px);
    line-height: 1.13;
    letter-spacing: -0.025em;
}
.mission-summary p { margin-top: 3px; color: var(--muted); font-size: 13px; line-height: 1.25; }
.hud-stats { display: flex; align-items: center; gap: 5px; }
.score-chip, .hud-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 30px;
    padding: 0 8px;
    border: 1px solid #ebcf93;
    border-radius: 7px;
    background: #fff7e7;
    color: #71460a;
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}
.score-dot { color: #9d5807; }
.hud-chip { border-color: #b8c9f2; background: var(--primary-soft); color: var(--primary-dark); }
.hud-chip > span { font-size: 11px; }
.timer-urgent { background: #fef0ee; border-color: #f0b1a9; color: #8e261e; }
.graph-stage {
    position: relative;
    min-height: 0;
    flex: 1 1 0;
    padding: 5px;
    border: 1px solid #dbe5f5;
    border-radius: 10px;
    background: radial-gradient(ellipse at 50% 32%, #f7faff, #e9f0fa);
}
.draft-indicator {
    position: absolute;
    inset: 6px 6px auto auto;
    padding: 3px 6px;
    border: 1px dashed #5477b8;
    border-radius: 5px;
    background: #f8fbff;
    color: #28446d;
    font-size: 11px;
    font-weight: 650;
    pointer-events: none;
}
#gameCanvas { display: flex; align-items: center; justify-content: center; width: 100%; height: 100%; }
#gameCanvas canvas { display: block; border-radius: 4px; box-shadow: 0 0 0 1px #cfdbed, 0 6px 18px #243d6812; }
.play-controls { display: flex; flex-direction: column; gap: 7px; }
.board-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 5px;
}
.board-actions .btn-launch {
    grid-column: 1 / -1;
    min-height: 43px;
    background: linear-gradient(110deg, #2652d5, #2244b8);
}
.board-actions .btn-launch:hover { background: var(--primary-dark); }
.board-actions .ghost-link { min-height: 32px; padding-inline: 4px; }
.board-status {
    display: grid;
    gap: 5px;
    min-width: 0;
    padding: 7px;
    border: 1px solid transparent;
    border-radius: 9px;
    color: #28446d;
    font-size: 12px;
    line-height: 1.3;
}
.board-status:not(:has(.board-messages > :not([hidden]), .result-actions:not([hidden]))) {
    visibility: hidden;
    padding-block: 0;
}
.board-status:has(.board-messages > :not([hidden])) {
    border-color: #d9e5ff;
    background: #eff5ff;
}
.board-status:has(.puzzle-result.solved:not([hidden])) {
    border-color: #e8ca83;
    background: linear-gradient(120deg, #fff9ea, #fff0c8);
    color: #593b07;
}
.board-messages { flex: 1; min-width: 0; max-height: 100%; overflow: auto; }
.puzzle-result { display: grid; gap: 4px; }
.solve-badge { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.solve-icon {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    flex: none;
    border: 1px solid #e4b94f;
    border-radius: 50%;
    background: #ffe39b;
    color: #754300;
    line-height: 1;
}
.result-actions .ghost-link { min-height: 26px; }
.toast {
    position: fixed;
    z-index: 5;
    right: 14px;
    bottom: 34px;
    max-width: min(440px, calc(100% - 28px));
    border-radius: 8px;
    background: #2b4fa4;
    color: white;
    font-size: 13px;
    font-weight: 650;
    opacity: 0;
    pointer-events: none;
}
.toast.info, .toast.error { padding: 8px 11px; opacity: 1; }
.toast.error { background: #972f26; }

.mode-panel {
    grid-area: modes;
    display: flex;
    flex-direction: column;
    gap: 9px;
    padding: 10px;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.mode-panel > * { flex: none; }
.mode-controls { display: grid; gap: 8px; }
.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; margin-top: 6px; }
.mode-card {
    display: grid;
    justify-items: start;
    align-content: center;
    gap: 2px;
    min-width: 0;
    min-height: 41px;
    padding: 4px 7px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #f9fbff;
    color: #324867;
    text-align: left;
}
.mode-card strong { font-size: 13px; }
.mode-card span { color: var(--muted); font-size: 10.5px; line-height: 1.18; }
.mode-card:hover, .mode-card.active { border-color: #a0b9ed; background: #eaf1ff; color: #173a91; }
.mode-card.active { box-shadow: inset 2px 0 0 var(--primary); }
.mode-card.daily { grid-column: 1 / -1; }
.mode-card.daily:not(.active) { background: #f2f9f6; }
.score-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 5px;
    padding-top: 6px;
    border-top: 1px solid var(--line);
    color: var(--muted);
    font-size: 12px;
}
.score-summary span { display: grid; gap: 2px; text-align: center; font-size: 11px; }
.score-summary strong { color: var(--ink); }
.daily-actions { display: flex; flex-wrap: wrap; gap: 4px; }
.daily-actions .ghost-link { min-height: 28px; padding-inline: 6px; font-size: 12px; }
.zen-controls { display: grid; gap: 4px; color: var(--muted); font-size: 12px; }
.zen-controls select {
    min-width: 0;
    width: 100%;
    min-height: 27px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: var(--panel);
    color: var(--ink);
    font: inherit;
}

.eq-list {
    display: grid;
    align-content: start;
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
}
.equation-item {
    display: flex;
    gap: 7px;
    align-items: center;
    padding: 6px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--gray-50);
}
.equation-item.editing { border-color: #8ca7f1; }
.equation-color { align-self: stretch; flex: 0 0 5px; border-radius: 6px; }
.equation-text { min-width: 0; flex: 1; overflow-wrap: anywhere; font: 13px var(--font-mono); }
.equation-buttons { display: flex; gap: 4px; }
.equation-buttons button {
    padding: 4px 6px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--primary-dark);
    font-size: 12px;
    font-weight: 650;
}
.equation-buttons .remove-btn { color: #8e261e; }
.empty-state { padding: 8px; color: var(--muted); font-size: 13px; }
.coord-row { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-block: 12px; }
.coord-box {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
    padding: 5px 8px;
    border: 1px solid #b9c9e6;
    border-radius: 8px;
    background: #f8faff;
    font: 14px var(--font-mono);
}
.coord-box input { flex: 1; min-width: 0; width: 100%; padding: 3px; border: 0; background: transparent; color: var(--ink); }

.game-dialog {
    width: min(430px, calc(100% - 22px));
    max-height: calc(100dvh - 28px);
    overflow: auto;
    margin: auto;
    padding: 16px;
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    color: var(--ink);
    box-shadow: var(--shadow-md);
}
.game-dialog::backdrop { background: rgb(16 37 75 / 55%); }
.game-dialog h2 { margin-bottom: 8px; font-size: 21px; }
.game-dialog p, .game-dialog label { font-size: 14px; }
.game-dialog label:not(.coord-box) { display: block; }
.game-dialog textarea, .game-dialog input[type="date"] {
    min-height: 34px;
    padding: 4px 7px;
    border: 1px solid var(--line);
    border-radius: 6px;
    background: white;
    color: var(--ink);
}
.game-dialog textarea { display: block; width: 100%; margin-top: 4px; resize: vertical; }
.dialog-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 10px; }
#archiveForm { margin-top: 10px; }
#archiveForm label { margin-bottom: 4px; }
#shareStatus:not(:empty) { margin-top: 8px; }

.site-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 3px 12px;
    padding-inline: 2px;
    color: #4f617d;
    font-size: 12px;
    line-height: 1.35;
}
.site-footer nav { display: flex; align-items: center; gap: 4px 13px; flex-wrap: wrap; }
.site-footer a { text-underline-offset: 2px; }
.script-notice { padding: 6px; background: #fff7e7; }

.page-shell {
    display: grid;
    gap: 16px;
    width: min(100%, 940px);
    margin-inline: auto;
    padding: clamp(10px, 3vw, 28px);
}
.content-page {
    padding: clamp(20px, 5vw, 46px);
    border: 1px solid var(--line);
    border-radius: 14px;
    background: var(--panel);
    color: #293956;
    line-height: 1.6;
    overflow-wrap: anywhere;
}
.content-page h1, .content-page h2, .content-page h3 { color: #20376f; line-height: 1.2; }
.content-page h1 { margin-bottom: 12px; font-size: clamp(25px, 5vw, 44px); letter-spacing: -0.035em; }
.content-page h2 { margin: 23px 0 8px; font-size: clamp(18px, 4vw, 24px); }
.content-page h3 { margin-bottom: 5px; font-size: 17px; }
.content-page p + p { margin-top: 9px; }
.content-page a:not([class]), .back-link { color: var(--primary-dark); }
.content-page code { padding: 2px 4px; border-radius: 4px; background: #edf2fc; font-family: var(--font-mono); }
.page-actions { display: flex; flex-wrap: wrap; gap: 7px; margin-block: 12px; }
.back-link { display: inline-block; margin-bottom: 9px; }
.content-list { padding-left: 20px; }
.content-list li + li { margin-top: 6px; }
.lesson-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; }
.lesson-grid article, .lesson-list li, .preference-box {
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 9px;
    background: #f7faff;
}
.lesson-grid p, .lesson-list p { margin-bottom: 7px; }
.lesson-list { list-style-position: inside; display: grid; gap: 8px; padding: 0; }
.lesson-list h3 { display: inline; }
.lesson-list p { margin-top: 4px; }
.mode-guide { display: grid; grid-template-columns: max-content 1fr; gap: 5px 10px; }
.mode-guide dt { font-weight: 700; }
.preference-box { margin-block: 12px; }
.examples-footer { width: min(100% - 24px, 1040px); margin: 12px auto; }

@media (max-width: 1040px) and (min-width: 761px) {
    .game-layout { grid-template-columns: minmax(215px, 236px) minmax(0, 1fr) minmax(165px, 190px); }
    .editor-panel, .play-panel, .mode-panel { padding: 7px; }
    .editor-tools .ghost-link { padding-inline: 4px; }
}

@media (max-width: 760px) {
    .app-shell { gap: 5px; padding: 5px 6px 4px; }
    .top-bar { min-height: 39px; padding: 3px 6px; gap: 5px; }
    .logo-img { width: 26px; height: 26px; }
    .brand { gap: 4px; }
    .brand-copy strong { font-size: 15px; }
    .brand-copy span { display: none; }
    .top-actions { gap: 3px; }
    .top-actions .ghost-link { min-height: 30px; padding-inline: 6px; font-size: 12px; }
    .game-layout {
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto auto auto auto minmax(0, 1fr) auto auto;
        grid-template-areas: 'modes' 'composer' 'tracks' 'title' 'board' 'actions' 'keyboard';
        gap: 4px;
    }
    .editor-panel { display: contents; }
    .equation-composer { grid-area: composer; gap: 2px; }
    .section-label label { font-size: 12px; }
    .eq-field, .btn-add { height: 35px; min-height: 35px; }
    .eq-field { font-size: 16px; }
    .editor-tools { gap: 3px; flex-wrap: nowrap; }
    .editor-tools .ghost-link { min-height: 26px; padding-inline: 5px; }
    .track-panel { grid-area: tracks; gap: 2px; height: 79px; }
    .track-heading { flex-direction: row; align-items: center; justify-content: space-between; }
    .track-heading .panel-heading { font-size: 12px; }
    .track-heading span { padding-block: 1px; }
    .eq-list { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 3px; }
    .eq-list .empty-state { grid-column: 1 / -1; padding: 2px 3px; font-size: 11px; }
    .equation-item { min-height: 24px; padding: 2px 4px; gap: 4px; }
    .equation-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        font-size: 11px;
    }
    .equation-buttons { gap: 3px; }
    .equation-buttons button { padding: 1px 3px; font-size: 10px; }
    .keyboard-box { grid-area: keyboard; --key-columns: 8; --key-rows: 3; --key-height: clamp(26px, 4.4vh, 37px); padding: 4px; }
    .math-keyboard, .keyboard-panel.active { gap: 3px; }
    .math-preview { height: 25px; }
    .keyboard-key { font-size: 12px; }
    .keyboard-tab, .keyboard-action { min-height: 25px; }
    .mode-panel { display: contents; }
    .mode-controls {
        grid-area: modes;
        gap: 3px;
        padding: 3px;
        border: 1px solid var(--line);
        border-radius: 8px;
        background: var(--panel);
    }
    .mode-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 3px; margin: 0; }
    .mode-panel .panel-heading, .mode-card span { display: none; }
    .mode-card { justify-items: center; text-align: center; min-height: 28px; padding: 1px; }
    .mode-card strong { font-size: 11px; }
    .mode-card.daily { grid-column: auto; }
    .score-summary { display: flex; justify-content: space-between; padding: 1px 3px 0; font-size: 11px; }
    .score-summary span { display: flex; gap: 5px; }
    .daily-actions { justify-content: end; }
    .zen-controls { display: flex; align-items: center; justify-content: end; }
    .zen-controls select { width: auto; min-height: 23px; }
    .play-panel { padding: 2px; border-radius: 9px; }
    .graph-toolbar {
        grid-area: title;
        flex-direction: row;
        align-items: center;
        gap: 4px;
        padding: 2px 4px;
        border: 0;
        background: transparent;
    }
    .mission-summary h1 { font-size: 16px; }
    .mission-summary p { margin-top: 1px; font-size: 11px; }
    .score-chip, .hud-chip { min-height: 24px; padding-inline: 5px; font-size: 11px; }
    .hud-chip > span { display: none; }
    .play-controls { grid-area: actions; gap: 3px; }
    .board-actions { display: flex; flex-wrap: wrap; gap: 3px; }
    .board-actions .btn-launch { flex: 1 1 auto; }
    .board-actions .btn-launch, .board-actions .ghost-link { min-height: 28px; padding-inline: 6px; font-size: 12px; }
    .board-actions .btn-launch span { display: none; }
    .board-status {
        display: flex;
        align-items: center;
        gap: 4px;
        height: 32px;
        padding: 0 4px;
        font-size: 11px;
    }
    .puzzle-result { display: flex; align-items: center; gap: 5px; }
    .solve-badge { gap: 3px; font-size: 12px; }
    .solve-icon { width: 19px; height: 19px; }
    .result-actions { flex: none; }
    .result-actions .ghost-link { min-height: 24px; padding-inline: 5px; font-size: 11px; }
    .graph-stage { padding: 3px; }
    .site-footer { font-size: 11px; }
    .app-shell .site-footer { justify-content: center; }
    .app-shell .site-footer > p { display: none; }
    .app-shell .site-footer nav { justify-content: center; gap: 3px 8px; }
}

@media (max-height: 650px) and (max-width: 760px) {
    .math-preview { display: none; }
    .track-panel { height: 53px; }
    .keyboard-box { --key-height: 26px; }
}

@media (max-height: 500px) and (min-width: 580px) and (max-width: 760px) {
    .game-layout {
        grid-template-columns: minmax(190px, 0.85fr) minmax(0, 1.15fr);
        grid-template-rows: auto auto auto minmax(0, 1fr) auto;
        grid-template-areas: 'modes modes' 'composer title' 'tracks board' 'keyboard board' 'keyboard actions';
    }
    .keyboard-box { align-self: start; --key-columns: 6; --key-rows: 4; --key-height: 24px; }
}

@media (max-height: 420px) and (min-width: 761px) {
    .keyboard-box { --key-height: 25px; }
    .math-preview { display: none; }
    .mode-panel { gap: 5px; }
    .mode-controls, .play-controls { gap: 5px; }
    .mode-card { min-height: 33px; }
    .mode-card span { display: none; }
}

@media (max-width: 350px) {
    .top-actions .ghost-link { padding-inline: 4px; }
    .keyboard-key { font-size: 11px; }
    .editor-tools .ghost-link { padding-inline: 5px; }
}
