:root {
  --paper: #f6f3ec;
  --card: #fffdf8;
  --ink: #1d232b;
  --muted: #6b7380;
  --line: #d9d3c6;
  --signal: #d9622b;
  --signal-soft: #fbe3d6;
  --good: #2f7d5b;
  --bad: #c0392b;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-user-select: none;
  user-select: none;
}
#app {
  max-width: 720px;
  margin: 0 auto;
  padding: 12px 16px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 100%;
}
button { font: inherit; color: inherit; cursor: pointer; }
.error { color: var(--bad); }

.gw-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.gw-brand { display: flex; align-items: center; gap: 8px; }
.gw-mark { color: var(--signal); font-size: 22px; line-height: 1; }
.gw-title { font-weight: 700; font-size: 20px; letter-spacing: -0.01em; }
.gw-date { display: flex; align-items: center; gap: 4px; }
.gw-date-label { font-size: 14px; font-weight: 600; min-width: 128px; text-align: center; }
.gw-icon {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid var(--line);
  background: var(--card); font-size: 18px; line-height: 1;
}
.gw-icon:disabled { opacity: 0.35; cursor: default; }

.gw-tabs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; }
.gw-tab {
  position: relative; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--card); font-size: 14px; font-weight: 600;
}
.gw-tab.on { background: var(--ink); color: var(--card); border-color: var(--ink); }
.gw-tab-dot {
  position: absolute; top: 5px; right: 6px; width: 7px; height: 7px; border-radius: 50%;
  background: transparent;
}
.gw-tab.done .gw-tab-dot { background: var(--good); }
.gw-tab.on.done .gw-tab-dot { background: #7fd4ab; }

.gw-bar { display: flex; justify-content: space-between; align-items: baseline; font-size: 13px; color: var(--muted); }
.gw-clock { font-variant-numeric: tabular-nums; font-size: 18px; font-weight: 700; color: var(--ink); }

.gw-stage { display: flex; flex-direction: column; align-items: center; gap: 12px; position: relative; }
.gw-loading { color: var(--muted); padding: 40px 0; }
.gw-rule { margin: 0; font-size: 13px; line-height: 1.45; color: var(--muted); text-align: center; }
.gw-hint { margin: 0; font-size: 13px; color: var(--bad); }

.gw-foot { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; justify-content: center; }
.gw-btn {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--card);
  font-size: 13px; font-weight: 600;
}
.gw-btn.primary { background: var(--signal); border-color: var(--signal); color: #fff; }
.gw-streak { font-size: 13px; color: var(--signal); font-weight: 700; }

/* ---------------- boards */
.gw-board {
  --cell: 48px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(var(--n), var(--cell));
  grid-auto-rows: var(--cell);
  border: 2px solid var(--ink);
  border-radius: 6px;
  overflow: hidden;
  background: var(--card);
  touch-action: none;
}
.gw-board.solved { box-shadow: 0 0 0 4px rgba(47, 125, 91, 0.25); }
.gw-cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  font-size: calc(var(--cell) * 0.46);
  font-weight: 600;
  cursor: pointer;
}
.gw-cell.bt { border-top: 2px solid var(--ink); }
.gw-cell.bl { border-left: 2px solid var(--ink); }
.gw-cell.bb { border-bottom: 2px solid var(--ink); }
.gw-cell.br { border-right: 2px solid var(--ink); }

/* Sentinels */
.gw-sentinels .gw-cell { border-color: rgba(29, 35, 43, 0.18); }
.gw-sentinels .gw-cell.bt { border-top-color: var(--ink); }
.gw-sentinels .gw-cell.bl { border-left-color: var(--ink); }
.gw-sentinels .gw-cell.bb { border-bottom-color: var(--ink); }
.gw-sentinels .gw-cell.br { border-right-color: var(--ink); }
.gw-x { color: rgba(29, 35, 43, 0.45); font-size: calc(var(--cell) * 0.4); }
.gw-sentinel {
  width: 46%; height: 46%; background: var(--ink); transform: rotate(45deg); border-radius: 3px;
}
.gw-cell.bad .gw-sentinel { background: var(--bad); }

