/* Puzzle Kaki: big, warm, calm. Built for an 11-inch iPad (1180 x 820 points).
   Rules from the design: text 24px+, 7:1 contrast for body text, buttons 72px+,
   letter tiles 104px, single taps only, colour is never the only signal. */
:root {
  --bg: #FFF4E6; --card: #FFFFFF; --ink: #2B1D12; --muted: #5B4636;
  --orange: #C2410C; --orange-dark: #8A2E08; --orange-soft: #FFE4D2;
  --sun: #F6C343; --sun-soft: #FFF1CC; --green: #2B7A4B; --green-soft: #DCF0E3;
  --line: #EAD6BF; --blue: #1D6FB8; --rose: #FCE1E4; --nearly: #B45309; --nearly-soft: #FFEDD5;
  --f-body: "Atkinson Hyperlegible", Verdana, system-ui, sans-serif;
  --f-head: "Nunito", "Atkinson Hyperlegible", system-ui, sans-serif;
  --f-ta: "Noto Sans Tamil", "Tamil Sangam MN", "Tamil MN", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink); font-family: var(--f-body);
  font-size: 24px; line-height: 1.4;
  -webkit-text-size-adjust: 100%; -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; }
button:focus-visible { outline: 4px solid var(--blue); outline-offset: 3px; }
h1, h2, h3 { font-family: var(--f-head); font-weight: 900; margin: 0; line-height: 1.15; letter-spacing: -0.01em; text-wrap: balance; }
h1 { font-size: 56px; }
h2 { font-size: 46px; }
h3 { font-size: 30px; }
p { margin: 0; }
.big { font-size: 30px; }
.muted { color: var(--muted); }
.ta, .ta * { font-family: var(--f-ta); }
[hidden] { display: none !important; }

/* ---------- frame ---------- */
.app {
  position: relative; height: 100vh; height: 100dvh; overflow: hidden; display: flex; flex-direction: column;
  background: linear-gradient(#CDEBFF 0%, #E6F5FF 45%, #FFF4E6 100%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.scene { position: fixed; inset: auto 0 0 0; width: 100%; height: 100%; object-fit: contain; object-position: bottom center; pointer-events: none; z-index: 0; }
.scene.calm { opacity: 0.16; }
.app > :not(.scene) { position: relative; z-index: 1; }
.app.calm { background: var(--bg); }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  padding: 16px 32px; background: rgba(255, 255, 255, 0.94); border-bottom: 2px solid var(--line);
}
.date { font-size: 24px; font-weight: 700; }
.top-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; justify-content: flex-end; }
.pill {
  display: inline-flex; align-items: center; gap: 8px; min-height: 56px; padding: 6px 18px;
  background: var(--sun-soft); border: 2px solid var(--sun); border-radius: 999px; font-weight: 700; font-size: 22px;
}
.voice-btn { background: var(--card); border-color: var(--orange); color: var(--orange-dark); cursor: pointer; min-height: 64px; }
.pill.clues .dot { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--orange); display: inline-block; }
.pill.clues .dot.on { background: var(--orange); }

.scr { flex: 1; display: flex; flex-direction: column; gap: 24px; padding: 28px 40px 32px; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.center { align-items: center; justify-content: center; text-align: center; }

/* ---------- buttons ---------- */
.btn {
  min-height: 80px; padding: 0 36px; border-radius: 24px; border: 3px solid var(--orange);
  background: var(--orange); color: #fff; font-weight: 700; font-size: 28px; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; gap: 12px;
  box-shadow: 0 6px 0 var(--orange-dark); transition: transform 0.08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--orange-dark); }
