:root {
  color-scheme: dark;
  --bg: #111918;
  --bg-glow: rgba(103, 129, 92, .16);
  --surface: #1a2421;
  --surface-raised: #222e2a;
  --surface-soft: #202b27;
  --text: #eef1e8;
  --text-soft: #c4cdc3;
  --muted: #89968c;
  --line: rgba(230, 237, 222, .13);
  --line-strong: rgba(230, 237, 222, .2);
  --accent: #d4ee78;
  --accent-contrast: #18211e;
  --theme-icon: #d4ee78;
  --swatch-outline: rgba(255, 255, 255, .2);
  --feedback-exact: #70d698;
  --feedback-misplaced: #929c94;
  --coral: #ff8068;
  --shadow: 0 28px 80px rgba(0, 0, 0, .25);
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --sans: Inter, "Noto Sans SC", "Microsoft YaHei", system-ui, sans-serif;
}

body[data-theme="light"] {
  color-scheme: light;
  --bg: #e8ebe2;
  --bg-glow: rgba(166, 192, 112, .2);
  --surface: #f5f6ef;
  --surface-raised: #fffef8;
  --surface-soft: #ecefe5;
  --text: #1e2b25;
  --text-soft: #46534a;
  --muted: #78847a;
  --line: rgba(42, 58, 47, .12);
  --line-strong: rgba(42, 58, 47, .2);
  --accent: #b8d36a;
  --accent-contrast: #1e2b25;
  --theme-icon: #52683a;
  --swatch-outline: rgba(30, 43, 37, .24);
  --feedback-exact: #338452;
  --feedback-misplaced: #91988f;
  --coral: #e96e59;
  --shadow: 0 24px 68px rgba(43, 55, 42, .12);
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; min-width: 320px; margin: 0; overflow: hidden; }
body {
  background: radial-gradient(ellipse at 73% 12%, var(--bg-glow), transparent 38%), var(--bg);
  color: var(--text);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
  transition: background-color .2s ease, color .2s ease;
}
.home-color-bends { position: fixed; z-index: 0; inset: 0; width: 100%; height: 100%; opacity: 0; visibility: hidden; pointer-events: none; transition: opacity .45s ease; }
body.color-bends-webgpu #homeColorBendsGpu, body.color-bends-webgl #homeColorBendsWebgl { visibility: visible; }
body.home-active .home-color-bends { opacity: .68; }
body[data-theme="light"].home-active .home-color-bends { opacity: .42; }
button { font: inherit; color: inherit; }
button:focus-visible, a:focus-visible { outline: 2px solid var(--coral); outline-offset: 3px; }
.app-shell { position: relative; z-index: 1; width: min(1240px, calc(100% - 64px)); height: 100vh; height: 100svh; margin: 0 auto; display: grid; grid-template-rows: 66px minmax(0, 1fr) 28px; overflow: hidden; }
.topbar { position: relative; display: flex; width: min(1060px, 100%); min-width: 0; align-items: center; justify-content: space-between; margin-inline: auto; padding-inline: 20px; border-bottom: 1px solid var(--line); }
.topbar-glass-filter, .home-card-glass-filter { position: absolute; z-index: -1; inset: 0; width: 100%; height: 100%; overflow: hidden; pointer-events: none; }
body.home-active .topbar { width: min(1080px, 100%); margin-top: 6px; border: 1px solid rgba(255, 255, 255, .28); border-radius: 14px; background: rgba(255, 255, 255, .07); -webkit-backdrop-filter: blur(5px) saturate(1.35); backdrop-filter: blur(5px) saturate(1.35); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -1px 0 rgba(255, 255, 255, .12), 0 8px 24px rgba(0, 0, 0, .08); transition: background-color .24s ease, border-color .24s ease, box-shadow .24s ease; }
body.home-active.glass-svg-supported .topbar { background: rgba(255, 255, 255, .025); -webkit-backdrop-filter: url(#home-header-glass-filter) saturate(1.25); backdrop-filter: url(#home-header-glass-filter) saturate(1.25); }
body[data-theme="light"].home-active .topbar { border-color: rgba(38, 52, 43, .2); background: rgba(255, 255, 255, .14); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .78), inset 0 -1px 0 rgba(255, 255, 255, .38), 0 8px 24px rgba(30, 43, 37, .07); }
body[data-theme="light"].home-active.glass-svg-supported .topbar { background: rgba(255, 255, 255, .045); }
body.home-active .brand-name { text-shadow: 0 1px 9px color-mix(in srgb, var(--bg) 72%, transparent); }
.brand { display: inline-flex; align-items: center; gap: 11px; color: var(--text); text-decoration: none; }
.brand-mark { width: 26px; height: 26px; display: grid; grid-template: repeat(2, 1fr) / repeat(2, 1fr); gap: 3px; transform: rotate(-8deg); }
.brand-mark i { display: block; border-radius: 4px; background: var(--accent); }
.brand-mark i:nth-child(2) { background: #a6c66a; }
.brand-mark i:nth-child(3) { background: var(--coral); }
.brand-mark i:nth-child(4) { background: #e9b94f; }
.brand-name { display: flex; align-items: center; gap: 9px; font-size: 15px; font-weight: 800; letter-spacing: .04em; }
.brand-en { color: var(--muted); font: 9px var(--mono); letter-spacing: .12em; }
.topbar-actions { display: flex; align-items: center; gap: 19px; }
.topbar-tag { display: flex; align-items: center; gap: 7px; color: var(--muted); font-size: 10px; }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px color-mix(in srgb, var(--accent) 55%, transparent); }
.back-home, .theme-toggle { display: inline-flex; align-items: center; gap: 8px; border: 1px solid var(--line); border-radius: 7px; background: var(--surface); color: var(--text-soft); cursor: pointer; transition: .18s ease; }
.back-home { padding: 7px 10px; font-size: 10px; }
.back-home:hover, .theme-toggle:hover { border-color: var(--line-strong); background: var(--surface-raised); color: var(--text); }
.theme-toggle { min-width: 82px; justify-content: center; padding: 7px 10px; font-size: 9px; }
.theme-icon { color: var(--theme-icon); font-size: 14px; line-height: 1; }
.hidden { display: none !important; }

.screen { display: none; min-height: 0; overflow: hidden; }
.screen.active { display: grid; }
.home-screen { place-items: center; padding: 16px 0; }
.home-card { position: relative; width: min(1080px, 100%); height: min(670px, 100%); min-height: 0; display: grid; grid-template-columns: 1.05fr .95fr; gap: clamp(32px, 6vw, 78px); padding: clamp(28px, 5vw, 62px); border: 1px solid var(--line); border-radius: 18px; background: color-mix(in srgb, var(--surface) 88%, transparent); box-shadow: var(--shadow); }
body.home-active .home-card { border-color: rgba(255, 255, 255, .28); background: rgba(255, 255, 255, .07); -webkit-backdrop-filter: blur(5px) saturate(1.35); backdrop-filter: blur(5px) saturate(1.35); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .4), inset 0 -1px 0 rgba(255, 255, 255, .12), 0 18px 50px rgba(0, 0, 0, .1); }
body.home-active.glass-svg-supported .home-card { background: rgba(255, 255, 255, .025); -webkit-backdrop-filter: url(#home-card-glass-filter) saturate(1.25); backdrop-filter: url(#home-card-glass-filter) saturate(1.25); }
body[data-theme="light"].home-active .home-card { border-color: rgba(38, 52, 43, .2); background: rgba(255, 255, 255, .18); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .78), inset 0 -1px 0 rgba(255, 255, 255, .38), 0 18px 50px rgba(30, 43, 37, .08); }
body[data-theme="light"].home-active.glass-svg-supported .home-card { background: rgba(255, 255, 255, .045); }
.home-copy { position: relative; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.eyebrow, .micro-label { font-family: var(--mono); text-transform: uppercase; letter-spacing: .13em; font-size: 9px; font-weight: 500; }
.eyebrow { display: flex; align-items: center; gap: 9px; color: var(--accent); }
.eyebrow-line { width: 20px; height: 1px; background: currentColor; }
.home-copy h1 { margin: 24px 0 16px; font-size: clamp(38px, 5vw, 60px); line-height: 1.14; letter-spacing: -.06em; font-weight: 700; }
.home-copy h1 span { color: var(--accent); }
.home-description { max-width: 385px; margin: 0; color: var(--muted); font-size: 13px; line-height: 1.9; }
.home-rule { display: flex; align-items: center; gap: 11px; margin-top: 29px; color: var(--text-soft); font-size: 10px; }
.rule-mark { display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--line-strong); border-radius: 50%; color: var(--coral); font: 8px var(--mono); }
.hero-orbit { position: absolute; width: 154px; height: 154px; top: 2px; right: 4px; display: grid; grid-template: 1fr 1fr / 1fr 1fr; place-items: center; transform: rotate(-14deg); opacity: .85; }
.hero-orbit::before, .hero-orbit::after { position: absolute; content: ""; border: 1px solid var(--line); border-radius: 50%; inset: 18px; }
.hero-orbit::after { inset: 38px; border-style: dashed; }
.hero-orbit i { z-index: 1; width: 16px; height: 16px; border-radius: 50%; background: var(--accent); box-shadow: 0 4px 12px rgba(0,0,0,.15); }
.hero-orbit i:nth-child(2) { background: #e9b94f; }
.hero-orbit i:nth-child(3) { background: var(--coral); }
.hero-orbit i:nth-child(4) { background: #6db8a7; }
.hero-orbit span { position: absolute; width: 4px; height: 4px; border-radius: 50%; background: var(--text-soft); }
.mode-panel { display: grid; grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 10px; min-height: 0; }
.mode-heading { display: flex; justify-content: space-between; align-items: center; padding: 2px 1px 3px; }
.mode-heading .micro-label { color: var(--text-soft); }
.mode-heading-note { color: var(--muted); font: 8px var(--mono); letter-spacing: .08em; }
.primary-modes { display: grid; grid-template-rows: repeat(2, minmax(0, 1fr)); gap: 10px; min-height: 0; transition: grid-template-rows .32s ease; }
.primary-modes.expanded-campaign { grid-template-rows: minmax(0, 1.7fr) minmax(0, 1fr); }
.primary-modes.expanded-pass { grid-template-rows: minmax(0, 1fr) minmax(0, 1.7fr); }
.mode-card { min-width: 0; border: 1px solid var(--line); border-radius: 11px; background: var(--surface-raised); text-align: left; transition: transform .18s ease, border-color .18s ease, background .18s ease, box-shadow .18s ease; }
.mode-card:hover { transform: translateY(-2px); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); background: var(--surface-soft); }
body.home-active .mode-card { border-color: color-mix(in srgb, var(--line-strong) 82%, transparent); background: color-mix(in srgb, var(--surface-raised) 78%, transparent); -webkit-backdrop-filter: blur(10px) saturate(1.25); backdrop-filter: blur(10px) saturate(1.25); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2), inset 0 -1px 0 rgba(255, 255, 255, .05), 0 8px 22px rgba(0, 0, 0, .09); }
body.home-active .mode-card:hover { background: color-mix(in srgb, var(--surface-soft) 84%, transparent); }
body[data-theme="light"].home-active .mode-card { background: color-mix(in srgb, var(--surface-raised) 84%, transparent); box-shadow: inset 0 1px 0 rgba(255, 255, 255, .88), inset 0 -1px 0 rgba(255, 255, 255, .4), 0 8px 22px rgba(30, 43, 37, .08); }
body[data-theme="light"].home-active .mode-card:hover { background: color-mix(in srgb, var(--surface-soft) 90%, transparent); }
.feature-mode-card { display: flex; min-height: 0; flex-direction: column; overflow: hidden; padding: 0; }
.feature-mode-toggle { display: flex; flex: 1 1 auto; align-items: center; gap: 13px; width: 100%; min-height: 88px; padding: clamp(14px, 2vw, 20px); border: 0; border-radius: inherit; background: transparent; color: var(--text); text-align: left; cursor: pointer; }
.feature-mode-toggle:focus-visible { outline-offset: -4px; border-radius: inherit; }
.feature-mode-summary { display: flex; min-width: 0; flex-direction: column; gap: 4px; }
.feature-mode-summary .mode-card-title { font-size: clamp(16px, 1.8vw, 20px); }
.accordion-arrow { flex: 0 0 auto; display: grid; place-items: center; width: 25px; height: 25px; border: 1px solid var(--line-strong); border-radius: 50%; font-size: 15px; line-height: 1; transition: transform .25s ease, color .2s ease, border-color .2s ease; }
.feature-mode-card.is-expanded .accordion-arrow { transform: rotate(45deg); color: var(--accent); border-color: color-mix(in srgb, var(--accent) 55%, var(--line)); }
.feature-mode-details { max-height: 0; overflow: hidden; visibility: hidden; opacity: 0; transition: max-height .32s ease, opacity .2s ease, visibility 0s linear .32s; }
.feature-mode-card.is-expanded .feature-mode-details { max-height: 190px; visibility: visible; opacity: 1; transition: max-height .32s ease, opacity .2s ease .06s, visibility 0s; }
.feature-mode-details-inner { padding: 0 clamp(14px, 2vw, 20px) 15px; }
.feature-mode-details p { margin: 0; color: var(--text-soft); font-size: 10px; line-height: 1.65; }
.feature-mode-details .mode-card-bottom { margin: 8px 0 9px; padding-top: 7px; }
.feature-mode-start { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 31px; padding: 0 10px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-contrast); font-size: 9px; font-weight: 700; cursor: pointer; transition: filter .18s ease, transform .18s ease; }
.feature-mode-start:hover { filter: brightness(1.06); transform: translateY(-1px); }
.feature-mode-start:active { transform: translateY(0); }
.other-mode-button { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto; align-items: center; gap: 10px; width: 100%; min-height: 58px; padding: 8px 13px; cursor: pointer; }
.other-mode-copy { display: grid; min-width: 0; grid-template-columns: 1fr; gap: 2px; }
.other-mode-copy .mode-card-kicker { font-size: 7px; letter-spacing: .08em; text-transform: uppercase; }
.other-mode-copy .mode-card-title { font-size: 12px; }
.other-mode-hint { color: var(--muted); font-size: 8px; }
.other-mode-range { display: flex; align-items: center; gap: 7px; color: var(--text-soft); font: 8px var(--mono); white-space: nowrap; }
.other-mode-range b { color: var(--coral); font-weight: 500; }
.other-mode-range .mode-arrow { margin-left: 1px; }
.mode-symbol { display: grid; place-items: center; width: 25px; height: 25px; border-radius: 7px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-size: 14px; }
.custom-symbol { color: var(--coral); background: color-mix(in srgb, var(--coral) 14%, transparent); }
.pass-symbol { color: var(--coral); background: color-mix(in srgb, var(--coral) 14%, transparent); }
.mode-card-kicker { color: var(--muted); font-size: 9px; }
.mode-arrow { margin-left: auto; color: var(--muted); font-size: 14px; transition: transform .18s ease; }
.mode-card:hover .mode-arrow { transform: translate(2px, -2px); color: var(--accent); }
.feature-mode-card.is-expanded:hover .accordion-arrow { transform: rotate(45deg); }
.mode-card-title { font-size: 17px; font-weight: 700; letter-spacing: -.03em; }
.mode-card-copy { align-self: start; color: var(--muted); font-size: 10px; line-height: 1.65; }
.mode-card-bottom { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding-top: 8px; border-top: 1px solid var(--line); color: var(--muted); font-size: 8px; }
.mini-levels { display: flex; align-items: center; gap: 5px; color: var(--text-soft); font: 8px var(--mono); }
.mini-levels i { display: grid; place-items: center; width: 19px; height: 19px; border: 1px solid var(--line-strong); border-radius: 50%; font-style: normal; }
.mini-levels i:first-child { border-color: var(--accent); color: var(--accent); }
.setting-preview { color: var(--text-soft); font: 9px var(--mono); }
.setting-preview b { padding: 0 3px; color: var(--coral); }
.pass-preview-hearts { color: var(--coral); font-size: 10px; letter-spacing: .1em; }
.mode-footnote { display: flex; align-items: center; gap: 7px; padding: 3px 1px 0; color: var(--muted); font-size: 9px; }
.footnote-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--coral); }

