/* Chess: a cozy cat café look. Mobile first (390 x 844), down to 360 wide. */
:root {
  --bg-top: #f6ecdf;
  --bg-low: #e8d3bb;
  --ink: #2d2421;
  --ink-soft: #6b5a52;
  --card: #fffaf3;
  --line: rgba(45, 36, 33, 0.12);
  --accent: #c2643c;
  --accent-dk: #9b4b28;
  --good: #3f8f55;
  --bad: #c0392f;
  --shadow: 0 10px 24px -16px rgba(60, 34, 20, 0.55);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: "Baloo 2", ui-rounded, system-ui, sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 85% 6%, rgba(255, 247, 232, 0.9), transparent 40%),
    linear-gradient(180deg, var(--bg-top), var(--bg-low)) fixed;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }

.app { max-width: 560px; margin: 0 auto; padding: calc(var(--sg-corner-top) - 2px) 12px calc(var(--safe-bottom) + 18px); } /* every screen's first row (48px) centers the corner (shared/menu.css) */
.app .sg-corner-slot { margin-left: calc(var(--sg-corner-left) - 12px); }

/* ---------- buttons ---------- */
.icon-btn {
  display: grid; place-items: center; width: 44px; height: 44px; border: 0; border-radius: 14px;
  background: rgba(255, 250, 243, 0.85); box-shadow: var(--shadow); cursor: pointer; flex: none;
}
.icon-btn svg, .act .ico svg, .link-btn .ico svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; }
.btn {
  min-height: 48px; padding: 8px 18px; border: 0; border-radius: 16px; cursor: pointer;
  font-weight: 800; font-size: 18px; line-height: 1.1;
}
.btn.primary { background: var(--accent); color: #fff; box-shadow: 0 6px 0 var(--accent-dk); }
.btn.primary:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--accent-dk); }
.btn.ghost { background: rgba(45, 36, 33, 0.07); }
.btn.danger { background: var(--bad); color: #fff; }
.btn.wide { display: block; width: 100%; margin-top: 12px; }
.btn:disabled { opacity: 0.5; }
.row-buttons { display: flex; gap: 10px; margin-top: 14px; }
.row-buttons .btn { flex: 1; }
.stack-buttons { display: grid; gap: 10px; margin-top: 14px; }

/* ---------- lobby ---------- */
.lobby-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; }
.account-slot { min-width: 0; }
.account-slot .acct-chip { max-width: 100%; }
.hero { display: flex; align-items: center; gap: 12px; margin: 4px 0 14px; }
.hero-cat { flex: none; width: 84px; }
.hero-cat svg { display: block; width: 84px; height: auto; }
.hero h1 { margin: 0; font-size: 40px; line-height: 1.05; font-weight: 800; }
.menu-account { display: grid; gap: 8px; margin: 0 0 12px; }
.hero p { margin: 4px 0 0; color: var(--ink-soft); font-size: 16px; line-height: 1.3; }