/* Balance */
.gw-dot { width: 52%; height: 52%; border-radius: 50%; background: var(--ink); }
.gw-ring { width: 52%; height: 52%; border-radius: 50%; border: calc(var(--cell) * 0.08) solid var(--signal); }
.gw-balance .gw-cell.given { background: #efeae0; cursor: default; }
.gw-balance .gw-cell.bad { background: #f6d3cf; }

/* Sixes */
.gw-sixes .gw-cell.given { color: var(--ink); background: #efeae0; cursor: default; }
.gw-sixes .gw-cell:not(.given) { color: var(--signal); }
.gw-sixes .gw-cell.sel { background: var(--signal-soft); box-shadow: inset 0 0 0 2px var(--signal); }
.gw-sixes .gw-cell.bad { color: var(--bad); background: #f6d3cf; }
.gw-pad { display: grid; grid-template-columns: repeat(7, 44px); gap: 6px; }
.gw-key {
  height: 44px; border-radius: 10px; border: 1px solid var(--line); background: var(--card);
  font-size: 18px; font-weight: 700;
}

/* Plots */
.gw-plots .gw-cell.pv { background: var(--signal-soft) !important; box-shadow: inset 0 0 0 1px var(--signal); }
.gw-clue {
  display: flex; align-items: center; justify-content: center;
  width: 62%; height: 62%; border-radius: 50%; background: var(--card); border: 1.5px solid var(--ink);
  font-size: calc(var(--cell) * 0.34);
}

/* Trail */
.gw-trail .gw-cell.lit { background: var(--signal-soft); }
.gw-path { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
.gw-path polyline {
  fill: none; stroke: var(--signal); stroke-width: 0.32; stroke-linecap: round; stroke-linejoin: round;
  opacity: 0.85; vector-effect: none;
}
.gw-num {
  position: relative; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 60%; height: 60%; border-radius: 50%; background: var(--ink); color: var(--card);
  font-size: calc(var(--cell) * 0.3);
}

.gw-win {
  display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-radius: 12px;
  background: var(--card); border: 1px solid var(--good); color: var(--good); font-size: 14px;
}
.gw-win span { color: var(--muted); }

/* pizzazz */
.gw-cell.pop > * { animation: gw-pop .28s cubic-bezier(.3, 1.6, .5, 1); }
.gw-sixes .gw-cell.pop { animation: gw-pop .28s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes gw-pop { 0% { transform: scale(.4); } 100% { transform: scale(1); } }
.gw-sentinel { transition: transform .15s; }
.gw-cell.pop .gw-sentinel { animation: gw-pop-diamond .3s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes gw-pop-diamond { 0% { transform: rotate(45deg) scale(.3); } 100% { transform: rotate(45deg) scale(1); } }
.gw-board.solved { animation: gw-glow 1.6s ease-in-out infinite alternate; }
@keyframes gw-glow { from { box-shadow: 0 0 0 4px rgba(47, 125, 91, 0.25); } to { box-shadow: 0 0 0 7px rgba(47, 125, 91, 0.12), 0 0 26px rgba(242, 193, 78, 0.55); } }
.gw-win { animation: gw-bounce .5s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes gw-bounce { 0% { transform: translateY(14px) scale(.85); opacity: 0; } 100% { transform: none; opacity: 1; } }
.gw-confetti { position: fixed; inset: 0; width: 100vw; height: 100vh; pointer-events: none; z-index: 50; }
.gw-tab { transition: transform .15s, background .15s; }
.gw-tab:hover { transform: translateY(-2px); }
.gw-tab.done .gw-tab-dot { animation: gw-pop .4s cubic-bezier(.3, 1.6, .5, 1); }

.gw-dayline { color: var(--signal); font-weight: 800; }
.gw-icon.ready { border-color: var(--signal); color: var(--signal); animation: gw-nudge 1.4s ease-in-out infinite; }
@keyframes gw-nudge { 50% { transform: translateX(3px); } }