.game-screen { place-items: center; padding: 10px 0; }
.game-card { width: min(1060px, 100%); height: min(760px, 100%); min-height: 0; display: grid; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 10px; padding: 20px 23px 13px; overflow: hidden; border: 1px solid var(--line); border-radius: 16px; background: var(--surface); box-shadow: var(--shadow); }
.game-header { display: flex; align-items: center; justify-content: space-between; min-height: 44px; }
.game-title-block { min-width: 0; }
.compact-eyebrow { color: var(--accent); font-size: 8px; }
.game-header h1 { display: flex; align-items: center; gap: 7px; margin: 4px 0 0; font-size: 21px; line-height: 1.1; letter-spacing: -.04em; }
.header-spark { color: var(--coral); font-size: 15px; }
.turn-counter { display: flex; align-items: baseline; gap: 5px; color: var(--muted); font: 11px var(--mono); white-space: nowrap; }
.turn-counter .turn-current { color: var(--text); font-size: 20px; }
.turn-separator { color: var(--muted); }
.turn-caption { margin-left: 4px; color: var(--muted); font: 9px var(--sans); }
.mode-controls { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; gap: 15px; min-height: 49px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-soft); }
.campaign-controls, .custom-controls { display: flex; align-items: center; gap: 10px; min-width: 0; }
.control-label { flex: 0 0 auto; color: var(--muted); font-size: 9px; }
.level-picker { display: grid; grid-template-columns: repeat(4, minmax(75px, 1fr)); gap: 5px; width: min(100%, 470px); }
.level-choice { display: flex; align-items: center; gap: 6px; min-width: 0; padding: 5px 7px; border: 1px solid transparent; border-radius: 6px; background: transparent; color: var(--muted); text-align: left; cursor: pointer; transition: .16s ease; }
.level-choice > span { display: grid; place-items: center; flex: 0 0 21px; width: 21px; height: 21px; border: 1px solid var(--line-strong); border-radius: 50%; font: 8px var(--mono); }
.level-choice small { overflow: hidden; font-size: 8px; white-space: nowrap; text-overflow: ellipsis; }
.level-choice:hover { background: color-mix(in srgb, var(--accent) 8%, transparent); color: var(--text-soft); }
.level-choice.active { border-color: color-mix(in srgb, var(--accent) 35%, transparent); background: color-mix(in srgb, var(--accent) 12%, transparent); color: var(--text); }
.level-choice.active > span { border-color: var(--accent); background: var(--accent); color: var(--accent-contrast); }
.round-facts { display: flex; align-items: center; gap: 10px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.round-facts b { color: var(--text-soft); font: 10px var(--mono); }
.round-facts i { width: 3px; height: 3px; border-radius: 50%; background: var(--coral); }
.custom-controls { flex-wrap: wrap; }
.pass-controls { display: flex; flex-direction: column; justify-content: center; gap: 5px; min-width: 0; }
.pass-progress-top { display: flex; align-items: center; gap: 9px; min-width: 0; }
.pass-progress-top strong { color: var(--text); font: 9px var(--mono); white-space: nowrap; }
.pass-difficulty { color: var(--muted); font-size: 8px; white-space: nowrap; }
.pass-hearts { display: inline-flex; align-items: center; gap: 3px; margin-left: auto; color: var(--coral); white-space: nowrap; }
.pass-hearts i { font-size: 12px; font-style: normal; line-height: 1; }
.pass-hearts i.spent { color: var(--line-strong); }
.pass-progress-track { height: 3px; overflow: hidden; border-radius: 4px; background: var(--line-strong); }
.pass-progress-track span { display: block; width: 3.125%; height: 100%; border-radius: inherit; background: var(--accent); transition: width .24s ease; }
.custom-control-fields { display: flex; align-items: center; gap: 9px; }
.compact-stepper { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 8px; white-space: nowrap; }
.compact-stepper b { min-width: 29px; color: var(--text); font: 9px var(--mono); text-align: center; }
.compact-stepper button { display: grid; place-items: center; width: 20px; height: 20px; border: 1px solid var(--line-strong); border-radius: 5px; background: transparent; color: var(--accent); line-height: 1; cursor: pointer; }
.compact-stepper button:disabled { opacity: .35; cursor: not-allowed; }
.control-divider { height: 18px; border-left: 1px solid var(--line); }
.apply-settings { padding: 6px 9px; border: 0; border-radius: 5px; background: var(--accent); color: var(--accent-contrast); font-size: 8px; font-weight: 700; white-space: nowrap; cursor: pointer; }
.apply-settings:hover { filter: brightness(1.04); }
.secret-strip { display: grid; grid-template-columns: 130px 1fr auto; align-items: center; gap: 12px; min-height: 49px; padding: 8px 13px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-raised); }
.secret-label { display: flex; align-items: center; gap: 7px; color: var(--text-soft); font-size: 9px; font-weight: 600; white-space: nowrap; }
.secret-lock { color: var(--coral); font-size: 15px; }
.secret-slots, .guess-slots { display: flex; justify-content: center; gap: 9px; }
.secret-slot { width: 23px; height: 23px; border: 1px solid var(--line-strong); border-radius: 50%; background: var(--surface-soft); box-shadow: inset 0 2px 3px rgba(0,0,0,.12); }
.secret-slot.revealed { border-color: var(--swatch-outline); box-shadow: inset 0 1px 2px rgba(0,0,0,.18), 0 2px 4px rgba(0,0,0,.12); }
.secret-helper { color: var(--muted); font-size: 8px; white-space: nowrap; }
.game-content { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(260px, .95fr); gap: 12px; min-height: 0; }
.history-panel, .play-panel { min-width: 0; min-height: 0; border: 1px solid var(--line); border-radius: 9px; background: var(--surface-soft); }
.history-panel { position: relative; display: grid; grid-template-rows: auto minmax(0, 1fr); padding: 12px 12px 8px; }
.history-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 0 2px 8px; color: var(--text-soft); font-size: 9px; font-weight: 700; }
.history-legend { display: flex; align-items: center; gap: 4px; color: var(--muted); font-size: 7px; font-weight: 400; white-space: nowrap; }
.history-legend i { display: inline-block; width: 7px; height: 7px; margin-left: 4px; border-radius: 50%; }
.history-legend .legend-exact { background: var(--feedback-exact); }
.history-legend .legend-misplaced { background: var(--feedback-misplaced); }
.history-list { display: flex; flex-direction: column; gap: 4px; min-height: 0; overflow-y: auto; scrollbar-width: none; }
.history-list::-webkit-scrollbar { display: none; }
.history-row { display: grid; grid-template-columns: 31px 1fr 110px; align-items: center; flex: 0 0 38px; min-height: 38px; padding: 3px 8px; border: 1px solid transparent; border-radius: 6px; background: color-mix(in srgb, var(--surface-raised) 76%, transparent); animation: row-in .24s ease both; }
@keyframes row-in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: translateY(0); } }
.history-index { color: var(--muted); font: 8px var(--mono); }
.history-colors { display: flex; align-items: center; gap: 8px; }
.history-color { width: 24px; height: 24px; border: 1px solid var(--swatch-outline); border-radius: 50%; box-shadow: inset 0 1px 2px rgba(0,0,0,.12); }
.feedback { display: flex; align-items: center; justify-content: flex-end; gap: 7px; }
.feedback-group { display: flex; align-items: center; justify-content: flex-end; gap: 3px; min-width: 37px; }
.feedback-dot { width: 5px; height: 5px; border-radius: 50%; background: var(--line-strong); }
.feedback-dot.exact { background: var(--feedback-exact); }
.feedback-dot.misplaced { background: var(--feedback-misplaced); }
.feedback-count { min-width: 9px; color: var(--muted); font: 8px var(--mono); }
.history-empty { position: absolute; top: 42px; right: 0; bottom: 0; left: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 9px; color: var(--muted); font-size: 9px; pointer-events: none; }
.empty-orbit { display: flex; align-items: center; justify-content: center; gap: 4px; width: 44px; height: 27px; }
.empty-orbit i { width: 7px; height: 7px; border: 1px solid var(--line-strong); border-radius: 50%; }
.empty-orbit i:nth-child(2), .empty-orbit i:nth-child(4) { transform: translateY(-4px); }
.play-panel { display: grid; grid-template-rows: minmax(0, 1fr) auto; gap: 8px; padding: 10px; }
.guess-area { display: flex; flex-direction: column; min-height: 0; padding: 4px 5px 2px; }
.guess-heading { display: flex; justify-content: space-between; align-items: center; }
.guess-heading .micro-label { color: var(--text-soft); font-size: 8px; }
.clear-button { border: 0; padding: 3px 0; background: transparent; color: var(--muted); font-size: 8px; cursor: pointer; }
.clear-button:hover { color: var(--coral); }
.guess-slots { margin: 10px 0 12px; gap: 10px; }
.guess-slot { position: relative; width: 31px; height: 31px; border: 1px dashed var(--line-strong); border-radius: 50%; background: var(--surface); cursor: pointer; transition: .15s ease; }
.guess-slot.filled { border: 1px solid var(--swatch-outline); box-shadow: inset 0 1px 2px rgba(0,0,0,.13), 0 3px 5px rgba(0,0,0,.1); }
.guess-slot:hover:not(:disabled) { transform: translateY(-2px); }
.guess-slot:not(.filled)::after { position: absolute; content: attr(data-index); inset: 0; display: grid; place-items: center; color: var(--muted); font: 8px var(--mono); }
.palette-head { display: flex; align-items: center; justify-content: space-between; gap: 5px; color: var(--text-soft); font-size: 8px; }
.palette-head span:first-child { font-weight: 700; }
.palette-head span:last-child { color: var(--muted); font-size: 7px; }
.color-palette { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; min-height: 30px; margin-top: 8px; }
.palette-color { position: relative; width: 24px; height: 24px; border: 1px solid var(--swatch-outline); border-radius: 50%; box-shadow: inset 0 1px 2px rgba(0,0,0,.13), 0 1px 3px rgba(0,0,0,.1); cursor: pointer; transition: transform .15s ease, opacity .15s ease; }
.palette-color:hover:not(:disabled) { transform: translateY(-3px) scale(1.06); }
.palette-color:disabled { opacity: .32; cursor: not-allowed; box-shadow: none; }
.palette-color:disabled::after { position: absolute; content: "✓"; inset: 0; display: grid; place-items: center; color: rgba(24,33,28,.75); font-size: 11px; font-weight: 800; }
.submit-button { display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 34px; margin-top: auto; padding: 0 11px; border: 0; border-radius: 6px; background: var(--accent); color: var(--accent-contrast); font-size: 9px; font-weight: 700; cursor: pointer; transition: .18s ease; }
.submit-button:disabled { background: var(--surface-raised); color: var(--muted); cursor: not-allowed; }
.submit-button:not(:disabled):hover { filter: brightness(1.05); transform: translateY(-1px); }
.submit-shortcut { font-size: 13px; }
.result-panel { display: flex; align-items: center; gap: 10px; min-height: 120px; padding: 13px; border: 1px solid color-mix(in srgb, var(--accent) 28%, var(--line)); border-radius: 8px; background: color-mix(in srgb, var(--accent) 11%, var(--surface-raised)); }
.result-panel.is-loss { border-color: color-mix(in srgb, var(--coral) 28%, var(--line)); background: color-mix(in srgb, var(--coral) 10%, var(--surface-raised)); }
.result-icon { display: grid; place-items: center; flex: 0 0 30px; height: 30px; border-radius: 50%; background: var(--accent); color: var(--accent-contrast); font-size: 14px; }
.is-loss .result-icon { background: var(--coral); }
.result-copy { flex: 1; min-width: 0; }
.result-copy .micro-label { color: var(--muted); font-size: 7px; }
.result-copy h2 { margin: 3px 0 2px; font-size: 12px; }
.result-copy p { margin: 0; color: var(--muted); font-size: 8px; line-height: 1.5; }
.result-actions { display: flex; flex-direction: column; gap: 5px; }
.result-action { white-space: nowrap; border: 0; padding: 6px 8px; border-radius: 5px; background: var(--accent); color: var(--accent-contrast); font-size: 8px; font-weight: 700; cursor: pointer; }
.result-action.secondary { border: 1px solid var(--line-strong); background: transparent; color: var(--text-soft); }
.play-hint { display: flex; align-items: center; gap: 7px; min-height: 22px; color: var(--muted); font-size: 7px; line-height: 1.4; }
.hint-icon { display: grid; place-items: center; flex: 0 0 14px; height: 14px; border: 1px solid var(--line-strong); border-radius: 50%; font: 8px var(--mono); }
.game-footer { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 8px; }
.game-footer i { padding: 0 3px; color: var(--coral); font-style: normal; }
.new-game-button { border: 0; padding: 4px 0 4px 8px; background: transparent; color: var(--text-soft); font-size: 8px; cursor: pointer; }
.new-game-button:hover { color: var(--coral); }
.new-game-button span { margin-left: 3px; font-size: 12px; }
.page-footer { display: flex; align-items: center; justify-content: space-between; gap: 12px; color: var(--muted); font-size: 8px; }
.page-footer i { padding: 0 3px; color: var(--coral); font-style: normal; }
.toast { position: fixed; left: 50%; bottom: 22px; z-index: 5; transform: translate(-50%, 12px); padding: 9px 14px; border: 1px solid var(--line-strong); border-radius: 7px; background: var(--surface-raised); color: var(--text); font-size: 10px; opacity: 0; pointer-events: none; transition: .2s ease; box-shadow: var(--shadow); }
.toast.show { transform: translate(-50%, 0); opacity: 1; }