.card { background: var(--card); border-radius: 22px; padding: 14px 14px 16px; box-shadow: var(--shadow); margin-bottom: 14px; }
.card h2 { margin: 0 0 4px; font-size: 22px; }
.card.quiet { padding: 10px 12px 12px; }
.card.quiet h2 { font-size: 17px; }
.card.quiet h3 { display: none; }
.card.quiet .muted { margin: 2px 0 8px; font-size: 14px; }
.card.quiet .btn { min-height: 44px; font-size: 15px; }
.card h3 { margin: 10px 0 6px; font-size: 15px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.muted { color: var(--ink-soft); margin: 6px 0; font-size: 15px; line-height: 1.35; }
.lede { color: var(--ink-soft); margin: 4px 0 10px; line-height: 1.35; }

.tables { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.trow {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 56px; padding: 8px 10px;
  border: 0; border-radius: 16px; background: rgba(45, 36, 33, 0.05); text-align: left; cursor: pointer;
}
.trow.yours { background: #fdebd9; box-shadow: inset 0 0 0 2px #f0b98f; }
.trow .tw { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.trow .tw b { font-size: 17px; line-height: 1.15; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.trow .tw small { color: var(--ink-soft); font-size: 14px; line-height: 1.2; }
.badge { flex: none; padding: 4px 10px; border-radius: 999px; font-weight: 800; font-size: 14px; background: rgba(45, 36, 33, 0.08); }
.badge.go, .badge.join { background: var(--accent); color: #fff; }
.badge.won { background: #dcefdc; color: #24683a; }
.badge.lost { background: #f6dcd8; color: #8c2c22; }

.resume {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 64px; margin-bottom: 14px; padding: 8px 12px;
  border: 0; border-radius: 20px; background: #fdebd9; box-shadow: var(--shadow); cursor: pointer; text-align: left;
}
.resume img { width: 48px; height: 48px; }
.resume span:not(.go) { flex: 1; display: flex; flex-direction: column; }
.resume small { color: var(--ink-soft); }
.resume .go svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0; min-height: 112px; padding: 10px 12px 12px;
  border: 0; border-radius: 20px; background: var(--card); box-shadow: var(--shadow); cursor: pointer; text-align: left;
}
.tile img { width: 52px; height: 52px; margin-bottom: 2px; }
.tile b { font-size: 19px; line-height: 1.1; }
.tile small { color: var(--ink-soft); font-size: 14px; line-height: 1.2; }
.tile:active, .trow:active, .resume:active { transform: scale(0.98); }

.lobby-links { display: grid; gap: 8px; margin-bottom: 14px; }
.link-btn {
  display: flex; align-items: center; gap: 10px; min-height: 52px; padding: 6px 14px 6px 8px; border: 0; border-radius: 16px;
  background: rgba(255, 250, 243, 0.8); box-shadow: var(--shadow); font-weight: 800; font-size: 17px; cursor: pointer; text-align: left;
}
.link-btn .ico { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: #e9a325; color: #fff; }
.link-btn .ico img { width: 34px; height: 34px; }
.link-btn:nth-child(2) .ico { background: #f3e1cc; }
.finished summary { min-height: 44px; display: flex; align-items: center; font-weight: 800; font-size: 18px; cursor: pointer; }
.finished .tables { margin-top: 6px; }
.save-slot { margin-top: 4px; }

/* ---------- the game screen ---------- */
.play-top { display: flex; align-items: center; gap: 8px; min-height: 48px; margin-bottom: 4px; }
.play-top-end { flex: none; width: 44px; }
.play-top h1 { flex: 1; margin: 0; font-size: 19px; line-height: 1.15; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.player { display: flex; align-items: center; gap: 8px; min-height: 50px; padding: 4px 6px; border-radius: 16px; }
.player.to-move { background: rgba(255, 250, 243, 0.75); }
.player .who { display: flex; flex-direction: column; min-width: 0; flex: 0 1 auto; max-width: 34%; }
.player .who b { font-size: 16px; line-height: 1.1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.player .who small { font-size: 13px; color: var(--ink-soft); line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.seat-empty, .seat-cpu, .seat-color {
  display: grid; place-items: center; width: 36px; height: 36px; flex: none; border-radius: 50%;
  background: rgba(45, 36, 33, 0.1); font-weight: 800; color: var(--ink-soft);
}
.seat-cpu { background: #f3e1cc; overflow: hidden; }
.seat-cpu img { width: 36px; height: 36px; }
.seat-color.w { background: #fbf6ec; box-shadow: inset 0 0 0 2px #2b2421; }
.seat-color.b { background: #3d3532; }

/* captured pieces nap in a cat bed */
.bed { position: relative; flex: 1; min-width: 40px; height: 34px; }
.bed.empty { visibility: hidden; }
.bed-art { position: absolute; inset: 6px 0 0; }
.bed-art svg { width: 100%; height: 100%; display: block; }
.nappers { position: absolute; left: 10%; right: 10%; top: 0; bottom: 4px; display: flex; align-items: center; justify-content: center; flex-wrap: nowrap; }
.napper { width: 22px; height: 22px; margin: 0 -5px; transform: rotate(-80deg) translateX(-3px); filter: drop-shadow(0 1px 0 rgba(0, 0, 0, 0.15)); }
.ahead { flex: none; font-weight: 800; font-size: 14px; color: var(--ink-soft); }
.clock {
  flex: none; margin-left: auto; min-width: 74px; padding: 3px 10px; border-radius: 12px; text-align: center;
  background: rgba(45, 36, 33, 0.08); font-weight: 800; font-size: 20px; font-variant-numeric: tabular-nums;
}
.clock.on { background: var(--ink); color: #fff; }
.clock.low.on { background: var(--bad); }
.clock.daily { font-size: 14px; min-width: 0; }
.clock:empty { display: none; }

.board-wrap { display: grid; place-items: center; margin: 2px 0; }
.board {
  --size: min(calc(100vw - 34px), 526px, calc(100dvh - 318px - var(--safe-top) - var(--safe-bottom)));
  --size-min: max(var(--size), 280px);
  position: relative; width: var(--size-min); height: var(--size-min);
  border-radius: 10px; overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none;
  box-shadow: 0 0 0 5px var(--frame), 0 14px 26px -12px rgba(50, 28, 14, 0.6);
  margin: 5px;
}
/* short phones (an iPhone SE): room for a two-line note under the board */
@media (max-height: 700px) {
  .board { --size: min(calc(100vw - 34px), 526px, calc(100dvh - 336px - var(--safe-top) - var(--safe-bottom))); }
}

.squares { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr); }
.sq { position: relative; background: var(--light); }
.sq.d { background-color: var(--dark); background-image: var(--pattern); background-size: 100% 100%; background-blend-mode: soft-light; }
.board[data-theme="night"] .sq.d, .board[data-theme="gold"] .sq.d { background-blend-mode: overlay; }
.sq .rank, .sq .file { position: absolute; font-size: calc(var(--size-min) / 34); font-weight: 800; line-height: 1; pointer-events: none; opacity: 0.85; }
.sq .rank { left: 3%; top: 4%; }
.sq .file { right: 5%; bottom: 3%; }
.sq.l .rank, .sq.l .file { color: var(--dark); }
.sq.d .rank, .sq.d .file { color: var(--light); }
.board.no-coords .rank, .board.no-coords .file { display: none; }
.sq.last::after { content: ""; position: absolute; inset: 0; background: rgba(255, 213, 79, 0.48); }
.sq.lastcat::after { content: ""; position: absolute; inset: 0; background: rgba(255, 168, 120, 0.3); }
.sq.sel::after { content: ""; position: absolute; inset: 0; background: rgba(105, 170, 80, 0.55); }
.sq.hint::after { content: ""; position: absolute; inset: 0; background: rgba(90, 160, 240, 0.5); animation: pulse 1.2s ease-in-out infinite; }
.sq.check::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle, rgba(230, 40, 30, 0.95) 0%, rgba(230, 40, 30, 0.5) 40%, transparent 72%); }
.sq.dot::before { content: ""; position: absolute; left: 35%; top: 35%; width: 30%; height: 30%; border-radius: 50%; background: rgba(30, 30, 30, 0.26); z-index: 2; }
.sq.cap::before { content: ""; position: absolute; inset: 4%; border-radius: 50%; box-shadow: inset 0 0 0 calc(var(--size-min) / 80) rgba(30, 30, 30, 0.3); z-index: 2; }
.sq.over::after { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 4px rgba(255, 255, 255, 0.85); }
.sq.catok::before {
  content: ""; position: absolute; left: 30%; top: 30%; width: 40%; height: 40%; z-index: 2; border-radius: 50%;
  background: rgba(194, 100, 60, 0.28); box-shadow: 0 0 0 2px rgba(194, 100, 60, 0.35);
}
/* the campaign's terrain and spells */
.sq.ice { background-image: var(--ice); background-size: 100% 100%; background-blend-mode: normal; }
.sq.fog { box-shadow: inset 0 0 0 100vmax rgba(232, 240, 250, 0.9); }
.sq.fog .rank, .sq.fog .file { color: #9fb2c8; }
.sq.fog::before {
  content: ""; position: absolute; inset: 0; opacity: 0.95;
  background: radial-gradient(circle at 24% 30%, #fff 0 5%, transparent 6%), radial-gradient(circle at 72% 62%, #fff 0 6%, transparent 7%),
    radial-gradient(circle at 58% 18%, #fff 0 3%, transparent 4%), radial-gradient(circle at 30% 78%, #fff 0 3.5%, transparent 4.5%);
}
.sq.frozen { box-shadow: inset 0 0 0 calc(var(--size-min) / 90) #6fb8f2, inset 0 0 calc(var(--size-min) / 30) #bfe3ff; }
.sq.warded { box-shadow: inset 0 0 0 calc(var(--size-min) / 90) #e8b230, inset 0 0 calc(var(--size-min) / 30) #fff1ae; }
.pc.terrain { background-size: 96% 96%; background-position: center; }
.sq.lava { background-image: var(--lava); background-size: 100% 100%; background-blend-mode: normal; }
.sq.sea { background-image: var(--sea); background-size: 100% 100%; background-blend-mode: normal; }
.sq.hill { box-shadow: inset 0 0 0 calc(var(--size-min) / 110) #e8a21c, inset 0 0 calc(var(--size-min) / 26) rgba(244, 196, 78, 0.75); }
.pc.swarm { filter: drop-shadow(0 0 2px #e5484d) drop-shadow(0 0 1px #e5484d); }
.rung.secret { background: linear-gradient(135deg, #f6efe6, #e9d6f2); box-shadow: inset 0 0 0 2px #8a3a4a; }
.checks { flex: none; padding: 2px 8px; border-radius: 10px; background: #fde8c8; color: #8a4a1c; font-weight: 800; font-size: 13px; }
.sq.portal0 { background-image: var(--portal0); background-size: 100% 100%; background-blend-mode: normal; }
.sq.portal1 { background-image: var(--portal1); background-size: 100% 100%; background-blend-mode: normal; }
.sq.arena { background-image: var(--arena); background-size: 100% 100%; background-blend-mode: normal; }
.sq.contest { box-shadow: inset 0 0 0 calc(var(--size-min) / 80) #e5484d; animation: pulse 0.9s ease-in-out infinite; }
.pc.knock { animation: knock 0.6s ease-in-out; z-index: 5; }
.pc.tell-pounce { animation: tellPounce 1.3s ease-in-out infinite; }
.pc.tell-feint { animation: tellFeint 1.1s ease-in-out infinite; }
.pc.tell-dodge { animation: tellDodge 1.3s ease-in-out infinite; transform-origin: 50% 92%; }
@keyframes tellPounce { 0%, 100% { transform: translate(var(--tx), var(--ty)); } 50% { transform: translate(var(--tx), var(--ty)) translateY(-5%) rotate(-9deg); } }
@keyframes tellFeint { 0%, 100% { transform: translate(var(--tx), var(--ty)); } 25% { transform: translate(var(--tx), var(--ty)) rotate(8deg); } 75% { transform: translate(var(--tx), var(--ty)) rotate(-8deg); } }
@keyframes tellDodge { 0%, 100% { transform: translate(var(--tx), var(--ty)); } 50% { transform: translate(var(--tx), var(--ty)) scale(1.1, 0.84); } }
.pc.mated { animation: mated 0.85s ease-in forwards; transform-origin: 50% 92%; z-index: 6; }
@keyframes mated {
  0% { transform: translate(var(--tx), var(--ty)); }
  12% { transform: translate(calc(var(--tx) + 7%), var(--ty)) rotate(4deg); }
  24% { transform: translate(calc(var(--tx) - 7%), var(--ty)) rotate(-4deg); }
  36% { transform: translate(calc(var(--tx) + 5%), var(--ty)) rotate(3deg); }
  48% { transform: translate(var(--tx), var(--ty)); }
  100% { transform: translate(calc(var(--tx) + 22%), calc(var(--ty) + 14%)) rotate(82deg); }
}
@keyframes knock {
  0%, 100% { transform: translate(var(--tx), var(--ty)); }
  20% { transform: translate(calc(var(--tx) + 9%), var(--ty)) rotate(6deg); }
  45% { transform: translate(calc(var(--tx) - 8%), var(--ty)) rotate(-6deg); }
  70% { transform: translate(calc(var(--tx) + 4%), var(--ty)); }
}
/* a capture contest (the Ember Arena) */
.contest-head { margin: 4px 0 6px; font-size: 21px; line-height: 1.2; }
.contest-tell { margin: 0 0 6px; font-size: 18px; font-weight: 800; color: #8a4a1c; }
.contest-note { margin: 0 0 12px; font-size: 14.5px; color: var(--ink-soft); line-height: 1.35; }
.contest-picks { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.btn.pick { display: grid; gap: 2px; justify-items: center; min-height: 64px; padding: 8px 4px; border-radius: 16px; font: inherit; cursor: pointer; border: 0; color: #fff; }
.btn.pick b { font-size: 17px; }
.btn.pick small { font-size: 12.5px; opacity: 0.9; }
.pick-pounce { background: #c2643c; }
.pick-dodge { background: #3b7a8a; }
.pick-feint { background: #7a52b8; }
.act.pick { color: #fff; }
.act.pick-pounce { background: #c2643c; }
.act.pick-dodge { background: #3b7a8a; }
.act.pick-feint { background: #7a52b8; }
.board.placing { box-shadow: 0 0 0 5px var(--accent), 0 14px 26px -12px rgba(50, 28, 14, 0.6); }
@keyframes pulse { 50% { opacity: 0.45; } }

.pieces { position: absolute; inset: 0; pointer-events: none; }
.pc {
  position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%;
  background-size: 92% 92%; background-position: center 70%; background-repeat: no-repeat; z-index: 3; will-change: transform;
}
.pc.cat { background-size: 100% 100%; background-position: center; z-index: 4; }
.pc.anim { transition: transform 0.2s cubic-bezier(0.3, 0.7, 0.3, 1); }
.pc.dragging { z-index: 10; transition: none; filter: drop-shadow(0 8px 6px rgba(0, 0, 0, 0.3)); }
.pc.gone { opacity: 0; transition: opacity 0.2s; }
.pc.pop { animation: pop 0.26s ease-out; }
@keyframes pop { from { opacity: 0; } }

.promo { position: absolute; inset: 0; z-index: 20; }
.promo-shade { position: absolute; inset: 0; border: 0; background: rgba(30, 20, 14, 0.45); cursor: pointer; }
.promo-pick {
  position: absolute; width: 12.5%; height: 12.5%; border: 0; border-radius: 50%; cursor: pointer;
  background-color: #fffaf3; background-size: 86%; background-position: center; background-repeat: no-repeat;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.35);
}

.note { min-height: 26px; margin: 2px 4px 0; font-size: 16px; font-weight: 700; line-height: 1.3; text-align: center; }
.note.cat { color: var(--accent-dk); }
.note.good, .note.done { color: var(--good); }
.note.bad { color: var(--bad); }

.moves {
  display: flex; align-items: center; gap: 2px; min-height: 44px; margin: 2px 0; padding: 0 4px;
  overflow-x: auto; scrollbar-width: none; white-space: nowrap; border-radius: 12px; background: rgba(255, 250, 243, 0.55);
}
.moves::-webkit-scrollbar { display: none; }
.mnum { color: var(--ink-soft); font-size: 14px; padding: 0 2px 0 6px; }
.mv { position: relative; min-height: 34px; min-width: 44px; padding: 2px 8px; border: 0; border-radius: 10px; background: transparent; font-weight: 700; font-size: 15px; cursor: pointer; }
.mv::after { content: ""; position: absolute; inset: -5px 0; } /* the whole height of the strip is the target: 44 px */
.mv.cur { background: var(--ink); color: #fff; }
.mcat { margin-left: 4px; padding-left: 15px; font-size: 12px; font-weight: 700; color: var(--accent-dk); background: url('data:image/svg+xml;charset=utf-8,%3Csvg xmlns="http://www.w3.org/2000/svg" viewBox="-8 -9 16 16"%3E%3Cg fill="%23c2643c"%3E%3Cellipse cx="0" cy="3" rx="5.2" ry="4.4"/%3E%3Ccircle cx="-5.6" cy="-3" r="2.2"/%3E%3Ccircle cx="-2" cy="-6.2" r="2.2"/%3E%3Ccircle cx="2" cy="-6.2" r="2.2"/%3E%3Ccircle cx="5.6" cy="-3" r="2.2"/%3E%3C/g%3E%3C/svg%3E') no-repeat left center / 12px 12px; }
.mv.cur .mcat { color: #ffd9c4; }
.mnone { color: var(--ink-soft); font-size: 14px; padding: 0 8px; }

.actions { display: flex; gap: 8px; margin-top: 6px; }
.act {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; min-height: 56px; min-width: 0;
  padding: 4px 6px; border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); cursor: pointer;
  font-weight: 800; font-size: 14px; line-height: 1.1;
}
.act span:last-child { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.act.primary { background: var(--accent); color: #fff; }
.act:active { transform: scale(0.97); }
.act.spell { background: #efe6fb; color: #4b2f7a; }
.act.spell span:last-child { white-space: normal; font-size: 13px; text-align: center; }
.act.spell.used, .act:disabled { opacity: 0.5; cursor: default; }
.act:disabled:active { transform: none; }

/* ---------- puzzles, skins ---------- */
.sub-top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; min-height: 48px; margin-bottom: 8px; }
.sub-top h1 { margin: 0; text-align: center; font-size: 26px; }
.sub-top .sg-corner-slot { justify-self: start; }
.big { font-size: 22px; font-weight: 800; margin: 0; }
.bar { height: 12px; border-radius: 99px; background: rgba(45, 36, 33, 0.1); overflow: hidden; margin: 8px 0 4px; }
.bar span { display: block; height: 100%; background: linear-gradient(90deg, #e9a325, var(--accent)); border-radius: 99px; }
.pgrid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.pz {
  position: relative; width: 100%; aspect-ratio: 1 / 1.05; min-height: 56px; border: 0; border-radius: 14px; background: var(--card);
  box-shadow: var(--shadow); cursor: pointer; display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2px;
}
.pz b { font-size: 20px; line-height: 1; }
.pz small { font-size: 10px; line-height: 1.1; color: var(--ink-soft); text-align: center; }
.pz.solved { background: #e3f1e1; }
.pz.next { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.pz .tick { position: absolute; top: 3px; right: 3px; width: 16px; height: 16px; }
.pz .tick svg { width: 16px; height: 16px; fill: none; stroke: var(--good); stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; }
.pz.clean .tick svg { stroke: #d8961a; }

.pad { padding: 0 4px; }
.skins-screen h2 { margin: 14px 0 8px; font-size: 21px; }
.skins { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.skin {
  width: 100%; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 6px 8px; min-height: 44px;
  border: 0; border-radius: 16px; background: var(--card); box-shadow: var(--shadow); cursor: pointer; text-align: center;
}
.skin b { font-size: 14px; line-height: 1.1; }
.skin small { font-size: 12px; color: var(--ink-soft); line-height: 1.1; display: inline-flex; align-items: center; gap: 2px; }
.skin small svg { width: 12px; height: 12px; fill: none; stroke: currentColor; stroke-width: 2.4; }
.skin.chosen { box-shadow: 0 0 0 3px var(--accent), var(--shadow); }
.skin.locked { opacity: 0.6; cursor: default; }
.skin.locked .mini { filter: grayscale(0.7); }
.mini { display: grid; grid-template-columns: repeat(4, 1fr); width: 100%; aspect-ratio: 1; border-radius: 8px; overflow: hidden; box-shadow: 0 0 0 3px var(--frame); margin-bottom: 4px; }
.mini span { position: relative; background: var(--light); }
.mini span.d { background-color: var(--dark); background-size: 100% 100%; background-blend-mode: soft-light; }
.mini img { position: absolute; inset: 6%; width: 88%; height: 88%; }
.toggle { display: flex; align-items: center; gap: 10px; min-height: 48px; margin-top: 12px; font-weight: 700; }
/* Kento's wardrobe: Kento in each outfit, on a soft spotlight */
.kento-fit .fit-pic {
  display: grid; place-items: end center; width: 100%; aspect-ratio: 1; margin-bottom: 4px; border-radius: 12px; overflow: hidden;
  background: radial-gradient(ellipse 70% 60% at 50% 40%, #fff7ea, #f1e2cc 70%, #e6d2b6);
}
.kento-fit .fit-pic svg { width: 76%; height: auto; margin-bottom: -6%; }
.skin.locked .fit-pic svg { filter: grayscale(1) brightness(1.15); opacity: 0.45; }
.medals { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0 0 8px; }
.medals .medal {
  width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff2b0, #f4c44e 55%, #b4801f);
  box-shadow: inset 0 0 0 2px rgba(122, 84, 20, 0.5), 0 2px 0 #c2643c;
}
.medals b { font-size: 15px; color: var(--ink-soft); }
.title-kento { width: 98px; }
.title-kento svg { display: block; width: 98px; height: auto; }
.toggle input { width: 22px; height: 22px; accent-color: var(--accent); }

/* ---------- sheet, toast, connection ---------- */
.sheet {
  width: min(100vw, 520px); max-width: 100vw; max-height: 88dvh; margin: auto auto 0; padding: 0; border: 0;
  border-radius: 26px 26px 0 0; background: var(--card); color: var(--ink); box-shadow: 0 -10px 40px rgba(40, 20, 10, 0.3); overflow: auto;
}
.sheet::backdrop { background: rgba(40, 24, 14, 0.42); }
.sheet-body { padding: 18px 16px calc(var(--safe-bottom) + 18px); }
/* a sheet's action row, pinned at its foot while the rest scrolls (like the shared pause menu's .sg-actions) */
.sheet-foot {
  position: sticky; bottom: calc(-18px - var(--safe-bottom)); z-index: 2; display: grid; gap: 8px;
  margin: 12px -16px calc(-18px - var(--safe-bottom)); padding: 14px 16px calc(18px + var(--safe-bottom));
  background: linear-gradient(to bottom, rgba(255, 255, 255, 0), var(--card) 14px);
}
.sheet-foot > .btn { margin: 0; }
.sheet h2 { margin: 0 0 6px; font-size: 24px; line-height: 1.15; padding-right: 40px; }
.sheet-close { position: absolute; top: 8px; right: 8px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(45, 36, 33, 0.07); font-size: 26px; line-height: 1; cursor: pointer; }
.sheet input[type="text"] { width: 100%; min-height: 48px; padding: 8px 14px; border: 2px solid var(--line); border-radius: 14px; font: inherit; font-size: 18px; background: #fff; }
.field { margin: 10px 0 4px; }
.field .label { display: block; font-weight: 800; margin-bottom: 4px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 6px 0; }
.chip { min-height: 44px; padding: 6px 14px; border: 0; border-radius: 14px; background: rgba(45, 36, 33, 0.07); font-weight: 700; font-size: 16px; cursor: pointer; }
.chip[aria-checked="true"] { background: var(--ink); color: #fff; }
.chip:disabled { opacity: 0.4; cursor: default; }
.levels { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0; }
.level { position: relative; display: flex; flex-direction: column; align-items: flex-start; min-height: 64px; padding: 8px 10px; border: 0; border-radius: 16px; background: rgba(45, 36, 33, 0.06); text-align: left; cursor: pointer; }
.level b { font-size: 17px; }
.level small { color: var(--ink-soft); font-size: 13px; line-height: 1.2; }
.level .wins { position: absolute; top: 6px; right: 8px; font-size: 12px; font-weight: 800; color: var(--good); }
.level[aria-checked="true"] { background: var(--ink); color: #fff; }
.level[aria-checked="true"] small { color: rgba(255, 255, 255, 0.75); }
.menu-list { display: grid; gap: 6px; margin-top: 6px; }
.menu-item { min-height: 50px; padding: 8px 14px; border: 0; border-radius: 14px; background: rgba(45, 36, 33, 0.05); text-align: left; font-weight: 700; font-size: 17px; cursor: pointer; }
.over-cat { display: grid; place-items: center; }
.over-cat img { width: 96px; height: 96px; }
.over-title { text-align: center; padding: 0 !important; font-size: 30px !important; }
.over-title + .lede { text-align: center; }
.rules-cat { display: grid; place-items: center; }
.rules { padding-left: 20px; margin: 6px 0 10px; line-height: 1.35; }
.rules li { margin-bottom: 6px; }

.toast {
  position: fixed; left: 50%; bottom: calc(var(--safe-bottom) + 22px); z-index: 100; max-width: min(92vw, 460px);
  padding: 10px 16px; border-radius: 14px; background: var(--ink); color: #fff; font-weight: 700; text-align: center;
  transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.conn { position: fixed; top: calc(var(--safe-top) + 8px); left: 50%; transform: translateX(-50%); z-index: 90; padding: 6px 14px; border-radius: 999px; background: var(--bad); color: #fff; font-weight: 800; }

@media (max-width: 370px) {
  .hero h1 { font-size: 38px; }
  .player .who { max-width: 30%; }
  .clock { min-width: 66px; font-size: 18px; }
  .act { font-size: 13px; }
}

/* ---------- the ladder (bots.js) ---------- */
.face { display: block; flex: none; width: 52px; height: 52px; border-radius: 50%; overflow: hidden; box-shadow: 0 0 0 2px #fff, 0 4px 10px -6px rgba(60, 34, 20, 0.6); }
.face svg { display: block; width: 100%; height: 100%; }
.face.big { width: 96px; height: 96px; }
.going { display: grid; gap: 8px; margin-bottom: 14px; }
.going .resume { margin-bottom: 0; }
.resume span.face { flex: none; display: block; width: 48px; height: 48px; }
.resume b { font-size: 17px; line-height: 1.15; }
.ladder h2 { margin-bottom: 0; }
.ladder > .muted { margin: 2px 0 8px; }
.rungs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.rung {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 66px; padding: 6px 10px 6px 6px; border: 0; border-radius: 18px;
  background: rgba(45, 36, 33, 0.045); text-align: left; cursor: pointer;
}
.rung:active { transform: scale(0.98); }
.rung.next { background: #fdebd9; box-shadow: inset 0 0 0 2px #f0b98f; }
.rung.locked { background: rgba(45, 36, 33, 0.03); }
.rung.locked .face { filter: grayscale(0.85) brightness(0.92); opacity: 0.55; }
.rung.locked .rw b { color: var(--ink-soft); }
.rung .rw { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.rung .rw b { display: flex; align-items: baseline; gap: 8px; font-size: 17px; line-height: 1.15; }
.rung .rw small { color: var(--ink-soft); font-size: 13.5px; line-height: 1.25; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.rung .rw small.playing { color: var(--accent-dk); font-weight: 800; -webkit-line-clamp: 1; }
.rating { font-size: 13px; font-weight: 800; color: var(--ink-soft); background: rgba(45, 36, 33, 0.07); padding: 0 7px; border-radius: 999px; line-height: 1.6; }
.rung .lock svg { width: 20px; height: 20px; fill: none; stroke: var(--ink-soft); stroke-width: 2.2; stroke-linecap: round; opacity: 0.7; }
.rung .won { flex: none; font-size: 13px; font-weight: 800; color: var(--good); }
.tile.soon { background: linear-gradient(160deg, #fffaf3, #f1e2ff); }
.tile.soon small { color: #6b4fa0; }
.card.online h2 { display: flex; align-items: center; gap: 8px; }
.card.online h2 .badge { font-size: 13px; }

/* a bot's sheet */
.bot-head { display: flex; align-items: center; gap: 14px; margin-bottom: 6px; }
.bot-head h2 { margin: 0; padding-right: 0; }
.bot-title { margin: 0; color: var(--ink-soft); font-size: 15px; line-height: 1.2; }
.bot-tags { display: flex; flex-wrap: wrap; gap: 6px; margin: 6px 0 0; }
.bot-tags .style { font-size: 13px; font-weight: 800; padding: 0 8px; border-radius: 999px; line-height: 1.6; color: #fff; }
.style.aggressive { background: #c0392f; }
.style.solid { background: #3f6f8f; }
.style.tricky { background: #7a52c0; }
.bot-says, .over-say { margin: 4px 0 8px; padding: 8px 12px; border-radius: 14px 14px 14px 4px; background: #fff; box-shadow: var(--shadow); font-weight: 700; line-height: 1.3; }
.over-say { text-align: center; border-radius: 14px; }
.over-open { text-align: center; font-weight: 800; color: var(--accent-dk); margin: 6px 0; }
.over-cat .face { width: 92px; height: 92px; }
.sheet-h3 { margin: 14px 0 2px; font-size: 14px; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); }
.seat-cpu svg { display: block; width: 40px; height: 40px; }
.seat-cpu:has(svg) { width: 40px; height: 40px; }

/* table talk: a speech bubble in the computer player's bar, beside its name (play.js placeTalk sets where), so it
   never covers the board */
.play { position: relative; }
.talk {
  position: absolute; z-index: 5; display: flex; align-items: center; padding: 4px 12px; border-radius: 16px 16px 16px 4px;
  background: #fff; box-shadow: 0 8px 18px -10px rgba(60, 34, 20, 0.6); font-weight: 700; font-size: 14px; line-height: 1.2;
  pointer-events: none; opacity: 0; transform: translateX(-4px); transition: opacity 0.2s, transform 0.2s; overflow: hidden;
}
.talk.show { opacity: 1; transform: none; }

/* ---------- the campaign (camp.js, map.js) ---------- */
/* living pieces: a capture pounces, tumbles and puffs (board.js) */
.pc.tumble { z-index: 6; animation: tumble 0.7s 0.1s ease-in forwards; }
@keyframes tumble {
  0% { opacity: 1; transform: translate(var(--tx), var(--ty)); }
  30% { transform: translate(calc(var(--tx) + var(--fly, 1) * 14%), calc(var(--ty) - 38%)) rotate(calc(var(--fly, 1) * 50deg)); }
  100% { opacity: 0; transform: translate(calc(var(--tx) + var(--fly, 1) * 75%), calc(var(--ty) + 30%)) rotate(calc(var(--fly, 1) * 230deg)) scale(0.45); }
}
.pc.pounce { animation: pounce 0.45s 0.2s ease-out; z-index: 4; }
@keyframes pounce {
  0%, 100% { transform: translate(var(--tx), var(--ty)); }
  40% { transform: translate(var(--tx), var(--ty)) scale(1.3); }
  70% { transform: translate(var(--tx), var(--ty)) scale(0.92); }
}
.puff { position: absolute; left: 0; top: 0; width: 12.5%; height: 12.5%; z-index: 5; pointer-events: none; }
.puff i { position: absolute; left: 40%; top: 58%; width: 22%; height: 22%; border-radius: 50%; background: rgba(255, 249, 236, 0.95); opacity: 0; animation: puff 0.7s 0.12s ease-out forwards; box-shadow: 0 0 0 1px rgba(150, 120, 90, 0.25); }
.puff i:nth-child(1) { --dx: -130%; --dy: -60%; }
.puff i:nth-child(2) { --dx: 130%; --dy: -70%; }
.puff i:nth-child(3) { --dx: -90%; --dy: 70%; }
.puff i:nth-child(4) { --dx: 100%; --dy: 60%; }
.puff i:nth-child(5) { --dx: 0%; --dy: -130%; }
@keyframes puff { 0% { opacity: 0.95; transform: translate(0, 0) scale(0.6); } 100% { opacity: 0; transform: translate(var(--dx), var(--dy)) scale(1.9); } }
.sq.flag::after {
  content: ""; position: absolute; inset: 8%; z-index: 1; background: no-repeat center / 80% url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 40 40'%3E%3Cpath d='M12 36 V5' stroke='%235a3a2a' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M13 6 L33 12 L13 19 Z' fill='%23e5484d' stroke='%237a2a2a' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
  animation: wave 1.6s ease-in-out infinite;
}
@keyframes wave { 50% { transform: translateY(-4%) rotate(-3deg); } }
.sq.caught::after { content: ""; position: absolute; inset: 0; background: rgba(229, 72, 77, 0.55); animation: pulse 0.5s ease-in-out 2; }

.camp-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 48px; margin-bottom: 8px; }
.camp-stars { font-weight: 800; font-size: 17px; color: #8a5a12; background: #fff3d0; padding: 4px 12px; border-radius: 999px; box-shadow: var(--shadow); }
.map-wrap { border-radius: 22px; overflow: hidden; box-shadow: var(--shadow); margin-bottom: 86px; }
.map { display: block; width: 100%; height: auto; font-family: "Baloo 2", ui-rounded, system-ui, sans-serif; }
.map .stop { cursor: pointer; }
.map .stop.shut text { opacity: 0.75; }
.map .pulse { animation: ring 1.6s ease-in-out infinite; transform-origin: center; transform-box: fill-box; }
@keyframes ring { 50% { opacity: 0.35; scale: 1.08; } }
.camp-next { position: fixed; left: 0; right: 0; bottom: 0; z-index: 6; padding: 10px 16px calc(var(--safe-bottom) + 12px); background: linear-gradient(180deg, transparent, rgba(232, 211, 187, 0.95) 30%); }
.camp-next .btn { max-width: 528px; margin: 0 auto; }
.tile.camp { background: linear-gradient(160deg, #fffaf3, #fff0c8); }
.stop-kicker { margin: 0 0 6px; font-size: 13px; font-weight: 800; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); padding-right: 44px; }
.ending-title { font-size: 26px; }
.ending-faces { display: flex; justify-content: center; gap: 8px; margin: 6px 0 10px; }
.ending-faces .face svg { width: 64px; height: 64px; display: block; }
.ending-stats { font-weight: 800; font-size: 18px; color: #8a4a1c; }
.ending-new { font-weight: 800; color: #3d3478; }
.leans { margin: 8px 0; font-size: 14.5px; color: var(--ink-soft); }
.leans summary { min-height: 44px; display: flex; align-items: center; font-weight: 800; color: var(--ink); cursor: pointer; }
.leans ul { margin: 2px 0 6px; padding-left: 20px; line-height: 1.4; }
.leans p { margin: 0; line-height: 1.35; }
/* the tide's hands (drops): a chip per kind of piece, yours tappable */
.hand { flex: 1; display: flex; gap: 4px; align-items: center; min-width: 40px; overflow-x: auto; scrollbar-width: none; }
.hand.empty { visibility: hidden; }
.hand-chip {
  position: relative; flex: none; display: inline-grid; place-items: center; width: 44px; height: 44px; padding: 0;
  border: 0; border-radius: 12px; background: rgba(45, 36, 33, 0.07); font: inherit;
}
button.hand-chip { cursor: pointer; background: #e7eefc; box-shadow: inset 0 0 0 2px #9fb2e6; }
.hand-chip.on { background: #7f8fd6; box-shadow: inset 0 0 0 2px #3d3478; }
.hand-chip img { width: 34px; height: 34px; }
.hand-chip b { position: absolute; right: 1px; bottom: 0; font-size: 12px; font-weight: 800; color: var(--ink); background: #fffaf3; border-radius: 8px; padding: 0 3px; line-height: 1.3; }
.spells { display: grid; gap: 6px; margin: 10px 0 12px; }
.spells-head { margin: 0; font-weight: 800; font-size: 15px; }
.spell-chip {
  display: grid; gap: 2px; text-align: left; padding: 9px 12px; min-height: 48px; border-radius: 14px; border: 2px solid #d9cdea;
  background: #faf6ff; color: #3d2a55; font: inherit; cursor: pointer;
}
.spell-chip b { font-size: 15px; }
.spell-chip small { font-size: 13.5px; color: #6a5a7e; line-height: 1.25; }
.spell-chip.on { border-color: #7a52b8; background: #efe6fb; }
.spell-chip.spent { opacity: 0.6; }
.star-rules { list-style: none; padding: 0; margin: 8px 0 4px; display: grid; gap: 4px; }
.star-rules li { color: var(--ink-soft); font-size: 15px; line-height: 1.3; }
.star-rules li span { color: #c8b9a6; font-size: 17px; }
.star-rules li.got { color: var(--ink); font-weight: 700; }
.star-rules li.got span { color: #e8a21c; }
.over-stars { display: flex; justify-content: center; gap: 6px; font-size: 46px; line-height: 1; }
.over-stars .star { color: #d9cbb8; animation: pop 0.3s ease-out backwards; }
.over-stars .star.on { color: #f0b429; text-shadow: 0 2px 0 #b37b12; }
.over-stars .star:nth-child(2) { animation-delay: 0.15s; }
.over-stars .star:nth-child(3) { animation-delay: 0.3s; }
.story-head { display: flex; align-items: center; gap: 8px; font-weight: 800; color: var(--ink-soft); padding-right: 44px; }
.face.small { width: 34px; height: 34px; }
.story { list-style: none; padding: 0; margin: 10px 0 4px; display: grid; gap: 10px; }
.story li { display: flex; gap: 10px; align-items: flex-start; }
.story .face { width: 44px; height: 44px; }
.story b { font-size: 14px; color: var(--ink-soft); }
.story p { margin: 0; padding: 7px 11px; border-radius: 4px 14px 14px 14px; background: #fff; box-shadow: var(--shadow); font-weight: 700; line-height: 1.3; }
#play[data-mode="walk"] .moves { justify-content: center; }

@media (prefers-reduced-motion: reduce) {
  .talk { transition: none; }
  .pc.tumble { animation: none; opacity: 0; transition: opacity 0.2s; }
  .pc.pounce, .puff, .sq.flag::after, .map .pulse, .over-stars .star { animation: none; }
  .puff { display: none; }
  .rung:active { transform: none; }
  .pc.anim, .pc.gone, .toast { transition: none; }
  .pc.pop, .sq.hint::after, .sq.contest, .pc.knock, .pc.mated, .pc.tell-pounce, .pc.tell-feint, .pc.tell-dodge { animation: none; }
  .tile:active, .trow:active, .resume:active, .act:active, .btn.primary:active { transform: none; }
}

/* iPhone: no double-tap zoom anywhere. touch-action isn't inherited, so it goes on every element
   (anything with its own touch-action keeps it). Text fields stay selectable. */
* { touch-action: manipulation; }
input, textarea { -webkit-user-select: text; user-select: text; }

/* Title screen: the shared layout (shared/mainmenu.js); these are only Chess' colors. */
#mm {
  --sg-bg: radial-gradient(circle at 85% 6%, rgba(255, 247, 232, 0.9), transparent 40%), linear-gradient(180deg, var(--bg-top), var(--bg-low));
  --sg-ink: var(--ink); --sg-ink-soft: var(--ink-soft);
  --sg-title: var(--accent-dk); --sg-title-shadow: 0 2px 0 #fff;
  --sg-accent: var(--accent); --sg-accent-ink: #fff;
  --sg-card: var(--card); --sg-card-ink: var(--ink); --sg-line: var(--line);
}
.sg-sheet { --sg-sheet-bg: var(--card); --sg-sheet-ink: var(--ink); --sg-accent: var(--accent); --sg-accent-ink: #fff; --sg-ink-soft: var(--ink-soft); }
#mm.sg-scened { --sg-title: #fff3dc; --sg-title-shadow: 0 3px 0 #5a3418; }
