:root {
  color-scheme: dark;
  --bg: #050a14;
  --bg-2: #091426;
  --panel: rgba(11, 24, 43, .72);
  --panel-strong: rgba(14, 31, 54, .94);
  --line: rgba(145, 197, 255, .13);
  --line-strong: rgba(139, 211, 255, .44);
  --text: #eff8ff;
  --muted: #8ea9bf;
  --cyan: #47e6ff;
  --blue: #4f7cff;
  --purple: #a86cff;
  --green: #61ffbc;
  --danger: #ff6b8b;
  --board: rgba(6, 15, 29, .78);
  --cell: rgba(255,255,255,.025);
  --cell-hover: rgba(71,230,255,.08);
  --cell-peer: rgba(79,124,255,.075);
  --cell-same: rgba(71,230,255,.11);
  --cell-selected: rgba(71,230,255,.21);
  --given: #e9f6ff;
  --entry: #54ddff;
  --shadow: 0 26px 70px rgba(0,0,0,.42);
  --radius: 24px;
}

[data-theme="light"] {
  color-scheme: light;
  --bg: #edf5fb;
  --bg-2: #dcecf8;
  --panel: rgba(255,255,255,.72);
  --panel-strong: rgba(255,255,255,.94);
  --line: rgba(13, 65, 101, .12);
  --line-strong: rgba(18, 121, 174, .38);
  --text: #10243a;
  --muted: #557189;
  --cyan: #00a9d6;
  --blue: #4169e1;
  --purple: #7b4ce3;
  --green: #0cad78;
  --danger: #e54365;
  --board: rgba(255,255,255,.84);
  --cell: rgba(7,39,70,.025);
  --cell-hover: rgba(0,169,214,.08);
  --cell-peer: rgba(65,105,225,.07);
  --cell-same: rgba(0,169,214,.10);
  --cell-selected: rgba(0,169,214,.16);
  --given: #132d46;
  --entry: #007fa7;
  --shadow: 0 26px 70px rgba(38,77,110,.16);
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 50% -20%, rgba(79,124,255,.18), transparent 34%),
    linear-gradient(150deg, var(--bg), var(--bg-2));
  overflow-x: hidden;
}
button, select { font: inherit; }
button { color: inherit; }
button:focus-visible, select:focus-visible { outline: 2px solid var(--cyan); outline-offset: 3px; }

.ambient { position: fixed; width: 42vw; height: 42vw; border-radius: 50%; filter: blur(95px); opacity: .16; pointer-events: none; }
.ambient-a { background: var(--blue); left: -18vw; top: 22vh; }
.ambient-b { background: var(--purple); right: -20vw; top: 42vh; }
.grid-noise {
  position: fixed; inset: 0; pointer-events: none; opacity: .16;
  background-image: linear-gradient(rgba(255,255,255,.018) 1px, transparent 1px), linear-gradient(90deg, rgba(255,255,255,.018) 1px, transparent 1px);
  background-size: 32px 32px;
  mask-image: linear-gradient(to bottom, black, transparent 75%);
}