@media (max-width: 900px) {
  .app-shell { width: min(760px, calc(100% - 36px)); grid-template-rows: 60px minmax(0, 1fr) 25px; }
  .home-card { grid-template-columns: .9fr 1.1fr; gap: 28px; padding: 30px; }
  .hero-orbit { width: 112px; height: 112px; right: 0; }
  .home-copy h1 { font-size: 43px; }
  .game-card { padding: 16px; gap: 8px; }
  .mode-controls { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .campaign-controls { gap: 8px; }
  .round-facts { justify-content: flex-end; }
  .game-content { grid-template-columns: minmax(0, 1fr) minmax(230px, .9fr); gap: 8px; }
}

@media (max-width: 640px) {
  .app-shell { width: calc(100% - 24px); grid-template-rows: 54px minmax(0, 1fr) 22px; }
  .topbar { padding-inline: 12px; }
  body.home-active .topbar { margin-top: 4px; border-radius: 12px; }
  .topbar-actions { gap: 9px; }
  .topbar-tag { display: none; }
  .theme-toggle { min-width: 70px; padding: 6px 8px; }
  .back-home { padding: 6px 8px; font-size: 9px; }
  .brand-name { font-size: 14px; }
  .brand-en { font-size: 8px; }
  .home-screen { padding: 8px 0; }
  .home-card { width: 100%; height: 100%; grid-template-columns: 1fr; grid-template-rows: auto minmax(0, 1fr); gap: 15px; padding: 19px; border-radius: 13px; }
  .home-copy { justify-content: flex-start; }
  .home-copy h1 { margin: 13px 0 7px; font-size: clamp(31px, 9vw, 39px); }
  .home-description { max-width: 440px; font-size: 10px; line-height: 1.6; }
  .home-rule { margin-top: 10px; font-size: 8px; }
  .rule-mark { width: 20px; height: 20px; }
  .hero-orbit { top: 0; right: 0; width: 76px; height: 76px; opacity: .65; }
  .hero-orbit i { width: 10px; height: 10px; }
  .hero-orbit::before { inset: 8px; }
  .hero-orbit::after { inset: 21px; }
  .mode-panel { grid-template-rows: auto minmax(0, 1fr) auto auto; gap: 7px; }
  .primary-modes { gap: 7px; }
  .primary-modes.expanded-campaign { grid-template-rows: minmax(0, 2fr) minmax(0, 1fr); }
  .primary-modes.expanded-pass { grid-template-rows: minmax(0, 1fr) minmax(0, 2fr); }
  .mode-heading-note { font-size: 7px; }
  .feature-mode-toggle { gap: 8px; min-height: 78px; padding: 10px 11px; }
  .feature-mode-summary .mode-card-title { font-size: 14px; }
  .feature-mode-summary .mode-card-copy { font-size: 8px; line-height: 1.45; }
  .feature-mode-details-inner { padding: 0 11px 10px; }
  .feature-mode-details p { font-size: 8px; }
  .feature-mode-details .mode-card-bottom { margin: 5px 0 6px; padding-top: 4px; }
  .feature-mode-start { min-height: 27px; font-size: 8px; }
  .other-mode-button { grid-template-columns: 22px minmax(0, 1fr) auto; gap: 7px; min-height: 52px; padding: 7px 9px; }
  .other-mode-copy .mode-card-title { font-size: 11px; }
  .other-mode-hint { display: none; }
  .other-mode-range { gap: 4px; font-size: 7px; }
  .mode-card-copy { font-size: 8px; }
  .mode-card-bottom { padding-top: 5px; font-size: 7px; }
  .pass-preview-hearts { font-size: 8px; }
  .mini-levels { gap: 3px; }
  .mini-levels i { width: 16px; height: 16px; font-size: 7px; }
  .mode-footnote { padding-top: 0; font-size: 8px; }
  .game-screen { padding: 5px 0; }
  .game-card { width: 100%; height: 100%; grid-template-rows: auto auto auto minmax(0, 1fr) auto; gap: 6px; padding: 10px; border-radius: 12px; }
  .game-header { min-height: 35px; }
  .compact-eyebrow { font-size: 7px; }
  .game-header h1 { font-size: 17px; }
  .turn-counter { gap: 3px; font-size: 9px; }
  .turn-counter .turn-current { font-size: 17px; }
  .turn-caption { font-size: 7px; }
  .mode-controls { padding: 6px; gap: 5px; }
  .campaign-controls { display: block; }
  .control-label { display: none; }
  .level-picker { width: 100%; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
  .level-choice { justify-content: center; gap: 4px; padding: 4px 3px; }
  .level-choice > span { flex-basis: 18px; width: 18px; height: 18px; font-size: 7px; }
  .level-choice small { font-size: 7px; }
  .round-facts { gap: 7px; font-size: 7px; }
  .round-facts b { font-size: 8px; }
  .custom-controls { display: block; }
  .custom-control-fields { justify-content: space-between; gap: 4px; }
  .compact-stepper { gap: 4px; font-size: 7px; }
  .compact-stepper button { width: 18px; height: 18px; }
  .compact-stepper b { min-width: 25px; font-size: 8px; }
  .apply-settings { padding: 5px 6px; font-size: 7px; }
  .secret-strip { grid-template-columns: 1fr auto; gap: 4px 8px; min-height: 42px; padding: 6px 9px; }
  .secret-label { grid-column: 1; font-size: 8px; }
  .secret-slots { grid-column: 2; grid-row: 1; gap: 6px; }
  .secret-slot { width: 19px; height: 19px; }
  .secret-helper { grid-column: 1 / -1; font-size: 7px; }
  .game-content { grid-template-columns: 1fr; grid-template-rows: minmax(80px, 1fr) auto; gap: 6px; }
  .history-panel { padding: 7px 8px 6px; }
  .history-head { padding: 0 1px 5px; font-size: 8px; }
  .history-legend { gap: 3px; font-size: 6px; }
  .history-legend i { width: 5px; height: 5px; margin-left: 2px; }
  .history-row { grid-template-columns: 25px 1fr 88px; flex-basis: 32px; min-height: 32px; padding: 2px 5px; }
  .history-colors { gap: 6px; }
  .history-color { width: 20px; height: 20px; }
  .feedback { gap: 4px; }
  .feedback-group { min-width: 31px; gap: 2px; }
  .feedback-dot { width: 4px; height: 4px; }
  .feedback-count { font-size: 7px; }
  .history-empty { top: 31px; gap: 4px; font-size: 7px; }
  .empty-orbit { height: 18px; }
  .empty-orbit i { width: 6px; height: 6px; }
  .play-panel { grid-template-rows: minmax(0, 1fr) auto; gap: 4px; padding: 7px 8px 6px; }
  .guess-area { padding: 0 2px; }
  .guess-slots { margin: 6px 0 8px; gap: 8px; }
  .guess-slot { width: 27px; height: 27px; }
  .color-palette { min-height: 25px; gap: 7px; margin-top: 5px; }
  .palette-color { width: 21px; height: 21px; }
  .submit-button { min-height: 29px; font-size: 8px; }
  .play-hint { min-height: 15px; font-size: 6px; }
  .hint-icon { flex-basis: 12px; height: 12px; font-size: 7px; }
  .result-panel { min-height: 84px; gap: 7px; padding: 8px; }
  .result-icon { flex-basis: 25px; height: 25px; }
  .result-copy h2 { font-size: 10px; }
  .result-copy p { font-size: 7px; }
  .result-action { padding: 5px 6px; font-size: 7px; }
  .result-actions { gap: 3px; }
  .game-footer { font-size: 7px; }
  .new-game-button { font-size: 7px; }
  .page-footer { font-size: 6px; }
  .toast { bottom: 12px; }
}

@media (max-height: 700px) {
  .app-shell { grid-template-rows: 54px minmax(0, 1fr) 23px; }
  .home-screen { padding: 8px 0; }
  .home-card { padding-top: 25px; padding-bottom: 25px; }
  .home-copy h1 { margin-top: 17px; font-size: clamp(36px, 4.5vw, 50px); }
  .home-rule { margin-top: 18px; }
  .game-card { padding-top: 12px; padding-bottom: 9px; gap: 7px; }
  .game-header { min-height: 36px; }
  .mode-controls { min-height: 43px; padding-top: 5px; padding-bottom: 5px; }
  .secret-strip { min-height: 42px; padding-top: 6px; padding-bottom: 6px; }
  .game-footer { min-height: 17px; }
}

@media (max-width: 640px) and (max-height: 680px) {
  .app-shell { grid-template-rows: 48px minmax(0, 1fr) 0; }
  .page-footer { display: none; }
  .home-card { padding: 13px 16px; gap: 8px; }
  .home-copy h1 { margin: 9px 0 5px; font-size: 30px; }
  .home-description { font-size: 9px; line-height: 1.45; }
  .home-rule { margin-top: 6px; }
  .hero-orbit { width: 60px; height: 60px; }
  .mode-panel { gap: 6px; }
  .primary-modes.expanded-campaign { grid-template-rows: minmax(0, 2fr) minmax(0, 1fr); }
  .primary-modes.expanded-pass { grid-template-rows: minmax(0, 1fr) minmax(0, 2fr); }
  .feature-mode-toggle { min-height: 68px; padding: 7px 9px; }
  .feature-mode-summary .mode-card-title { font-size: 12px; }
  .feature-mode-summary .mode-card-copy { font-size: 7px; }
  .feature-mode-details-inner { padding: 0 9px 7px; }
  .feature-mode-details p { font-size: 7px; }
  .feature-mode-start { min-height: 24px; font-size: 7px; }
  .other-mode-button { min-height: 46px; padding: 6px 8px; }
  .other-mode-copy .mode-card-title { font-size: 10px; }
  .other-mode-range { font-size: 6px; }
  .mode-card-bottom { padding-top: 3px; }
  .mode-symbol { width: 20px; height: 20px; }
  .mode-footnote { font-size: 7px; }
  .game-screen { padding: 2px 0; }
  .game-card { padding: 7px; gap: 4px; }
  .game-header { min-height: 30px; }
  .game-header h1 { font-size: 15px; }
  .mode-controls { padding: 4px; }
  .round-facts { display: none; }
  .secret-strip { min-height: 35px; }
  .game-content { grid-template-rows: minmax(45px, 1fr) auto; gap: 4px; }
  .history-panel { padding: 5px 6px; }
  .history-row { flex-basis: 27px; min-height: 27px; }
  .history-color { width: 17px; height: 17px; }
  .play-panel { padding: 5px 6px; }
  .guess-slots { margin: 4px 0 5px; }
  .guess-slot { width: 24px; height: 24px; }
  .color-palette { min-height: 22px; margin-top: 3px; }
  .palette-color { width: 18px; height: 18px; }
  .submit-button { min-height: 25px; }
  .play-hint { display: none; }
  .game-footer { min-height: 14px; }
}

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