:root {
    --ink: #17201b;
    --ink-soft: #56625b;
    --paper: #f4f7f3;
    --surface: #ffffff;
    --line: #d6ddd7;
    --line-strong: #afb9b1;
    --night: #171b19;
    --night-2: #242a27;
    --lime: #c7f05a;
    --lime-dark: #779d15;
    --coral: #f05c4f;
    --yellow: #f1c84a;
    --blue: #3377d6;
    --green: #28845d;
    --radius: 8px;
    --shadow: 0 18px 48px rgba(18, 28, 22, 0.12);
}

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

html {
    scroll-behavior: smooth;
}

body {
    min-width: 320px;
    min-height: 100vh;
    background: var(--paper);
    color: var(--ink);
    font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang TC", "Noto Sans TC", sans-serif;
    font-size: 16px;
    line-height: 1.5;
    letter-spacing: 0;
}

button,
input {
    color: inherit;
    font: inherit;
    letter-spacing: 0;
}

button,
a,
input,
.cell {
    -webkit-tap-highlight-color: transparent;
}

button {
    border: 0;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
    outline: 3px solid #4b8bea;
    outline-offset: 3px;
}

a {
    color: inherit;
}

.skip-link {
    position: fixed;
    top: 8px;
    left: 8px;
    z-index: 1000;
    padding: 10px 14px;
    background: var(--surface);
    border-radius: 4px;
    transform: translateY(-160%);
}

.skip-link:focus {
    transform: translateY(0);
}

.site-header {
    position: relative;
    z-index: 20;
    display: flex;
    align-items: center;
    justify-content: space-between;
    min-height: 76px;
    padding: 12px max(24px, calc((100vw - 1440px) / 2));
    background: var(--night);
    border-bottom: 1px solid #363c39;
    color: #fff;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: inherit;
    text-decoration: none;
}

.brand-mark {
    position: relative;
    display: grid;
    width: 42px;
    height: 42px;
    place-items: center;
    background: var(--lime);
    border-radius: 50%;
}

.brand-mark::before,
.brand-mark::after,
.brand-mark span::before,
.brand-mark span::after {
    position: absolute;
    width: 50px;
    height: 3px;
    background: var(--lime);
    content: "";
    left: -4px;
    top: 19px;
}

.brand-mark::after { transform: rotate(45deg); }
.brand-mark span::before { transform: rotate(90deg); }
.brand-mark span::after { transform: rotate(135deg); }

.brand-mark span {
    position: relative;
    z-index: 1;
    display: block;
    width: 25px;
    height: 25px;
    background: var(--night);
    border: 4px solid var(--lime);
    border-radius: 50%;
}

.brand-copy {
    display: flex;
    flex-direction: column;
    line-height: 1.05;
}

.brand-copy strong {
    color: var(--lime);
    font-size: 21px;
    font-weight: 900;
}

.brand-copy small {
    margin-top: 5px;
    color: #a9b2ad;
    font-size: 11px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.icon-button,
.settings-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    background: #252b28;
    border: 1px solid #3b423e;
    border-radius: 6px;
    color: #eef2ef;
    cursor: pointer;
    transition: background-color 150ms ease, border-color 150ms ease;
}

.icon-button {
    width: 40px;
    font-weight: 800;
}

.settings-button {
    gap: 7px;
    padding: 0 14px;
    text-decoration: none;
}

.icon-button:hover,
.settings-button:hover {
    background: #343c38;
    border-color: #5a655f;
}

main {
    width: min(100%, 1500px);
    margin: 0 auto;
}

.game-stage {
    min-height: calc(100vh - 76px);
    padding: 36px 30px 44px;
}

.game-topline {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    margin-bottom: 22px;
}

.eyebrow {
    margin-bottom: 5px;
    color: var(--lime-dark);
    font-size: 11px;
    font-weight: 850;
    text-transform: uppercase;
}

.game-topline h1 {
    max-width: 760px;
    font-size: 30px;
    font-weight: 800;
    line-height: 1.15;
}

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

.daily-button,
.difficulty-button {
    min-height: 48px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    cursor: pointer;
}

.daily-button {
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 16px;
    font-size: 13px;
    font-weight: 750;
}

