/* Bobby's Cat — Times Tables
   The page shell (colours, body, top bar) comes first, because shared.css
   only carries fonts and resets; every page styles its own top bar.
   Everything after the shell is prefixed .tt- so nothing can collide with
   another game's stylesheet. */

/* ---- page shell ---- */
:root {
  --ink: #24345a;
  --muted: #71809c;
  --paper: #fffdf8;
  --coral: #ff6f61;
  --yellow: #ffc94f;
  --aqua: #54c9c1;
  --green: #42b883;
  --purple: #7776df;
  --purple-dark: #5553b8;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: "Nunito", sans-serif;
  background:
    radial-gradient(circle at 6% 10%, rgba(255, 201, 79, 0.2) 0 95px, transparent 96px),
    radial-gradient(circle at 95% 42%, rgba(119, 118, 223, 0.14) 0 170px, transparent 171px),
    linear-gradient(145deg, #f6f3ff, #f2efff 60%, #eef6fb);
  overflow-x: hidden;
}

button { color: inherit; }
.topbar {
  height: 72px;
  padding: 0 clamp(18px, 5vw, 72px);
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(36, 52, 90, 0.08);
  background: rgba(255, 253, 248, 0.84);
  backdrop-filter: blur(14px);
  position: relative;
  z-index: 10;
}
.brand { display: flex; align-items: center; gap: 11px; }
.brand-mark {
  width: 41px; height: 41px; display: grid; place-items: center;
  border-radius: 14px; background: var(--purple); color: white; font-size: 22px;
  transform: rotate(-5deg); box-shadow: 0 7px 16px rgba(119, 118, 223, 0.28);
}
.brand-name { font: 800 22px/1 "Baloo 2", cursive; }
.brand-name small { display: block; font: 800 9px/1.3 "Nunito", sans-serif; letter-spacing: 1.6px; color: var(--purple-dark); }
.top-actions { display: flex; align-items: center; gap: 9px; }
.icon-btn {
  width: 41px; height: 41px; display: grid; place-items: center;
  border: 1px solid #e4e4dc; border-radius: 13px; background: white;
  text-decoration: none; cursor: pointer; transition: 0.18s; box-shadow: 0 4px 12px rgba(36, 52, 90, 0.04);
}
.icon-btn:hover { transform: translateY(-2px); }
@media (max-width: 430px) {
  .topbar { padding: 0 15px; }
  .brand-name { font-size: 18px; }
}

/* ---- times tables ---- */
.tt-page {
  --tt-ink: var(--ink, #24345a);
  --tt-muted: var(--muted, #71809c);
  --tt-coral: var(--coral, #ff6f61);
  --tt-aqua: var(--aqua, #54c9c1);
  --tt-green: var(--green, #42b883);
  --tt-yellow: var(--yellow, #ffc94f);
  --tt-purple: var(--purple, #7776df);
  --tt-card: #fff;
  --tt-line: #e4e2f5;
  --tt-soft: #f4f2fd;
  --tt-board: #3a3878;
  --tt-board-2: #4b49918f;

  max-width: 960px;
  margin: 0 auto;
  padding: 18px 16px 48px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  color: var(--tt-ink);
}
.tt-page *,
.tt-page *::before,
.tt-page *::after { box-sizing: border-box; }

/* ---- intro ---- */
.tt-welcome {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
.tt-welcome h1 {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: clamp(28px, 6vw, 40px);
  margin: 2px 0 6px;
  line-height: 1.1;
}
.tt-welcome h1 span { color: var(--tt-coral); }
.tt-eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tt-muted);
}
.tt-welcome-copy { margin: 0; color: var(--tt-muted); max-width: 54ch; }
.tt-best-pill {
  background: var(--tt-card);
  border: 1px solid var(--tt-line);
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  white-space: nowrap;
}
.tt-best-pill span { color: var(--tt-muted); font-weight: 600; }

/* ---- table picker ---- */
.tt-picker {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--tt-card);
  border: 1px solid var(--tt-line);
  border-radius: 16px;
  padding: 10px 14px;
}
.tt-picker > span {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--tt-muted);
}
.tt-nums { display: flex; gap: 5px; flex-wrap: wrap; }
.tt-num {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: 1px solid var(--tt-line);
  background: transparent;
  border-radius: 10px;
  min-width: 40px;
  padding: 7px 9px;
  font-weight: 800;
}
.tt-num:hover { border-color: var(--tt-coral); }
.tt-num[aria-pressed="true"] {
  background: var(--tt-coral);
  border-color: var(--tt-coral);
  color: #fff;
}

/* ---- game tabs ---- */
.tt-tabs { display: flex; gap: 8px; flex-wrap: wrap; }
.tt-tab {
  font: inherit;
  color: inherit;
  cursor: pointer;
  flex: 1 1 190px;
  text-align: left;
  background: var(--tt-card);
  border: 1px solid var(--tt-line);
  border-radius: 16px;
  padding: 11px 15px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.tt-tab b { font-family: "Baloo 2", "Nunito", sans-serif; font-size: 19px; font-weight: 600; }
.tt-tab small { color: var(--tt-muted); font-size: 12.5px; }
.tt-tab:hover { border-color: var(--tt-coral); }
.tt-tab[aria-selected="true"] {
  background: var(--tt-purple);
  border-color: var(--tt-purple);
  color: #fff;
}
.tt-tab[aria-selected="true"] small { color: #e6e4ff; }

/* ---- panels ---- */
.tt-panel { display: none; flex-direction: column; gap: 12px; }
.tt-panel.is-on { display: flex; }
.tt-howto { margin: 0; color: var(--tt-muted); font-size: 15px; max-width: 62ch; }
.tt-howto b { color: var(--tt-ink); }
.tt-centre { text-align: center; max-width: none; }
.tt-footnote { font-size: 13px; color: var(--tt-muted); margin: 4px 0 0; }

.tt-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.tt-stat {
  background: var(--tt-card);
  border: 1px solid var(--tt-line);
  border-radius: 12px;
  padding: 5px 13px;
  min-width: 78px;
}
.tt-stat span {
  display: block;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--tt-muted);
}
.tt-stat strong { font-size: 19px; font-variant-numeric: tabular-nums; }
.tt-spacer { margin-left: auto; }
.tt-hearts { letter-spacing: 3px; font-size: 19px; color: var(--tt-coral); }
.tt-hearts i { opacity: 0.22; font-style: normal; }

.tt-btn {
  font: inherit;
  cursor: pointer;
  background: var(--tt-card);
  border: 1px solid var(--tt-line);
  color: var(--tt-ink);
  border-radius: 12px;
  padding: 9px 15px;
  font-weight: 700;
}
.tt-btn:hover { border-color: var(--tt-coral); color: var(--tt-coral); }
.tt-btn-primary {
  background: var(--tt-coral);
  border-color: var(--tt-coral);
  color: #fff;
}
.tt-btn-primary:hover { color: #fff; filter: brightness(1.06); }
.tt-page :focus-visible { outline: 3px solid var(--tt-coral); outline-offset: 2px; border-radius: 10px; }

/* ---- progress strip (chain + stones) ---- */
.tt-strip {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  background: var(--tt-card);
  border: 1px solid var(--tt-line);
  border-radius: 14px;
  padding: 8px;
}
.tt-step {
  flex: 1 1 46px;
  min-width: 46px;
  height: 44px;
  border-radius: 10px;
  background: var(--tt-soft);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: 15px;
  color: var(--tt-muted);
  border: 2px solid transparent;
}
.tt-step u { text-decoration: none; font-size: 9.5px; font-weight: 700; opacity: 0.7; margin-top: 3px; }
.tt-step.is-done { background: var(--tt-green); color: #06301f; }
.tt-step.is-next {
  border-color: var(--tt-coral);
  color: var(--tt-coral);
  background: var(--tt-card);
  animation: tt-breathe 1.6s ease-in-out infinite;
}
@keyframes tt-breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.05); } }

/* ---- playfield ---- */
.tt-field {
  position: relative;
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  aspect-ratio: 1;
  background: var(--tt-board);
  border-radius: 20px;
  padding: 8px;
  touch-action: none;
}
.tt-grid { display: grid; width: 100%; height: 100%; gap: 3px; }
.tt-cell {
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  font-size: clamp(10px, 2.4vw, 15px);
  color: #fff;
}
.tt-cell.is-snake { background: var(--tt-green); }
.tt-cell.is-head { background: #fff; color: var(--tt-board); }
.tt-cell.is-chip { background: var(--tt-yellow); color: #3a2a00; }
.tt-cell.is-wrong { background: var(--tt-coral); color: #fff; }

/* ---- stepping stones ---- */
.tt-stones { display: grid; width: 100%; height: 100%; gap: 6px; position: relative; }
.tt-stone {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  background: var(--tt-board-2);
  color: #fff;
  font-weight: 800;
  font-size: clamp(13px, 3.4vw, 20px);
  font-variant-numeric: tabular-nums;
  transition: transform 0.1s, background 0.15s;
}
.tt-stone:hover { transform: translateY(-2px); }
.tt-stone.is-done { background: var(--tt-green); color: #06301f; }
.tt-stone.is-here { background: #fff; color: var(--tt-board); box-shadow: 0 0 0 4px var(--tt-coral); }
.tt-stone.is-wrong { animation: tt-nope 0.3s; background: var(--tt-coral); }
.tt-trail { position: absolute; inset: 0; pointer-events: none; }
@keyframes tt-nope { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ---- line up ---- */
.tt-lineup { display: flex; flex-direction: column; gap: 14px; }
.tt-slots { display: grid; grid-template-columns: repeat(6, 1fr); gap: 7px; }
@media (min-width: 720px) { .tt-slots { grid-template-columns: repeat(12, 1fr); } }
.tt-slot {
  border: 2px dashed var(--tt-line);
  background: var(--tt-card);
  border-radius: 12px;
  padding: 7px 2px 5px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  min-height: 64px;
  justify-content: center;
  cursor: pointer;
}
.tt-slot b { font-size: 17px; font-weight: 800; font-variant-numeric: tabular-nums; min-height: 21px; }
.tt-slot small { font-size: 10.5px; color: var(--tt-muted); font-weight: 700; }
.tt-slot.is-filled { border-style: solid; border-color: var(--tt-green); background: #eafaf3; }
.tt-slot.is-filled small { color: var(--tt-ink); opacity: 0.7; }
.tt-slot.is-ready { border-color: var(--tt-coral); }
.tt-slot.is-wrong { animation: tt-nope 0.3s; border-color: var(--tt-coral); }

.tt-tray {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  background: var(--tt-board);
  border-radius: 16px;
  padding: 12px;
  min-height: 78px;
  align-content: center;
}
.tt-pill {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: 12px;
  background: var(--tt-yellow);
  color: #3a2a00;
  font-weight: 800;
  font-size: 18px;
  font-variant-numeric: tabular-nums;
  padding: 10px 15px;
  transition: transform 0.1s;
}
.tt-pill:hover { transform: translateY(-2px); }
.tt-pill.is-sel { background: #fff; box-shadow: 0 0 0 4px var(--tt-coral); }
.tt-pill.is-gone { visibility: hidden; }
.tt-tray p { color: #d9d7ff; margin: auto; font-size: 14px; text-align: center; }

/* ---- finish overlay ---- */
.tt-over {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  text-align: center;
  padding: 24px;
  background: rgba(32, 28, 86, 0.92);
  border-radius: 20px;
  color: #fff;
}
.tt-over.is-on { display: flex; }
.tt-over h3 {
  font-family: "Baloo 2", "Nunito", sans-serif;
  font-size: clamp(22px, 5.5vw, 32px);
  margin: 0;
  font-weight: 600;
}
.tt-over p { margin: 0; opacity: 0.88; max-width: 32ch; font-size: 15px; }

@media (prefers-reduced-motion: reduce) {
  .tt-page *, .tt-page *::before, .tt-page *::after {
    animation: none !important;
    transition: none !important;
  }
}
