:root {
    --paper: #f4faf6;
    --paper-strong: #eaf7ef;
    --ink: #11251b;
    --muted: #62766b;
    --mint: #45bd83;
    --mint-dark: #16845a;
    --mint-pale: #d9f3e5;
    --gold: #f1c568;
    --line: rgba(27, 87, 57, .14);
    --shadow: 0 30px 80px rgba(32, 92, 62, .14);
    --display: "STZhongsong", "FZSongYi-Z13", "Noto Serif CJK SC", serif;
    --sans: "HarmonyOS Sans SC", "MiSans", "Microsoft YaHei UI", sans-serif;
    --mono: "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html {
    min-width: 320px;
    color: var(--ink);
    background: var(--paper);
    font-family: var(--sans);
    scroll-behavior: smooth;
}

body {
    min-height: 100dvh;
    margin: 0;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 8% 18%, rgba(69, 189, 131, .11), transparent 26rem),
        radial-gradient(circle at 92% 72%, rgba(131, 218, 183, .15), transparent 30rem),
        var(--paper);
}

body::before {
    content: "";
    position: fixed;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    opacity: .34;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120' viewBox='0 0 120 120'%3E%3Cpath d='M0 119.5h120M119.5 0v120' fill='none' stroke='%23238e5c' stroke-opacity='.08'/%3E%3Ccircle cx='1' cy='1' r='1' fill='%23238e5c' fill-opacity='.14'/%3E%3C/svg%3E");
}

button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
a { color: inherit; text-decoration: none; }
img, svg { display: block; }

.skip-link {
    position: fixed;
    z-index: 100;
    top: 12px;
    left: 12px;
    padding: 8px 12px;
    color: white;
    background: var(--ink);
    border-radius: 8px;
    transform: translateY(-160%);
}

.skip-link:focus { transform: none; }

.topbar {
    width: min(1440px, calc(100% - 56px));
    min-height: 82px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 auto;
    border-bottom: 1px solid var(--line);
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
}

.brand img {
    width: 42px;
    height: 42px;
    border: 1px solid rgba(255,255,255,.9);
    border-radius: 13px;
    box-shadow: 0 9px 24px rgba(35, 142, 92, .2);
}

.brand span { display: grid; line-height: 1.15; }
.brand strong { font-size: 15px; letter-spacing: .04em; }
.brand small { margin-top: 5px; color: var(--muted); font-family: var(--mono); font-size: 8px; letter-spacing: .15em; text-transform: uppercase; }

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

.sound-button,
.back-link {
    min-height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 0 15px;
    color: var(--ink);
    background: rgba(255,255,255,.62);
    border: 1px solid var(--line);
    border-radius: 12px;
    font-size: 12px;
    font-weight: 700;
    cursor: pointer;
    transition: transform 180ms ease, background 180ms ease, border-color 180ms ease;
}

