/* ============================================================
   7Deer Math — global stylesheet
   ============================================================ */

:root {
  --bg: #faf7f2;
  --panel: #ffffff;
  --ink: #21263a;
  --muted: #6b7286;
  --line: #e8e2d8;
  --brand: #f4633a;
  --brand-dark: #d94f28;
  --teal: #14a89a;
  --teal-soft: #dcf3f0;
  --yellow: #ffc233;
  --purple: #7c5cff;
  --purple-soft: #ece6ff;
  --green: #2fa864;
  --green-soft: #e0f5e9;
  --red: #e5484d;
  --red-soft: #fde8e8;
  --blue: #3d7bd9;
  --blue-soft: #e4edfb;
  --shadow: 0 2px 10px rgba(33, 38, 58, 0.07), 0 10px 30px rgba(33, 38, 58, 0.06);
  --radius: 16px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue",
    Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

main { flex: 1; }

a { color: var(--brand-dark); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { line-height: 1.25; }

/* ---------- top navigation ---------- */

.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--line);
}

.topnav-inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 18px;
  flex-wrap: wrap;
}

.brand {
  font-weight: 800;
  font-size: 19px;
  letter-spacing: -0.2px;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 8px;
}
.brand:hover { text-decoration: none; }
.brand .logo { font-size: 22px; }

.nav-links {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-left: auto;
}

.nav-links a {
  padding: 7px 12px;
  border-radius: 10px;
  color: var(--muted);
  font-weight: 600;
  font-size: 14.5px;
}
.nav-links a:hover { background: #f1ece3; color: var(--ink); text-decoration: none; }
.nav-links a.active { background: var(--brand); color: #fff; }

.nav-links a .daily-dot {
  display: inline-block;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--teal);
  margin-left: 5px;
  vertical-align: middle;
}

/* ---------- layout ---------- */

.wrap {
  max-width: 1040px;
  margin: 0 auto;
  padding: 26px 20px 60px;
  width: 100%;
}

.game-wrap {
  max-width: 640px;
  margin: 0 auto;
}

.page-title {
  font-size: 26px;
  font-weight: 800;
  margin: 6px 0 2px;
  letter-spacing: -0.3px;
}
.page-sub {
  color: var(--muted);
  margin: 0 0 18px;
  font-size: 15px;
}

/* ---------- buttons & chips ---------- */

.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.06s ease, box-shadow 0.12s ease, background 0.12s ease;
}
.btn:hover { box-shadow: var(--shadow); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: default; box-shadow: none; }

.btn-primary {
  background: var(--brand);
  border-color: var(--brand);
  color: #fff;
}
.btn-primary:hover { background: var(--brand-dark); }

.btn-teal { background: var(--teal); border-color: var(--teal); color: #fff; }
.btn-teal:hover { filter: brightness(0.93); }

.btn-ghost { background: transparent; }

.btn-sm { padding: 6px 12px; font-size: 13.5px; border-radius: 10px; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 14px;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--muted);
}
.chip b { color: var(--ink); font-size: 15px; }

.hud {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin: 0 0 14px;
}
.hud .spacer { flex: 1; }

/* ---------- panels ---------- */

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

.panel-title {
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--muted);
  font-weight: 800;
  margin: 0 0 10px;
}

/* ---------- home page ---------- */

.hero {
  padding: 46px 8px 30px;
  text-align: center;
}
.hero h1 {
  font-size: 40px;
  margin: 0 0 10px;
  letter-spacing: -0.8px;
}
.hero h1 .accent { color: var(--brand); }
.hero p {
  color: var(--muted);
  font-size: 17px;
  max-width: 560px;
  margin: 0 auto 22px;
}
.hero-badges {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.game-cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
  margin: 26px 0;
}

