:root {
  --paper: #efe4d6;
  --ink: #2a1810;
  --muted: #7a5a4c;
  --accent: #c46a4a;
  --line: #d9c4b2;
  --board: #e7d6c6;
  --stage: #c9b49f;
  font-family: "Figtree", "Trebuchet MS", sans-serif;
}
html[data-theme="cat"] {
  --paper: #efe4d6;
  --ink: #2a1810;
  --muted: #7a5a4c;
  --accent: #c46a4a;
  --line: #d9c4b2;
  --board: #e7d6c6;
  --stage: #c9b49f;
}
html[data-theme="dog"] {
  --paper: #e7efe4;
  --ink: #1e3a5f;
  --muted: #5d6f6a;
  --accent: #5a7a3a;
  --line: #c5d2c4;
  --board: #dce6d8;
  --stage: #8aa070;
}
html[data-theme="squirrel"] {
  --paper: #f0e6d4;
  --ink: #3a2414;
  --muted: #7a6248;
  --accent: #b85a2b;
  --line: #d4c4a8;
  --board: #e6d8c0;
  --stage: #8a6238;
}
html[data-theme="hub"] {
  --paper: #efe8dc;
  --ink: #2c2a22;
  --muted: #6b6a5c;
  --accent: #5c4a32;
  --line: #d4cbb8;
  --board: #e8e2d4;
  --stage: #b7a78c;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; background:
    radial-gradient(120% 70% at 50% 0%, rgba(255,255,255,0.22), transparent 55%),
    var(--paper);
  color: var(--ink); }