.app-shell { width: min(1440px, calc(100% - 36px)); margin: 0 auto; padding: 20px 0 28px; position: relative; z-index: 1; }
.glass { background: var(--panel); border: 1px solid var(--line); box-shadow: var(--shadow); backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px); }
.topbar { min-height: 72px; border-radius: 20px; padding: 12px 18px; display: flex; align-items: center; justify-content: space-between; }
.brand { display: inline-flex; align-items: center; gap: 12px; color: inherit; text-decoration: none; }
.brand-mark { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 13px; color: #00141c; font-weight: 1000; font-size: 24px; background: linear-gradient(145deg, var(--cyan), #8cffed); box-shadow: 0 0 26px rgba(71,230,255,.28); }
.brand-copy { display: grid; gap: 2px; }
.brand-copy strong { letter-spacing: .13em; font-size: 15px; }
.brand-copy small { color: var(--muted); font-size: 10px; letter-spacing: .11em; }
.top-actions { display: flex; gap: 8px; }
.icon-btn { width: 42px; height: 42px; border: 1px solid var(--line); background: rgba(255,255,255,.035); border-radius: 12px; cursor: pointer; transition: .2s ease; font-weight: 800; }
.icon-btn:hover { border-color: var(--line-strong); transform: translateY(-1px); background: rgba(71,230,255,.08); }

.hero-row { padding: 34px 8px 24px; display: flex; justify-content: space-between; align-items: end; gap: 24px; }
.eyebrow { color: var(--cyan); letter-spacing: .22em; font-size: 11px; font-weight: 900; margin-bottom: 10px; }
h1 { margin: 0; font-size: clamp(26px, 4vw, 49px); letter-spacing: -.04em; line-height: 1.08; }
h1 span { color: var(--cyan); text-shadow: 0 0 22px rgba(71,230,255,.24); }
.hero-row p { color: var(--muted); margin: 10px 0 0; font-size: 14px; }
.level-chip { min-width: 120px; padding: 10px 16px; border-left: 2px solid var(--cyan); text-align: right; }
.level-chip span { display:block; color: var(--muted); font-size: 10px; letter-spacing: .18em; }
.level-chip strong { font-size: 25px; letter-spacing: .08em; }

.game-layout { display: grid; grid-template-columns: minmax(210px, 250px) minmax(500px, 680px) minmax(210px, 250px); gap: 18px; justify-content: center; align-items: start; }
.panel, .board-panel { border-radius: var(--radius); }
.panel { padding: 20px; }
.board-panel { padding: 18px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; font-size: 12px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.panel-title b { width: 7px; height: 7px; border-radius: 50%; background: var(--green); box-shadow: 0 0 10px var(--green); }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin: 18px 0; }
.stat { border: 1px solid var(--line); border-radius: 14px; padding: 12px; background: rgba(255,255,255,.025); }
.stat small, .field-label, .mission-card small, .best-card small { display: block; color: var(--muted); font-size: 10px; margin-bottom: 5px; }
.stat strong { font-size: 16px; }
.field-label { margin: 12px 0 7px; }
.select-wrap select { width: 100%; border: 1px solid var(--line); background: var(--panel-strong); color: var(--text); border-radius: 13px; padding: 11px 12px; cursor: pointer; }
.side-actions { display: grid; gap: 8px; margin-top: 15px; }
.primary-btn, .secondary-btn { min-height: 44px; border-radius: 13px; border: 0; cursor: pointer; font-weight: 900; transition: .2s ease; }
.primary-btn { color: #00131b; background: linear-gradient(135deg, var(--cyan), #7fffc8); box-shadow: 0 9px 24px rgba(71,230,255,.18); }
.secondary-btn { background: rgba(255,255,255,.04); color: var(--text); border: 1px solid var(--line); }
.primary-btn:hover, .secondary-btn:hover { transform: translateY(-1px); filter: brightness(1.06); }
.streak-card { display:flex; justify-content:space-between; align-items:center; margin-top: 15px; border-radius: 15px; padding: 13px; background: linear-gradient(135deg, rgba(168,108,255,.12), rgba(71,230,255,.07)); border: 1px solid var(--line); }
.streak-card small { display:block; color:var(--muted); font-size:10px; }
.streak-card strong { font-size: 17px; }
.flame { color: #ffd35a; font-size: 23px; filter: drop-shadow(0 0 8px rgba(255,211,90,.45)); }
.mini-note { color: var(--muted); font-size: 10px; line-height: 1.6; margin-top: 14px; }

.board-toolbar { display:flex; justify-content:space-between; align-items:center; margin-bottom: 14px; }
.puzzle-id { color: var(--muted); font-size: 10px; letter-spacing: .12em; }
.puzzle-id span { color: var(--cyan); font-weight: 900; }
.pause-btn { border: 1px solid var(--line); background: rgba(255,255,255,.03); border-radius: 10px; padding: 7px 10px; cursor:pointer; font-size: 11px; }
.board-wrap { position:relative; width: min(100%, 590px); margin: 0 auto; }
.sudoku-board {
  width: 100%; aspect-ratio: 1; display:grid; grid-template-columns: repeat(9,1fr); grid-template-rows: repeat(9,1fr);
  border: 2px solid var(--line-strong); border-radius: 16px; overflow:hidden; background: var(--board); box-shadow: inset 0 0 38px rgba(71,230,255,.025), 0 10px 44px rgba(0,0,0,.19);
}
.cell { position:relative; border: 0; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: var(--cell); display:grid; place-items:center; cursor:pointer; user-select:none; -webkit-tap-highlight-color: transparent; transition: background .12s ease, box-shadow .12s ease, transform .12s ease; font-weight: 820; font-size: clamp(19px, 3.15vw, 33px); color: var(--entry); }
.cell:nth-child(9n) { border-right:0; }
.cell:nth-last-child(-n+9) { border-bottom:0; }
.cell.box-right { border-right: 2px solid var(--line-strong); }
.cell.box-bottom { border-bottom: 2px solid var(--line-strong); }
.cell:hover { background: var(--cell-hover); }
.cell.given { color: var(--given); font-weight: 950; cursor: default; }
.cell.peer { background: var(--cell-peer); }
.cell.same { background: var(--cell-same); color: var(--cyan); text-shadow: 0 0 13px rgba(71,230,255,.25); }
.cell.selected { background: var(--cell-selected); box-shadow: inset 0 0 0 2px var(--cyan), inset 0 0 22px rgba(71,230,255,.10); z-index: 2; }
.cell.error { color: var(--danger); animation: shake .25s ease; }
.cell.hinted { animation: hintPulse .65s ease; }
.notes { position:absolute; inset: 4px; display:grid; grid-template-columns:repeat(3,1fr); grid-template-rows:repeat(3,1fr); font-size: clamp(6px, 1.05vw, 10px); line-height:1; color: var(--muted); font-weight:700; }
.notes i { font-style:normal; display:grid; place-items:center; }
.pause-overlay { position:absolute; inset:0; border-radius:16px; z-index:10; display:flex; flex-direction:column; align-items:center; justify-content:center; text-align:center; gap:9px; background: color-mix(in srgb, var(--panel-strong) 94%, transparent); backdrop-filter: blur(16px); }
.pause-overlay[hidden] { display:none; }
.pause-symbol { width:58px; height:58px; display:grid; place-items:center; border-radius:50%; color:var(--cyan); border:1px solid var(--line-strong); font-weight:950; font-size:24px; }
.pause-overlay strong { font-size: 22px; }
.pause-overlay span { color:var(--muted); font-size:12px; }
.pause-overlay button { margin-top:6px; border:0; border-radius:12px; background:var(--cyan); color:#00141b; font-weight:900; padding:10px 18px; cursor:pointer; }

.number-pad { display:grid; grid-template-columns:repeat(9,1fr); gap:7px; margin: 16px auto 10px; max-width:590px; }
.num-btn { min-width:0; aspect-ratio: 1.05; border:1px solid var(--line); border-radius:12px; background:rgba(255,255,255,.035); cursor:pointer; font-size:clamp(16px,2vw,21px); font-weight:900; transition:.15s ease; }
.num-btn:hover { transform:translateY(-1px); border-color:var(--line-strong); background:rgba(71,230,255,.09); }
.num-btn.complete { opacity:.28; pointer-events:none; }
.tool-row { display:grid; grid-template-columns:repeat(4,1fr); gap:8px; max-width:590px; margin:0 auto; }
.tool-btn { min-height:56px; border:1px solid var(--line); border-radius:13px; background:rgba(255,255,255,.025); cursor:pointer; display:flex; align-items:center; justify-content:center; gap:6px; position:relative; transition:.15s ease; }
.tool-btn span { font-size:20px; color:var(--cyan); }
.tool-btn small { font-size:11px; font-weight:800; }
.tool-btn i { position:absolute; top:5px; right:6px; color:var(--muted); font-size:8px; font-style:normal; font-weight:900; }
.tool-btn.active { background:rgba(71,230,255,.11); border-color:var(--line-strong); }
.tool-btn:hover { transform:translateY(-1px); }
.tool-btn:disabled { opacity:.36; cursor:not-allowed; transform:none; }

.info-panel { display:grid; gap:12px; }
.mission-card { border:1px solid rgba(71,230,255,.18); border-radius:16px; padding:14px; background:linear-gradient(145deg, rgba(71,230,255,.08), rgba(79,124,255,.04)); }
.mission-card strong { display:block; font-size:14px; margin:4px 0 10px; }
.progress-bar { height:5px; border-radius:999px; overflow:hidden; background:rgba(255,255,255,.07); }
.progress-bar i { display:block; height:100%; width:0; background:linear-gradient(90deg,var(--cyan),var(--green)); transition:width .3s ease; }
.mission-card > span { display:block; color:var(--muted); font-size:9px; margin-top:7px; text-align:right; }
.tip-card { display:flex; gap:10px; border:1px solid var(--line); border-radius:14px; padding:12px; background:rgba(255,255,255,.02); }
.tip-icon { flex:0 0 28px; height:28px; border-radius:9px; display:grid; place-items:center; color:var(--cyan); background:rgba(71,230,255,.08); }
.tip-card strong { font-size:11px; }
.tip-card p { color:var(--muted); font-size:9.5px; line-height:1.6; margin:4px 0 0; }
.best-card { margin-top:2px; border-radius:16px; padding:14px; border:1px solid var(--line); background:rgba(255,255,255,.025); }
.best-card strong { display:block; font-size:25px; letter-spacing:.05em; color:var(--green); }
.best-card span { display:block; color:var(--muted); font-size:9px; margin-top:4px; }

footer { display:flex; justify-content:space-between; gap:12px; padding:22px 8px 0; color:var(--muted); font-size:9px; letter-spacing:.12em; }
.toast { position:fixed; left:50%; bottom:30px; transform:translate(-50%,20px); padding:10px 16px; border-radius:999px; background:var(--panel-strong); border:1px solid var(--line-strong); box-shadow:var(--shadow); z-index:50; font-size:12px; opacity:0; pointer-events:none; transition:.22s ease; }
.toast.show { opacity:1; transform:translate(-50%,0); }
.modal { position:fixed; inset:0; z-index:60; display:grid; place-items:center; padding:20px; background:rgba(2,7,14,.72); backdrop-filter:blur(10px); }
.modal[hidden] { display:none; }
.modal-card { width:min(390px,100%); border-radius:24px; padding:30px; text-align:center; }
.result-badge { color:var(--green); font-size:10px; letter-spacing:.24em; font-weight:950; }
.modal-card h2 { margin:8px 0 4px; font-size:29px; }
.modal-card p { color:var(--muted); font-size:12px; margin:0 0 18px; }
.result-stats { display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:18px; }
.result-stats div { border:1px solid var(--line); border-radius:12px; padding:10px 6px; }
.result-stats small { display:block; color:var(--muted); font-size:9px; margin-bottom:3px; }
.result-stats strong { font-size:14px; }
.modal-card .primary-btn { width:100%; }
.modal-link { border:0; background:transparent; color:var(--muted); cursor:pointer; margin-top:10px; font-size:11px; }

@keyframes shake { 0%,100%{transform:translateX(0)} 30%{transform:translateX(-3px)} 70%{transform:translateX(3px)} }
@keyframes hintPulse { 0%{box-shadow:inset 0 0 0 2px var(--green)} 100%{box-shadow:inset 0 0 0 0 transparent} }

@media (max-width: 1080px) {
  .game-layout { grid-template-columns: minmax(190px,230px) minmax(460px,650px); }
  .info-panel { display:none; }
}
@media (max-width: 790px) {
  .app-shell { width:min(100% - 18px, 660px); padding-top:9px; }
  .topbar { min-height:62px; border-radius:17px; }
  .hero-row { padding:23px 4px 16px; }
  .hero-row p { display:none; }
  .level-chip { min-width:90px; }
  .game-layout { display:block; }
  .side-panel { display:grid; grid-template-columns:1fr auto; align-items:center; gap:10px; margin-bottom:10px; padding:12px 14px; border-radius:17px; }
  .side-panel .panel-title, .side-panel .field-label, .side-panel .select-wrap, .side-panel .side-actions, .side-panel .streak-card, .side-panel .mini-note { display:none; }
  .stats-grid { grid-template-columns:repeat(4,1fr); gap:6px; margin:0; }
  .stat { padding:8px; border-radius:10px; }
  .stat small { font-size:8px; }
  .stat strong { font-size:12px; }
  .board-panel { border-radius:17px; padding:11px; }
  .cell { font-size:clamp(18px,6.2vw,29px); }
  .notes { font-size:clamp(6px,2vw,9px); inset:2px; }
  .number-pad { gap:5px; margin-top:10px; }
  .num-btn { border-radius:9px; font-size:17px; }
  .tool-btn { min-height:49px; border-radius:10px; gap:4px; }
  .tool-btn span { font-size:17px; }
  .tool-btn small { font-size:9px; }
  footer { padding-top:14px; }
}
@media (max-width: 520px) {
  .brand-copy small { display:none; }
  .brand-mark { width:38px; height:38px; }
  h1 { font-size:27px; }
  .level-chip { display:none; }
  .hero-row { padding-top:18px; }
  .hero-row h1 span { display:block; }
  .side-panel { overflow-x:auto; }
  .stats-grid { min-width:330px; }
  .board-toolbar { margin-bottom:9px; }
  .board-panel { padding:9px; }
  .tool-btn small { display:none; }
  .tool-btn { min-height:44px; }
  footer span:last-child { display:none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration:.001ms!important; animation-iteration-count:1!important; transition-duration:.001ms!important; scroll-behavior:auto!important; }
}
