:root {
  --bg: #f4f7fc;
  --bg-deep: #eaf1fb;
  --panel: rgba(255, 255, 255, .94);
  --panel-solid: #ffffff;
  --panel-muted: #f7f9fd;
  --text: #10203a;
  --text-strong: #07152d;
  --muted: #64738b;
  --line: #dce5f1;
  --line-strong: #c8d6e8;
  --accent: #1769e0;
  --accent-strong: #0b4fbd;
  --accent-soft: #eaf3ff;
  --accent-faint: rgba(23, 105, 224, .09);
  --cyan: #0f8fa8;
  --danger: #d83245;
  --danger-soft: #fff0f2;
  --ok: #16865a;
  --ok-soft: #ebfaf4;
  --warning: #b76a07;
  --warning-soft: #fff7e8;
  --light-square: #e8eef7;
  --dark-square: #6682aa;
  --select: #f5b31f;
  --legal: rgba(15, 113, 235, .44);
  --capture: rgba(216, 50, 69, .64);
  --shadow-xs: 0 2px 10px rgba(22, 49, 86, .06);
  --shadow-sm: 0 10px 28px rgba(22, 49, 86, .09);
  --shadow: 0 18px 48px rgba(22, 49, 86, .11);
  --shadow-lg: 0 28px 80px rgba(17, 40, 76, .18);
  --radius: 24px;
  --radius-md: 18px;
  --radius-sm: 13px;
  --font-sans: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --font-mono: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  color-scheme: light;
}