#app { height: 100%; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
.wrap {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px 12px 12px;
  min-height: 0;
}
.top { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-shrink: 0; }
.kicker { font-size: 11px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--accent); margin: 0; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: 24px; font-weight: 500; margin: 2px 0 0; }
.tag { font-family: Georgia, serif; font-style: italic; color: var(--accent); margin: 6px 0 0; }
.muted { color: var(--muted); font-size: 14px; line-height: 1.5; }
.lives-row { display: flex; align-items: center; gap: 8px; }
.lives { display: flex; gap: 2px; }
.mute {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  display: grid;
  place-items: center;
  padding: 0;
  color: var(--ink);
}
.life { width: 32px; height: 32px; object-fit: contain; }
.life.off { opacity: 0.22; filter: grayscale(0.6); }
.sizes {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin: 10px 0 6px;
  max-width: 760px;
  width: 100%;
  margin-left: auto;
  margin-right: auto;
}
.size {
  flex: 1;
  min-height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: transparent;
  font-weight: 600;
}
.size.on { background: var(--accent); color: var(--paper); border-color: transparent; }
.board-meta {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
  max-width: 760px;
  width: 100%;
  margin: 0 auto 6px;
  flex-shrink: 0;
  text-align: center;
}
.stage {
  flex: 1 1 auto;
  min-height: 0;
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 14px;
  border-radius: 22px;
  display: grid;
  place-items: center;
  container-type: size;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(255,255,255,0.16), transparent 55%),
    linear-gradient(180deg, color-mix(in srgb, var(--stage) 55%, #6b4424), #4a2e18);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.28),
    inset 0 -8px 18px rgba(0,0,0,0.28),
    0 22px 44px rgba(40, 24, 12, 0.28);
  border: 8px solid color-mix(in srgb, var(--stage) 35%, #3a2414);
}
.grid {
  display: grid;
  gap: 6px;
  width: min(100%, 100cqh);
  max-height: 100%;
  aspect-ratio: 1;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.cell {
  aspect-ratio: 1;
  border: 0;
  position: relative;
  min-height: 0;
  min-width: 0;
  padding: 0;
  border-radius: 10px;
  touch-action: none;
  -webkit-touch-callout: none;
  user-select: none;
  box-shadow:
    inset 0 3px 0 rgba(255,255,255,0.4),
    inset 0 -6px 0 rgba(0,0,0,0.22),
    0 5px 0 rgba(0,0,0,0.2);
}
.cell:active { transform: translateY(1px); }
.cell .fig,
.cell .mark-fig {
  position: absolute;
  inset: 4%;
  width: 92%;
  height: 92%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 8px rgba(40, 20, 8, 0.28));
}
.cell .mark-fig { inset: 18%; width: 64%; height: 64%; opacity: 0.9; filter: none; }
.cell.flash { outline: 2px solid var(--accent); }
.r0 { background: linear-gradient(180deg, #f3ddd0, #d9b6a4); }
.r1 { background: linear-gradient(180deg, #d7e4c6, #b4c59a); }
.r2 { background: linear-gradient(180deg, #ead7b4, #c9ae86); }
.r3 { background: linear-gradient(180deg, #c8d6e6, #9eb3c8); }
.r4 { background: linear-gradient(180deg, #e6cddc, #c5a7b8); }
.r5 { background: linear-gradient(180deg, #d0e4dc, #a8c4b8); }
.r6 { background: linear-gradient(180deg, #eed9a8, #d0b36c); }
.r7 { background: linear-gradient(180deg, #d0d8c0, #a8b494); }
.tools {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-width: 760px;
  width: 100%;
  margin: 10px auto 0;
  flex-shrink: 0;
}
.tool {
  display: grid;
  grid-template-columns: 44px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  align-items: center;
  min-height: 64px;
  padding: 8px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--board);
  text-align: left;
}
.tool img { width: 44px; height: 44px; object-fit: contain; grid-row: 1 / 3; }
.tool span { font-weight: 600; }
.tool small { color: var(--muted); font-size: 12px; }
.tool.on { background: var(--accent); color: var(--paper); border-color: transparent; }
.tool.on small { color: color-mix(in srgb, var(--paper) 82%, var(--accent)); }
.hint-line {
  max-width: 760px;
  width: 100%;
  margin: 8px auto 0;
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
}
.coach {
  max-width: 760px;
  width: 100%;
  margin: 8px auto 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--accent);
  color: var(--paper);
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.coach p {
  margin: 0;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.35;
}
.coach p + p { margin-top: 6px; }
.coach button {
  flex-shrink: 0;
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--paper) 45%, transparent);
  background: color-mix(in srgb, var(--paper) 18%, transparent);
  color: inherit;
  font-weight: 600;
}
.bar { display: flex; flex-wrap: wrap; gap: 8px; max-width: 760px; width: 100%; margin: 8px auto 0; flex-shrink: 0; }
.bar button, .ghost, .solid {
  min-height: 40px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
}
.ghost { min-height: 36px; font-size: 13px; }
.solid { background: var(--accent); color: var(--paper); border-color: transparent; }
.overlay {
  max-width: 760px;
  width: 100%;
  margin: 8px auto 0;
  padding: 12px 16px;
  border: 1px solid var(--line);
  background: var(--board);
  border-radius: 10px;
  flex-shrink: 0;
}
.hub { display: grid; gap: 12px; margin-top: 24px; }
.hub a {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--line);
  background: var(--board);
  border-radius: 16px;
  padding: 0 16px 0 0;
  min-height: 108px;
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(40, 24, 12, 0.12);
}
.hub a img {
  width: 120px;
  height: 108px;
  object-fit: cover;
  filter: none;
}
.hub a strong { display: block; font-family: Georgia, serif; font-size: 22px; font-weight: 500; }
.hub a span { display: block; margin-top: 6px; color: var(--muted); font-size: 14px; }
@media (min-width: 720px) {
  .hub { grid-template-columns: repeat(3, 1fr); }
  .hub a { grid-template-columns: 1fr; text-align: center; padding: 0 0 18px; }
  .hub a img { width: 100%; height: 180px; margin: 0; }
}
@media (max-width: 420px) {
  .tool small { display: none; }
  .tool { min-height: 56px; }
  h1 { font-size: 22px; }
}
