:root {
  color-scheme: dark;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #eaf1f8;
  background: #0b1423;
  font-synthesis: none;
  --muted: #a6b6ca;
  --faint: #8295ad;
  --line: #2b3b51;
  --gold: #f4d68b;
  --mint: #a7e9d4;
}

* { box-sizing: border-box; }

[hidden] { display: none !important; }

body {
  min-width: 280px;
  margin: 0;
  background:
    radial-gradient(circle at 13% 8%, #c1dcf0 0 1px, transparent 1.5px) 0 0 / 311px 293px,
    radial-gradient(circle at 81% 27%, #839db4 0 .8px, transparent 1.3px) 0 0 / 239px 271px,
    radial-gradient(ellipse at 16% 14%, #1a35494d, transparent 48%),
    radial-gradient(ellipse at 88% 31%, #302c4840, transparent 45%),
    #0b1423;
  line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}

button, input { font: inherit; }
button { color: inherit; cursor: pointer; touch-action: manipulation; }
a { color: inherit; text-decoration: none; }
button, a, input { -webkit-tap-highlight-color: #a7e9d430; }

:is(button, a, input):focus-visible {
  outline: 3px solid var(--mint);
  outline-offset: 4px;
}

button:disabled { cursor: default; opacity: .42; }

.topbar, .shell, footer {
  width: min(1120px, calc(100% - 64px));
  margin-inline: auto;
}

.topbar {
  min-height: 100px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid #a6b6ca1a;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  padding-block: 10px;
  font-size: 19px;
  font-weight: 650;
  letter-spacing: .1em;
}

.brand-symbol { color: var(--gold); font-size: 28px; line-height: 1; }
.home-link { padding-block: 12px; color: var(--muted); font-size: 13px; }
.home-link span { margin-left: 7px; color: var(--gold); }
.home-link:hover, .home-return a:hover, footer a:hover { color: var(--gold); }

.intro {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  align-items: end;
  gap: 48px;
  padding-block: 47px 36px;
}

.eyebrow {
  display: block;
  margin: 0 0 12px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .14em;
}

h1 { margin: 0; font-size: clamp(30px, 3.3vw, 42px); font-weight: 620; line-height: 1.38; letter-spacing: -.03em; }
h1 em { color: var(--gold); font-style: normal; }
.intro-copy { max-width: 560px; margin: 17px 0 0; color: var(--muted); font-size: 14px; line-height: 1.85; }

.daily-card {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 18px 16px;
  border: 1px solid #6f8b9d36;
  border-radius: 14px;
  background: #142536b3;
}

.daily-mark { flex: 0 0 auto; color: var(--mint); font-size: 31px; line-height: 1; }
.daily-card > div { flex: 1; min-width: 0; }
.daily-card strong { display: block; font-size: 12px; font-weight: 600; overflow-wrap: anywhere; }
.daily-card small { display: block; margin-top: 5px; color: var(--muted); font-size: 11px; }
.link-button { flex: 0 0 auto; min-height: 44px; padding: 0 5px; border: 0; background: transparent; color: var(--mint); font-size: 12px; text-decoration: underline; text-underline-offset: 4px; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 340px; gap: 24px; align-items: start; }
.board-panel, .control-panel { min-width: 0; border: 1px solid #61788e45; border-radius: 22px; background: #111e30f2; box-shadow: 0 18px 54px #030a162e; }
.board-panel { padding: 26px; }
.board-heading { display: flex; align-items: start; justify-content: space-between; gap: 15px; margin-bottom: 23px; }
.board-heading .eyebrow { margin-bottom: 8px; }
.source-label { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.75; }
.status-pill { flex: 0 0 auto; margin-top: 1px; padding: 5px 10px; border: 1px solid #61788e70; border-radius: 999px; color: #c8d7e6; font-size: 10px; white-space: nowrap; }
.status-pill.complete { border-color: #a7e9d46b; background: #a7e9d412; color: var(--mint); }
.status-pill.complete::before { content: "✓ "; }
.board-wrap { padding: 9px; border: 1px solid #3a526667; border-radius: 16px; background: #081422; box-shadow: inset 0 0 35px #030a1638; }
.board { --grid-size: 4; --tile-gap: 7px; display: grid; grid-template-rows: repeat(var(--grid-size), minmax(0, 1fr)); gap: var(--tile-gap); width: 100%; aspect-ratio: 1; }
.board-row { display: grid; grid-template-columns: repeat(var(--grid-size), minmax(0, 1fr)); gap: var(--tile-gap); min-height: 0; }
.board-row > [role="gridcell"] { min-width: 0; min-height: 0; }

.tile {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 1px solid #354a60;
  border-radius: 10px;
  background: linear-gradient(145deg, #1b2b3e, #162538);
  box-shadow: inset 0 1px 0 #a8c1d20b;
  transition: border-color 140ms ease, background-color 140ms ease, box-shadow 140ms ease;
}

.tile svg { display: block; width: 100%; height: 100%; overflow: visible; pointer-events: none; }
.wires { fill: none; stroke: #8fa7bf; stroke-width: 7; stroke-linecap: round; stroke-linejoin: round; }
.hub { fill: #192a3d; stroke: #9eb2c8; stroke-width: 3; }
.tile[data-lit="true"] { border-color: #a68e59; background: linear-gradient(145deg, #344038, #26362f); box-shadow: inset 0 0 20px #f4d68b09; }
.tile[data-lit="true"] .wires { stroke: #f9dda0; }
.tile[data-lit="true"] .hub { fill: #fff0bd; stroke: #fff0bd; }
.tile-state { position: absolute; bottom: 5px; left: 7px; color: #a8bbce; font-size: 13px; line-height: 1; pointer-events: none; }
.tile[data-lit="true"] .tile-state { color: #fff0bd; font-size: 10px; font-weight: 650; }
.tile-source { position: absolute; top: 5px; right: 6px; color: var(--gold); font-size: 18px; line-height: 1; pointer-events: none; }
.tile[data-source="true"] { border: 2px solid var(--gold); }
.tile[data-source="true"] .tile-source { filter: drop-shadow(0 0 5px #f4d68b60); }
.tile:focus-visible { z-index: 1; outline-color: #c5ffee; outline-offset: 2px; box-shadow: 0 0 0 5px #081422; }
.tile:disabled { opacity: 1; }
.board-fallback { margin: 30px 12px; text-align: center; color: var(--muted); font-size: 14px; }

.stats { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); margin-top: 23px; padding-block: 1px; }
.stats > div { display: flex; flex-direction: column; align-items: center; gap: 3px; border-right: 1px solid var(--line); }
.stats > div:last-child { border-right: 0; }
.stats strong { color: #edf3f9; font-size: 25px; font-weight: 550; font-variant-numeric: tabular-nums; line-height: 1.4; }
.stats > div:first-child strong { color: var(--gold); }
.stats span { color: var(--muted); font-size: 11px; }
.persistence-note { margin: 20px 0 0; padding-top: 15px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; line-height: 1.8; overflow-wrap: anywhere; }

.control-panel { padding: 26px 24px; }
.panel-heading .eyebrow { margin-bottom: 9px; }
h2 { margin: 0; font-size: 20px; font-weight: 550; letter-spacing: -.02em; }
.instruction { display: flex; align-items: start; gap: 10px; margin: 19px 0 25px; color: var(--muted); font-size: 12px; line-height: 1.85; }
.instruction-icon { flex: 0 0 auto; margin-top: 1px; color: var(--gold); font-size: 24px; line-height: 1.2; }
.control-stack { display: grid; gap: 10px; }
.button { min-height: 46px; padding: 11px 10px; border: 1px solid #43526a; border-radius: 9px; background: #1b2a3e; font-size: 12px; font-weight: 550; line-height: 1.6; transition: background-color 140ms ease, border-color 140ms ease; }
.hint-button { border-color: var(--gold); background: var(--gold); color: #22303b; font-size: 14px; }
.hint-button > span { margin-right: 5px; }
.control-note { margin: 0 0 9px; color: var(--faint); font-size: 11px; line-height: 1.85; }
.paired-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.difficulty { margin-top: 27px; padding-top: 23px; border-top: 1px solid var(--line); }
.difficulty .eyebrow { margin-bottom: 11px; }
.size-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 4px; gap: 5px; border: 1px solid #35465e; border-radius: 11px; background: #0b1728; }
.size-options button { min-height: 42px; padding: 8px; border: 1px solid transparent; border-radius: 7px; background: transparent; color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.size-options button[aria-pressed="true"] { border-color: #789e9759; background: #29403f; color: #c8f1e7; font-weight: 650; }
.size-options button[aria-pressed="true"]::before { content: "✓ "; }
.privacy-note { display: flex; align-items: start; gap: 10px; margin-top: 23px; color: var(--faint); }
.privacy-note > span { font-size: 20px; line-height: 1.6; }
.privacy-note p { margin: 0; font-size: 11px; line-height: 1.85; }
.share-fallback { margin-top: 18px; padding: 12px; border: 1px solid #577b7c; border-radius: 10px; background: #102c32; }
.share-fallback label { display: block; margin-bottom: 8px; color: #c4e2dc; font-size: 11px; }
.share-fallback > div { display: flex; gap: 7px; }
.share-fallback input { min-width: 0; width: 100%; min-height: 44px; padding: 8px; border: 1px solid #5c7c86; border-radius: 6px; background: #091c29; color: #e2f4ef; font-size: 12px; }
.copy-button { flex: 0 0 auto; min-height: 44px; padding: 8px 10px; border: 1px solid #6e9890; border-radius: 6px; background: #284844; color: #d6f7ee; font-size: 12px; }

.completion-area { display: flex; align-items: start; justify-content: space-between; gap: 24px; margin-top: 23px; }
.message-line { margin: 0; padding-block: 10px; color: var(--muted); font-size: 12px; }
.text-button { flex: 0 0 auto; min-height: 44px; padding: 10px 0; border: 0; background: transparent; color: var(--muted); font-size: 11px; text-decoration: underline; text-underline-offset: 4px; }
.home-return { margin: 18px 0 46px; text-align: center; }
.home-return a { display: inline-block; padding-block: 12px; color: #b8c9d8; font-size: 12px; }
footer { display: flex; justify-content: space-between; gap: 24px; padding-block: 23px 29px; border-top: 1px solid #a6b6ca1a; color: var(--faint); font-size: 10px; }
footer a { padding: 4px 0; }
.toast { position: fixed; z-index: 10; bottom: max(24px, env(safe-area-inset-bottom)); left: 50%; width: max-content; max-width: min(520px, calc(100% - 32px)); padding: 14px 20px; border: 1px solid #7ba699; border-radius: 12px; background: #1d3837; box-shadow: 0 10px 35px #0006; color: #ecfff7; font-size: 13px; line-height: 1.75; text-align: center; opacity: 0; transform: translate(-50%, 10px); pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; }
.toast.visible { opacity: 1; transform: translate(-50%, 0); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }

@media (hover: hover) {
  .tile:not(:disabled):hover { border-color: #b9d2df; background: #26384c; }
  .tile[data-lit="true"]:not(:disabled):hover { border-color: #ffe8ae; background: #3a483c; }
  .button.secondary:not(:disabled):hover { border-color: #718da3; background: #25374c; }
  .hint-button:not(:disabled):hover { border-color: #ffeab5; background: #ffe5a9; }
  .size-options button:not([aria-pressed="true"]):hover { background: #1a2d3d; color: #e1eaf4; }
  .link-button:hover, .text-button:hover { color: #d1f5ea; }
  .copy-button:hover { background: #355952; }
}

@media (max-width: 960px) {
  .topbar, .shell, footer { width: min(720px, calc(100% - 48px)); }
  .topbar { min-height: 84px; }
  .intro { grid-template-columns: 1fr; gap: 24px; padding-block: 34px 27px; }
  .daily-card { max-width: 100%; padding: 13px 16px; }
  .daily-card strong { font-size: 13px; }
  .game-layout { grid-template-columns: minmax(0, 1fr) 280px; gap: 18px; }
  .board-panel { padding: 18px; }
  .board-heading { flex-direction: column; gap: 10px; margin-bottom: 17px; }
  .board-heading .status-pill { align-self: start; }
  .board-wrap { padding: 5px; border-radius: 12px; }
  .board { --tile-gap: 4px; }
  .tile { border-radius: 7px; }
  .tile-source { font-size: 15px; top: 3px; right: 4px; }
  .tile-state { bottom: 4px; left: 5px; }
  .control-panel { padding: 22px 18px; }
  .stats strong { font-size: 22px; }
}

@media (max-width: 740px) {
  .topbar, .shell, footer { width: min(540px, calc(100% - 32px)); }
  .topbar { min-height: 75px; gap: 16px; }
  .brand { font-size: 16px; gap: 8px; }
  .brand-symbol { font-size: 25px; }
  .home-link { font-size: 11px; }
  .intro { padding-top: 28px; gap: 23px; }
  h1 { font-size: clamp(28px, 7.4vw, 38px); }
  .intro .eyebrow { margin-bottom: 10px; font-size: 10px; }
  .intro-copy { margin-top: 13px; font-size: 13px; line-height: 1.85; }
  .daily-card { gap: 10px; padding: 12px; border-radius: 12px; }
  .daily-card strong { font-size: 12px; }
  .daily-mark { font-size: 27px; }
  .game-layout { grid-template-columns: minmax(0, 1fr); gap: 18px; }
  .board-panel { padding: 18px; border-radius: 18px; }
  .board-heading { flex-direction: row; gap: 10px; margin-bottom: 17px; }
  .source-label { max-width: 270px; font-size: 10px; }
  .status-pill { padding: 4px 8px; font-size: 10px; }
  .board-wrap { padding: 5px; }
  .board { --tile-gap: 5px; }
  .tile { border-radius: 8px; }
  .tile-source { top: 4px; right: 5px; font-size: 16px; }
  .tile-state { bottom: 5px; left: 6px; }
  .stats { margin-top: 20px; }
  .stats strong { font-size: 24px; }
  .persistence-note { margin-top: 17px; }
  .control-panel { padding: 23px; border-radius: 18px; }
  .instruction { margin-bottom: 20px; }
  .button { min-height: 48px; font-size: 13px; }
  .hint-button { font-size: 14px; }
  .control-note { margin-bottom: 6px; }
  .difficulty { margin-top: 23px; padding-top: 20px; }
  .privacy-note { margin-top: 18px; }
  .completion-area { margin-top: 14px; gap: 18px; }
  .message-line { font-size: 11px; }
  .text-button { font-size: 10px; }
  .home-return { margin-block: 15px 32px; }
  .home-return a { font-size: 11px; }
  footer { gap: 12px; padding-block: 19px 23px; }
}

@media (max-width: 380px) {
  .board-panel { padding: 14px; }
  .board-heading { gap: 8px; }
  .source-label { max-width: 195px; }
  .board-wrap { padding: 4px; }
  .board { --tile-gap: 4px; }
  .tile { border-radius: 6px; }
  .tile-source { top: 3px; right: 3px; font-size: 14px; }
  .tile-state { bottom: 3px; left: 4px; }
  .tile[data-lit="true"] .tile-state { font-size: 9px; }
  .control-panel { padding: 20px; }
  .paired-actions { gap: 8px; }
  .button { font-size: 12px; }
  .hint-button { font-size: 14px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}