.daily-dot {
    width: 9px;
    height: 9px;
    background: var(--coral);
    border-radius: 50%;
    box-shadow: 0 0 0 4px rgba(240, 92, 79, 0.14);
}

.daily-dot.complete {
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(40, 132, 93, 0.14);
}

.difficulty-button {
    display: grid;
    grid-template-columns: 1fr auto;
    min-width: 180px;
    padding: 7px 12px 7px 14px;
    text-align: left;
}

.difficulty-button > span:first-child {
    font-size: 14px;
    font-weight: 800;
}

.difficulty-button small {
    grid-column: 1;
    color: var(--ink-soft);
    font-size: 11px;
}

.difficulty-button > span:last-child {
    grid-row: 1 / 3;
    grid-column: 2;
    align-self: center;
    padding-left: 12px;
}

.daily-button:hover,
.difficulty-button:hover {
    border-color: var(--line-strong);
    background: #fbfdfb;
}

.game-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 270px;
    align-items: start;
    gap: 16px;
}

.game-workbench {
    min-width: 0;
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.scorebar {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    min-height: 86px;
    padding: 13px 22px;
    background: var(--night);
    color: #fff;
}

.score-block {
    display: flex;
    align-items: center;
    gap: 13px;
}

.score-time {
    justify-content: flex-end;
}

.score-block > span:last-child {
    display: flex;
    flex-direction: column;
}

.score-block small {
    margin-bottom: 1px;
    color: #9ca6a0;
    font-size: 10px;
    font-weight: 700;
}

.score-block strong {
    color: var(--lime);
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 29px;
    font-variant-numeric: tabular-nums;
    line-height: 1;
}

.flag-shape {
    position: relative;
    width: 20px;
    height: 26px;
    border-left: 3px solid #f3f5f3;
}

.flag-shape::before {
    position: absolute;
    top: 1px;
    left: 0;
    width: 14px;
    height: 10px;
    background: var(--coral);
    clip-path: polygon(0 0, 100% 25%, 75% 100%, 0 85%);
    content: "";
}

.flag-shape::after {
    position: absolute;
    bottom: 0;
    left: -7px;
    width: 14px;
    height: 3px;
    background: #f3f5f3;
    content: "";
}

.clock-shape {
    position: relative;
    width: 23px;
    height: 23px;
    border: 3px solid #f3f5f3;
    border-radius: 50%;
}

.clock-shape::before,
.clock-shape::after {
    position: absolute;
    left: 9px;
    top: 4px;
    width: 2px;
    height: 7px;
    background: var(--coral);
    transform-origin: bottom;
    content: "";
}

.clock-shape::after {
    transform: rotate(120deg);
}

.face-button {
    display: grid;
    width: 52px;
    height: 52px;
    place-items: center;
    background: var(--lime);
    border: 4px solid #333a36;
    border-radius: 50%;
    color: var(--night);
    font-family: ui-monospace, monospace;
    font-size: 15px;
    font-weight: 900;
    cursor: pointer;
    transition: transform 130ms ease, background-color 130ms ease;
}

.face-button:hover { transform: scale(1.06); }
.face-button:active { transform: scale(0.94); }

.tool-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 14px;
    background: #edf1ed;
    border-bottom: 1px solid var(--line);
}

.mode-switch {
    display: flex;
    gap: 3px;
    padding: 3px;
    background: #dfe5df;
    border-radius: 6px;
}

.mode-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-width: 88px;
    height: 34px;
    padding: 0 12px;
    background: transparent;
    border-radius: 4px;
    color: #4c5851;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.mode-button.active {
    background: var(--surface);
    box-shadow: 0 1px 3px rgba(16, 26, 20, 0.15);
    color: var(--ink);
}

.board-tools {
    display: flex;
    align-items: center;
    gap: 4px;
}

.tool-button {
    display: grid;
    width: 34px;
    height: 34px;
    place-items: center;
    background: var(--surface);
    border: 1px solid #cad2cc;
    border-radius: 4px;
    font-weight: 850;
    cursor: pointer;
}

