:root {
  color-scheme: dark;
  --ink: #edf7ff;
  --muted: #90a5bb;
  --cyan: #49f6e8;
  --blue: #5d8cff;
  --violet: #a969ff;
  --pink: #ff5eaa;
  --danger: #ff4e70;
  --gold: #ffe779;
  --panel: rgba(8, 15, 34, 0.76);
  --line: rgba(139, 219, 255, 0.16);
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; overscroll-behavior: none; }

body {
  min-height: 100vh;
  min-height: 100svh;
  overflow-x: hidden;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background:
    radial-gradient(circle at 15% 5%, rgba(49, 102, 197, .2), transparent 34%),
    radial-gradient(circle at 88% 78%, rgba(142, 57, 195, .16), transparent 32%),
    #050813;
}

button, a, select { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
button { font: inherit; color: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.game-shell { width: min(1280px, 100%); margin: 0 auto; padding: 14px clamp(10px, 2.2vw, 28px) 18px; display: flex; flex-direction: column; min-height: 100svh; }

.brand-bar { display: flex; align-items: center; justify-content: space-between; height: 46px; }
.brand { display: inline-flex; align-items: center; gap: 10px; color: var(--ink); text-decoration: none; font-size: 15px; font-weight: 900; letter-spacing: .16em; }
.brand-mark { width: 24px; height: 24px; transform: rotate(45deg); border: 1px solid rgba(73,246,232,.65); border-radius: 7px 2px; box-shadow: inset 0 0 12px rgba(73,246,232,.28), 0 0 18px rgba(73,246,232,.14); position: relative; }
.brand-mark::after { content: ""; position: absolute; inset: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 9px var(--cyan); }
.brand-actions { display: flex; gap: 7px; align-items: center; }
.icon-button, .hud-button, .close-button { border: 1px solid var(--line); background: rgba(10,19,41,.72); color: #b8cbe0; backdrop-filter: blur(12px); border-radius: 10px; }
.icon-button { width: 34px; height: 34px; }
.icon-button:hover, .hud-button:hover, .close-button:hover { color: #fff; border-color: rgba(73,246,232,.46); }

.language-control { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 11px; border: 1px solid var(--line); border-radius: 10px; color: #7f99b2; background: rgba(8,15,34,.72); backdrop-filter: blur(12px); font-size: 9px; letter-spacing: .08em; }
.language-control select { min-width: 86px; border: 0; outline: 0; color: #d8edf5; background: transparent; font: 700 10px/1.2 inherit; cursor: pointer; }
.language-control option { color: #e7f6ff; background: #0b1730; }

.game-frame {
  position: relative;
  width: min(600px, 100%);
  aspect-ratio: 1 / 1;
  margin: clamp(10px, 2.4vw, 26px) auto;
  max-height: calc(100svh - 120px);
  overflow: hidden;
  border: 1px solid rgba(121, 202, 255, .2);
  border-radius: clamp(14px, 2vw, 24px);
  background: #071022;
  box-shadow: 0 30px 80px rgba(0,0,0,.48), inset 0 0 0 1px rgba(255,255,255,.02);
  isolation: isolate;
  flex: 0 1 auto;
}
.game-frame, .game-frame * { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-user-drag: none; }
.game-frame::before { content: ""; position: absolute; inset: 0; z-index: 4; pointer-events: none; background: repeating-linear-gradient(to bottom, transparent 0 3px, rgba(118,228,255,.022) 4px); mix-blend-mode: screen; }
#gameCanvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.vignette { position: absolute; inset: 0; z-index: 3; pointer-events: none; box-shadow: inset 0 0 100px rgba(1,5,15,.72); }

.screen { position: absolute; inset: 0; z-index: 10; display: none; }
.screen.is-active { display: flex; animation: screen-in .4s cubic-bezier(.2,.8,.2,1) both; }
@keyframes screen-in { from { opacity: 0; transform: scale(1.015); } }

/* ---------- MENU ---------- */
.menu-screen { flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: clamp(26px, 5vw, 54px); text-align: center; background: linear-gradient(180deg, rgba(4,9,23,.86), rgba(4,9,23,.5)); }
#menuScreen .eyebrow { display: none; }
.menu-copy { width: 100%; max-width: 460px; }
.eyebrow { display: flex; align-items: center; justify-content: center; gap: 9px; margin: 0 0 10px; color: #8ffcf2; font-size: clamp(10px, 1.15vw, 13px); font-weight: 800; letter-spacing: .18em; text-transform: uppercase; }
.eyebrow > span { width: 23px; height: 1px; background: currentColor; box-shadow: 0 0 7px currentColor; }
.logo-title { margin: 0; font-family: "Microsoft JhengHei UI", "Microsoft YaHei", sans-serif; font-size: clamp(54px, 13vw, 96px); line-height: .82; letter-spacing: -.06em; font-weight: 950; text-shadow: 0 10px 45px rgba(0,0,0,.45); }
.logo-title em { color: transparent; font-style: normal; -webkit-text-stroke: 1.5px rgba(143,252,242,.86); filter: drop-shadow(0 0 11px rgba(73,246,232,.25)); }
.menu-desc { margin: 16px auto 22px; color: #9bafc4; font-size: clamp(12px, 1.5vw, 15px); line-height: 1.8; max-width: 380px; }

.mode-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.mode-card { display: flex; flex-direction: column; gap: 6px; align-items: center; padding: 18px 12px; border: 1px solid rgba(121,202,255,.22); border-radius: 14px; background: rgba(10,19,41,.6); color: var(--ink); transition: transform .16s, border-color .16s, box-shadow .16s; }
.mode-card b { font-size: clamp(14px, 2vw, 18px); font-weight: 900; letter-spacing: .06em; }
.mode-card small { color: var(--muted); font-size: 10px; letter-spacing: .14em; }
.mode-card:hover { transform: translateY(-2px); border-color: rgba(73,246,232,.5); box-shadow: 0 12px 30px rgba(37,224,205,.14); }
.mode-card.is-selected { border-color: rgba(73,246,232,.85); box-shadow: 0 0 0 1px rgba(73,246,232,.4), 0 12px 30px rgba(37,224,205,.18); }

.difficulty-group { margin-top: 4px; display: flex; flex-direction: column; align-items: center; gap: 9px; transition: opacity .2s; }
body[data-mode="2p"] .difficulty-group { opacity: .3; pointer-events: none; }
.group-label { color: #7f99b2; font-size: 10px; letter-spacing: .2em; font-weight: 800; }
.difficulty-chips { display: flex; gap: 8px; }
.difficulty-chip { padding: 9px 16px; border: 1px solid rgba(121,202,255,.22); border-radius: 999px; background: rgba(10,19,41,.6); color: #c4d8e8; font-size: 12px; font-weight: 800; letter-spacing: .08em; transition: border-color .16s, color .16s, background .16s; }
.difficulty-chip:hover { color: #fff; border-color: rgba(73,246,232,.45); }
.difficulty-chip.is-selected { color: #061216; background: linear-gradient(115deg, #82fff4, #45dfd7); border-color: rgba(128,255,245,.85); box-shadow: 0 8px 22px rgba(37,224,205,.2); }
.menu-hint { color: var(--muted); font-size: 11px; letter-spacing: .12em; margin: 4px 0 0; }

/* ---------- SLIDING TOGGLE ---------- */
.toggle-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; width: 100%; max-width: 360px; margin-top: 10px; padding: 11px 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(10,19,41,.55); backdrop-filter: blur(12px); }
.toggle-text { display: flex; flex-direction: column; gap: 3px; text-align: left; }
.toggle-title { color: #d8edf5; font-size: 13px; font-weight: 800; letter-spacing: .04em; }
.toggle-sub { color: var(--muted); font-size: 10px; letter-spacing: .03em; line-height: 1.4; max-width: 250px; }
.switch { position: relative; display: inline-block; width: 46px; height: 26px; flex: 0 0 auto; }
.switch input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; z-index: 1; }
.switch .slider { position: absolute; inset: 0; border-radius: 999px; background: rgba(120,140,170,.4); transition: background .2s ease; }
.switch .slider::before { content: ""; position: absolute; left: 3px; top: 3px; width: 20px; height: 20px; border-radius: 50%; background: #eaf6ff; box-shadow: 0 2px 6px rgba(0,0,0,.4); transition: transform .2s ease; }
.switch input:checked + .slider { background: linear-gradient(115deg, #82fff4, #45dfd7); }
.switch input:checked + .slider::before { transform: translateX(20px); }
.switch input:focus-visible + .slider { outline: 2px solid var(--cyan); outline-offset: 2px; }

.menu-side { width: 100%; max-width: 460px; display: flex; justify-content: center; }
.record-card { width: 100%; padding: 16px 20px; border: 1px solid var(--line); border-radius: 16px; background: var(--panel); backdrop-filter: blur(14px); box-shadow: inset 0 0 26px rgba(73,246,232,.05); }
.record-eyebrow { display: block; color: #8ffcf2; font-size: 10px; letter-spacing: .22em; font-weight: 800; margin-bottom: 10px; text-align: center; }
.record-row { display: flex; align-items: baseline; justify-content: space-between; padding: 6px 0; border-top: 1px solid rgba(139,219,255,.08); }
.record-row strong { font-size: 22px; font-weight: 900; font-variant-numeric: tabular-nums; }
.record-row span { color: var(--muted); font-size: 11px; letter-spacing: .16em; }
.record-row.streak strong { color: var(--cyan); }
.record-row.best strong { color: var(--gold); }

/* ---------- GAME HUD ---------- */
.game-hud { position: absolute; z-index: 12; top: 0; left: 0; right: 0; display: none; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; pointer-events: none; }
body[data-state="playing"] .game-hud { display: flex; }
.game-hud .hud-button { pointer-events: auto; width: 40px; height: 40px; display: inline-flex; align-items: center; justify-content: center; font-size: 16px; }
.hud-info { pointer-events: none; text-align: center; flex: 1; }
.hud-turn { display: block; font-size: clamp(15px, 2.4vw, 20px); font-weight: 900; letter-spacing: .04em; text-shadow: 0 2px 16px rgba(0,0,0,.5); }
.hud-meta { color: var(--muted); font-size: 10px; letter-spacing: .16em; }

/* ---------- OVERLAYS (result / help / pause) ---------- */
.overlay { position: absolute; inset: 0; z-index: 20; display: none; align-items: center; justify-content: center; padding: 22px; background: rgba(3,7,18,.62); backdrop-filter: blur(6px); }
.overlay.is-open { display: flex; animation: screen-in .3s cubic-bezier(.2,.8,.2,1) both; }
.modal-card { width: min(420px, 100%); padding: clamp(22px, 4vw, 34px); border: 1px solid rgba(121,202,255,.22); border-radius: 20px; background: linear-gradient(180deg, rgba(11,21,46,.96), rgba(7,13,30,.96)); box-shadow: 0 30px 80px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.03); text-align: center; }
.compact-card { width: min(360px, 100%); }
.result-card .result-title { margin: 6px 0 8px; font-size: clamp(30px, 6vw, 46px); font-weight: 950; letter-spacing: -.02em; }
.result-message { color: #9bafc4; font-size: 14px; line-height: 1.7; margin: 0 0 8px; }
.result-streak { color: var(--gold); font-size: 12px; font-weight: 800; letter-spacing: .2em; margin-bottom: 14px; }
.result-streak[hidden] { display: none; }
.modal-card h2 { margin: 6px 0 4px; font-size: clamp(22px, 4vw, 30px); font-weight: 900; }
.help-card { text-align: left; }
.help-rules { color: #9bafc4; font-size: 13.5px; line-height: 1.9; white-space: pre-line; margin: 14px 0 20px; }
.close-button { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; font-size: 20px; line-height: 1; }

.primary-button, .secondary-button, .text-button { display: block; width: 100%; margin-top: 10px; border-radius: 13px; font-weight: 900; letter-spacing: .08em; transition: transform .16s, border-color .16s, filter .16s; }
.primary-button { min-height: 52px; border: 1px solid rgba(128,255,245,.85); color: #061216; background: linear-gradient(115deg, #82fff4, #45dfd7 45%, #7fffd2); box-shadow: 0 10px 30px rgba(37,224,205,.18), inset 0 1px rgba(255,255,255,.8); }
.primary-button.slim { min-height: 46px; }
.primary-button:hover { transform: translateY(-1px); filter: brightness(1.04); }
.secondary-button { min-height: 46px; border: 1px solid var(--line); background: rgba(10,19,41,.7); color: #cfe2f2; }
.secondary-button:hover { border-color: rgba(73,246,232,.45); }
.text-button { background: none; border: 0; color: var(--muted); font-size: 12px; letter-spacing: .14em; margin-top: 8px; }
.text-button:hover { color: #fff; }

.toast { position: absolute; z-index: 30; left: 50%; bottom: 22px; transform: translateX(-50%) translateY(8px); padding: 9px 16px; border: 1px solid var(--line); border-radius: 999px; background: var(--panel); color: #d8edf5; font-size: 12px; letter-spacing: .08em; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; }
.toast.is-visible { opacity: 1; transform: translateX(-50%) translateY(0); }

.footer-note { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 11px; letter-spacing: .06em; margin-top: auto; padding-top: 6px; }
.footer-note i { width: 7px; height: 7px; border-radius: 50%; background: var(--cyan); box-shadow: 0 0 9px var(--cyan); display: inline-block; margin-right: 7px; }

@media (min-width: 900px) and (orientation: landscape) {
  .menu-screen { flex-direction: row; text-align: left; gap: 7%; }
  .menu-copy { width: min(54%, 520px); }
  .menu-side { width: auto; }
  .eyebrow { justify-content: flex-start; }
  .record-card { width: 280px; }
}

/* ---------- 2026 refresh: playful mobile-first game room ---------- */
:root {
  --ink: #202039;
  --muted: #77768e;
  --cyan: #5f62e9;
  --blue: #8d8ff5;
  --violet: #ad68e7;
  --pink: #f36c8e;
  --danger: #dc4e70;
  --gold: #f3af45;
  --panel: #ffffff;
  --line: #e5e4f1;
}

body {
  color: var(--ink);
  background:
    radial-gradient(circle at 3% 8%, rgba(255, 200, 107, .42), transparent 25%),
    radial-gradient(circle at 95% 12%, rgba(157, 126, 255, .28), transparent 27%),
    linear-gradient(145deg, #f8f6ff 0%, #f1f2ff 48%, #fff7f2 100%);
}

.game-shell { width: min(760px, 100%); padding: 10px clamp(12px, 4vw, 28px) 18px; }
.brand-bar { height: 52px; }
.brand { color: #383754; font-size: 17px; letter-spacing: -.01em; }
.brand-mark { width: 29px; height: 29px; transform: rotate(0); border: 0; border-radius: 10px; background: linear-gradient(135deg, #696be9, #9b71e9); box-shadow: 0 7px 15px rgba(95,98,233,.25); }
.brand-mark::after { inset: 8px; background: #fff; box-shadow: none; }
.brand-actions { gap: 6px; }
.icon-button, .hud-button, .close-button { border-color: #e4e2f0; background: #fff; color: #5c5b76; box-shadow: 0 3px 10px rgba(54,49,112,.06); }
.icon-button { width: 36px; height: 36px; border-radius: 12px; }
.language-control { padding: 0; border: 0; background: transparent; box-shadow: none; }
.language-control > span { display: none; }
.language-control select { min-width: 62px; color: #66647c; font-size: 11px; font-weight: 800; }
.language-control option { color: #28273d; background: #fff; }

.game-frame {
  width: min(620px, 100%);
  margin: 8px auto 12px;
  border: 0;
  border-radius: 26px;
  background: #fff;
  box-shadow: 0 20px 52px rgba(59,51,126,.14), 0 2px 7px rgba(59,51,126,.06);
}
.game-frame::before { display: none; }
.vignette { box-shadow: inset 0 0 60px rgba(58,51,111,.12); }
body[data-state="menu"] .game-frame { aspect-ratio: auto; min-height: min(690px, calc(100svh - 88px)); max-height: none; }
body[data-state="playing"] .game-frame, body[data-state="over"] .game-frame { aspect-ratio: 1; max-height: calc(100svh - 90px); }

.menu-screen { justify-content: flex-start; gap: 18px; padding: clamp(25px, 6vw, 42px) clamp(18px, 6vw, 46px) 26px; overflow-y: auto; text-align: left; background: #fff; }
.menu-copy { max-width: 480px; }
.eyebrow { justify-content: flex-start; color: #7674d8; margin-bottom: 8px; font-size: 10px; letter-spacing: .12em; }
.eyebrow > span { display: none; }
.logo-title { color: #2e2d49; font-size: clamp(42px, 11vw, 65px); line-height: .88; letter-spacing: -.07em; text-shadow: none; }
.logo-title br { display: none; }
.logo-title em { color: #797ae5; -webkit-text-stroke: 0; filter: none; }
.logo-title em::before { content: " "; }
.menu-desc { margin: 13px 0 20px; max-width: 420px; color: #77768e; font-size: 14px; line-height: 1.65; }

.mode-grid { gap: 10px; }
.mode-card { position: relative; min-height: 104px; align-items: flex-start; padding: 16px 13px; border: 2px solid #ecebf5; border-radius: 18px; background: #fafaff; color: #373650; text-align: left; box-shadow: none; }
.mode-card::before { display: grid; place-items: center; width: 30px; height: 30px; margin-bottom: 4px; border-radius: 9px; color: #fff; font-size: 16px; font-weight: 900; }
#playAiButton::before { content: "×"; background: #696be9; }
#play2pButton::before { content: "○"; background: #f17a99; }
.mode-card b { font-size: 14px; letter-spacing: 0; }
.mode-card small { color: #9492a8; font-size: 9px; line-height: 1.35; letter-spacing: .03em; }
.mode-card:hover { transform: translateY(-2px); border-color: #b4b4f4; box-shadow: 0 9px 18px rgba(99,99,215,.12); }
.mode-card.is-selected { border-color: #7778e9; background: #f4f4ff; box-shadow: 0 0 0 3px rgba(111,112,233,.12); }

.difficulty-group { align-items: flex-start; margin-top: 3px; gap: 8px; }
.group-label { color: #8b899d; font-size: 10px; letter-spacing: .1em; }
.difficulty-chips { width: 100%; gap: 7px; }
.difficulty-chip { flex: 1; padding: 10px 5px; border-color: #e7e6f0; background: #fff; color: #747286; font-size: 11px; letter-spacing: 0; }
.difficulty-chip.is-selected { border-color: #7778e9; color: #fff; background: #7778e9; box-shadow: 0 6px 12px rgba(105,107,233,.22); }
.toggle-row { max-width: none; padding: 12px 13px; border-color: #e9e8f1; border-radius: 15px; background: #fafaff; }
.toggle-title { color: #47465e; font-size: 13px; letter-spacing: 0; }
.toggle-sub { color: #9290a4; font-size: 10px; max-width: 275px; }
.switch .slider { background: #d8d7e5; }
.switch input:checked + .slider { background: #7778e9; }

.menu-side { max-width: 480px; }
.record-card { display: grid; grid-template-columns: repeat(5, 1fr); gap: 0; padding: 12px 8px 8px; border: 0; border-radius: 16px; background: #f6f5fc; box-shadow: none; }
.record-eyebrow { grid-column: 1 / -1; margin: 0 0 8px; color: #8b899d; font-size: 9px; letter-spacing: .12em; }
.record-row { flex-direction: column; align-items: center; gap: 2px; padding: 2px; border: 0; }
.record-row strong { color: #47465e; font-size: 20px; }
.record-row span { color: #9795a8; font-size: 8px; letter-spacing: .04em; text-align: center; }
.record-row.streak strong { color: #7778e9; }
.record-row.best strong { color: #d98b25; }
.menu-hint { display: none; }

.game-hud { padding: 14px; }
.game-hud .hud-button { width: 38px; height: 38px; border-radius: 12px; }
.hud-turn { color: #33324f; font-size: 17px; text-shadow: none; }
.hud-meta { color: #77768e; font-size: 9px; letter-spacing: .06em; }
.overlay { background: rgba(43,40,75,.36); backdrop-filter: blur(5px); }
.modal-card { border: 0; border-radius: 24px; background: #fff; box-shadow: 0 22px 50px rgba(44,40,83,.24); color: #34334f; }
.result-card .result-title { color: #5f62e9; }
.result-message, .help-rules { color: #77768e; }
.primary-button { border: 0; color: #fff; background: #686ae7; box-shadow: 0 9px 18px rgba(105,107,233,.25); }
.secondary-button { border-color: #e6e5ef; background: #f8f8fc; color: #55546b; }
.text-button { color: #87859a; }
.toast { border: 0; background: #34334f; color: #fff; box-shadow: 0 8px 20px rgba(43,40,75,.22); }
.footer-note { justify-content: center; color: #8d8b9f; font-size: 10px; text-align: center; }
.footer-note > span:first-child { display: none; }

@media (min-width: 700px) {
  body[data-state="menu"] .game-frame { min-height: 620px; }
  .menu-screen { padding: 48px 64px 32px; }
  .menu-copy, .menu-side { max-width: 500px; }
}

@media (max-width: 380px) {
  .game-shell { padding-inline: 9px; }
  .brand { font-size: 15px; }
  .logo-title { font-size: 40px; }
  .menu-screen { padding-inline: 15px; }
  .mode-card { min-height: 96px; padding: 12px 10px; }
  .toggle-sub { max-width: 210px; }
}

/* 手机上的首页先服务于“开始一局”，长期战绩留在较宽屏幕展示。 */
@media (max-width: 620px) {
  .menu-screen { gap: 15px; }
  .menu-desc { margin-bottom: 16px; }
  .mode-card { min-height: 97px; }
  .toggle-row { padding-block: 10px; }
  .toggle-sub { display: -webkit-box; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
  .menu-side { display: none; }
}
