:root {
  --bg: #f3f2ef;
  --surface: #fff;
  --text: #191919;
  --muted: #666;
  --border: #e0dfdc;
  --accent: #0a66c2;
  --accent-hover: #004182;
  --success: #057642;
  --warning: #b24020;
  --radius: 12px;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

#app { max-width: 1000px; margin: 0 auto; min-height: 100vh; display: flex; flex-direction: column; }

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 10;
}

.top-bar-left { display: flex; align-items: center; gap: 8px; }
.logo { font-size: 1.1rem; font-weight: 600; }

.btn-icon {
  border: none; background: none; font-size: 1.25rem;
  cursor: pointer; padding: 4px 8px; border-radius: 8px;
}
.btn-icon:hover { background: var(--bg); }

.user-chip {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid var(--border); background: var(--surface);
  padding: 6px 12px 6px 6px; border-radius: 999px; cursor: pointer;
}
.user-chip:hover { background: var(--bg); }

.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: #fff;
}
.avatar.dad { background: #0a66c2; }
.avatar.george { background: #057642; }
.avatar.grace { background: #915907; }

#main { flex: 1; padding: 20px 24px; }

.muted { color: var(--muted); font-size: .9rem; }

/* Hub */
.hub-hero {
  text-align: center;
  padding: 24px 16px;
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.hub-hero h2 { font-size: 1.4rem; margin-bottom: 6px; }
.hub-hero p { color: var(--muted); }

.date-badge {
  display: inline-block;
  margin-top: 12px;
  padding: 4px 12px;
  background: var(--bg);
  border-radius: 999px;
  font-size: .85rem;
  color: var(--muted);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--surface);
  border-radius: var(--radius);
  padding: 14px 10px;
  text-align: center;
  box-shadow: var(--shadow);
}
.stat-card .num { font-size: 1.5rem; font-weight: 700; color: var(--accent); }
.stat-card .lbl { font-size: .75rem; color: var(--muted); margin-top: 2px; }

.section-title {
  font-size: .85rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin: 20px 0 10px;
}

.game-grid { display: flex; flex-direction: column; gap: 10px; }

.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  transition: box-shadow .15s, border-color .15s;
}
.game-card:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.game-card.done { border-left: 4px solid var(--success); }

.game-icon {
  width: 44px; height: 44px; border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.4rem; flex-shrink: 0;
}
.game-icon.pinpoint { background: #e8f4fc; }
.game-icon.queens { background: #fce8f0; }
.game-icon.crossclimb { background: #f0e8fc; }
.game-icon.tango { background: #fcf8e8; }
.game-icon.zip { background: #e8fce8; }
.game-icon.sudoku { background: #fce8e8; }
.game-icon.patches { background: #e8f0fc; }
.game-icon.wend { background: #f0fce8; }

.game-info { flex: 1; min-width: 0; }
.game-info h3 { font-size: 1rem; margin-bottom: 2px; }
.game-info p { font-size: .82rem; color: var(--muted); }

.game-meta { text-align: right; font-size: .78rem; color: var(--muted); }
.game-meta .time { font-weight: 600; color: var(--success); }
.game-meta .played { margin-top: 4px; }

/* Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 10px 20px; border-radius: 999px; border: none;
  font-size: .95rem; font-weight: 600; cursor: pointer;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-secondary { background: var(--bg); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-text { background: none; border: none; color: var(--accent); cursor: pointer; padding: 8px; font-size: .9rem; }
.btn-hint { background: #fff8e8; color: #915907; border: 1px solid #e8d8a8; }
.btn-hint:hover { background: #fff0c8; }

.game-actions {
  display: flex; gap: 10px; flex-wrap: wrap;
  margin: 16px 0; align-items: center;
}

.timer {
  font-variant-numeric: tabular-nums;
  font-size: 1.1rem; font-weight: 600;
  padding: 6px 14px;
  background: var(--bg);
  border-radius: 999px;
}

/* Game layout — LinkedIn style */
.game-panel-wide { max-width: 600px; margin: 0 auto; padding: 24px 20px; }

.game-action-bar .btn-cooldown {
  position: relative;
  overflow: hidden;
}
.game-action-bar .btn-cooldown .btn-cooldown-label {
  position: relative;
  z-index: 1;
}
.game-action-bar .btn-cooldown .btn-cooldown-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--cooldown-pct, 0));
  transform-origin: left center;
  background: rgba(0, 0, 0, 0.14);
  pointer-events: none;
  z-index: 0;
}
.game-action-bar .btn-cooldown.is-cooling { opacity: 0.92; }
.game-action-bar .btn-cooldown.is-cooling .btn-cooldown-fill {
  transition: transform 0.08s linear;
}

.game-header {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  margin-bottom: 24px;
  gap: 12px;
}
.difficulty-badge {
  justify-self: start;
  padding: 6px 14px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: .82rem;
  color: var(--muted);
  background: var(--surface);
}
.game-timer {
  justify-self: center;
  display: flex; align-items: center; gap: 6px;
  font-size: 1.15rem; font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.game-timer-val {
  display: inline-block;
  min-width: 3.2ch;
  text-align: center;
}
.timer-icon { color: var(--muted); }
.game-timer-val.timer-frozen { color: var(--text); }
.game-timer-stopped .game-timer { opacity: 0.85; }
.btn-reset {
  justify-self: end;
  padding: 8px 18px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  font-size: .9rem; font-weight: 600;
  cursor: pointer;
}
.btn-reset:hover { background: var(--bg); }

.game-action-bar {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 20px 0;
}
.btn-game {
  padding: 14px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: #f0efec;
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  color: var(--text);
}
.btn-game:hover { background: #e8e6e1; }
.hint-badge {
  display: inline-block;
  margin-left: 4px;
  padding: 1px 7px;
  background: #fff;
  border-radius: 999px;
  font-size: .8rem;
  color: var(--muted);
}

.how-to-play {
  margin-top: 20px;
  padding: 16px 18px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  font-size: .9rem;
  line-height: 1.5;
}
.how-to-play strong { display: block; margin-bottom: 8px; }
.legend-row { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; font-size: .85rem; color: var(--muted); }
.legend-row span { display: flex; align-items: center; gap: 6px; }

/* Wend */
.wend-board-wrap { display: flex; justify-content: center; margin: 0 auto; }
.wend-board {
  display: grid; gap: 0; background: #555;
  border: 2px solid #555; border-radius: 4px; overflow: hidden;
  touch-action: none; user-select: none; cursor: pointer;
}
.wend-cell {
  display: flex; align-items: center; justify-content: center;
  position: relative; box-sizing: border-box;
}
.wend-wall { background: #9a9a9a; }
.wend-unsolved { background: #e0ded8; }
.wend-hinted, .wend-solved { /* solid fill set inline */ }
.wend-current { background: #b0aea8; }
.wend-letter {
  width: 44px; height: 44px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.2rem; font-weight: 700;
  background: #c8c6c2; color: #555;
}
.wend-letter.colored { box-shadow: 0 1px 3px rgba(0,0,0,.15); }
.wend-check {
  position: absolute; top: 2px; right: 2px;
  width: 18px; height: 18px; border-radius: 50%;
  background: #4caf50; color: #fff; font-size: .65rem;
  display: flex; align-items: center; justify-content: center;
}
.wend-word-list { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.wend-word-row { display: flex; align-items: center; gap: 6px; min-height: 36px; }
.wend-len-badge {
  padding: 6px 14px; background: #f0efec; border-radius: 999px;
  font-size: .88rem; font-weight: 600; color: var(--muted);
}
.wend-chip {
  width: 32px; height: 32px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  color: #fff; font-weight: 700; font-size: .9rem;
}
.wend-done-check { color: #4caf50; font-weight: 700; margin-left: 6px; }

.wend-solved-state .game-action-bar .btn-game,
.wend-solved-state .btn-reset { opacity: 0.45; pointer-events: none; }
.wend-solved-state .wend-board { pointer-events: none; }
.wend-solved-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.wend-solved-msg { color: var(--muted); margin-bottom: 14px; font-size: .95rem; }
.btn-wend-ok {
  width: 100%;
  max-width: 400px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: #3d3d3d;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-wend-ok:hover { background: #2a2a2a; }

/* Patches */
.patches-board-wrap { display: flex; justify-content: center; }
.patches-board {
  display: grid; gap: 2px;
  background: #b8b6b0; padding: 2px;
  border-radius: 6px; box-sizing: border-box;
}
.patches-cell {
  background: #e0ded8;
  aspect-ratio: 1;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; user-select: none;
  position: relative; min-width: 0; min-height: 0;
}
.patches-cell.patches-filled { border-radius: 2px; }
.patches-cell.patches-selecting { outline: 2px solid #e8881a; z-index: 1; }
.patches-clue-icon {
  position: relative;
  width: 58%; height: 58%;
  max-width: 52px; max-height: 52px;
  display: flex; align-items: center; justify-content: center;
  color: #3a3a3a;
}
.patches-clue-icon .shape-icon { width: 100%; height: 100%; display: block; }
.patches-clue-icon .shape-wide { width: 110%; height: 70%; }
.patches-clue-icon .shape-tall { width: 70%; height: 110%; }
.patches-clue-icon.patches-clue-shape-only {
  width: 68%; height: 68%;
  max-width: 58px; max-height: 58px;
}
.patches-num-in {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(0.8rem, 2.4vw, 1.2rem);
  font-weight: 800; color: #1a1a1a; pointer-events: none;
  text-shadow: 0 0 3px #e0ded8, 0 0 3px #e0ded8;
}
.patches-legend-icons { gap: 20px 28px; flex-wrap: wrap; }
.patches-legend-icons .legend-item {
  display: flex; align-items: center; gap: 8px;
  font-size: .88rem; color: var(--muted);
}
.patches-legend-icons .legend-icon-wrap {
  width: 28px; height: 28px; display: flex;
  align-items: center; justify-content: center; color: #444;
}
.patches-legend-icons .shape-icon { width: 100%; height: 100%; }
.patches-solved-state .game-action-bar .btn-game,
.patches-solved-state .btn-reset { opacity: 0.45; pointer-events: none; }
.patches-solved-state .patches-board { pointer-events: none; }
.patches-solved-bar {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border); text-align: center;
}
.patches-solved-msg { color: var(--muted); margin-bottom: 14px; font-size: .95rem; }
.btn-patches-ok {
  width: 100%; max-width: 400px;
  padding: 16px 24px; border: none; border-radius: 999px;
  background: #3d3d3d; color: #fff;
  font-size: 1.05rem; font-weight: 600; cursor: pointer;
}
.btn-patches-ok:hover { background: #2a2a2a; }

/* Zip */
.zip-board-wrap { display: flex; justify-content: center; margin: 16px 0; }
.zip-board-inner {
  position: relative;
  touch-action: none;
  cursor: crosshair;
}
.zip-board {
  display: grid;
  gap: 2px;
  padding: 2px;
  background: #e0ded8;
  border-radius: 8px;
  position: relative;
  z-index: 1;
}
.zip-walls-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}
.zip-wall {
  position: absolute;
  background: #1a1a1a;
  border-radius: 1px;
  pointer-events: none;
}
.zip-path-svg {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 3;
  pointer-events: none;
  overflow: visible;
}
.zip-cell {
  background: #f5f4f1;
  border-radius: 2px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.zip-dots-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  pointer-events: none;
}
.zip-dot {
  position: absolute;
  width: clamp(28px, 9vw, 40px);
  height: clamp(28px, 9vw, 40px);
  border-radius: 50%;
  background: #222;
  color: #fff;
  font-weight: 700;
  font-size: clamp(0.8rem, 2.5vw, 1rem);
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translate(-50%, -50%);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.zip-path-line-done {
  animation: zipLineGlow 0.7s ease-out forwards;
}
.zip-dot-done {
  animation: zipDotPop 0.55s ease-out forwards;
}
.zip-board-inner.zip-complete {
  animation: zipBoardCelebrate 0.85s ease-out;
}
@keyframes zipLineGlow {
  0% { stroke-opacity: 0.55; filter: drop-shadow(0 0 0 transparent); }
  45% { stroke-opacity: 1; filter: drop-shadow(0 0 10px rgba(247, 127, 0, 0.65)); }
  100% { stroke-opacity: 1; filter: drop-shadow(0 0 4px rgba(252, 191, 73, 0.35)); }
}
@keyframes zipDotPop {
  0% { transform: translate(-50%, -50%) scale(1); }
  40% { transform: translate(-50%, -50%) scale(1.28); }
  100% { transform: translate(-50%, -50%) scale(1); }
}
@keyframes zipBoardCelebrate {
  0% { transform: scale(1); }
  35% { transform: scale(1.03); }
  100% { transform: scale(1); }
}
.zip-solved-state .game-action-bar .btn-game,
.zip-solved-state .btn-reset { opacity: 0.45; pointer-events: none; }
.zip-solved-state .zip-board-inner { pointer-events: none; cursor: default; }
.zip-solved-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.zip-solved-msg { color: var(--muted); margin-bottom: 14px; font-size: .95rem; }
.btn-zip-ok {
  width: 100%;
  max-width: 400px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: #3d3d3d;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-zip-ok:hover { background: #2a2a2a; }
.zip-dot-demo {
  width: 22px; height: 22px; border-radius: 50%;
  background: #222; color: #fff; font-size: .75rem; font-weight: 700;
  display: inline-flex; align-items: center; justify-content: center;
}
.zip-fill-demo {
  width: 40px; height: 24px; border-radius: 4px;
  background: linear-gradient(90deg, #d62828, #f77f00, #fcbf49);
  display: inline-block;
}
.zip-wall-demo {
  width: 28px;
  height: 6px;
  border-radius: 2px;
  background: #1a1a1a;
  display: inline-block;
}
.zip-legend-item { display: flex; align-items: center; gap: 8px; }

/* Tango */
.tango-board-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0;
}
.tango-board {
  position: relative;
  display: inline-block;
}
.tango-grid {
  display: grid;
  gap: 4px;
  background: #e0ded8;
  padding: 4px;
  border-radius: 8px;
  position: relative;
  z-index: 1;
}
.tango-cell {
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
  position: relative;
  z-index: 1;
}
.tango-cell:disabled { cursor: default; }
.tango-cell.tango-given { background: #f5ead6; }
.tango-cell.tango-cell-solved { cursor: default; }
.tango-cell.tango-conflict {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(220, 60, 60, 0.28) 0,
    rgba(220, 60, 60, 0.28) 6px,
    rgba(255, 255, 255, 0.15) 6px,
    rgba(255, 255, 255, 0.15) 12px
  ) !important;
}
.tango-cell.tango-hint-target {
  box-shadow: inset 0 0 0 3px #c47a3a;
  animation: tangoHintPulse 1.2s ease-in-out infinite;
}
@keyframes tangoHintPulse {
  0%, 100% { box-shadow: inset 0 0 0 3px #c47a3a; }
  50% { box-shadow: inset 0 0 0 3px #e8a55a; }
}
.tango-hint-slot { min-height: 0; }
.tango-hint-banner {
  margin: 12px 0 0;
  padding: 12px 14px;
  border-radius: 10px;
  background: #fff8ef;
  border: 1px solid #ecdaba;
  color: #5a4a32;
  font-size: 0.92rem;
  line-height: 1.45;
}
.tango-actions .btn-cooldown {
  position: relative;
  overflow: hidden;
}
.tango-actions .btn-cooldown .btn-cooldown-label {
  position: relative;
  z-index: 1;
}
.tango-actions .btn-cooldown .btn-cooldown-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--cooldown-pct, 0));
  transform-origin: left center;
  background: rgba(0, 0, 0, 0.14);
  pointer-events: none;
  z-index: 0;
}
.tango-actions .btn-cooldown.is-cooling { opacity: 0.92; }
.tango-actions .btn-cooldown.is-cooling .btn-cooldown-fill {
  transition: transform 0.08s linear;
}
.tango-symbol { width: 36px; height: 36px; pointer-events: none; }
.tango-constraints {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 3;
}
.tango-eq, .tango-neq {
  position: absolute;
  font-weight: 700;
  font-size: 0.95rem;
  color: #444;
  background: #fff;
  padding: 1px 4px;
  border-radius: 3px;
  box-shadow: 0 0 0 2px #e0ded8;
  transform: translate(-50%, -50%);
  line-height: 1.1;
  pointer-events: none;
  z-index: 4;
}
.tango-neq { color: #555; }
.tango-howto {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafafa;
}
.tango-howto summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.tango-howto summary::-webkit-details-marker { display: none; }
.tango-rules {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.tango-rules li { margin: 8px 0; }
.tango-rule-icon { width: 18px; height: 18px; vertical-align: -3px; display: inline-block; }
.tango-rule-demo {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 8px;
  padding-left: 4px;
}
.tango-demo-row {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid var(--border);
}
.tango-demo-icon { width: 22px; height: 22px; }
.tango-demo-mark {
  margin-left: 6px;
  font-weight: 700;
  font-size: 0.95rem;
}
.tango-demo-mark.ok { color: #2a9d4a; }
.tango-demo-mark.bad { color: #d64545; }
.tango-solved-slot { min-height: 0; }
.tango-solved-bar {
  margin-top: 16px;
  text-align: center;
  animation: tangoBarIn 0.35s ease both;
}
@keyframes tangoBarIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.tango-solved-msg { color: var(--muted); margin-bottom: 14px; font-size: 0.95rem; }
.btn-tango-ok {
  width: 100%;
  max-width: 400px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: #3d3d3d;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-tango-ok:hover { background: #2a2a2a; }
.tango-solved-state .game-action-bar .btn-game,
.tango-solved-state .btn-reset { opacity: 0.45; pointer-events: none; }

.hint-count { font-size: .85rem; color: var(--muted); }

/* Game board common */
.game-panel {
  background: var(--surface);
  border-radius: var(--radius);
  max-width: 600px;
  margin: 0 auto;
  padding: 24px 20px;
  box-shadow: var(--shadow);
}

.game-instructions {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 16px;
  line-height: 1.5;
}

/* Pinpoint */
.pinpoint-words { display: flex; flex-direction: column; gap: 8px; margin: 16px 0; }
.pinpoint-word {
  padding: 12px 16px; background: var(--bg); border-radius: 8px;
  font-weight: 600; font-size: 1.05rem;
  opacity: .3; transition: opacity .3s;
}
.pinpoint-word.revealed { opacity: 1; }
.pinpoint-meta { margin-top: 8px; }
.pinpoint-guess { display: flex; gap: 8px; margin-top: 12px; }
.pinpoint-guess input {
  flex: 1; padding: 10px 14px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 1rem;
}
.pinpoint-guess-history {
  display: flex; flex-direction: column; gap: 6px;
  margin-top: 14px; min-height: 8px;
}
.pinpoint-wrong-guess {
  padding: 8px 12px; background: var(--bg); border-radius: 8px;
  font-weight: 600; color: var(--muted);
  text-decoration: line-through; text-decoration-thickness: 2px;
}
.pinpoint-result { margin-top: 16px; padding: 12px; border-radius: 8px; }
.pinpoint-result.win { background: #e8f5ee; color: var(--success); }
.pinpoint-result.lose { background: #fce8e8; color: var(--warning); }
.pinpoint-solved-state .pinpoint-guess input,
.pinpoint-solved-state .pinpoint-guess .btn { opacity: 0.45; pointer-events: none; }
.pinpoint-solved-bar {
  margin-top: 20px; padding-top: 16px;
  border-top: 1px solid var(--border); text-align: center;
}
.pinpoint-solved-msg { color: var(--muted); margin-bottom: 8px; font-size: .95rem; }
.pinpoint-solved-cat { margin-bottom: 14px; font-size: 1rem; }
.btn-pinpoint-ok {
  width: 100%; max-width: 400px;
  padding: 16px 24px; border: none; border-radius: 999px;
  background: #3d3d3d; color: #fff;
  font-size: 1.05rem; font-weight: 600; cursor: pointer;
}
.btn-pinpoint-ok:hover { background: #2a2a2a; }

/* Queens / grids */
.grid-board {
  display: inline-grid;
  gap: 2px;
  background: var(--border);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 2px;
  margin: 12px auto;
}
.grid-cell {
  width: 36px; height: 36px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; font-size: 1.1rem; user-select: none;
  position: relative;
}
.grid-cell.sm { width: 30px; height: 30px; font-size: .9rem; }
.grid-cell.xs { width: 26px; height: 26px; font-size: .75rem; }
.grid-cell.queen { background: #fce8f0; }
.grid-cell.marked { background: #f0f0f0; }
.grid-cell.selected { outline: 2px solid var(--accent); z-index: 1; }
.grid-cell.wall { background: #ccc; cursor: default; }
.grid-cell.path { background: #d4edda; }
.grid-cell.path-current { background: #a8d5b5; }
.grid-cell.fixed { background: #e8f4fc; font-weight: 700; }
.grid-cell.error { background: #fce8e8; }
.grid-cell.region-0 { background: #f8f0ff; }
.grid-cell.region-1 { background: #f0f8ff; }
.grid-cell.region-2 { background: #fff8f0; }
.grid-cell.region-3 { background: #f0fff4; }
.grid-cell.region-4 { background: #fff0f4; }
.grid-cell.region-5 { background: #f4f0ff; }
.grid-cell.region-6 { background: #f0ffff; }
.grid-cell.region-7 { background: #fffff0; }

.board-wrap { text-align: center; overflow-x: auto; }

/* Mini Sudoku */
.sudoku-board-wrap { display: flex; justify-content: center; margin: 16px 0; }
.sudoku-board {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 2px;
  background: #2a2a2a;
  padding: 2px;
  border-radius: 6px;
  box-sizing: border-box;
}
.sudoku-cell {
  background: #fff;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  position: relative;
}
.sudoku-cell.fixed { background: #e8f4fc; }
.sudoku-cell.selected { background: #fff9e6; z-index: 1; }
.sudoku-cell.error,
.sudoku-cell.error.fixed {
  background: #fcd8d8 !important;
}
.sudoku-cell.error .sudoku-val,
.sudoku-cell.error .sudoku-input {
  color: #b71c1c;
}
.sudoku-cell.error.selected { background: #f9c4c4 !important; }
.sudoku-cell.error .sudoku-input:focus { background: #f9c4c4; }
.sudoku-cell.sudoku-box-right { box-shadow: inset -5px 0 0 #1a1a1a; }
.sudoku-cell.sudoku-box-bottom { box-shadow: inset 0 -5px 0 #1a1a1a; }
.sudoku-cell.sudoku-box-right.sudoku-box-bottom {
  box-shadow: inset -5px 0 0 #1a1a1a, inset 0 -5px 0 #1a1a1a;
}
.sudoku-val {
  font-size: clamp(1rem, 5vw, 2.5rem);
  font-weight: 700;
  color: #1a1a1a;
  line-height: 1;
}
.sudoku-input {
  width: 100%;
  height: 100%;
  border: none;
  background: transparent;
  text-align: center;
  font-size: clamp(1rem, 5vw, 2.5rem);
  font-weight: 700;
  color: #1a1a1a;
  outline: none;
  padding: 0;
  font-family: inherit;
}
.sudoku-input:focus { background: #fff9e6; }
.sudoku-numpad {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 0 auto 16px;
  max-width: 560px;
  width: 100%;
}
.sudoku-numpad-btn {
  flex: 1;
  max-width: 120px;
  padding: 12px 8px;
  border: 2px solid #d8d8d8;
  border-radius: 10px;
  background: #fff;
  color: #1a1a1a;
  font-size: clamp(0.75rem, 2vw, 1.125rem);
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
}
.sudoku-numpad-btn:hover:not(.complete):not(:disabled) { background: #f5f5f5; border-color: #bbb; }
.sudoku-numpad-btn.complete,
.sudoku-numpad-btn:disabled {
  color: #b0b0b0;
  background: #f0f0f0;
  border-color: #e8e8e8;
  cursor: default;
}
.sudoku-board-solved .sudoku-cell,
.sudoku-board-solved .sudoku-cell.fixed,
.sudoku-board-solved .sudoku-cell.selected {
  background: #9fd9b0 !important;
}
.sudoku-board-solved .sudoku-val,
.sudoku-board-solved .sudoku-input {
  color: #1a5c32;
}
.sudoku-board-solved .sudoku-input:focus { background: #9fd9b0; }
.sudoku-solved-state .game-action-bar .btn-game,
.sudoku-solved-state .btn-reset { opacity: 0.45; pointer-events: none; }
.sudoku-solved-state .sudoku-board,
.sudoku-solved-state .sudoku-numpad { pointer-events: none; }
.sudoku-solved-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.sudoku-solved-msg { color: var(--muted); margin-bottom: 14px; font-size: .95rem; }
.btn-sudoku-ok {
  width: 100%;
  max-width: 400px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: #3d3d3d;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-sudoku-ok:hover { background: #2a2a2a; }

/* Tango */
.tango-sun { color: #e8a317; }
.tango-moon { color: #4a6fa5; }
.tango-constraint {
  position: absolute; font-size: .65rem; font-weight: 700;
  color: var(--muted); pointer-events: none;
}
.tango-constraint.eq { color: var(--success); }
.tango-constraint.neq { color: var(--warning); }

/* Crossclimb */
.cc-board {
  margin: 16px auto;
  width: 100%;
  max-width: 600px;
  background: #fff;
  border-radius: 12px;
  padding: 24px 16px;
  box-shadow: var(--shadow);
}
.cc-stack-wrap {
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 8px;
}
.cc-rail {
  width: 14px;
  background: linear-gradient(#ddd, #ddd) center/2px 100% no-repeat;
  position: relative;
}
.cc-stack {
  flex: 1;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cc-row {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.cc-row-mid[draggable="true"] { cursor: grab; }
.cc-row-mid[draggable="true"]:active { cursor: grabbing; }
.cc-word {
  display: flex;
  gap: 4px;
  justify-content: center;
  padding: 10px 12px;
  border-radius: 6px;
  width: 100%;
  max-width: 320px;
  box-sizing: border-box;
}
.cc-word.cc-cap {
  background: #ffd8be;
}
.cc-word.cc-cap .cc-cell {
  text-decoration: underline;
  text-underline-offset: 3px;
}
.cc-word.cc-mid {
  background: #efefef;
}
.cc-word.cc-hidden {
  background: #f5f5f5;
  color: #bbb;
}
.cc-cell {
  flex: 1;
  max-width: 52px;
  min-width: 40px;
  text-align: center;
  font-size: clamp(1.1rem, 3vw, 1.45rem);
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 6px 2px;
  background: rgba(255, 255, 255, 0.45);
  border-radius: 4px;
}
.cc-cell-input {
  border: none;
  outline: none;
  font: inherit;
  color: inherit;
  text-decoration: underline;
  text-underline-offset: 3px;
  text-transform: uppercase;
}
.cc-clue-cap { margin: 4px 0 2px; font-weight: 600; color: #444; }
.cc-clue-cap-sub {
  margin: 0 0 8px;
  font-size: 0.76rem;
  color: var(--muted);
  font-style: italic;
}
.cc-row-cap.is-active-row .cc-word {
  outline: 2px solid rgba(196, 122, 58, 0.25);
  outline-offset: 2px;
}
.cc-connector {
  width: 100%;
  text-align: center;
  color: #888;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1;
  padding: 2px 0;
}
.cc-connector-dim { opacity: 0.35; }
.cc-connector-active { color: #555; }
.cc-clue {
  margin: 6px 0 0;
  font-size: 0.82rem;
  color: var(--muted);
  text-align: center;
  line-height: 1.35;
  max-width: 340px;
}
.cc-guess-row { width: 100%; display: flex; justify-content: center; }
.cc-guess-input, .cc-cap-input {
  width: 100%;
  max-width: 280px;
  padding: 12px;
  text-align: center;
  border: 1px solid #d0d0d0;
  border-radius: 6px;
  background: #efefef;
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}
.cc-compound-guess {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.cc-phase-hint {
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  margin: 8px 0 0;
}
.cc-compound-goal {
  margin: 14px 0 0;
  text-align: center;
  font-size: 0.88rem;
  color: #555;
  line-height: 1.4;
}
.cc-compound-len {
  color: var(--muted);
  font-weight: 500;
}
.cc-compound-solved {
  margin: 2px 0 8px;
  text-align: center;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--success);
}
.cc-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 16px;
}
.cc-actions .btn-game {
  flex: 1;
  max-width: 200px;
}
.cc-actions .btn-cooldown {
  position: relative;
  overflow: hidden;
}
.cc-actions .btn-cooldown .btn-cooldown-label {
  position: relative;
  z-index: 1;
}
.cc-actions .btn-cooldown .btn-cooldown-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  transform: scaleX(var(--cooldown-pct, 0));
  transform-origin: left center;
  background: rgba(0, 0, 0, 0.14);
  pointer-events: none;
  z-index: 0;
}
.cc-actions .btn-cooldown.is-cooling {
  opacity: 0.92;
}
.cc-actions .btn-cooldown.is-cooling .btn-cooldown-fill {
  transition: transform 0.08s linear;
}
.cc-guess-input.is-active,
.cc-row-mid.is-active-row .cc-guess-input {
  border-color: #c47a3a;
  box-shadow: 0 0 0 2px rgba(196, 122, 58, 0.25);
  background: #fff;
}
.cc-row-mid.is-active-row .cc-word,
.cc-row-mid.is-active-row .cc-guess-row {
  outline: 2px solid rgba(196, 122, 58, 0.2);
  outline-offset: 2px;
  border-radius: 6px;
}
.cc-solved-state .cc-actions .btn-game,
.cc-solved-state .btn-reset { opacity: 0.45; pointer-events: none; }
.cc-solved-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.cc-solved-msg { color: var(--muted); margin-bottom: 14px; font-size: 0.95rem; }
.btn-cc-ok {
  width: 100%;
  max-width: 400px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: #3d3d3d;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-cc-ok:hover { background: #2a2a2a; }

/* Queens */
.queens-panel { max-width: 600px; margin: 0 auto; }
.queens-board-wrap {
  display: flex;
  justify-content: center;
  margin: 16px 0;
  overflow-x: auto;
}
.queens-grid {
  display: grid;
  gap: 0;
  border: 2px solid #222;
  background: #222;
}
.queens-grid-solved { perspective: 600px; }
.queens-cell {
  padding: 0;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.85rem, 2.5vw, 1.35rem);
  cursor: pointer;
  color: #555;
  position: relative;
  box-sizing: border-box;
}
.queens-cell.queens-marked { color: #888; font-size: 0.75em; }
.queens-cell.queens-has-queen { color: #111; }
.queens-cell.queens-conflict,
.queens-cell.queens-region-conflict {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(220, 60, 60, 0.28) 0,
    rgba(220, 60, 60, 0.28) 6px,
    rgba(255, 255, 255, 0.15) 6px,
    rgba(255, 255, 255, 0.15) 12px
  ) !important;
}
.queens-howto, .queens-examples {
  margin-top: 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px 14px;
  background: #fafafa;
}
.queens-howto summary, .queens-examples summary {
  font-weight: 700;
  cursor: pointer;
  list-style: none;
}
.queens-howto summary::-webkit-details-marker,
.queens-examples summary::-webkit-details-marker { display: none; }
.queens-rules {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.5;
}
.queens-example-carousel {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
}
.queens-carousel-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #fff;
  font-size: 1.4rem;
  line-height: 1;
  cursor: pointer;
}
.queens-example-card {
  text-align: center;
  min-height: 180px;
}
.queens-example-title {
  font-size: 0.88rem;
  color: #444;
  margin: 0 0 10px;
  line-height: 1.35;
}
.queens-example-grid {
  display: inline-grid;
  gap: 0;
  border: 2px solid #222;
}
.queens-ex-cell {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.85rem;
  border: 1px solid rgba(0, 0, 0, 0.12);
  box-sizing: border-box;
}
.queens-ex-mark { color: #888; font-size: 0.7rem; }
.queens-ex-conflict {
  background-image: repeating-linear-gradient(
    45deg,
    rgba(220, 60, 60, 0.35) 0,
    rgba(220, 60, 60, 0.35) 5px,
    rgba(255, 255, 255, 0.1) 5px,
    rgba(255, 255, 255, 0.1) 10px
  ) !important;
}
.queens-carousel-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 10px;
}
.queens-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ccc;
}
.queens-dot.active { background: #222; }
.queens-cell.queens-has-queen { color: #111; }
.queens-grid-solved .queens-cell.queens-flip {
  animation: queensFlip 0.45s ease both;
}
@keyframes queensFlip {
  0% { transform: rotateY(-90deg) scale(0.6); opacity: 0.2; }
  60% { transform: rotateY(8deg) scale(1.08); opacity: 1; }
  100% { transform: rotateY(0deg) scale(1); opacity: 1; }
}
.queens-solved-slot { min-height: 0; }
.queens-solved-slot .queens-solved-bar {
  margin-top: 16px;
  padding-top: 0;
  border-top: none;
  text-align: center;
  animation: queensBarIn 0.35s ease both;
}
@keyframes queensBarIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.queens-solved-state .game-action-bar .btn-game,
.queens-solved-state .btn-reset { opacity: 0.45; pointer-events: none; }
.queens-solved-state .queens-cell { pointer-events: none; }
.queens-solved-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.queens-solved-msg { color: var(--muted); margin-bottom: 14px; font-size: 0.95rem; }
.btn-queens-ok {
  width: 100%;
  max-width: 400px;
  padding: 16px 24px;
  border: none;
  border-radius: 999px;
  background: #3d3d3d;
  color: #fff;
  font-size: 1.05rem;
  font-weight: 600;
  cursor: pointer;
}
.btn-queens-ok:hover { background: #2a2a2a; }

/* Zip */
.zip-cell .num-hint {
  position: absolute; top: 2px; left: 4px;
  font-size: .65rem; font-weight: 700; color: var(--accent);
}

/* Patches */
.patches-placed { opacity: .85; }
.patches-color-0 { background: #cce5ff !important; }
.patches-color-1 { background: #ffd6cc !important; }
.patches-color-2 { background: #d6ffcc !important; }
.patches-color-3 { background: #e8ccff !important; }
.patches-color-4 { background: #fff0cc !important; }
.patches-color-5 { background: #ccf0ff !important; }
.patches-clue { font-size: .7rem; line-height: 1.2; text-align: center; }
.patches-shape { font-size: .85rem; }

/* Wend */
.wend-lengths { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.wend-length-chip {
  padding: 6px 12px; background: var(--bg); border-radius: 999px;
  font-size: .85rem; font-weight: 600;
}
.wend-length-chip.found { background: #d4edda; color: var(--success); text-decoration: line-through; }

/* Sudoku */
.sudoku-box { border: 2px solid var(--text) !important; }

/* Leaderboard */
.leaderboard { display: flex; flex-direction: column; gap: 8px; }
.lb-row {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: var(--surface);
  border-radius: var(--radius); box-shadow: var(--shadow);
}
.lb-rank { font-weight: 700; width: 24px; color: var(--muted); }
.lb-rank.gold { color: #c9a227; }
.lb-name { flex: 1; font-weight: 600; }
.lb-stat { font-size: .85rem; color: var(--muted); text-align: right; }
.lb-stat strong { color: var(--text); display: block; }

.tabs { display: flex; gap: 4px; margin-bottom: 16px; overflow-x: auto; }
.tab {
  padding: 8px 14px; border: none; background: var(--bg);
  border-radius: 999px; cursor: pointer; font-size: .85rem; white-space: nowrap;
}
.tab.active { background: var(--accent); color: #fff; }

/* Modal */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.4);
  display: none;
  align-items: center; justify-content: center; z-index: 100;
  padding: 16px;
}
.modal-overlay.is-open {
  display: flex;
}
.modal-overlay[hidden] {
  display: none !important;
}
.modal {
  background: var(--surface); border-radius: var(--radius);
  padding: 24px; width: 100%; max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,.2);
}
.modal h2 { margin-bottom: 6px; }

.user-picker { display: flex; flex-direction: column; gap: 10px; margin: 20px 0; }
.user-option {
  display: flex; align-items: center; gap: 12px;
  padding: 14px; border: 2px solid var(--border);
  border-radius: var(--radius); cursor: pointer; background: var(--surface);
}
.user-option:hover, .user-option.selected { border-color: var(--accent); background: #f0f7fc; }
.user-option .name { font-weight: 600; }
.user-option .sub { font-size: .82rem; color: var(--muted); }

/* Toast */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  background: #333; color: #fff; padding: 10px 20px;
  border-radius: 999px; font-size: .9rem; z-index: 200;
  box-shadow: var(--shadow);
}

/* Win screen */
.win-screen { text-align: center; padding: 24px; }
.win-screen h2 { font-size: 1.6rem; margin-bottom: 8px; color: var(--success); }
.win-stats { display: flex; justify-content: center; gap: 24px; margin: 20px 0; }
.win-stat .val { font-size: 1.4rem; font-weight: 700; }
.win-stat .lbl { font-size: .8rem; color: var(--muted); }

.connections-played {
  margin-top: 16px; padding: 12px; background: var(--bg);
  border-radius: 8px; font-size: .88rem;
}

.share-row { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }

.profile-stats { margin: 12px 0; }
.profile-stat-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
  font-size: .9rem;
}
.profile-stat-row:last-child { border-bottom: none; }
.profile-stat-row strong { color: var(--accent); }

.game-review-bar {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.game-review-result {
  font-size: .95rem;
  color: var(--muted);
  margin-bottom: 12px;
}
.game-review-stats {
  background: var(--bg);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: left;
}
.game-review-stats-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  margin-bottom: 8px;
}
.game-review-state .game-action-bar,
.game-review-state .btn-reset,
.game-review-state .zip-board-inner,
.game-review-state .sudoku-board,
.game-review-state .tango-board,
.game-review-state .queens-board-wrap,
.game-review-state .patches-board,
.game-review-state .wend-board-wrap,
.game-review-state .cc-board {
  pointer-events: none;
}
.zip-cell.zip-on-path { cursor: pointer; }
.game-review-state .zip-board-inner { pointer-events: none; }

@media (max-width: 640px) {
  #main { padding: 16px 12px; }
  .game-panel { padding: 16px 12px; max-width: 100%; }
  .game-header {
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 6px;
    font-size: .85rem;
  }
  .difficulty-badge { font-size: .7rem; padding: 3px 8px; }
  .game-action-bar { gap: 8px; }
  .btn-game { padding: 10px 12px; font-size: .9rem; }
  .sudoku-board-wrap,
  .patches-board-wrap,
  .tango-board-wrap,
  .zip-board-wrap,
  .cc-board-wrap,
  .queens-board-wrap,
  .wend-board-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
  }
  .hub-hero h2 { font-size: 1.2rem; }
  .stats-row { gap: 8px; }
  .stat-card .num { font-size: 1.25rem; }
  .tabs { overflow-x: auto; flex-wrap: nowrap; }
}

@media (max-width: 480px) {
  .grid-cell { width: 32px; height: 32px; }
  .grid-cell.sm { width: 28px; height: 28px; }
  .cc-board { padding: 16px 10px; }
  .cc-cell { min-width: 34px; font-size: 1rem; }
  .cc-guess-input { font-size: 1rem; letter-spacing: 0.15em; }
}