.tool-button:hover { border-color: #8d9991; }

#zoom-level {
    width: 47px;
    color: var(--ink-soft);
    font-family: ui-monospace, monospace;
    font-size: 10px;
    text-align: center;
}

.board-viewport {
    max-width: 100%;
    min-height: 420px;
    max-height: calc(100vh - 300px);
    overflow: auto;
    overscroll-behavior: contain;
    scrollbar-color: #6e7972 #202522;
    scrollbar-width: thin;
    background: var(--night-2);
}

.board-viewport::-webkit-scrollbar { width: 10px; height: 10px; }
.board-viewport::-webkit-scrollbar-track { background: #202522; }
.board-viewport::-webkit-scrollbar-thumb { background: #69746e; border: 2px solid #202522; border-radius: 5px; }

.board-shell {
    position: relative;
    display: grid;
    width: max-content;
    min-width: 100%;
    min-height: inherit;
    place-items: center;
    padding: 22px;
}

.game-board {
    --cell-size: 38px;
    --cols: 9;
    display: grid;
    grid-template-columns: repeat(var(--cols), var(--cell-size));
    width: max-content;
    padding: 7px;
    background: #0f1311;
    border: 1px solid #3c4540;
    border-radius: 5px;
    box-shadow: 0 15px 38px rgba(0, 0, 0, 0.28);
    touch-action: pan-x pan-y;
}

.cell {
    position: relative;
    display: grid;
    width: var(--cell-size);
    height: var(--cell-size);
    min-width: 0;
    min-height: 0;
    place-items: center;
    overflow: hidden;
    background: #d7dfd7;
    border: 1px solid #8e9a91;
    border-top-color: #f5f8f5;
    border-left-color: #f5f8f5;
    border-radius: 0;
    color: var(--ink);
    cursor: pointer;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: max(12px, calc(var(--cell-size) * 0.48));
    font-weight: 900;
    line-height: 1;
    touch-action: manipulation;
    user-select: none;
    -webkit-user-select: none;
}

.cell:hover:not(.revealed) {
    background: #e8eee8;
}

.cell:active:not(.revealed),
.cell.long-pressed {
    background: #c4cec5;
    border-color: #7f8b82;
}

.cell.revealed {
    background: #f4f6f3;
    border-color: #ccd3cd;
    cursor: default;
}

.cell.flagged::before,
.cell.mine::before {
    display: block;
    width: 50%;
    height: 50%;
    content: "";
}

.cell.flagged::before {
    background: var(--coral);
    clip-path: polygon(16% 0, 87% 17%, 69% 53%, 28% 47%, 28% 82%, 78% 82%, 78% 100%, 5% 100%, 5% 82%, 17% 82%);
}

.cell.mine::before {
    background: var(--night);
    border: calc(var(--cell-size) * 0.08) solid var(--coral);
    border-radius: 50%;
    box-shadow: 0 calc(var(--cell-size) * -0.28) 0 calc(var(--cell-size) * -0.22) var(--night),
                0 calc(var(--cell-size) * 0.28) 0 calc(var(--cell-size) * -0.22) var(--night),
                calc(var(--cell-size) * 0.28) 0 0 calc(var(--cell-size) * -0.22) var(--night),
                calc(var(--cell-size) * -0.28) 0 0 calc(var(--cell-size) * -0.22) var(--night);
}

.cell.exploded {
    background: var(--coral);
    border-color: #bd3930;
}

.cell.exploded::before { background: #fff; border-color: #541713; }

.cell.wrong-flag::after {
    position: absolute;
    color: #9c241c;
    content: "×";
    font-size: 80%;
}

.cell.questioned { color: #7f5530; }
.number-1 { color: #246ccc; }
.number-2 { color: #21845b; }
.number-3 { color: #d04b3f; }
.number-4 { color: #634bb0; }
.number-5 { color: #a54b25; }
.number-6 { color: #147b83; }
.number-7 { color: #222; }
.number-8 { color: #6d756f; }

.cell-pop { animation: cell-pop 160ms ease-out both; }
.cell-pulse { animation: cell-pulse 280ms ease-out; }

@keyframes cell-pop {
    0% { transform: scale(0.82); background: #fff; }
    100% { transform: scale(1); }
}

@keyframes cell-pulse {
    50% { background: var(--yellow); }
}

.pause-cover {
    position: absolute;
    inset: 0;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    background: rgba(23, 27, 25, 0.94);
    color: #fff;
    cursor: pointer;
}

.pause-cover[hidden] { display: none; }
.pause-cover strong { color: var(--lime); font-size: 21px; }
.pause-cover span { color: #aeb8b2; font-size: 12px; }

.game-footline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 43px;
    padding: 9px 14px;
    background: #edf1ed;
    border-top: 1px solid var(--line);
    color: #667169;
    font-size: 10px;
}

.live-status {
    overflow: hidden;
    color: #4c5750;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mobile-hint { display: none; }

.session-panel {
    overflow: hidden;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
}

.progress-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    padding: 19px 18px 12px;
}

.progress-heading > div {
    display: flex;
    align-items: baseline;
    gap: 10px;
}

.progress-heading .eyebrow { margin: 0; }
.progress-heading strong { font-size: 25px; }
.progress-heading > span { color: var(--ink-soft); font-size: 10px; }

.progress-track {
    height: 5px;
    margin: 0 18px 20px;
    overflow: hidden;
    background: #e1e6e2;
    border-radius: 3px;
}

.progress-track span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--green);
    transition: width 180ms ease;
}

.session-stats {
    border-top: 1px solid var(--line);
    border-bottom: 1px solid var(--line);
}

.session-stats > div {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    min-height: 54px;
    padding: 10px 18px;
    border-bottom: 1px solid #e6ebe7;
}

.session-stats > div:last-child { border: 0; }
.session-stats dt { color: var(--ink-soft); font-size: 11px; font-weight: 700; }
.session-stats dd { font-size: 21px; font-weight: 850; }
.session-stats dd small { margin-left: 3px; color: var(--ink-soft); font-size: 9px; }

.mini-mission {
    display: flex;
    align-items: center;
    gap: 11px;
    margin: 15px 14px;
    padding: 12px;
    background: #f2f5e9;
    border: 1px solid #dce5bd;
    border-radius: 6px;
}

.mission-mark {
    display: grid;
    flex: 0 0 auto;
    width: 32px;
    height: 32px;
    place-items: center;
    background: var(--yellow);
    border-radius: 50%;
    font-size: 12px;
    font-weight: 900;
}

.mini-mission strong { display: block; font-size: 11px; }
.mini-mission p { margin-top: 2px; color: var(--ink-soft); font-size: 9px; }

.secondary-action,
.primary-action {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 44px;
    padding: 0 16px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.primary-action {
    background: var(--night);
    color: var(--lime);
}

.primary-action:hover { background: #2c332f; }

.secondary-action {
    background: var(--surface);
    border: 1px solid var(--line-strong);
}

.secondary-action:hover { background: #f1f4f1; }
.session-panel > .secondary-action { width: calc(100% - 28px); margin: 0 14px 15px; }

.leaderboard-section {
    padding: 58px 30px 72px;
    background: var(--surface);
    border-top: 1px solid var(--line);
}

.section-heading {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    padding-bottom: 22px;
    border-bottom: 1px solid var(--line);
}

.section-heading h2 {
    font-size: 27px;
    line-height: 1.15;
}

.global-stats {
    display: flex;
    gap: 28px;
    color: var(--ink-soft);
    font-size: 10px;
}

.global-stats strong {
    display: block;
    color: var(--ink);
    font-family: ui-monospace, monospace;
    font-size: 17px;
}

.leaderboard-tabs {
    display: flex;
    gap: 22px;
    margin-top: 18px;
    border-bottom: 1px solid var(--line);
}

.leaderboard-tabs button {
    position: relative;
    padding: 11px 3px;
    background: transparent;
    color: var(--ink-soft);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
}

.leaderboard-tabs button[aria-selected="true"] { color: var(--ink); }
.leaderboard-tabs button[aria-selected="true"]::after {
    position: absolute;
    right: 0;
    bottom: -1px;
    left: 0;
    height: 3px;
    background: var(--coral);
    content: "";
}

.leaderboard-panel[hidden] { display: none; }
.rank-list { list-style: none; }
.rank-list li {
    display: grid;
    grid-template-columns: 50px minmax(0, 1fr) 120px 75px;
    align-items: center;
    min-height: 57px;
    border-bottom: 1px solid #e7ebe8;
}

.rank-list li:first-child .rank-number { color: var(--coral); }
.rank-number { color: #8a958e; font-family: ui-monospace, monospace; font-size: 11px; font-weight: 800; }
.rank-player { overflow: hidden; font-size: 13px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.rank-list li > strong { font-family: ui-monospace, monospace; font-size: 16px; text-align: right; }
.rank-list li > strong small { color: var(--ink-soft); font-size: 9px; }

.challenge-button {
    justify-self: end;
    width: 60px;
    height: 30px;
    background: transparent;
    border: 1px solid var(--line);
    border-radius: 4px;
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 800;
    cursor: pointer;
}

.challenge-button:hover { background: var(--lime); border-color: var(--lime-dark); color: var(--ink); }

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 190px;
    color: var(--ink-soft);
    text-align: center;
}

.empty-state strong { margin-bottom: 4px; color: var(--ink); font-size: 15px; }
.empty-state span { font-size: 11px; }

footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    max-width: 1500px;
    min-height: 72px;
    margin: 0 auto;
    padding: 16px 30px;
    color: var(--ink-soft);
    font-size: 10px;
}

footer nav { display: flex; gap: 18px; }
footer a { text-decoration: none; }
footer a:hover { color: var(--ink); text-decoration: underline; }

.app-dialog {
    width: min(92vw, 660px);
    max-height: min(88vh, 820px);
    margin: auto;
    overflow: auto;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.32);
    color: var(--ink);
}

.app-dialog::backdrop {
    background: rgba(11, 16, 13, 0.7);
    backdrop-filter: blur(5px);
}

.app-dialog header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 20px;
}

.app-dialog h2 { font-size: 24px; line-height: 1.15; }

.dialog-close {
    display: grid;
    flex: 0 0 auto;
    width: 36px;
    height: 36px;
    place-items: center;
    background: #edf1ed;
    border-radius: 50%;
    color: #56615a;
    font-size: 22px;
    cursor: pointer;
}

.settings-dialog form,
.help-content {
    padding: 26px;
}

.field-label,
.difficulty-grid legend {
    display: block;
    margin: 22px 0 7px;
    color: var(--ink-soft);
    font-size: 10px;
    font-weight: 800;
}

.text-input {
    width: 100%;
    height: 46px;
    padding: 0 13px;
    background: #f7f9f7;
    border: 1px solid var(--line-strong);
    border-radius: 5px;
}

.difficulty-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    border: 0;
}

.difficulty-grid legend { grid-column: 1 / -1; width: 100%; }
.difficulty-grid input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty-grid label > span {
    position: relative;
    display: grid;
    min-height: 74px;
    padding: 12px 12px 11px 45px;
    background: #f8faf8;
    border: 1px solid var(--line);
    border-radius: 6px;
    cursor: pointer;
}

.difficulty-grid label > span small {
    position: absolute;
    top: 14px;
    left: 13px;
    color: #9ca69f;
    font-family: ui-monospace, monospace;
    font-size: 9px;
}

.difficulty-grid span strong { font-size: 13px; }
.difficulty-grid span em { color: var(--ink-soft); font-size: 10px; font-style: normal; }
.difficulty-grid input:checked + span { background: #f3f8df; border-color: var(--lime-dark); box-shadow: inset 0 0 0 1px var(--lime-dark); }
.difficulty-grid input:focus-visible + span { outline: 3px solid #4b8bea; outline-offset: 2px; }

.custom-fields {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-top: 10px;
    padding: 12px;
    background: #f3f5f3;
    border-radius: 6px;
}

.custom-fields[hidden] { display: none; }
.custom-fields label { color: var(--ink-soft); font-size: 9px; font-weight: 700; }
.custom-fields input { width: 100%; height: 38px; margin-top: 4px; padding: 0 8px; background: #fff; border: 1px solid var(--line-strong); border-radius: 4px; }

.setting-toggles {
    margin: 18px 0;
    border-top: 1px solid var(--line);
}

.setting-toggles label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    min-height: 57px;
    border-bottom: 1px solid var(--line);
    cursor: pointer;
}

.setting-toggles strong { display: block; font-size: 11px; }
.setting-toggles small { display: block; margin-top: 1px; color: var(--ink-soft); font-size: 9px; }
.setting-toggles input { width: 38px; height: 21px; accent-color: var(--green); }
.settings-dialog .primary-action { width: 100%; }
.form-error { min-height: 20px; color: #ad352c; font-size: 10px; }

.result-dialog { width: min(92vw, 430px); text-align: center; }
.result-content { padding: 34px 28px 28px; }
.result-symbol {
    display: grid;
    width: 64px;
    height: 64px;
    margin: 0 auto 18px;
    place-items: center;
    background: var(--lime);
    border-radius: 50%;
    font-size: 32px;
    font-weight: 900;
}

.result-symbol.lose { background: var(--coral); color: #fff; }
.result-dialog h2 { margin-bottom: 6px; font-size: 27px; }
.result-dialog #result-copy { color: var(--ink-soft); font-size: 11px; }
.result-time { display: flex; align-items: baseline; justify-content: center; gap: 6px; margin: 22px 0 3px; }
.result-time strong { font-family: ui-monospace, monospace; font-size: 50px; line-height: 1; }
.result-time span { color: var(--ink-soft); font-size: 11px; }
.result-rank { margin-bottom: 22px; color: var(--green); font-size: 10px; font-weight: 800; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.result-actions .primary-action { grid-column: 1 / -1; }

.help-dialog { width: min(92vw, 520px); }
.rule-list { margin-top: 22px; border-top: 1px solid var(--line); }
.rule-list > div { display: flex; align-items: flex-start; gap: 13px; padding: 15px 0; border-bottom: 1px solid var(--line); }
.rule-list > div > span { display: grid; flex: 0 0 auto; width: 30px; height: 30px; place-items: center; background: #edf1ed; border-radius: 50%; font-size: 12px; font-weight: 900; }
.rule-list p { color: var(--ink-soft); font-size: 10px; }
.rule-list strong { display: block; margin-bottom: 2px; color: var(--ink); font-size: 12px; }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 18px; color: var(--ink-soft); font-size: 10px; }
kbd { display: inline-grid; min-width: 27px; height: 25px; margin-right: 4px; padding: 0 5px; place-items: center; background: #f0f3f0; border: 1px solid #c8d0ca; border-bottom-width: 2px; border-radius: 4px; color: var(--ink); font-family: ui-monospace, monospace; }

.toast {
    position: fixed;
    bottom: max(20px, env(safe-area-inset-bottom));
    left: 50%;
    z-index: 100;
    max-width: calc(100vw - 32px);
    padding: 10px 16px;
    background: var(--night);
    border: 1px solid #3d4641;
    border-radius: 6px;
    color: #fff;
    font-size: 11px;
    opacity: 0;
    pointer-events: none;
    transform: translate(-50%, 14px);
    transition: opacity 180ms ease, transform 180ms ease;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 980px) {
    .game-layout { grid-template-columns: minmax(0, 1fr); }
    .session-panel { display: grid; grid-template-columns: 1fr 1.2fr; }
    .progress-heading { grid-column: 1; }
    .progress-track { grid-column: 1; }
    .session-stats { grid-row: 1 / 3; grid-column: 2; border-top: 0; border-left: 1px solid var(--line); }
    .mini-mission { grid-column: 1; }
    .session-panel > .secondary-action { grid-column: 2; align-self: center; }
}

@media (max-width: 700px) {
    .site-header { min-height: 62px; padding: 9px 14px; }
    .brand-mark { width: 34px; height: 34px; }
    .brand-mark::before, .brand-mark::after, .brand-mark span::before, .brand-mark span::after { top: 15px; left: -3px; width: 40px; height: 2px; }
    .brand-mark span { width: 22px; height: 22px; border-width: 3px; }
    .brand-copy strong { font-size: 18px; }
    .brand-copy small { display: none; }
    .icon-button { width: 38px; height: 38px; }
    .settings-button { width: 38px; height: 38px; padding: 0; }
    a.settings-button:not(.header-game-link) { width: auto; padding: 0 10px; white-space: nowrap; }
    .settings-button span:last-child { display: none; }

    .game-stage { min-height: calc(100vh - 62px); padding: 20px 12px 30px; }
    .game-topline { align-items: stretch; flex-direction: column; gap: 13px; margin-bottom: 13px; }
    .game-topline h1 { font-size: 23px; }
    .topline-actions { display: grid; grid-template-columns: 1fr 1.15fr; }
    .daily-button, .difficulty-button { min-width: 0; min-height: 45px; }
    .daily-button { padding: 0 11px; font-size: 11px; }

    .scorebar { min-height: 72px; padding: 9px 13px; }
    .score-block { gap: 8px; }
    .score-block small { font-size: 8px; }
    .score-block strong { font-size: 23px; }
    .flag-shape { transform: scale(0.82); }
    .clock-shape { transform: scale(0.82); }
    .face-button { width: 46px; height: 46px; border-width: 3px; font-size: 13px; }

    .tool-row { align-items: stretch; flex-direction: column; gap: 8px; padding: 8px; }
    .mode-switch { display: grid; grid-template-columns: 1fr 1fr; }
    .mode-button { width: 100%; min-width: 0; height: 38px; }
    .board-tools { justify-content: flex-end; }
    .board-tools .tool-button:first-child { margin-right: auto; }
    .tool-button { width: 38px; height: 36px; }

    .board-viewport { min-height: 350px; max-height: 58vh; }
    .board-shell { padding: 12px; }
    .game-board { padding: 5px; }
    .cell { font-size: max(12px, calc(var(--cell-size) * 0.46)); }

    .game-footline { min-height: 40px; padding: 7px 9px; }
    .desktop-hint { display: none; }
    .mobile-hint { display: inline; }
    .live-status { max-width: 40%; }

    .session-panel { display: block; }
    .progress-heading { padding: 15px 14px 10px; }
    .progress-track { margin: 0 14px 14px; }
    .session-stats { display: grid; grid-template-columns: repeat(3, 1fr); border-left: 0; }
    .session-stats > div { display: block; min-height: 65px; padding: 10px 12px; border-right: 1px solid #e6ebe7; border-bottom: 0; text-align: center; }
    .session-stats > div:last-child { border-right: 0; }
    .session-stats dt { margin-bottom: 2px; }
    .mini-mission { margin: 12px; }
    .session-panel > .secondary-action { width: calc(100% - 24px); margin: 0 12px 12px; }

    .leaderboard-section { padding: 42px 16px 54px; }
    .section-heading { align-items: flex-start; flex-direction: column; gap: 15px; }
    .section-heading h2 { font-size: 23px; }
    .global-stats { width: 100%; justify-content: space-between; gap: 12px; }
    .rank-list li { grid-template-columns: 38px minmax(0, 1fr) 75px 57px; min-height: 54px; }
    .rank-list li > strong { font-size: 13px; }
    .challenge-button { width: 50px; }

    footer { align-items: flex-start; flex-direction: column; padding: 20px 16px; }
    footer nav { flex-wrap: wrap; gap: 10px 16px; }

    .settings-dialog form, .help-content { padding: 20px 16px; }
    .app-dialog h2 { font-size: 21px; }
    .difficulty-grid { grid-template-columns: 1fr; }
    .difficulty-grid label > span { min-height: 62px; }
    .custom-fields { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 8px; }
}

@media (max-width: 390px) {
    .brand { gap: 8px; }
    .header-actions { gap: 5px; }
    #sound-button { display: none; }
    .header-game-link { width: auto; padding: 0 9px; font-size: 10px; }
    .game-topline h1 { font-size: 21px; }
    .daily-button { font-size: 10px; }
    .difficulty-button { padding-left: 10px; }
    .scorebar { padding-right: 8px; padding-left: 8px; }
    .score-block > span:first-child { display: none; }
    .game-footline { display: block; }
    .live-status { max-width: none; margin-top: 3px; text-align: left; }
    .result-actions { grid-template-columns: 1fr; }
    .result-actions .primary-action { grid-column: auto; }
    .shortcut-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
    }
}