.sound-button:hover,
.back-link:hover { background: #fff; border-color: rgba(35,142,92,.28); transform: translateY(-2px); }
.sound-button:active,
.back-link:active { transform: translateY(0) scale(.98); }
.sound-button:focus-visible,
.back-link:focus-visible,
.start-button:focus-visible,
.pause-button:focus-visible { outline: 3px solid rgba(69,189,131,.34); outline-offset: 3px; }
.sound-button[aria-pressed="true"] span { color: var(--muted); }

.page-shell {
    width: min(1440px, calc(100% - 56px));
    min-height: calc(100dvh - 144px);
    display: grid;
    grid-template-columns: minmax(170px, .72fr) minmax(580px, 2fr) minmax(210px, .82fr);
    align-items: center;
    gap: clamp(24px, 3vw, 54px);
    margin: 0 auto;
    padding: 56px 0 36px;
}

.intro-copy { align-self: center; }

.kicker {
    display: flex;
    align-items: center;
    gap: 9px;
    margin: 0 0 22px;
    color: var(--mint-dark);
    font-family: var(--mono);
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .12em;
    text-transform: uppercase;
}

.kicker i { width: 8px; height: 8px; background: var(--mint); border-radius: 50%; box-shadow: 0 0 0 6px rgba(69,189,131,.11); }

.intro-copy h1 {
    margin: 0;
    font-family: var(--display);
    font-size: clamp(58px, 6.2vw, 104px);
    font-weight: 900;
    line-height: .86;
    letter-spacing: -.075em;
}

.intro-copy h1 em { color: var(--mint-dark); font-style: normal; }

.intro-text {
    max-width: 28em;
    margin: 30px 0 0;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.9;
    text-wrap: pretty;
}

.control-hints { display: flex; flex-wrap: wrap; gap: 9px; margin-top: 26px; }
.control-hints span { display: inline-flex; align-items: center; gap: 5px; color: var(--muted); font-size: 10px; }
kbd,
.touch-hint {
    min-width: 24px;
    height: 24px;
    display: inline-grid;
    place-items: center;
    padding: 0 6px;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-bottom-width: 3px;
    border-radius: 6px;
    font-family: var(--mono);
    font-size: 9px;
    font-weight: 700;
}

.game-column { min-width: 0; }

.game-frame {
    position: relative;
    overflow: hidden;
    background: rgba(255,255,255,.76);
    border: 1px solid rgba(34, 123, 79, .16);
    border-radius: 28px 28px 18px 18px;
    box-shadow: var(--shadow), inset 0 1px 0 rgba(255,255,255,.95);
    backdrop-filter: blur(18px);
}

.frame-head,
.frame-foot {
    min-height: 47px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    color: var(--muted);
    font-family: var(--mono);
    font-size: 9px;
    letter-spacing: .08em;
}

.frame-head { border-bottom: 1px solid var(--line); }
.frame-foot { min-height: 43px; border-top: 1px solid var(--line); }
.frame-foot b { color: var(--mint-dark); }

.live-mark { display: flex; align-items: center; gap: 8px; }
.live-mark span { width: 7px; height: 7px; background: var(--mint); border-radius: 50%; box-shadow: 0 0 0 5px rgba(69,189,131,.12); animation: live-pulse 1.8s ease-in-out infinite; }

.canvas-wrap {
    position: relative;
    aspect-ratio: 16 / 9;
    min-height: 340px;
    overflow: hidden;
    background: linear-gradient(155deg, #edf9f2, #dff3e9 58%, #f6fbf8);
}

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

.hud {
    position: absolute;
    z-index: 5;
    top: 14px;
    right: 14px;
    left: 14px;
    display: grid;
    grid-template-columns: 1fr auto 1fr auto;
    align-items: start;
    gap: 10px;
    pointer-events: none;
}

.hud > div {
    min-width: 78px;
    display: grid;
    justify-items: center;
    padding: 8px 12px;
    background: rgba(255,255,255,.68);
    border: 1px solid rgba(255,255,255,.8);
    border-radius: 12px;
    box-shadow: 0 8px 22px rgba(35, 100, 67, .08);
    backdrop-filter: blur(12px);
}

.hud > div:first-child { justify-self: start; }
.hud > div:nth-child(3) { justify-self: end; }
.hud small { color: var(--muted); font-size: 8px; letter-spacing: .12em; }
.hud strong { color: var(--ink); font-family: var(--mono); font-size: 15px; font-variant-numeric: tabular-nums; }
.combo-box strong { color: var(--mint-dark); }

.pause-button {
    width: 38px;
    height: 38px;
    display: grid;
    place-items: center;
    color: var(--ink);
    background: rgba(255,255,255,.72);
    border: 1px solid rgba(255,255,255,.85);
    border-radius: 12px;
    font-family: var(--mono);
    font-size: 12px;
    font-weight: 900;
    cursor: pointer;
    pointer-events: auto;
}

.game-panel {
    position: absolute;
    z-index: 7;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    padding: 22px;
    text-align: center;
    background: rgba(240, 250, 245, .84);
    backdrop-filter: blur(13px);
}

.game-panel[hidden],
.hud[hidden],
.pause-overlay[hidden] { display: none; }

.panel-orbit { position: absolute; top: 22px; right: 24px; width: 90px; height: 90px; opacity: .6; }
.panel-orbit span { position: absolute; inset: 0; border: 1px solid rgba(35,142,92,.18); border-radius: 50%; animation: orbit-turn 9s linear infinite; }
.panel-orbit span:nth-child(2) { inset: 12px; animation-direction: reverse; }
.panel-orbit span:nth-child(3) { inset: 28px; background: rgba(69,189,131,.08); }

.panel-icon { width: 58px; height: 58px; margin-bottom: 12px; border: 4px solid rgba(255,255,255,.88); border-radius: 19px; box-shadow: 0 14px 32px rgba(35,142,92,.2); animation: icon-float 3.8s ease-in-out infinite; }
.panel-eyebrow { margin: 0 0 4px; color: var(--mint-dark); font-family: var(--mono); font-size: 9px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.game-panel h2 { margin: 4px 0 6px; font-family: var(--display); font-size: clamp(22px, 3vw, 34px); letter-spacing: -.04em; }
.game-panel > p:not(.panel-eyebrow) { max-width: 34em; margin: 0; color: var(--muted); font-size: 11px; line-height: 1.7; }

.difficulty-picker { display: flex; gap: 8px; margin: 14px 0 13px; padding: 0; border: 0; }
.difficulty-picker legend { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }
.difficulty-picker label { cursor: pointer; }
.difficulty-picker input { position: absolute; opacity: 0; pointer-events: none; }
.difficulty-picker span { min-width: 78px; display: grid; padding: 8px 12px; color: var(--muted); background: rgba(255,255,255,.56); border: 1px solid var(--line); border-radius: 10px; font-size: 11px; font-weight: 750; transition: all 160ms ease; }
.difficulty-picker small { margin-top: 2px; font-size: 8px; font-weight: 500; }
.difficulty-picker input:checked + span { color: #fff; background: var(--ink); border-color: var(--ink); box-shadow: 0 9px 20px rgba(17,37,27,.16); transform: translateY(-2px); }
.difficulty-picker input:focus-visible + span { outline: 3px solid rgba(69,189,131,.32); outline-offset: 2px; }

.start-button {
    min-width: 190px;
    min-height: 46px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 22px;
    padding: 0 8px 0 20px;
    color: #fff;
    background: var(--mint-dark);
    border: 0;
    border-radius: 13px;
    box-shadow: 0 15px 28px rgba(22,132,90,.22);
    font-size: 12px;
    font-weight: 800;
    cursor: pointer;
    transition: transform 180ms ease, box-shadow 180ms ease, background 180ms ease;
}
.start-button i { width: 32px; height: 32px; display: grid; place-items: center; color: var(--mint-dark); background: #fff; border-radius: 9px; font-family: var(--mono); font-size: 16px; font-style: normal; }
.start-button:hover { background: #0f734d; box-shadow: 0 18px 34px rgba(22,132,90,.28); transform: translateY(-2px); }
.start-button:active { transform: translateY(0) scale(.985); }
.music-credit { margin-top: 9px; color: #7a8e82; font-size: 8px; }

.rank-badge { width: 68px; height: 68px; display: grid; place-items: center; margin-bottom: 6px; color: #fff; background: var(--mint-dark); border: 6px solid rgba(255,255,255,.84); border-radius: 23px; box-shadow: 0 15px 35px rgba(35,142,92,.24); font-family: var(--display); font-size: 36px; font-weight: 900; transform: rotate(-5deg); }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 7px; margin: 12px 0; }
.result-grid div { min-width: 92px; display: grid; padding: 8px 12px; background: rgba(255,255,255,.56); border: 1px solid var(--line); border-radius: 10px; }
.result-grid small { color: var(--muted); font-size: 8px; }
.result-grid strong { color: var(--ink); font-family: var(--mono); font-size: 15px; }
.text-button { margin-top: 8px; padding: 4px 8px; color: var(--muted); background: transparent; border: 0; font-size: 9px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

.pause-overlay {
    position: absolute;
    z-index: 8;
    inset: 0;
    display: grid;
    align-content: center;
    justify-items: center;
    gap: 8px;
    color: #fff;
    text-align: center;
    background: rgba(17,37,27,.78);
    backdrop-filter: blur(12px);
}
.pause-overlay span { color: #8be0b5; font-family: var(--mono); font-size: 10px; letter-spacing: .24em; }
.pause-overlay strong { font-family: var(--display); font-size: 28px; }
.pause-overlay button { margin-top: 10px; padding: 10px 22px; color: var(--ink); background: #fff; border: 0; border-radius: 10px; font-size: 11px; font-weight: 800; cursor: pointer; }

.toast { position: absolute; z-index: 6; top: 76px; left: 50%; padding: 7px 12px; color: #fff; background: rgba(17,37,27,.88); border-radius: 9px; font-size: 10px; opacity: 0; pointer-events: none; transform: translate(-50%, -10px); transition: opacity 180ms ease, transform 180ms ease; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

.privacy-note { margin: 11px 0 0; color: var(--muted); font-size: 9px; text-align: center; }

.mascot-card { align-self: stretch; display: grid; align-content: end; min-width: 0; }
.mascot-art { height: min(55vh, 560px); overflow: hidden; mix-blend-mode: multiply; -webkit-mask-image: linear-gradient(to bottom, transparent, #000 11%, #000 78%, transparent); mask-image: linear-gradient(to bottom, transparent, #000 11%, #000 78%, transparent); }
.mascot-art img { width: 100%; height: auto; transform: translateY(-2%); }
.mascot-note { position: relative; z-index: 2; margin-top: -38px; padding: 14px 16px; background: rgba(255,255,255,.7); border: 1px solid var(--line); border-radius: 14px 14px 4px 14px; box-shadow: 0 16px 40px rgba(36,96,65,.1); backdrop-filter: blur(12px); }
.mascot-note span { color: var(--mint-dark); font-family: var(--mono); font-size: 8px; font-weight: 700; letter-spacing: .12em; }
.mascot-note p { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.6; }

footer { width: min(1440px, calc(100% - 56px)); min-height: 62px; display: flex; align-items: center; justify-content: space-between; margin: 0 auto; color: var(--muted); border-top: 1px solid var(--line); font-family: var(--mono); font-size: 8px; letter-spacing: .05em; }

@keyframes live-pulse { 50% { opacity: .4; transform: scale(.72); } }
@keyframes icon-float { 50% { transform: translateY(-5px) rotate(1deg); } }
@keyframes orbit-turn { to { transform: rotate(360deg); } }

@media (max-width: 1180px) {
    .page-shell { grid-template-columns: 180px minmax(560px, 1fr); }
    .mascot-card { display: none; }
}

@media (max-width: 860px) {
    .topbar,
    .page-shell,
    footer { width: min(100% - 32px, 720px); }
    .page-shell { min-height: auto; grid-template-columns: 1fr; gap: 24px; padding-top: 34px; }
    .intro-copy { display: grid; justify-items: center; text-align: center; }
    .intro-copy h1 { font-size: clamp(54px, 15vw, 82px); line-height: .91; }
    .intro-copy h1 br { display: none; }
    .intro-text { margin-top: 20px; }
    .control-hints { justify-content: center; margin-top: 15px; }
    .kicker { margin-bottom: 14px; }
    .canvas-wrap { min-height: 0; }
    footer { margin-top: 32px; }
}

@media (max-width: 560px) {
    .topbar { min-height: 66px; }
    .brand img { width: 36px; height: 36px; border-radius: 11px; }
    .brand strong { font-size: 13px; }
    .brand small { font-size: 7px; }
    .back-link { display: none; }
    .sound-button { min-height: 36px; padding: 0 11px; }
    .sound-button b { display: none; }
    .page-shell { padding-top: 27px; }
    .intro-copy h1 { font-size: 52px; }
    .intro-text { max-width: 31em; font-size: 12px; }
    .control-hints span:not(.touch-hint) { display: none; }
    .game-frame { border-radius: 20px 20px 14px 14px; }
    .frame-head,
    .frame-foot { min-height: 40px; padding: 0 12px; }
    .frame-foot span:first-child { display: none; }
    .frame-foot { justify-content: center; }
    .canvas-wrap { aspect-ratio: 10 / 13; }
    .game-panel { padding: 16px; }
    .panel-orbit { display: none; }
    .panel-icon { width: 54px; height: 54px; }
    .game-panel h2 { font-size: 23px; }
    .game-panel > p:not(.panel-eyebrow) { max-width: 23em; font-size: 10px; }
    .difficulty-picker { width: 100%; gap: 5px; margin: 12px 0; }
    .difficulty-picker label { flex: 1; }
    .difficulty-picker span { min-width: 0; padding: 8px 5px; }
    .start-button { min-width: 180px; min-height: 44px; }
    .music-credit { margin-top: 7px; }
    .hud { grid-template-columns: 1fr 1fr 1fr auto; top: 9px; right: 9px; left: 9px; gap: 5px; }
    .hud > div { min-width: 0; padding: 6px 5px; }
    .hud strong { font-size: 12px; }
    .pause-button { width: 34px; height: 34px; }
    .toast { top: 60px; }
    .result-grid { width: 100%; gap: 5px; }
    .result-grid div { min-width: 0; padding: 7px 5px; }
    footer { min-height: 72px; flex-direction: column; justify-content: center; gap: 6px; text-align: center; }
}

@media (max-width: 360px) {
    .topbar,
    .page-shell,
    footer { width: calc(100% - 24px); }
    .kicker { font-size: 8px; }
    .intro-copy h1 { font-size: 46px; }
    .intro-text { font-size: 11px; }
    .difficulty-picker span { font-size: 10px; }
    .difficulty-picker small { font-size: 7px; }
}

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