.btn.ghost { background: var(--card); color: var(--orange-dark); box-shadow: 0 6px 0 var(--line); }
.btn.big { min-height: 104px; font-size: 34px; min-width: min(560px, 100%); }
.btn.small { min-height: 72px; font-size: 26px; padding: 0 24px; }
.btn:disabled { background: #E7E1DA; border-color: #CFC6BC; color: #4A3D33; box-shadow: none; }
.link-btn { background: none; border: 0; color: var(--orange-dark); text-decoration: underline; font-size: 24px; min-height: 64px; padding: 0 16px; cursor: pointer; }
.row-actions { display: flex; gap: 20px; justify-content: center; flex-wrap: wrap; }
.pulse { animation: pulse 2.4s ease-in-out infinite; }
@keyframes pulse { 50% { box-shadow: 0 6px 0 var(--orange-dark), 0 0 0 10px rgba(246, 195, 67, 0.7); } }
@media (prefers-reduced-motion: reduce) { .pulse { animation: none; outline: 5px solid var(--sun); } * { transition: none !important; } }

.card { background: var(--card); border: 3px solid var(--line); border-radius: 28px; padding: 24px; box-shadow: 0 5px 0 var(--line); }

/* ---------- start / end ---------- */
.start h1, .end h1 { font-size: 64px; text-shadow: 0 0 14px #fff, 0 0 4px #fff; }
.start p.big, .end p.big { text-shadow: 0 0 12px #fff, 0 0 4px #fff; font-weight: 700; }
.sun-big svg { width: 160px; height: 160px; }
.end .remind { max-width: 640px; width: 100%; text-align: left; margin-top: 12px; }

/* ---------- home ---------- */
.home { display: grid; grid-template-columns: 1fr 1.2fr; gap: 32px; align-items: start; }
.home .col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.greet { display: flex; align-items: center; gap: 16px; }
.greet h2 { font-size: 52px; text-shadow: 0 0 12px #fff, 0 0 4px #fff; }
.sun svg { width: 112px; height: 112px; }
.bubble { margin-top: 10px; background: var(--card); border: 3px solid var(--sun); border-radius: 22px; padding: 12px 18px; font-size: 24px; }
.sub { font-size: 28px; text-shadow: 0 0 10px #fff; }
.pz { display: flex; align-items: center; gap: 20px; width: 100%; text-align: left; cursor: pointer; min-height: 100px; padding: 10px 22px; }
.pz .badge { width: 76px; height: 76px; border-radius: 26px; display: grid; place-items: center; flex: none; }
.badge svg { width: 64px; height: 64px; }
.b-word { background: var(--orange-soft); } .b-sudoku { background: #DDEBFA; } .b-crossword { background: var(--sun-soft); } .b-tamil { background: var(--green-soft); }
.badge.big { width: 120px; height: 120px; border-radius: 34px; margin: 0 auto; }
.badge.big svg { width: 88px; height: 88px; }
.pz .txt { display: flex; flex-direction: column; }
.pz-name { font-family: var(--f-head); font-weight: 900; font-size: 30px; }
.pz .state { font-size: 22px; color: var(--muted); font-weight: 700; }
.pz.next { border-color: var(--orange); }
.pz.done { background: var(--green-soft); border-color: var(--green); cursor: default; }
.pz.done .state { color: var(--green); }
.pz:disabled { color: var(--ink); opacity: 1; }

.remind { display: flex; flex-direction: column; gap: 12px; border-color: var(--sun); background: var(--sun-soft); }
.remind h3 { font-size: 28px; }
.rem { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.rem.done span:first-child { color: var(--green); font-weight: 700; }

/* ---------- intro ---------- */
.intro-card { max-width: 820px; display: flex; flex-direction: column; gap: 16px; padding: 32px 40px; }

/* ---------- puzzle shell ---------- */
.puz { align-items: center; text-align: center; overflow: auto; padding-top: 20px; padding-bottom: 12px; gap: 16px; }
.puzzle-area { width: 100%; max-width: 1100px; display: flex; flex-direction: column; align-items: center; gap: 18px; }
.actions {
  display: flex; gap: 16px; justify-content: center; flex-wrap: wrap;
  padding: 14px 24px calc(14px + env(safe-area-inset-bottom)); background: rgba(255, 255, 255, 0.94); border-top: 2px solid var(--line);
}
.actions .btn { min-height: 76px; font-size: 26px; }
.say-line { font-size: 26px; font-weight: 700; color: var(--orange-dark); background: var(--card); border: 3px solid var(--sun); border-radius: 20px; padding: 8px 20px; }
.ask { font-family: var(--f-head); font-weight: 900; font-size: 30px; }
.ask.ta { font-family: var(--f-ta); font-weight: 700; }
.ask-en { font-size: 22px; margin-top: -10px; }
.clue { font-size: 40px; font-weight: 700; max-width: 900px; }
.hint { min-height: 1.4em; font-size: 26px; font-weight: 700; color: var(--nearly); }

/* letters */
.board { display: flex; flex-direction: column; align-items: center; gap: 22px; width: 100%; }
.slots, .tiles { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }
.slot {
  width: min(96px, calc((100vw - 120px) / var(--n) - 12px)); height: 104px; display: grid; place-items: center;
  font-family: var(--f-head); font-weight: 900; font-size: 56px; background: var(--card);
  border: 3px solid var(--line); border-bottom: 7px solid var(--orange); border-radius: 14px 14px 6px 6px;
}
.slots.ta .slot, .tiles.ta .tile { font-family: var(--f-ta); font-weight: 700; font-size: 44px; }
.slot.given { background: var(--sun-soft); }
.slot.right { background: var(--green-soft); border-color: var(--green); }
.slot.nearly { background: var(--nearly-soft); border-color: var(--nearly); }
.tile {
  width: 104px; height: 104px; border-radius: 26px; font-family: var(--f-head); font-weight: 900; font-size: 56px;
  background: var(--card); color: var(--ink); border: 3px solid var(--ink); box-shadow: 0 6px 0 var(--ink); cursor: pointer;
}
.tile:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }
.tile:disabled { visibility: hidden; }

/* sudoku */
.sudoku-wrap { display: flex; gap: 40px; align-items: center; justify-content: center; flex-wrap: wrap; }
.sudoku { display: grid; grid-template-columns: repeat(var(--n), var(--cell)); border: 5px solid var(--ink); border-radius: 12px; overflow: hidden; background: var(--card); }
.sudoku.s4 { --cell: 96px; }
.sudoku.s6 { --cell: 84px; }
.sudoku .cell {
  width: var(--cell); height: var(--cell); border: 1px solid #BFAE9C; display: grid; place-items: center;
  font-family: var(--f-head); font-weight: 900; font-size: calc(var(--cell) * 0.5); background: var(--card); padding: 0; border-radius: 0;
}
.sudoku .cell.edge-r { border-right: 4px solid var(--ink); }
.sudoku .cell.edge-b { border-bottom: 4px solid var(--ink); }
.sudoku .cell.given { background: #F4EDE4; }
.sudoku .cell.mine { color: var(--blue); }
.sudoku .cell.empty { cursor: pointer; }
.sudoku .cell.sel { background: var(--sun-soft); box-shadow: inset 0 0 0 5px var(--orange); }
.sudoku .cell.right { background: var(--green-soft); }
.sudoku .cell.nearly { background: var(--nearly-soft); box-shadow: inset 0 0 0 5px var(--nearly); }
.numpad { display: grid; grid-template-columns: repeat(2, 104px); gap: 16px; }
.sudoku.s6 + .numpad { grid-template-columns: repeat(3, 96px); }
.num { width: 100%; height: 104px; border-radius: 24px; border: 3px solid var(--ink); background: var(--card); box-shadow: 0 6px 0 var(--ink); font-family: var(--f-head); font-weight: 900; font-size: 52px; cursor: pointer; }
.num:active { transform: translateY(4px); box-shadow: 0 2px 0 var(--ink); }

/* crossword */
.cw-current { font-size: 32px; max-width: 1000px; }
.cw-num { color: var(--orange-dark); }
.cw-layout { display: flex; gap: 32px; align-items: flex-start; justify-content: center; width: 100%; }
.cw-grid { display: grid; grid-template-columns: repeat(5, 80px); gap: 4px; }
.cw-cell { width: 80px; height: 80px; position: relative; display: grid; place-items: center; font-family: var(--f-head); font-weight: 900; font-size: 44px; background: var(--card); border: 3px solid var(--ink); border-radius: 10px; }
.cw-cell.block { background: transparent; border-color: transparent; }
.cw-cell .n { position: absolute; top: 2px; left: 6px; font-size: 16px; font-family: var(--f-body); font-weight: 700; }
.cw-cell.locked { background: #F4EDE4; }
.cw-cell.sel { background: var(--sun-soft); border-color: var(--orange); border-width: 4px; }
.cw-cell.right { background: var(--green-soft); border-color: var(--green); }
.cw-cell.nearly { background: var(--nearly-soft); border-color: var(--nearly); }
.cw-side { display: flex; flex-direction: column; gap: 16px; align-items: center; width: min(640px, 100%); }
.cw-clues { display: flex; flex-direction: column; gap: 8px; width: 100%; }
.cw-clue { text-align: left; min-height: 64px; padding: 10px 18px; border-radius: 18px; border: 3px solid var(--line); background: var(--card); font-size: 24px; cursor: pointer; }
.cw-clue b { color: var(--orange-dark); }
.cw-clue.sel { border-color: var(--orange); background: var(--sun-soft); }
.cw-clue.done { border-color: var(--green); background: var(--green-soft); }
.cw-clue .tick { color: var(--green); font-weight: 700; }
.cw-tiles .tile { width: 96px; height: 96px; font-size: 50px; }

/* tamil */
.picture { font-size: 150px; line-height: 1.1; }
.ta-line { font-size: 48px; font-weight: 700; line-height: 1.6; }
.gap { display: inline-block; width: 170px; height: 0.9em; border-bottom: 6px solid var(--orange); vertical-align: middle; }
.choices { display: flex; gap: 20px; flex-wrap: wrap; justify-content: center; max-width: 1000px; }
.choice {
  min-width: 220px; min-height: 104px; padding: 8px 28px; border-radius: 26px; border: 3px solid var(--ink); background: var(--card);
  box-shadow: 0 6px 0 var(--ink); font-size: 44px; font-weight: 700; cursor: pointer;
}
.choice.faded { opacity: 0.35; box-shadow: none; text-decoration: line-through; }
.choice.right { background: var(--green-soft); border-color: var(--green); box-shadow: 0 6px 0 var(--green); }
.choice.right::after { content: " ✓"; }

/* solved */
.solved h1 { color: var(--orange-dark); }

/* setup */
.code { font-size: 56px; letter-spacing: 0.15em; font-weight: 700; font-variant-numeric: tabular-nums; }
.keypad { display: grid; grid-template-columns: repeat(3, 120px); gap: 14px; }
.key { height: 88px; border-radius: 20px; border: 3px solid var(--ink); background: var(--card); font-size: 34px; font-weight: 700; cursor: pointer; }
.key.btn { padding: 0; font-size: 28px; }

/* ---------- held upright ---------- */
@media (orientation: portrait), (max-width: 900px) {
  .home { grid-template-columns: 1fr; }
  .scr { padding: 24px 28px; }
  .sudoku-wrap { flex-direction: column; gap: 28px; }
  .sudoku.s4 + .numpad { grid-template-columns: repeat(4, 104px); }
  .sudoku.s6 + .numpad { grid-template-columns: repeat(6, 96px); }
  .cw-layout { flex-direction: column; align-items: center; }
  .cw-grid { grid-template-columns: repeat(5, 92px); }
  .cw-cell { width: 92px; height: 92px; }
  .cw-side { width: min(680px, 100%); }
}
/* landscape is short on height: tighten the crossword */
@media (orientation: landscape) and (max-height: 860px) {
  .cw-current { display: none; }
  .cw-grid { grid-template-columns: repeat(5, 72px); }
  .cw-cell { width: 72px; height: 72px; font-size: 40px; }
  .cw-tiles .tile { width: 88px; height: 88px; font-size: 46px; }
  .picture { font-size: 120px; }
}
