/* Birthday Sudoku (bday.coolsudoku.app). Always the app's dark theme; tokens from ../styles.css.
   Built for the TikTok in-app browser: every screen fits one phone screen without scrolling. */

:root {
  color-scheme: dark;
  --bg: #1A1E32;
  --card: #25305A;
  --board: #222E5D;
  --text: #FFFFFF;
  --text-2: rgb(255 255 255 / 0.74);
  --accent: #3A20D8;
  --accent-2: #5740FD;
  --accent-text: #9AA5FF;
  --grid: #1A1E32;
  --focus: #7C8CFF;
  --brand-navy: #232F5C;
  --brand-blue: linear-gradient(180deg, #3F5BF2 0%, #1638FF 100%);
  --r-control: 12px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  /* One date tile: 8 tiles plus the gaps take about 9.6 tile widths of the column. */
  --t: min(44px, calc((min(100vw, 440px) - 40px) / 9.6));
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
h1, h2, p { margin: 0; }
img, svg { display: block; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; -webkit-tap-highlight-color: transparent; }

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 1.0625rem;
  line-height: 1.5;
  color: var(--text);
  background-color: var(--bg);
  background-image:
    radial-gradient(circle at 85% 0%, rgb(22 56 255 / 0.35), transparent 45%),
    radial-gradient(circle at 0% 100%, rgb(87 64 253 / 0.25), transparent 45%);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }

.page {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: min(100%, 440px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px max(20px, env(safe-area-inset-bottom));
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 0.9375rem;
}
.brand img { border-radius: 7px; }

/* ---------- Screen 1: the question ---------- */

.hero { display: grid; gap: 10px; margin-top: 2vh; }
h1 {
  font-family: var(--font-display);
  font-size: clamp(2rem, 1.4rem + 3vw, 2.5rem);
  font-weight: 800;
  line-height: 1.06;
  letter-spacing: -0.035em;
  text-wrap: balance;
}
.lead { color: var(--text-2); text-wrap: pretty; }

/* ---------- Date tiles ---------- */

.date-entry { display: grid; justify-items: center; gap: 8px; }
.tiles { display: flex; gap: calc(var(--t) * 0.36); }
.tile-group { display: grid; justify-items: center; gap: 6px; }
.tile-group > div { display: flex; gap: calc(var(--t) * 0.1); }
.tile-group small {
  color: var(--text-2);
  font-size: 0.6875rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.page:not([data-state="input"]) .tile-group small { display: none; }
.tile {
  display: grid;
  place-items: center;
  width: var(--t);
  height: calc(var(--t) * 1.14);
  border-radius: calc(var(--t) * 0.2);
  background: rgb(255 255 255 / 0.04);
  box-shadow: inset 0 0 0 1.5px rgb(255 255 255 / 0.14);
  font: 900 calc(var(--t) * 0.62) var(--font-display);
  transition: background 0.2s var(--ease), box-shadow 0.2s var(--ease), opacity 0.3s var(--ease);
}
.tile.filled { background: var(--brand-navy); box-shadow: 0 2px 8px rgb(0 0 0 / 0.25); animation: press 0.18s var(--ease); }
.tile.active { box-shadow: inset 0 0 0 2px var(--focus); }
.tile.active::after {
  content: "";
  width: 2px;
  height: 46%;
  border-radius: 1px;
  background: var(--focus);
  animation: caret 1s steps(1) infinite;
}
/* Digits that go into the board turn brand blue once the date is complete. */
.tile.hot { background: var(--brand-blue); box-shadow: 0 4px 14px rgb(22 56 255 / 0.45); }
.tile.sent { opacity: 0.4; }
/* Smaller tiles on the result screen leave the board more room. */
.page[data-state="result"] { --t: min(34px, calc((min(100vw, 440px) - 40px) / 11)); }
.page[data-state="result"] { gap: 12px; }
.page[data-state="result"] .date-entry { gap: 4px; }
.tiles.shake { animation: shake 0.4s var(--ease); }
.date-label { color: var(--text-2); font-weight: 600; font-size: 0.9375rem; }
.error { color: #FF9AA0; font-size: 0.9375rem; font-weight: 600; text-align: center; }

/* ---------- Keypad (the app's number pad) ---------- */

.keypad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: auto;
}
.keypad button {
  min-height: 58px;
  border: 0;
  border-radius: var(--r-control);
  background: var(--card);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.04);
  color: var(--accent-text);
  font: 600 1.75rem var(--font-display);
  cursor: pointer;
  touch-action: manipulation;
  transition: transform 0.12s var(--ease), background 0.12s;
}
.keypad button:active { transform: scale(0.95); background: #2E3A6B; }
.keypad .key-back { display: grid; place-items: center; color: var(--text-2); }
.keypad .key-back svg { width: 28px; height: 28px; }

/* ---------- Persona ---------- */

.persona { display: grid; justify-items: center; gap: 4px; text-align: center; animation: rise 0.45s var(--ease) both; }
.chip {
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--brand-blue);
  font-size: 0.75rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.persona h2 {
  margin-top: 6px;
  font-family: var(--font-display);
  font-size: clamp(1.75rem, 1.3rem + 2.4vw, 2.25rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.03em;
}
.persona-line { color: var(--text-2); font-size: 1rem; }

/* ---------- Board ---------- */

.board-wrap { display: grid; justify-items: center; }
.board {
  /* As large as the screen allows, leaving room for everything else on the result screen. */
  --size: min(100%, max(220px, calc(100dvh - 440px)));
  /* One grid for all 81 cells, so every line runs straight across the board. The 1px tracks
     between boxes plus the gaps on both sides make the 3px box lines. */
  --tracks: repeat(3, 1fr) 1px repeat(3, 1fr) 1px repeat(3, 1fr);
  display: grid;
  grid-template: var(--tracks) / var(--tracks);
  gap: 1px;
  width: var(--size);
  aspect-ratio: 1;
  padding: 3px;
  border-radius: var(--r-control);
  background: var(--grid);
  box-shadow: 0 18px 50px rgb(0 0 0 / 0.35);
  container-type: inline-size;
  animation: grow 0.45s var(--ease) both;
}
.page[data-state="reveal"] .board { --size: min(100%, max(220px, calc(100dvh - 260px))); }
.cell {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  line-height: 1;
  background: var(--board);
  font: 600 7.4cqi var(--font-display);
  font-variant-numeric: tabular-nums;
}
.cell.given { animation: fade 0.35s var(--ease) both; }
.cell b {
  display: grid;
  place-items: center;
  width: calc(100% - 4px);
  height: calc(100% - 4px);
  border-radius: 22%;
  background: var(--brand-blue);
  box-shadow: 0 2px 8px rgb(22 56 255 / 0.5);
  font-weight: 800;
}
.flyer {
  position: fixed;
  z-index: 10;
  display: grid;
  place-items: center;
  border-radius: calc(var(--t) * 0.2);
  background: var(--brand-blue);
  box-shadow: 0 8px 24px rgb(22 56 255 / 0.55);
  font: 900 calc(var(--t) * 0.62) var(--font-display);
  pointer-events: none;
  transform-origin: 0 0;
}

/* ---------- Actions ---------- */

.actions { display: grid; gap: 10px; margin-top: auto; animation: rise 0.45s var(--ease) 0.15s both; }
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 50px;
  padding: 0 18px;
  border: 0;
  border-radius: var(--r-control);
  background: var(--accent);
  color: #FFFFFF;
  font-weight: 700;
  font-size: 0.9375rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s var(--ease), filter 0.15s;
}
.button:hover { filter: brightness(1.08); }
.button:active { transform: scale(0.97); }
.button-cta {
  min-height: 58px;
  background: var(--accent-2);
  font-size: min(1rem, 3.9vw);
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 10px 30px rgb(87 64 253 / 0.45);
}
.button-cta img { border-radius: 7px; }
.button-ghost {
  padding: 0 10px;
  background: rgb(255 255 255 / 0.06);
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 0.12);
  letter-spacing: 0;
  text-transform: none;
  font-size: 1rem;
}
.note { color: var(--text-2); font-size: 0.8125rem; text-align: center; margin-top: -4px; }
.actions-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  translate: -50% 0;
  padding: 10px 16px;
  border-radius: 999px;
  background: #FFFFFF;
  color: #0F172A;
  font-weight: 700;
  font-size: 0.9375rem;
  animation: rise 0.25s var(--ease);
}

@keyframes caret { 50% { opacity: 0; } }
@keyframes press { 50% { transform: scale(1.12); } }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }
@keyframes rise { from { opacity: 0; transform: translateY(12px); } }
@keyframes grow { from { opacity: 0; transform: scale(0.92); } }
@keyframes fade { from { opacity: 0; transform: scale(0.6); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 1ms !important; animation-delay: 0ms !important; transition: none !important; }
}