.game-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  color: var(--ink);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  position: relative;
}
.game-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 6px 22px rgba(33, 38, 58, 0.12);
  text-decoration: none;
}
.game-card .icon {
  width: 52px; height: 52px;
  border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 27px;
}
.game-card h3 { margin: 0; font-size: 19px; }
.game-card p { margin: 0; color: var(--muted); font-size: 14.5px; }
.game-card .tag {
  position: absolute;
  top: 14px; right: 14px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  color: var(--teal);
  background: var(--teal-soft);
  border-radius: 999px;
  padding: 4px 10px;
}

.icon-bg-orange { background: #ffe8de; }
.icon-bg-teal { background: var(--teal-soft); }
.icon-bg-purple { background: var(--purple-soft); }
.icon-bg-green { background: var(--green-soft); }
.icon-bg-blue { background: var(--blue-soft); }
.icon-bg-yellow { background: #fff3d6; }

.daily-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin: 10px 0 34px;
}
.daily-card {
  background: linear-gradient(135deg, #fff8ef, #fff);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
}
.daily-card:hover { text-decoration: none; box-shadow: var(--shadow); }
.daily-card .icon { font-size: 24px; }
.daily-card b { display: block; }
.daily-card span { color: var(--muted); font-size: 13px; }
.daily-card.done { opacity: 0.62; }

.section-h {
  font-size: 21px;
  font-weight: 800;
  margin: 34px 0 6px;
  letter-spacing: -0.3px;
}
.section-p { color: var(--muted); margin: 0 0 14px; max-width: 640px; }

.seo-copy { max-width: 760px; color: #3c4257; font-size: 15px; }
.seo-copy h2 { font-size: 20px; margin: 26px 0 8px; }

/* ---------- game shell ---------- */

.game-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 6px;
  flex-wrap: wrap;
}
.game-head .page-title { margin: 0; }

.mode-tabs {
  display: inline-flex;
  background: #efe9df;
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}
.mode-tabs button {
  appearance: none;
  border: 0;
  background: transparent;
  font-family: inherit;
  font-weight: 700;
  font-size: 13.5px;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  color: var(--muted);
}
.mode-tabs button.active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 4px rgba(33, 38, 58, 0.12);
}

.board-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 14px 0;
}

.center { text-align: center; }

.hint-text {
  color: var(--muted);
  font-size: 13.5px;
  text-align: center;
  margin: 10px 0 0;
}

