:root {
  color-scheme: dark;
  --ink: #e9e3d5;
  --muted: #9b9a9f;
  --void: #0d0e15;
  --panel: #171821;
  --panel-2: #1d1e28;
  --line: #343440;
  --gold: #d3a64d;
  --gold-soft: #f0d38a;
  --moss: #78a28b;
  --danger: #b85e68;
  --cell: clamp(38px, 11.1vw, 62px);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--void); }
body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 50% -10%, rgba(102, 121, 103, .14), transparent 42%),
    linear-gradient(180deg, #14151e 0, #0d0e15 72%);
  overflow-x: hidden;
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: .22;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='80' height='80' viewBox='0 0 80 80'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.7' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.18'/%3E%3C/svg%3E");
}
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; }
.ambient { position: fixed; top: 240px; left: 50%; width: 580px; height: 580px; transform: translateX(-50%); background: radial-gradient(circle, rgba(211,166,77,.065), transparent 66%); pointer-events: none; }
.topbar { height: 72px; border-bottom: 1px solid rgba(255,255,255,.07); display: flex; align-items: center; justify-content: space-between; padding: 0 max(22px, calc((100vw - 1080px)/2)); position: relative; z-index: 2; }
.brand { color: var(--ink); text-decoration: none; font-weight: 800; letter-spacing: .17em; font-size: 13px; display: flex; align-items: center; gap: 12px; }
.brand-mark { width: 27px; height: 27px; transform: rotate(45deg); border: 1px solid var(--gold); display: grid; grid-template-columns: 1fr 1fr; padding: 5px; gap: 3px; }
.brand-mark i { display: block; background: var(--gold); opacity: .7; }
.header-actions { display: flex; gap: 8px; }
.icon-button { width: 34px; height: 34px; border: 1px solid var(--line); border-radius: 50%; background: transparent; color: var(--muted); cursor: pointer; }
.icon-button:hover, .icon-button:focus-visible { color: var(--gold-soft); border-color: var(--gold); }
.language-button { width: 48px; border-radius: 17px; font-size: 11px; color: var(--gold-soft); }
.modal-language { position: absolute; top: 12px; left: 15px; background: none; border: 0; color: var(--gold-soft); font-size: 12px; padding: 6px; cursor: pointer; }
html[lang="zh-CN"] h1 { font-size: clamp(34px, 6vw, 52px); line-height: 1.25; }
html[lang="zh-CN"] .intro-copy { line-height: 1.8; }
html[lang="zh-CN"] .eyebrow { letter-spacing: .12em; }
@media (max-width: 390px) { .brand { gap: 8px; font-size: 11px; letter-spacing: .12em; } .header-actions { gap: 5px; } }
main { width: min(100% - 28px, 900px); margin: 0 auto; position: relative; z-index: 1; }
.intro { display: grid; grid-template-columns: 1.1fr .9fr; align-items: end; gap: 48px; padding: 54px 0 34px; }
.eyebrow { margin: 0 0 12px; color: var(--gold); font-size: 10px; font-weight: 800; letter-spacing: .22em; }
h1, h2 { font-family: Georgia, "Times New Roman", serif; font-weight: 400; }
h1 { font-size: clamp(38px, 6vw, 58px); line-height: .98; margin: 0; letter-spacing: -.025em; }
h1 em { color: var(--gold-soft); font-weight: 400; }
.intro-copy { color: var(--muted); font-family: Georgia, serif; font-size: 16px; line-height: 1.65; max-width: 340px; margin: 0 0 4px; }
.game-shell { border: 1px solid var(--line); background: rgba(21,22,31,.82); box-shadow: 0 30px 100px rgba(0,0,0,.3); }
.statusbar { min-height: 68px; display: grid; grid-template-columns: 1fr 2fr 1fr; align-items: center; border-bottom: 1px solid var(--line); padding: 0 24px; }
.stat { display: flex; flex-direction: column; gap: 4px; }
.stat-right { align-items: flex-end; }
.stat-label { color: #717178; font-size: 9px; letter-spacing: .19em; font-weight: 800; }
.stat strong { color: var(--danger); font-size: 15px; letter-spacing: .14em; }
.stat-right strong { color: var(--gold-soft); letter-spacing: 0; font-size: 20px; }
.stat strong small { color: #717178; font-size: 11px; }
.status-center { color: var(--muted); text-align: center; font-family: Georgia, serif; font-size: 13px; font-style: italic; }
.board-wrap { padding: 38px 16px 26px; position: relative; display: flex; flex-direction: column; align-items: center; }
.board { display: grid; grid-template-columns: repeat(7, var(--cell)); grid-template-rows: repeat(7, var(--cell)); border: 1px solid #44444f; box-shadow: 0 0 0 8px #11121a, 0 0 0 9px #292a34; background: #101118; }
.tile { position: relative; border: 0; border-right: 1px solid #33343d; border-bottom: 1px solid #33343d; background: linear-gradient(145deg, #24252f, #1a1b24); color: #b5b3ad; padding: 0; cursor: pointer; display: grid; place-items: center; font-family: Georgia, serif; font-weight: 700; font-size: clamp(16px, 5vw, 24px); user-select: none; touch-action: manipulation; transition: background .18s, transform .12s, color .18s; }
.tile::before { content: ""; position: absolute; inset: 6px; border: 1px solid rgba(255,255,255,.025); }
.tile:nth-child(7n) { border-right: 0; }
.tile:nth-last-child(-n+7) { border-bottom: 0; }
.tile:not(.revealed):hover, .tile:not(.revealed):focus-visible { background: #2e2f3a; outline: 1px solid var(--gold); z-index: 2; }
.tile.revealed { cursor: default; background: #13141c; color: #8e8d92; }
.tile.revealed::before { border-color: transparent; }
.tile.n1 { color: #8bb5a4; } .tile.n2 { color: #d4bc7e; } .tile.n3 { color: #d78373; } .tile.n4, .tile.n5 { color: #bd7aa0; }
.tile.flagged { color: var(--gold-soft); background: #24221f; }
.tile.flagged::after { content: "◇"; font-size: 27px; text-shadow: 0 0 14px rgba(211,166,77,.4); }
.tile.hazard.revealed { background: rgba(122,44,54,.3); color: #e7959e; }
.tile.hazard.revealed::after { content: "✹"; font-size: 26px; }
.tile.entrance::after { content: "⌂"; font-size: 18px; color: var(--moss); }
.tile.gate:not(.revealed)::after { content: "✦"; color: #6d6250; font-size: 18px; }
.tile.gate.revealed { color: var(--gold-soft); background: radial-gradient(circle, rgba(211,166,77,.3), #17171d 65%); }
.tile.gate.revealed::after { content: "✦"; font-size: 27px; animation: glow 1.5s ease-in-out infinite alternate; }
.tile.blocked { opacity: .56; cursor: not-allowed; }
.tile.just-revealed { animation: reveal .25s ease-out; }
@keyframes reveal { from { transform: scale(.82); opacity: .3; } }
@keyframes glow { to { text-shadow: 0 0 20px var(--gold); transform: scale(1.08); } }
.corner { position: absolute; width: 21px; height: 21px; border-color: var(--gold); opacity: .7; }
.corner-a { top: 23px; left: max(12px, calc(50% - 7 * var(--cell)/2 - 24px)); border-left: 1px solid; border-top: 1px solid; }
.corner-b { bottom: 48px; right: max(12px, calc(50% - 7 * var(--cell)/2 - 24px)); border-right: 1px solid; border-bottom: 1px solid; }
.mode-hint { margin-top: 24px; font-size: 11px; color: #74747c; }
.controls { min-height: 76px; border-top: 1px solid var(--line); padding: 14px 20px; display: flex; align-items: center; justify-content: space-between; }
.mode-switch { background: #0f1017; border: 1px solid #2e2f39; padding: 3px; display: flex; }
.mode-button { min-width: 112px; border: 0; color: #73737b; background: transparent; padding: 10px 16px; cursor: pointer; font-size: 11px; text-transform: uppercase; letter-spacing: .08em; font-weight: 800; }
.mode-button span { margin-right: 7px; }
.mode-button.active { background: #28272a; color: var(--gold-soft); box-shadow: inset 0 0 0 1px #49433b; }
.reset-button { border: 0; background: none; color: #74747c; text-decoration: underline; text-underline-offset: 4px; font-size: 11px; cursor: pointer; }
.below-game { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; padding: 18px 0 58px; }
.truth-card, .mode-card { border: 1px solid var(--line); min-height: 112px; background: rgba(23,24,33,.6); padding: 20px; display: flex; align-items: center; gap: 16px; }
.truth-icon { color: var(--moss); font-size: 30px; }
.truth-card strong, .mode-card strong { font-family: Georgia, serif; font-size: 15px; font-weight: 400; }
.truth-card p, .mode-card p { margin: 6px 0 0; color: #76767e; font-size: 11px; line-height: 1.5; }
.mode-card { justify-content: space-between; }
.mode-kicker { display: block; color: var(--gold); font-size: 8px; letter-spacing: .17em; margin-bottom: 4px; font-weight: 800; }
.mode-card button { flex: 0 0 auto; border: 0; background: none; color: var(--gold-soft); font-size: 11px; cursor: pointer; }
footer { border-top: 1px solid rgba(255,255,255,.06); width: min(100% - 44px, 1080px); margin: 0 auto; min-height: 70px; display: flex; justify-content: space-between; align-items: center; color: #56565e; font-family: Georgia, serif; font-style: italic; font-size: 11px; }
footer button { border: 0; background: none; color: #686870; cursor: pointer; }
.modal { width: min(92vw, 520px); color: var(--ink); background: #191a23; border: 1px solid #48464a; padding: 38px; box-shadow: 0 30px 100px #000; text-align: center; }
.modal::backdrop { background: rgba(7,8,12,.82); backdrop-filter: blur(7px); }
.modal-close { position: absolute; top: 12px; right: 15px; border: 0; background: none; color: #777780; font-size: 24px; cursor: pointer; }
.modal h2 { font-size: 34px; margin: 5px 0 23px; color: var(--gold-soft); }
.sigil, .result-burst { color: var(--gold); font-size: 34px; margin-bottom: 16px; }
.lesson-grid { display: grid; gap: 11px; text-align: left; }
.lesson { display: grid; grid-template-columns: 54px 1fr; align-items: center; gap: 15px; border: 1px solid #30313a; padding: 10px; }
.lesson p { color: #85858d; line-height: 1.45; font-size: 12px; margin: 0; }
.lesson strong { color: var(--ink); }
.demo-tile { width: 46px; height: 46px; background: #11121a; display: grid; place-items: center; color: var(--gold-soft); font: bold 21px Georgia, serif; border: 1px solid #363740; }
.demo-ward { color: var(--gold); font-size: 27px; }
.demo-gate { color: var(--gold-soft); }
.kind-note { color: #74747c; font-family: Georgia, serif; font-style: italic; font-size: 12px; line-height: 1.5; }
.primary-button, .secondary-button { border: 1px solid var(--gold); background: var(--gold); color: #17140e; padding: 13px 24px; font-size: 11px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; cursor: pointer; }
.primary-button { width: 100%; margin-top: 10px; }
.secondary-button { background: transparent; color: var(--gold-soft); }
.result-modal { width: min(92vw, 470px); }
.result-modal h2 { margin-bottom: 8px; }
.result-modal > p:not(.eyebrow) { color: var(--muted); font-family: Georgia, serif; }
.result-stats { display: grid; grid-template-columns: repeat(3,1fr); border: 1px solid var(--line); margin: 24px 0 14px; }
.result-stats div { padding: 13px 5px; border-right: 1px solid var(--line); }
.result-stats div:last-child { border: 0; }
.result-stats span { display: block; color: #707078; font-size: 8px; letter-spacing: .17em; margin-bottom: 4px; }
.result-stats strong { color: var(--gold-soft); font-family: Georgia, serif; font-size: 19px; }
.share-card { white-space: pre-wrap; color: #aaa8a1; background: #101118; padding: 14px; text-align: left; border: 1px solid #2f3039; font-size: 12px; line-height: 1.5; }
.result-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.result-actions button { width: auto; margin-top: 0; }
.text-modal { text-align: left; }
.text-modal ol { color: #9998a0; padding-left: 20px; line-height: 1.55; font-size: 13px; }
.text-modal li { margin-bottom: 12px; }
.text-modal strong { color: var(--ink); }
.text-modal > p:not(.eyebrow) { color: #9998a0; line-height: 1.6; font-size: 13px; }
.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; background: var(--gold-soft); color: #17140e; padding: 10px 16px; font-size: 11px; font-weight: 800; transition: .2s; z-index: 10; }
.toast.show { opacity: 1; transform: translate(-50%,0); }

@media (max-width: 650px) {
  .topbar { height: 62px; padding: 0 17px; }
  main { width: min(100% - 18px, 520px); }
  .intro { grid-template-columns: 1fr; gap: 14px; padding: 32px 8px 25px; }
  h1 { font-size: 40px; }
  .intro-copy { font-size: 14px; max-width: none; }
  .statusbar { min-height: 62px; padding: 0 13px; grid-template-columns: 1fr 1.5fr 1fr; }
  .status-center { font-size: 10px; }
  .board-wrap { padding: 31px 5px 22px; }
  .controls { padding: 12px 10px; }
  .mode-button { min-width: 94px; padding: 10px 8px; font-size: 9px; }
  .below-game { grid-template-columns: 1fr; padding-bottom: 36px; }
  .modal { padding: 32px 20px 24px; }
  .modal h2 { font-size: 29px; }
  .result-actions { grid-template-columns: 1fr; }
}

@media (max-width: 390px) {
  :root { --cell: calc((100vw - 42px)/7); }
  .status-center { display: none; }
  .statusbar { grid-template-columns: 1fr 1fr; }
  .controls { flex-direction: column; gap: 12px; }
  .mode-switch { width: 100%; }
  .mode-button { flex: 1; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