* { box-sizing: border-box; }
html { min-height: 100%; scroll-behavior: smooth; }
body {
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  font-family: var(--font-sans);
  color: var(--text);
  background:
    radial-gradient(circle at 7% 4%, rgba(34, 119, 239, .14), transparent 29rem),
    radial-gradient(circle at 93% 9%, rgba(35, 160, 195, .10), transparent 25rem),
    linear-gradient(180deg, #fbfdff 0%, var(--bg) 44%, var(--bg-deep) 100%);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -2;
  pointer-events: none;
  background:
    linear-gradient(rgba(23, 105, 224, .026) 1px, transparent 1px),
    linear-gradient(90deg, rgba(23, 105, 224, .026) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, #000 0%, transparent 84%);
}
body::after {
  content: "";
  position: fixed;
  width: 22rem;
  height: 22rem;
  right: -9rem;
  bottom: -10rem;
  z-index: -1;
  border-radius: 50%;
  background: rgba(23, 105, 224, .08);
  filter: blur(2px);
  pointer-events: none;
}
button, input, select, textarea { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: .67rem 1rem;
  color: #fff;
  background: linear-gradient(145deg, #2380f0, var(--accent));
  box-shadow: 0 9px 20px rgba(23, 105, 224, .20);
  cursor: pointer;
  font-weight: 760;
  font-size: .91rem;
  letter-spacing: .008em;
  transition: transform .16s ease, box-shadow .18s ease, border-color .18s ease, background .18s ease, opacity .16s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 13px 26px rgba(23, 105, 224, .24); }
button:active { transform: translateY(0); box-shadow: 0 5px 14px rgba(23, 105, 224, .18); }
button:focus-visible, [role="button"]:focus-visible { outline: 3px solid rgba(55, 143, 255, .34); outline-offset: 3px; }
button:disabled { opacity: .43; cursor: not-allowed; transform: none; box-shadow: none; }
button.secondary {
  color: #24405f;
  background: #f7faff;
  border-color: var(--line-strong);
  box-shadow: var(--shadow-xs);
}
button.secondary:hover { background: #edf5ff; border-color: #9ec5f5; box-shadow: var(--shadow-sm); }
button.danger { color: #fff; background: linear-gradient(145deg, #eb5364, var(--danger)); box-shadow: 0 9px 20px rgba(216, 50, 69, .19); }
button.ok { color: #fff; background: linear-gradient(145deg, #27a979, var(--ok)); box-shadow: 0 9px 20px rgba(22, 134, 90, .19); }
button.ghost {
  color: var(--accent-strong);
  background: rgba(255, 255, 255, .54);
  border-color: var(--line-strong);
  box-shadow: none;
}
button.ghost:hover { background: var(--accent-soft); border-color: #9bc5f8; }
button[data-action="open-replay"]:disabled,
button[data-action="open-replay"]:disabled:hover { filter: grayscale(1); color: #7f8b99; background: #eef1f4; border-color: #d3d8de; }

input, select, textarea {
  width: 100%;
  min-height: 44px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  background: #fff;
  padding: .72rem .86rem;
  color: var(--text-strong);
  outline: none;
  font-size: .94rem;
  transition: border-color .18s ease, box-shadow .18s ease, background .18s ease;
}
input:hover, select:hover, textarea:hover { border-color: #aabdd5; }
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(23, 105, 224, .11); }
textarea { min-height: 7rem; resize: vertical; }
label { display: grid; gap: .4rem; color: #30445f; font-size: .9rem; font-weight: 780; }
small, .small { color: var(--muted); font-size: .85rem; line-height: 1.58; }

/* Floating Dynamic Island */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 80;
  height: auto;
  padding-top: max(.62rem, env(safe-area-inset-top));
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.dynamic-island {
  width: min(34rem, calc(100vw - 1.2rem));
  max-height: 64px;
  overflow: hidden;
  pointer-events: auto;
  color: #f7fbff;
  background:
    radial-gradient(circle at 15% 0%, rgba(71, 154, 255, .34), transparent 13rem),
    linear-gradient(145deg, rgba(6, 18, 42, .97), rgba(10, 38, 82, .97));
  border: 1px solid rgba(145, 196, 255, .22);
  border-radius: 25px;
  box-shadow: 0 16px 48px rgba(7, 24, 55, .28), inset 0 1px 0 rgba(255, 255, 255, .13);
  backdrop-filter: blur(24px) saturate(145%);
  -webkit-backdrop-filter: blur(24px) saturate(145%);
  transition: width .36s cubic-bezier(.2,.8,.2,1), max-height .36s cubic-bezier(.2,.8,.2,1), border-radius .3s ease, box-shadow .3s ease;
}
.dynamic-island.is-open {
  width: min(60rem, calc(100vw - 1.2rem));
  max-height: 142px;
  border-radius: 28px;
  box-shadow: 0 24px 68px rgba(7, 24, 55, .34), inset 0 1px 0 rgba(255, 255, 255, .15);
}
.island-summary {
  min-height: 62px;
  padding: .55rem .62rem .55rem .72rem;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .7rem;
  align-items: center;
}
.brand {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: .62rem;
  border-radius: 18px;
  cursor: pointer;
  user-select: none;
}
.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 15px;
  color: #fff;
  background: linear-gradient(145deg, #4fa1ff, #1466da 58%, #0aa0bd);
  box-shadow: 0 9px 22px rgba(37, 133, 245, .34), inset 0 1px 0 rgba(255,255,255,.28);
  font-size: 1.42rem;
}
.brand-copy { min-width: 0; }
.brand h1 { margin: 0; color: #fff; font-size: 1.02rem; line-height: 1.1; letter-spacing: .02em; font-weight: 880; }
.brand p { margin: .16rem 0 0; color: rgba(225, 238, 255, .68); font-size: .69rem; white-space: nowrap; }
.island-activity {
  min-width: 0;
  justify-self: center;
  display: flex;
  align-items: center;
  gap: .48rem;
  padding: .42rem .72rem;
  border: 1px solid rgba(155, 203, 255, .17);
  border-radius: 999px;
  color: #e9f4ff;
  background: rgba(255, 255, 255, .07);
  font-size: .79rem;
  font-weight: 720;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.activity-dot {
  width: .5rem;
  height: .5rem;
  flex: 0 0 auto;
  border-radius: 50%;
  background: #58d5ff;
  box-shadow: 0 0 0 4px rgba(88, 213, 255, .11), 0 0 14px rgba(88, 213, 255, .82);
  animation: islandPulse 2.2s ease-in-out infinite;
}
.island-toggle {
  min-height: 42px;
  padding: .54rem .75rem;
  display: flex;
  align-items: center;
  gap: .48rem;
  color: #f4f9ff;
  background: rgba(255, 255, 255, .10);
  border-color: rgba(160, 207, 255, .19);
  box-shadow: none;
  border-radius: 15px;
  font-size: .79rem;
}
.island-toggle:hover { background: rgba(255,255,255,.16); box-shadow: none; }
.toggle-glyph {
  position: relative;
  width: 17px;
  height: 12px;
  display: inline-block;
}
.toggle-glyph::before, .toggle-glyph::after {
  content: "";
  position: absolute;
  left: 0;
  width: 17px;
  height: 2px;
  border-radius: 2px;
  background: currentColor;
  transition: transform .24s ease, top .24s ease;
}
.toggle-glyph::before { top: 2px; }
.toggle-glyph::after { top: 8px; }
.dynamic-island.is-open .toggle-glyph::before { top: 5px; transform: rotate(45deg); }
.dynamic-island.is-open .toggle-glyph::after { top: 5px; transform: rotate(-45deg); }
.top-nav {
  max-height: 0;
  padding: 0 .65rem;
  overflow: hidden;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: .42rem;
  opacity: 0;
  transform: translateY(-7px);
  transition: max-height .32s ease, padding .32s ease, opacity .22s ease, transform .28s ease;
}
.dynamic-island.is-open .top-nav { max-height: 76px; padding: .18rem .65rem .72rem; opacity: 1; transform: translateY(0); }
.top-nav button {
  min-height: 40px;
  padding: .52rem .5rem;
  color: #dcecff;
  background: rgba(255, 255, 255, .07);
  border-color: rgba(158, 203, 255, .13);
  box-shadow: none;
  border-radius: 13px;
  font-size: .78rem;
  white-space: nowrap;
}
.top-nav button:hover { color: #fff; background: rgba(75, 155, 255, .20); box-shadow: none; }
.top-nav button[aria-current="page"] { color: #fff; background: linear-gradient(145deg, rgba(61, 151, 255, .72), rgba(22, 103, 224, .66)); border-color: rgba(149, 204, 255, .33); }
@keyframes islandPulse { 0%,100% { opacity: .68; transform: scale(.92); } 50% { opacity: 1; transform: scale(1.08); } }

.app-shell {
  width: min(1320px, calc(100% - 2rem));
  margin: clamp(5.8rem, 8vw, 6.7rem) auto 3rem;
}
.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.18fr) minmax(320px, .82fr);
  gap: 1.15rem;
  align-items: stretch;
}
.card, .panel {
  position: relative;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid rgba(197, 212, 231, .88);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}
.card::before, .panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .94);
}
.card::after {
  content: "";
  position: absolute;
  width: 13rem;
  height: 13rem;
  right: -7rem;
  top: -7rem;
  border-radius: 50%;
  pointer-events: none;
  background: rgba(23, 105, 224, .08);
}
.card { padding: clamp(1.15rem, 2.8vw, 2.35rem); }
.hero-card { min-height: 445px; display: grid; align-content: center; }
.hero-eyebrow { display: flex; flex-wrap: wrap; gap: .52rem; align-items: center; margin-bottom: 1rem; }
.hero-title {
  margin: 0 0 1rem;
  max-width: 13ch;
  color: var(--text-strong);
  font-size: clamp(2.15rem, 5vw, 4.8rem);
  line-height: 1.01;
  letter-spacing: -.052em;
  font-weight: 920;
}
.hero-title span {
  color: transparent;
  background: linear-gradient(100deg, var(--accent-strong), #2585ef 62%, #0a94b1);
  -webkit-background-clip: text;
  background-clip: text;
}
.hero-copy { margin: 0 0 1.35rem; max-width: 68ch; color: var(--muted); font-size: 1rem; line-height: 1.78; }
.action-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .68rem; }
.feature-list { display: grid; gap: .7rem; margin-top: 1.15rem; }
.feature { display: flex; gap: .68rem; align-items: flex-start; color: #38506d; font-size: .91rem; line-height: 1.62; }
.feature b { color: var(--accent-strong); font-weight: 820; }
.feature-dot {
  flex: 0 0 auto;
  width: .62rem;
  height: .62rem;
  margin-top: .48rem;
  border-radius: 50%;
  background: linear-gradient(145deg, #2d87ef, #0aa0b9);
  box-shadow: 0 0 0 4px rgba(23, 105, 224, .09);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: .32rem;
  min-height: 29px;
  padding: .3rem .68rem;
  border: 1px solid #bdd6f6;
  border-radius: 999px;
  color: #1453a1;
  background: #edf5ff;
  font-size: .79rem;
  font-weight: 820;
  letter-spacing: .005em;
}
.badge.official { color: #8a4f04; background: #fff8e9; border-color: #f1d49b; }
.stat-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .72rem; }
.stat-card {
  padding: 1rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, rgba(255,255,255,.96), rgba(241,247,255,.85));
  box-shadow: var(--shadow-xs);
}
.stat-card strong { display: block; margin-bottom: .28rem; color: var(--text-strong); font-size: 1.55rem; line-height: 1; }
.stat-card span { color: var(--muted); font-size: .82rem; }
.official-note, .copyright-note {
  padding: .9rem 1rem;
  border: 1px solid #efd49d;
  border-radius: var(--radius-sm);
  color: #80500d;
  background: linear-gradient(145deg, #fffaf0, #fff5df);
  font-size: .88rem;
  line-height: 1.65;
}

.layout {
  display: grid;
  grid-template-columns: minmax(340px, 720px) minmax(320px, 1fr);
  gap: 1.18rem;
  align-items: start;
}
.levels-layout { grid-template-columns: minmax(310px, .92fr) minmax(340px, 1.08fr); }
.board-wrap { position: relative; display: grid; gap: .78rem; min-width: 0; }
.toolbar { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; justify-content: space-between; }
.toolbar-left, .toolbar-right { display: flex; flex-wrap: wrap; gap: .48rem; align-items: center; }
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 38px;
  gap: .34rem;
  padding: .48rem .78rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #38506c;
  background: rgba(255,255,255,.88);
  box-shadow: var(--shadow-xs);
  font-size: .85rem;
  font-weight: 790;
}
.status-pill.check { color: #a45a05; background: var(--warning-soft); border-color: #f0d39a; }
.status-pill.done { color: #10704a; background: var(--ok-soft); border-color: #a9dfca; }
.status-pill.error { color: #b9293b; background: var(--danger-soft); border-color: #f0b5bd; }

.chessboard {
  width: min(100%, 720px);
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  grid-template-rows: repeat(8, 1fr);
  overflow: hidden;
  container-type: inline-size;
  border: clamp(5px, 1.1vw, 10px) solid #213653;
  border-radius: 22px;
  background: #213653;
  box-shadow: 0 25px 65px rgba(20, 43, 77, .25), 0 0 0 1px rgba(255,255,255,.3) inset;
  touch-action: manipulation;
  user-select: none;
}
.square {
  position: relative;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  cursor: pointer;
  isolation: isolate;
  transition: filter .12s ease, box-shadow .12s ease;
}
.square.light { background: var(--light-square); }
.square.dark { background: var(--dark-square); }
.square:hover { filter: brightness(1.045); }
.square.selected { outline: max(3px, .55cqi) solid var(--select); outline-offset: calc(max(3px, .55cqi) * -1); z-index: 3; }
.square.legal::after {
  content: "";
  position: absolute;
  z-index: 2;
  width: 26%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: var(--legal);
  box-shadow: 0 0 0 .45cqi rgba(255,255,255,.20);
}
.square.capture::after {
  content: "";
  position: absolute;
  z-index: 2;
  inset: 8%;
  border: max(3px, .52cqi) solid var(--capture);
  border-radius: 50%;
}
.square.last-from, .square.last-to { box-shadow: inset 0 0 0 999px rgba(255, 193, 35, .23); }
.piece {
  position: relative;
  z-index: 1;
  width: 91%;
  height: 91%;
  display: grid;
  place-items: center;
  font-family: "Segoe UI Symbol", "Noto Sans Symbols 2", "DejaVu Sans", serif;
  font-size: 10.15cqi;
  line-height: .82;
  transform: translateY(-.015em);
  filter: drop-shadow(0 .35cqi .32cqi rgba(4, 15, 31, .25));
  transition: transform .12s ease;
}
.piece.black { color: #101a28; text-shadow: 0 1px 0 rgba(255,255,255,.24); }
.piece.white { color: #fff; text-shadow: 0 .18cqi .45cqi rgba(8, 24, 45, .76), 0 0 1px #31435a; }
.piece.invert { transform: rotate(180deg) translateY(.015em); }
.coord {
  position: absolute;
  z-index: 4;
  pointer-events: none;
  font-size: clamp(.5rem, 1.15cqi, .73rem);
  font-weight: 860;
  opacity: .74;
}
.coord.file { right: .22rem; bottom: .12rem; }
.coord.rank { left: .22rem; top: .12rem; }
.square.light .coord { color: #536882; }
.square.dark .coord { color: #f0f5fb; }

.board-wrap .pass-stamp-overlay {
  position: absolute;
  z-index: 12;
  top: 52%;
  left: 50%;
  transform: translate(-50%, -50%) rotate(-11deg);
  pointer-events: none;
}
.pass-stamp {
  display: inline-block;
  padding: clamp(.55rem, 2vw, 1rem) clamp(.9rem, 3vw, 1.7rem);
  border: clamp(4px, .7vw, 7px) solid var(--ok);
  border-radius: 999px;
  color: var(--ok);
  background: rgba(255,255,255,.84);
  box-shadow: 0 18px 45px rgba(22,134,90,.26);
  backdrop-filter: blur(8px);
  font-size: clamp(2.4rem, 7vw, 4.8rem);
  font-weight: 920;
  letter-spacing: .08em;
  line-height: 1;
}

.side-panel { padding: 1.1rem; display: grid; gap: .82rem; }
.panel h2, .panel h3, .card h2, .card h3 { margin: 0; color: var(--text-strong); font-weight: 860; letter-spacing: -.018em; }
.panel-title { display: flex; flex-wrap: wrap; gap: .68rem; align-items: center; justify-content: space-between; }
.compact-actions { gap: .42rem; }
.compact-actions button, .compact-actions .upload-label { min-height: 38px; padding: .48rem .7rem; font-size: .82rem; }
.engine-note {
  padding: .85rem .92rem;
  border: 1px solid #bad5f7;
  border-radius: var(--radius-sm);
  color: #174b8a;
  background: linear-gradient(145deg, #eef6ff, #e7f1ff);
  font-size: .87rem;
  line-height: 1.62;
}
.empty-state {
  padding: 1rem;
  border: 1px dashed #b9c9dc;
  border-radius: var(--radius-sm);
  color: var(--muted);
  background: rgba(247, 250, 254, .88);
  font-size: .88rem;
  line-height: 1.68;
  text-align: center;
}
.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .84rem; }
.form-grid .full { grid-column: 1 / -1; }
.switch-line { display: flex; flex-wrap: wrap; gap: .52rem .72rem; align-items: center; }
.switch-line label { display: inline-flex; align-items: center; gap: .35rem; }
.switch-line input { width: auto; min-height: auto; }

.move-log {
  max-height: 410px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: #f8faff;
  scrollbar-width: thin;
  scrollbar-color: #afc4dc transparent;
}
.move-row {
  display: grid;
  grid-template-columns: 3rem minmax(0, 1fr) minmax(0, 1fr);
  gap: .48rem;
  align-items: center;
  padding: .62rem .76rem;
  border-bottom: 1px solid var(--line);
}
.move-row:last-child { border-bottom: 0; }
.move-no { color: #7b8ba1; font-size: .85rem; font-weight: 820; }
.move-san { min-width: 0; display: flex; align-items: center; gap: .34rem; font-family: var(--font-mono); font-size: .88rem; font-weight: 760; }
.move-grade {
  display: inline-grid;
  place-items: center;
  min-width: 1.55rem;
  height: 1.45rem;
  padding: 0 .28rem;
  border-radius: 7px;
  font-family: var(--font-sans);
  font-size: .73rem;
  font-weight: 920;
}
.move-grade.excellent { color: #087149; background: #dff8ee; }
.move-grade.good { color: #1462b8; background: #e5f1ff; }
.move-grade.inaccuracy { color: #936006; background: #fff2ce; }
.move-grade.mistake { color: #b24d11; background: #ffe9d8; }
.move-grade.blunder { color: #bd263a; background: #ffe1e6; }

.palette { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: .4rem; }
.palette button {
  min-height: 48px;
  padding: .48rem .15rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: var(--text);
  background: #f8faff;
  box-shadow: none;
  font-size: 1.34rem;
}
.palette button:hover { background: var(--accent-soft); box-shadow: none; }
.palette button.active { border-color: var(--accent); outline: 3px solid rgba(23,105,224,.18); background: #eaf3ff; }

.levels-stack { display: grid; gap: .95rem; align-items: start; }
.puzzle-panel { min-height: 0; }
.official-puzzle-panel { border-color: #efd19b; }
.puzzle-scroll { max-height: clamp(260px, 37vh, 430px); overflow-y: auto; padding-right: .18rem; overscroll-behavior: contain; }
.official-scroll { max-height: clamp(290px, 41vh, 470px); }
.local-scroll { max-height: clamp(245px, 35vh, 410px); }
.level-list { display: grid; gap: .76rem; }
.level-item {
  display: grid;
  gap: .65rem;
  padding: .94rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(160deg, #fff, #f6f9fd);
  transition: transform .15s ease, box-shadow .16s ease, border-color .16s ease;
}
.level-item:hover { transform: translateY(-1px); border-color: #a9c9ef; box-shadow: var(--shadow-sm); }
.level-item.official-item { border-color: #efd39e; background: linear-gradient(160deg, #fff, #fff9ed); }
.level-item header { display: flex; gap: .7rem; align-items: flex-start; justify-content: space-between; }
.level-title { color: var(--text-strong); font-size: 1rem; font-weight: 850; }
.level-meta { color: var(--muted); font-size: .83rem; line-height: 1.55; }
.level-desc { margin-top: .25rem; color: #4c6079; font-size: .88rem; line-height: 1.6; }
.level-actions { display: flex; flex-wrap: wrap; gap: .4rem; }
.level-actions button { min-height: 36px; padding: .46rem .68rem; font-size: .81rem; }
.passed-mark {
  display: inline-flex;
  align-items: center;
  gap: .24rem;
  padding: .22rem .58rem;
  border: 1px solid #aadfc9;
  border-radius: 999px;
  color: #11714b;
  background: var(--ok-soft);
  font-size: .78rem;
  font-weight: 860;
}
.upload-label {
  min-height: 42px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .45rem;
  padding: .67rem .95rem;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  color: #29415f;
  background: #f7faff;
  cursor: pointer;
  font-size: .89rem;
  font-weight: 760;
  transition: transform .16s ease, box-shadow .18s ease, border-color .18s ease;
}
.upload-label:hover { transform: translateY(-1px); border-color: #a5c8f1; box-shadow: var(--shadow-sm); }
.upload-label input { display: none; }
.solution-box { max-height: 240px; overflow: auto; display: grid; gap: .35rem; padding: .72rem; border: 1px solid var(--line); border-radius: var(--radius-sm); background: #f8faff; }
.solution-line { font-family: var(--font-mono); font-size: .88rem; }
.game-list-scroll { max-height: min(68vh, 720px); overflow-y: auto; display: grid; gap: .76rem; padding-right: .16rem; overscroll-behavior: contain; }
.game-item .badge { white-space: nowrap; }
.compact-stats .stat-card { padding: .76rem; }
.compact-stats .stat-card strong { font-size: 1.22rem; }

.solution-viewer-layout { display: grid; gap: .9rem; }
.solution-modal-card { width: min(680px, 100%); }
.solution-viewer-board { width: min(100%, 430px); margin: 0 auto; }
.solution-viewer-board .chessboard { width: 100%; border-radius: 17px; }
.solution-viewer-controls { display: flex; flex-wrap: wrap; gap: .42rem; justify-content: center; align-items: center; }
.solution-viewer-controls .step-indicator { min-width: 6rem; color: var(--text); font-size: .89rem; font-weight: 790; text-align: center; }
.solution-viewer-controls .step-san { width: 100%; color: var(--accent-strong); font-family: var(--font-mono); font-size: .98rem; font-weight: 830; text-align: center; }
.solution-viewer-controls button { min-height: 36px; padding: .43rem .66rem; border-radius: 10px; font-size: .8rem; }
.replay-controls { justify-content: flex-start; }
.replay-layout .move-log { max-height: 220px; }

.analysis-panel {
  display: grid;
  gap: .7rem;
  padding: .9rem;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: linear-gradient(155deg, #fbfdff, #f2f7fd);
}
.analysis-panel h3 { margin: 0; }
.eval-summary { display: grid; gap: .34rem; color: #354b66; font-size: .88rem; line-height: 1.52; }
.eval-bar { position: relative; height: .72rem; overflow: hidden; border: 1px solid #52657e; border-radius: 999px; background: #14243a; }
.eval-bar span { display: block; height: 100%; background: #f7fbff; border-right: 1px solid #52657e; transition: width .32s ease; }
.analysis-lines { display: grid; gap: .46rem; }
.analysis-line {
  display: grid;
  grid-template-columns: 2.2rem minmax(4rem, .8fr) 4.2rem 3.1rem;
  gap: .42rem;
  align-items: center;
  padding: .53rem .62rem;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #fff;
  font-family: var(--font-mono);
  font-size: .83rem;
}
.analysis-line small { grid-column: 1 / -1; overflow-wrap: anywhere; font-family: var(--font-mono); }
.line-no { color: var(--muted); font-weight: 850; }
.line-move { color: var(--accent-strong); font-weight: 860; }
.line-eval { font-weight: 860; }
.line-depth { color: var(--muted); }
.error-text { color: var(--danger); background: var(--danger-soft); border-color: #efb8c0; }
.loading-orb {
  display: inline-block;
  width: .72rem;
  height: .72rem;
  margin-right: .42rem;
  border: 2px solid rgba(23,105,224,.22);
  border-top-color: var(--accent);
  border-radius: 50%;
  vertical-align: -.08rem;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.move-review-card {
  display: grid;
  grid-template-columns: 3.15rem minmax(0, 1fr);
  gap: .72rem;
  align-items: center;
  padding: .78rem;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}
.move-review-symbol { display: grid; place-items: center; width: 3.15rem; height: 3.15rem; border-radius: 13px; font-size: 1.35rem; font-weight: 920; }
.move-review-title { margin-bottom: .18rem; color: var(--text-strong); font-weight: 840; }
.move-review-meta { color: var(--muted); font-size: .8rem; line-height: 1.5; }
.move-review-card.excellent { border-color: #a9dfc9; background: #f4fcf8; }
.move-review-card.excellent .move-review-symbol { color: #08724b; background: #daf6ea; }
.move-review-card.good { border-color: #b7d4f5; background: #f5f9ff; }
.move-review-card.good .move-review-symbol { color: #135eae; background: #e1efff; }
.move-review-card.inaccuracy { border-color: #efd59d; background: #fffaf0; }
.move-review-card.inaccuracy .move-review-symbol { color: #946006; background: #fff0c8; }
.move-review-card.mistake { border-color: #efc4a4; background: #fff8f2; }
.move-review-card.mistake .move-review-symbol { color: #b44d12; background: #ffe6d3; }
.move-review-card.blunder { border-color: #efb5be; background: #fff5f6; }
.move-review-card.blunder .move-review-symbol { color: #bd263b; background: #ffdde3; }

.modal {
  position: fixed;
  inset: 0;
  z-index: 120;
  padding: 1rem;
  display: grid;
  place-items: center;
  background: rgba(9, 24, 46, .50);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}
.modal.hidden, .toast.hidden { display: none; }
.modal-card {
  width: min(620px, 100%);
  max-height: min(92vh, 900px);
  overflow-y: auto;
  display: grid;
  gap: .88rem;
  padding: 1.15rem;
  border: 1px solid rgba(203, 217, 234, .9);
  border-radius: 22px;
  background: var(--panel-solid);
  box-shadow: 0 32px 95px rgba(7, 23, 49, .34);
}
.modal-actions { display: flex; flex-wrap: wrap; gap: .5rem; justify-content: flex-end; }
.promo-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: .52rem; }
.promo-grid button { min-height: 62px; padding: .8rem .3rem; border-radius: 14px; font-size: 1.8rem; }
.toast {
  position: fixed;
  z-index: 150;
  left: 50%;
  bottom: max(1.2rem, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: min(620px, calc(100% - 1.4rem));
  padding: .78rem 1.08rem;
  border: 1px solid rgba(151, 196, 248, .22);
  border-radius: 999px;
  color: #fff;
  background: rgba(7, 27, 61, .94);
  box-shadow: 0 18px 55px rgba(7, 23, 49, .28);
  font-size: .88rem;
  font-weight: 730;
  text-align: center;
  backdrop-filter: blur(14px);
}
.site-footer {
  display: flex;
  flex-wrap: wrap;
  gap: .5rem 1rem;
  justify-content: center;
  padding: 1.4rem 1rem max(2rem, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(194, 209, 227, .72);
  color: var(--muted);
  font-size: .81rem;
  text-align: center;
}

@supports not (font-size: 1cqi) {
  .piece { font-size: clamp(1.8rem, 8vw, 4.55rem); }
  .solution-viewer-board .piece { font-size: clamp(1.6rem, 7vw, 3.2rem); }
}

@media (min-width: 981px) {
  .levels-stack { grid-template-rows: auto auto; }
  .games-layout, .replay-layout { grid-template-columns: minmax(330px, .82fr) minmax(440px, 1.18fr); }
}

@media (max-width: 980px) {
  .hero, .layout, .levels-layout { grid-template-columns: 1fr; }
  .hero-card { min-height: auto; }
  .chessboard { margin-inline: auto; border-radius: 19px; }
  .board-wrap { max-width: 740px; width: 100%; margin-inline: auto; }
  .move-log { max-height: 280px; }
  .solution-viewer-board { width: min(100%, 390px); }
  .puzzle-scroll, .official-scroll, .local-scroll { max-height: 370px; }
  .game-list-scroll { max-height: 540px; }
  .analysis-line { grid-template-columns: 2.1rem 1fr 3.8rem; }
  .analysis-line .line-depth { display: none; }
}

@media (max-width: 680px) {
  .site-header { padding-top: max(.42rem, env(safe-area-inset-top)); }
  .dynamic-island { width: calc(100vw - .75rem); max-height: 58px; border-radius: 22px; }
  .dynamic-island.is-open { width: calc(100vw - .75rem); max-height: 210px; border-radius: 24px; }
  .island-summary { min-height: 56px; padding: .42rem .48rem .42rem .52rem; gap: .46rem; }
  .brand-mark { width: 38px; height: 38px; border-radius: 13px; font-size: 1.28rem; }
  .brand p { display: none; }
  .island-activity { padding: .36rem .55rem; font-size: .74rem; }
  .island-toggle { min-height: 38px; padding: .42rem .58rem; }
  .island-toggle > span:first-child { display: none; }
  .top-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .dynamic-island.is-open .top-nav { max-height: 146px; padding: .2rem .52rem .58rem; }
  .top-nav button { min-height: 37px; }
  .app-shell { width: min(100% - .7rem, 1320px); margin-top: 5rem; }
  .card, .side-panel { padding: .86rem; }
  .action-grid, .form-grid, .stat-grid { grid-template-columns: 1fr; }
  .hero-title { font-size: clamp(2rem, 12vw, 3.2rem); }
  .toolbar { align-items: stretch; }
  .toolbar-left, .toolbar-right { width: 100%; }
  .toolbar button, .toolbar select, .toolbar .upload-label { flex: 1 1 auto; justify-content: center; min-width: 0; padding: .53rem .62rem; font-size: .81rem; }
  .palette { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .move-row { grid-template-columns: 2.35rem minmax(0, 1fr) minmax(0, 1fr); padding: .52rem .54rem; }
  .move-san { font-size: .81rem; }
  .pass-stamp { font-size: 2.15rem; border-width: 4px; }
  .solution-modal-card { padding: .78rem; }
  .solution-viewer-board { width: min(100%, 330px); }
  .solution-viewer-controls button { padding: .4rem .54rem; font-size: .76rem; }
  .levels-stack { gap: .68rem; }
  .puzzle-scroll, .official-scroll, .local-scroll { max-height: 330px; }
  .game-list-scroll { max-height: 470px; }
  .analysis-line { grid-template-columns: 1.9rem 1fr; font-size: .78rem; }
  .analysis-line .line-eval { justify-self: end; }
  .analysis-line small { font-size: .73rem; }
  .analysis-panel, .engine-note { padding: .72rem; }
  .move-review-card { grid-template-columns: 2.7rem minmax(0,1fr); padding: .65rem; }
  .move-review-symbol { width: 2.7rem; height: 2.7rem; font-size: 1.15rem; }
}

@media (max-width: 390px) {
  .island-activity { max-width: 7.4rem; }
  .brand-copy { display: none; }
  .dynamic-island.is-open .top-nav { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .app-shell { width: calc(100% - .42rem); }
  .card, .side-panel { border-radius: 19px; padding: .72rem; }
  .chessboard { border-radius: 14px; }
  button { padding-inline: .72rem; }
}

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

/* 棋子直线滑动：脚本按格数、距离与斜向比例为每一着计算独立匀速。 */
.chessboard { position: relative; }
.chessboard.is-animating .square { cursor: default; }
.moving-piece-layer {
  position: absolute;
  z-index: 20;
  display: grid;
  place-items: center;
  pointer-events: none;
  will-change: transform;
}
.moving-piece-layer .piece {
  width: 91%;
  height: 91%;
  transition: none;
}