/* ---------- win overlay ---------- */

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(24, 28, 44, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 60;
  padding: 20px;
}
.overlay.hidden { display: none; }
.overlay .panel {
  max-width: 380px;
  width: 100%;
  text-align: center;
  animation: pop 0.25s ease;
}
@keyframes pop {
  from { transform: scale(0.9); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}
.overlay h2 { margin: 4px 0 6px; font-size: 24px; }
.overlay .stars { font-size: 34px; letter-spacing: 6px; margin: 6px 0; }
.overlay .stars .dim { color: #dcd6ca; }
.overlay .sub { color: var(--muted); margin: 0 0 16px; }
.overlay .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }

/* ---------- toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 18px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: all 0.25s ease;
  z-index: 80;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- how-to ---------- */

details.howto {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 4px 18px;
  margin: 16px 0;
}
details.howto summary {
  cursor: pointer;
  font-weight: 800;
  padding: 12px 0;
  font-size: 15px;
}
details.howto ul { margin: 8px 0 14px; padding-left: 20px; color: #3c4257; }
details.howto li { margin: 5px 0; }

/* ---------- footer ---------- */

.site-footer {
  border-top: 1px solid var(--line);
  background: #fff;
  margin-top: 40px;
}
.site-footer .inner {
  max-width: 1040px;
  margin: 0 auto;
  padding: 22px 20px;
  color: var(--muted);
  font-size: 13.5px;
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  align-items: center;
}
.site-footer a { color: var(--muted); font-weight: 600; }

/* ============================================================
   Sixsum
   ============================================================ */

.sixsum-target {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}
.sixsum-target .big {
  font-size: 46px;
  font-weight: 800;
  letter-spacing: -1px;
  color: var(--brand);
}
.sixsum-target .meta {
  color: var(--muted);
  font-size: 13.5px;
  text-align: right;
}

.tile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.num-tile {
  appearance: none;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 14px;
  font-family: inherit;
  font-size: 26px;
  font-weight: 800;
  color: var(--ink);
  padding: 16px 6px;
  cursor: pointer;
  position: relative;
  transition: border-color 0.1s ease, background 0.1s ease, transform 0.08s ease;
}
.num-tile:active { transform: scale(0.96); }
.num-tile.selected { border-color: var(--brand); background: #fff1eb; }
.num-tile.used {
  opacity: 0.32;
  text-decoration: line-through;
  cursor: default;
  pointer-events: none;
}
.num-tile.result { background: var(--teal-soft); border-color: #bfe5e0; }
.num-tile.just-merged { animation: mergedPop 0.3s ease; }
@keyframes mergedPop {
  0% { transform: scale(0.7); }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); }
}
.num-tile.shake { animation: shake 0.3s ease; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.op-pad {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.op-btn {
  appearance: none;
  border: 2px solid var(--line);
  background: #fff;
  border-radius: 14px;
  font-size: 24px;
  font-weight: 800;
  padding: 10px 0;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  transition: all 0.1s ease;
}
.op-btn:hover { border-color: #cfc8ba; }
.op-btn.selected { border-color: var(--brand); background: #fff1eb; color: var(--brand); }
.op-btn:disabled { opacity: 0.4; cursor: default; }

.sixsum-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 4px;
}

.closest-note { text-align: center; color: var(--muted); font-size: 13.5px; margin: 12px 0 0; }

/* ============================================================
   Sumcode
   ============================================================ */

.crypt-eq {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  margin: 6px 0 16px;
  font-family: "SF Mono", ui-monospace, Menlo, Consolas, monospace;
}
.crypt-row {
  display: flex;
  gap: 5px;
}
.crypt-cell {
  width: 40px; height: 46px;
  border: 2px solid var(--line);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-size: 22px;
  font-weight: 800;
  background: #fff;
}
.crypt-cell.leader { border-bottom-width: 4px; }
.crypt-line { width: 200px; height: 3px; background: var(--ink); border-radius: 2px; margin: 4px 0; }
.crypt-op { font-size: 22px; font-weight: 800; align-self: flex-end; margin-right: 4px; }
.crypt-eq.wrong .crypt-cell { border-color: var(--red); background: var(--red-soft); }

.map-grid {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-top: 8px;
}
.map-row {
  display: grid;
  grid-template-columns: 44px repeat(10, 1fr);
  gap: 5px;
  align-items: center;
}
.map-row .letter {
  font-weight: 800;
  font-size: 18px;
  text-align: center;
  background: var(--purple-soft);
  color: var(--purple);
  border-radius: 8px;
  padding: 6px 0;
}
.digit-cell {
  appearance: none;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  padding: 7px 0;
  cursor: pointer;
  color: var(--ink);
}
.digit-cell:hover { border-color: #cfc8ba; }
.digit-cell.taken { opacity: 0.35; cursor: default; }
.digit-cell.assigned { background: var(--purple); border-color: var(--purple); color: #fff; }
.digit-cell.locked { background: var(--green); border-color: var(--green); color: #fff; cursor: default; }

.sumcode-status {
  display: flex;
  justify-content: space-between;
  color: var(--muted);
  font-size: 13.5px;
  margin-top: 14px;
  flex-wrap: wrap;
  gap: 8px;
}

/* ============================================================
   Opmaze
   ============================================================ */

.maze-statusbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.maze-statusbar .val {
  font-size: 15px;
  color: var(--muted);
}
.maze-statusbar .val b {
  font-size: 24px;
  color: var(--ink);
  margin: 0 3px;
}
.maze-statusbar .val b.goal { color: var(--brand); }

.maze-grid {
  display: grid;
  gap: 5px;
  position: relative;
  margin: 0 auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.maze-cell {
  border-radius: 9px;
  background: #f2ede4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  aspect-ratio: 1;
  color: var(--muted);
  transition: background 0.1s ease;
}
.maze-cell.op-plus { background: var(--green-soft); color: var(--green); }
.maze-cell.op-minus { background: var(--red-soft); color: var(--red); }
.maze-cell.op-times { background: var(--blue-soft); color: var(--blue); }
.maze-cell.op-div { background: var(--purple-soft); color: var(--purple); }
.maze-cell.wall { background: #d8d2c6; box-shadow: inset 0 0 0 3px #cfc8ba; }
.maze-cell.start { background: #fff3d6; color: #a06a00; }
.maze-cell.exit { background: var(--brand); color: #fff; font-size: 16px; }
.maze-cell.invalid { animation: shake 0.3s ease; }

.maze-token {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  border-radius: 50%;
  background: var(--ink);
  color: #fff;
  box-shadow: 0 4px 10px rgba(33, 38, 58, 0.35);
  z-index: 5;
  transition: left 0.12s ease, top 0.12s ease;
  pointer-events: none;
}
.maze-token .v {
  font-size: 15px;
}
.maze-token.bump { animation: shake 0.25s ease; }

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 62px);
  grid-template-rows: repeat(2, 46px);
  gap: 6px;
  justify-content: center;
  margin-top: 16px;
}
.dpad button {
  appearance: none;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font-size: 19px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
}
.dpad button:active { background: var(--teal-soft); }
.dpad .d-up { grid-column: 2; grid-row: 1; }
.dpad .d-left { grid-column: 1; grid-row: 2; }
.dpad .d-down { grid-column: 2; grid-row: 2; }
.dpad .d-right { grid-column: 3; grid-row: 2; }

/* ============================================================
   Balanzo
   ============================================================ */

.scale-scene {
  position: relative;
  max-width: 540px;
  height: 158px;
  margin: 0 auto;
}
.scale-post {
  position: absolute;
  top: 26px;
  left: 50%;
  transform: translateX(-50%);
  width: 12px;
  height: 128px;
  background: linear-gradient(#cbbfa8, #b3a68c);
  border-radius: 6px;
  z-index: 0;
}
.scale-base {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 12px;
  background: #b3a68c;
  border-radius: 6px;
  z-index: 0;
}
.scale-beam {
  position: absolute;
  top: 20px;
  left: 0;
  right: 0;
  height: 12px;
  background: linear-gradient(#a8926b, #8f7a55);
  border-radius: 8px;
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
  transform-origin: 50% 50%;
  z-index: 2;
}
.scale-beam::before {
  content: "";
  position: absolute;
  left: 50%; top: 50%;
  width: 24px; height: 24px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: #6e5c3e;
  border: 4px solid #5c4d33;
  z-index: 3;
}
.scale-pan {
  position: absolute;
  top: 14px;
  width: 42%;
  min-height: 84px;
  max-height: 130px;
  overflow-y: auto;
  background: var(--teal-soft);
  border: 2px solid #bfe5e0;
  border-radius: 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-content: flex-start;
  padding: 7px;
  transition: transform 0.45s cubic-bezier(0.34, 1.4, 0.64, 1);
  z-index: 1;
}
.scale-pan.left { left: 0; }
.scale-pan.right { right: 0; }

.wblock {
  min-width: 38px;
  height: 38px;
  padding: 0 8px;
  border-radius: 10px;
  background: var(--yellow);
  color: #6b4d00;
  font-weight: 800;
  font-size: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  cursor: pointer;
  font-family: inherit;
  box-shadow: 0 2px 0 #d9a929;
  transition: transform 0.08s ease;
}
.wblock:active { transform: scale(0.94); }
.wblock.on-left { background: #ffd9c7; color: #8a3d16; box-shadow: 0 2px 0 #eab08d; }
.wblock.on-pan { background: var(--teal); color: #fff; box-shadow: 0 2px 0 #0d8076; }
.wblock.shake { animation: shake 0.3s ease; }

.inventory {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  min-height: 48px;
  margin-top: 16px;
  padding: 8px;
  border: 2px dashed var(--line);
  border-radius: 14px;
  background: #fffdf9;
}

.balanzo-sums {
  display: flex;
  justify-content: space-between;
  font-weight: 800;
  color: var(--muted);
  margin-top: 10px;
  font-size: 14px;
}
.balanzo-sums .balanced { color: var(--green); }

/* ============================================================
   Sumstack
   ============================================================ */

.stack-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 10px 6px 6px;
  background: linear-gradient(#f4efe6, #fbf8f2);
  border: 2px solid var(--line);
  border-radius: 14px;
}
.stack-col {
  position: relative;
  min-height: 320px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 4px;
  border-radius: 10px;
  cursor: pointer;
  padding-bottom: 4px;
}
.stack-col:hover { background: rgba(20, 168, 154, 0.07); }
.stack-col.droptarget { background: rgba(20, 168, 154, 0.14); }
.stack-col.danger { background: var(--red-soft); }

.sblock {
  height: 34px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 17px;
  color: #fff;
  background: var(--teal);
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.15);
  transition: transform 0.15s ease, opacity 0.2s ease;
}
.sblock.c1 { background: #14a89a; }
.sblock.c2 { background: #3d7bd9; }
.sblock.c3 { background: #7c5cff; }
.sblock.c4 { background: #f4633a; }
.sblock.clearing { animation: blockClear 0.35s ease forwards; }
@keyframes blockClear {
  0% { transform: scale(1); opacity: 1; }
  40% { transform: scale(1.15); }
  100% { transform: scale(0.2); opacity: 0; }
}
.sblock.fall { animation: blockFall 0.18s ease-in; }
@keyframes blockFall {
  from { transform: translateY(-46px); opacity: 0.4; }
  to { transform: translateY(0); opacity: 1; }
}

.stack-col .colsum {
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  color: #b3ab9c;
  padding-top: 2px;
}

.next-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: center;
  margin: 14px 0 4px;
}
.next-preview .label { color: var(--muted); font-size: 13.5px; font-weight: 700; }
.next-preview .sblock { width: 52px; }

.score-pop {
  position: absolute;
  font-weight: 800;
  font-size: 18px;
  color: var(--brand);
  pointer-events: none;
  animation: scorePop 0.8s ease forwards;
  z-index: 10;
}
@keyframes scorePop {
  from { transform: translateY(0); opacity: 1; }
  to { transform: translateY(-42px); opacity: 0; }
}

/* ============================================================
   Hero grid (home first screen with playable sudoku)
   ============================================================ */

.hero-grid {
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  gap: 30px;
  align-items: center;
  padding: 26px 0 8px;
  text-align: left;
}
.hero-grid .hero-copy h1 { font-size: 34px; margin-bottom: 12px; }
.hero-grid .hero-copy p { font-size: 15.5px; margin-bottom: 18px; }
.hero-grid .hero-badges { justify-content: flex-start; }

.hero-game {
  padding: 16px;
  max-width: 470px;
  width: 100%;
  justify-self: center;
}
.hero-game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}
.hero-game-head h2 {
  font-size: 17px;
  margin: 0;
  display: flex;
  align-items: center;
  gap: 8px;
}
.hero-game-head .chip { font-size: 12px; padding: 3px 10px; }
.hero-full-link { font-size: 13px; font-weight: 700; white-space: nowrap; }

/* ============================================================
   Sudoku
   ============================================================ */

.sud-root { user-select: none; -webkit-user-select: none; }

.sud-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.sud-title { font-weight: 800; font-size: 14.5px; }
.sud-status {
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
}
.sud-status b { color: var(--ink); }

.sud-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: var(--ink);
  touch-action: manipulation;
}
.sud-cell {
  aspect-ratio: 1;
  background: #fff;
  border: 0.5px solid #e6e0d5;
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(13px, 3.6vw, 21px);
  color: var(--teal);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.08s ease;
}
.sud-cell.given { color: var(--ink); background: #f8f4ec; cursor: default; }
.sud-cell.b-right { border-right: 2px solid var(--ink); }
.sud-cell.b-bottom { border-bottom: 2px solid var(--ink); }
.sud-cell.same { background: #ffe8de; }
.sud-cell.sel { background: var(--brand) !important; color: #fff !important; }
.sud-cell.wrong { color: var(--red) !important; }
.sud-cell.conflict { background: var(--red-soft); }

.sud-numpad {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  gap: 6px;
  margin-top: 12px;
}
.sud-key {
  appearance: none;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 9px;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(15px, 3.4vw, 19px);
  padding: 9px 0;
  cursor: pointer;
  color: var(--ink);
}
.sud-key:hover { border-color: #cfc8ba; }
.sud-key:active { transform: scale(0.94); background: var(--teal-soft); }

.sud-tools {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-top: 10px;
  justify-content: center;
}

@media (max-width: 900px) {
  .hero-grid { grid-template-columns: 1fr; padding-top: 18px; }
  .hero-grid .hero-copy { text-align: center; }
  .hero-grid .hero-copy h1 { font-size: 27px; }
  .hero-grid .hero-badges { justify-content: center; }
  .hero-game { margin: 0 auto; }
}

/* ---------- win banner (auto-advance) ---------- */

.win-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1.5px solid var(--green);
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(33, 38, 58, 0.22);
  padding: 12px 16px 14px;
  z-index: 70;
  display: flex;
  align-items: center;
  gap: 14px;
  max-width: min(92vw, 560px);
  overflow: hidden;
  animation: bannerIn 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}
@keyframes bannerIn {
  from { transform: translateX(-50%) translateY(-16px); opacity: 0; }
  to { transform: translateX(-50%) translateY(0); opacity: 1; }
}
.win-banner .wb-main { display: flex; flex-direction: column; gap: 2px; }
.win-banner .wb-title { font-weight: 800; font-size: 16px; }
.win-banner .stars { font-size: 16px; letter-spacing: 3px; color: var(--yellow); }
.win-banner .stars .dim { color: #e2dccd; }
.win-banner .wb-sub { color: var(--muted); font-size: 12.5px; }
.win-banner .wb-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.win-banner .wb-timer {
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: 100%;
  background: var(--green);
  transform-origin: left;
  animation: wbTimer 3.2s linear forwards;
}
@keyframes wbTimer {
  from { transform: scaleX(1); }
  to { transform: scaleX(0); }
}

@media (max-width: 560px) {
  .win-banner { flex-direction: column; align-items: stretch; gap: 8px; top: 64px; }
  .win-banner .wb-actions .btn { flex: 1; }
}

/* ---------- friend invite banner (share link with progress params) ---------- */

.friend-banner {
  position: fixed;
  top: 72px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1.5px solid var(--teal);
  border-radius: 14px;
  box-shadow: 0 10px 34px rgba(33, 38, 58, 0.22);
  padding: 12px 14px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(92vw, 560px);
  animation: bannerIn 0.28s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.friend-banner .fb-main { display: flex; flex-direction: column; gap: 2px; }
.friend-banner .fb-title { font-weight: 800; font-size: 15px; }
.friend-banner .fb-sub { color: var(--muted); font-size: 12.5px; }

@media (max-width: 560px) {
  .friend-banner { flex-direction: column; align-items: stretch; gap: 8px; top: 64px; }
}

/* ---------- share fallback modal ---------- */

.share-box {
  width: 100%;
  min-height: 84px;
  border: 1.5px solid var(--line);
  border-radius: 10px;
  padding: 10px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--ink);
  resize: none;
  background: #fffdf9;
  margin-bottom: 12px;
}

/* ============================================================
   Calcage
   ============================================================ */

.grid-statusbar {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.cag-board {
  display: grid;
  border: 2.5px solid var(--ink);
  border-radius: 10px;
  overflow: hidden;
  background: #fff;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  max-width: 430px;
  margin: 0 auto;
}
.cag-cell {
  position: relative;
  aspect-ratio: 1;
  background: #fff;
  border: 0.5px solid #e6e0d5;
  border-radius: 0;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(15px, 4.2vw, 22px);
  color: var(--teal);
  cursor: pointer;
  padding: 0;
  line-height: 1;
  transition: background 0.08s ease;
}
.cag-cell.br-cage { border-right: 2px solid var(--ink); }
.cag-cell.bb-cage { border-bottom: 2px solid var(--ink); }
.cag-cell.given { background: #f8f4ec; color: var(--ink); cursor: default; }
.cag-cell.sel { background: var(--brand) !important; color: #fff !important; }
.cag-cell.same { background: #ffe8de; }
.cag-cell.hinted { color: var(--purple); }
.cag-cell.dup { color: var(--red) !important; background: var(--red-soft) !important; }
.cag-cell.cage-ok { background: var(--green-soft); }
.cag-cell.cage-bad { background: var(--red-soft); }
.cag-clue {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  line-height: 1;
  pointer-events: none;
}

.grid-numpad {
  display: flex;
  gap: 6px;
  justify-content: center;
  margin-top: 12px;
  flex-wrap: wrap;
}
.grid-key {
  appearance: none;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 9px;
  font-family: inherit;
  font-weight: 800;
  font-size: 18px;
  min-width: 44px;
  padding: 9px 0;
  cursor: pointer;
  color: var(--ink);
}
.grid-key:hover { border-color: #cfc8ba; }
.grid-key:active { transform: scale(0.94); background: var(--teal-soft); }
.grid-key-erase { min-width: 58px; }

.grid-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 12px;
}

/* ============================================================
   Futoshiki
   ============================================================ */

.futo-board {
  display: grid;
  max-width: 430px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.futo-cell {
  aspect-ratio: 1;
  background: #fff;
  border: 1px solid #ddd6c8;
  border-radius: 8px;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(15px, 4vw, 21px);
  color: var(--teal);
  cursor: pointer;
  padding: 0;
  line-height: 1;
}
.futo-cell.given { background: #f8f4ec; color: var(--ink); cursor: default; }
.futo-cell.sel { background: var(--purple) !important; border-color: var(--purple) !important; color: #fff !important; }
.futo-cell.same { background: var(--purple-soft); }
.futo-cell.hinted { color: var(--purple); }
.futo-cell.dup { color: var(--red) !important; background: var(--red-soft) !important; }
.futo-sign {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 15px;
  color: var(--purple);
  user-select: none;
  -webkit-user-select: none;
}
.futo-sign.point-down { transform: rotate(90deg); }
.futo-sign.point-up { transform: rotate(-90deg); }

/* ============================================================
   Hanoi
   ============================================================ */

.han-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin: 0 auto;
  max-width: 480px;
}
.han-rod {
  position: relative;
  height: 268px;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
  padding-bottom: 10px;
  border-radius: 12px;
  cursor: pointer;
}
.han-rod::before {
  content: "";
  position: absolute;
  bottom: 8px;
  left: 50%;
  transform: translateX(-50%);
  width: 10px;
  height: calc(100% - 8px);
  background: linear-gradient(#cbbfa8, #b3a68c);
  border-radius: 6px;
  z-index: 0;
}
.han-rod::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 4%;
  right: 4%;
  height: 10px;
  background: #b3a68c;
  border-radius: 6px;
  z-index: 0;
}
.han-rod.droptarget { background: rgba(20, 168, 154, 0.1); }
.han-rod.lift-source { background: rgba(244, 99, 58, 0.08); }

.han-disk {
  position: relative;
  z-index: 1;
  height: 27px;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 14px;
  color: #fff;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.18);
  pointer-events: none;
  transition: transform 0.12s ease;
}
.han-disk.d1 { background: #14a89a; }
.han-disk.d2 { background: #3d7bd9; }
.han-disk.d3 { background: #7c5cff; }
.han-disk.d4 { background: #f4633a; }
.han-disk.d5 { background: #2fa864; }
.han-disk.d6 { background: #e5484d; }
.han-disk.d7 { background: #d97706; }
.han-disk.d8 { background: #21263a; }
.han-disk.lifted { transform: translateY(-32px); outline: 2.5px solid var(--brand); }

.han-label {
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  font-weight: 800;
  color: #c9c2b4;
  font-size: 13px;
  z-index: 0;
}

.han-status {
  display: flex;
  justify-content: center;
  gap: 22px;
  color: var(--muted);
  font-size: 14px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.han-status b { color: var(--ink); }

/* ============================================================
   Sumplete
   ============================================================ */

.sum-board {
  display: grid;
  gap: 4px;
  max-width: 430px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.sum-cell {
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 10px;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(16px, 4.4vw, 22px);
  color: var(--ink);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
  transition: all 0.1s ease;
}
.sum-cell:active { transform: scale(0.95); }
.sum-cell.out {
  background: #f1ece3;
  color: #b3ab9c;
  text-decoration: line-through;
  border-color: #e8e2d8;
}
.sum-cell.hinted { outline: 2px solid var(--teal); }

.sum-target {
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--muted);
  background: #fffdf9;
  border: 1.5px dashed var(--line);
  border-radius: 10px;
  padding: 2px 4px;
  text-align: center;
}
.sum-target .met { color: var(--green); }
.sum-corner { color: #d8d2c6; }

/* ============================================================
   Picross
   ============================================================ */

.pic-board {
  display: grid;
  gap: 3px;
  max-width: 460px;
  margin: 0 auto;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}
.pic-clue {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-weight: 800;
  font-size: 11.5px;
  color: var(--ink);
  background: #f8f4ec;
  border-radius: 7px;
}
.pic-clue-col { flex-direction: column; justify-content: flex-end; padding: 3px 2px; }
.pic-clue-row { justify-content: flex-end; padding: 2px 5px; }
.pic-clue.done { color: #c9c2b4; }

.pic-cell {
  aspect-ratio: 1;
  border: 1.5px solid var(--line);
  background: #fff;
  border-radius: 6px;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(10px, 2.6vw, 14px);
  color: #cfc8ba;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.pic-cell.filled { background: var(--purple); border-color: var(--purple); color: #fff; }
.pic-cell.wrong { background: var(--red-soft); border-color: var(--red); color: var(--red); }
.pic-cell.hinted { outline: 2px solid var(--teal); }
.pic-cell.flash { animation: shake 0.3s ease; }

.pic-tools {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  flex-wrap: wrap;
  margin-top: 14px;
}
.pic-mode {
  display: inline-flex;
  background: #efe9df;
  border-radius: 12px;
  padding: 3px;
  gap: 3px;
}
.pic-mode .btn { border: 0; background: transparent; box-shadow: none; }
.pic-mode .btn.active { background: #fff; box-shadow: 0 1px 4px rgba(33, 38, 58, 0.12); }

/* ---------- responsive ---------- */
@media (max-width: 640px) {
  .hero h1 { font-size: 30px; }
  .page-title { font-size: 22px; }
  .wrap { padding: 18px 14px 44px; }
  .crypt-cell { width: 32px; height: 40px; font-size: 18px; }
  .maze-cell { font-size: 11.5px; border-radius: 6px; }
  .maze-token .v { font-size: 12px; }
  .stack-col { min-height: 250px; }
  .sblock { height: 30px; font-size: 15px; }
  .sixsum-target .big { font-size: 36px; }
  .cag-board { max-width: 100%; }
  .futo-board { max-width: 100%; }
  .futo-sign { font-size: 13px; }
  .han-rod { height: 230px; }
  .han-disk { height: 24px; font-size: 12.5px; }
  .sum-board { max-width: 100%; }
  .sum-target { font-size: 11.5px; padding: 2px; }
  .pic-board { max-width: 100%; }
  .pic-clue { font-size: 10px; }
}
