/* Newcomers Sudoku — web play page (play.html)
   Mirrors the app's GameScreen palette + layout (iOS-style, light). */

:root {
  --bg-top: #F0F4FF;
  --bg-mid: #F5EEFF;
  --bg-bot: #FFF5F0;
  --surface: #FFFFFF;
  --grid-shadow: rgba(0, 0, 0, 0.09);
  --grid-border: rgba(0, 122, 255, 0.125);

  --blue: #007AFF;
  --light-blue: #4FC3F7;
  --purple: #AF52DE;
  --green: #34C759;
  --red: #FF3B30;
  --orange: #FF9500;
  --yellow: #FFD60A;
  --gray: #8E8E93;
  --dark: #1C1C1E;

  --thin-line: rgba(167, 139, 250, 0.09);
  --thick-line: rgba(0, 122, 255, 0.25);
  --block-blue: rgba(0, 122, 255, 0.03);
  --block-purple: rgba(175, 82, 222, 0.03);
  --prefilled-tint: rgba(175, 82, 222, 0.12);
  --note: rgba(153, 153, 153, 0.38);

  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; }

body {
  font-family: var(--font);
  background: linear-gradient(180deg, var(--bg-top) 0%, var(--bg-mid) 50%, var(--bg-bot) 100%);
  background-attachment: fixed;
  color: var(--dark);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.app-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 520px;
  margin: 0 auto;
  padding: 14px 18px 6px;
}
.app-bar .brand {
  font-weight: 800;
  font-size: 18px;
  color: var(--dark);
  text-decoration: none;
  letter-spacing: -0.02em;
}
.app-bar .brand span { color: var(--purple); }
.app-bar select {
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--dark);
  background: var(--surface);
  border: 1px solid rgba(0, 122, 255, 0.18);
  border-radius: 10px;
  padding: 7px 10px;
  cursor: pointer;
  max-width: 190px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.game-wrap {
  max-width: 520px;
  margin: 0 auto;
  padding: 6px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* ── Intro heading (SEO + on-page topic) ── */
.game-intro { text-align: center; padding: 2px 0 4px; }
.game-intro h1 {
  font-size: 20px;
  font-weight: 800;
  color: var(--dark);
  margin: 0 0 4px;
  letter-spacing: -0.02em;
}
.game-intro p {
  font-size: 14px;
  color: #636366;
  margin: 0;
  line-height: 1.5;
}

/* ── Grid ── */
.board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1 / 1;
  background: var(--surface);
  border: 2px solid var(--grid-border);
  border-radius: 16px;
  box-shadow: 0 3px 10px var(--grid-shadow);
  overflow: hidden;
  direction: ltr; /* spatial puzzle stays LTR in RTL locales */
}
.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(14px, 4.4vw, 22px);
  font-weight: 700;
  color: var(--dark);
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  line-height: 1;
  transition: background 0.08s ease;
}
/* checkerboard block tints */
.cell.blk0, .cell.blk2, .cell.blk4, .cell.blk6, .cell.blk8 { background: var(--block-blue); }
.cell.blk1, .cell.blk3, .cell.blk5, .cell.blk7 { background: var(--block-purple); }
/* given (prefilled) tint overrides block bg */
.cell.given { background: var(--prefilled-tint); }
.cell.given .digit { color: var(--dark); font-weight: 800; }
.cell.played .digit { color: var(--blue); }
.cell.wrong .digit { color: var(--red); }

/* selection + highlights (single light-blue system) */
.cell.selected { background: rgba(79, 195, 247, 0.40); }
.cell.sameval { background: rgba(79, 195, 247, 0.35); }
.cell.peer { background: rgba(79, 195, 247, 0.12); }

/* digit circle behind the selected cell */
.cell .digit { position: relative; z-index: 1; }
.cell.selected .digit {
  width: 62%; height: 62%;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  background: rgba(79, 195, 247, 0.20);
}

/* thin/thick grid lines */
.cell { border-top: 0.5px solid var(--thin-line); border-left: 0.5px solid var(--thin-line); }
.cell.bt { border-top: 1.8px solid var(--thick-line); }
.cell.bl { border-left: 1.8px solid var(--thick-line); }

/* notes (pencil marks) — 3x3 mini grid */
.cell .notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  width: 100%; height: 100%;
  font-size: clamp(7px, 2vw, 11px);
  color: var(--note);
  font-weight: 600;
  pointer-events: none;
}
.cell .notes span {
  display: flex; align-items: center; justify-content: center;
  visibility: hidden;
}
.cell .notes span.on { visibility: visible; }

/* ── Word panel (gradient card, mirrors WordPanel) ── */
.word-panel {
  position: relative;
  background: linear-gradient(135deg, #AF52DE, #5AC8FA);
  border-radius: 12px;
  box-shadow: 0 4px 8px rgba(175, 82, 222, 0.15);
  padding: 14px 18px;
  min-height: 96px;
  text-align: center;
  color: #fff;
}
.word-panel .wp-group {
  font-size: 14px;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.02em;
}
.word-panel .wp-word {
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 800;
  line-height: 1.15;
  margin-top: 2px;
}
.word-panel .wp-base {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.72);
  margin-top: 2px;
}
.word-panel .wp-hint {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.85);
  font-weight: 600;
  margin-top: 10px;
}
.word-panel .wp-speak {
  position: absolute;
  top: 10px;
  right: 12px;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
  border-radius: 50%;
  width: 34px; height: 34px;
  font-size: 16px;
  cursor: pointer;
  display: none;
}
.word-panel .wp-speak.show { display: block; }
[dir="rtl"] .word-panel .wp-speak { right: auto; left: 12px; }

/* ── Control bar ── */
.control-bar {
  display: flex;
  justify-content: center;
  gap: 16px;
}
.tool {
  width: 44px; height: 44px;
  border: none;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--gray);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.06s ease, background 0.1s ease;
}
.tool:active { transform: scale(0.94); }
.tool.active { background: rgba(255, 149, 0, 0.10); color: var(--orange); }
.tool:disabled { color: #D1D1D6; cursor: default; }

/* ── Numpad ── */
.numpad {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
}
.num-btn {
  position: relative;
  aspect-ratio: 1 / 1;
  margin: 4px;
  border-radius: 14px;
  border: 1.5px solid;
  font-family: var(--font);
  font-size: clamp(20px, 6vw, 26px);
  font-weight: 700;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.06s ease, opacity 0.1s ease;
  background-clip: padding-box;
}
.num-btn:active { transform: scale(0.92); }
.num-btn.full { opacity: 0.55; }
.num-btn .cnt {
  position: absolute;
  top: 3px; right: 5px;
  font-size: 10px;
  font-weight: 700;
  padding: 1px 5px;
  border-radius: 6px;
}
[dir="rtl"] .num-btn .cnt { right: auto; left: 5px; }
.num-erase {
  aspect-ratio: 1 / 1;
  margin: 4px;
  border: none;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.03);
  color: var(--gray);
  font-size: 20px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.num-erase:active { transform: scale(0.92); }

/* ── Footer CTA ── */
.app-footer {
  max-width: 520px;
  margin: 0 auto;
  text-align: center;
  padding: 22px 18px 44px;
}
.app-footer .cta-line {
  font-size: 17px;
  font-weight: 700;
  color: var(--dark);
  margin-bottom: 14px;
}
.app-footer .store-badge img { height: 54px; width: auto; }
.app-footer .fine { margin-top: 16px; font-size: 13px; color: var(--gray); }
.app-footer .fine a { color: var(--blue); text-decoration: none; }

/* ── Win dialog ── */
.win {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(28, 28, 30, 0.5);
  backdrop-filter: blur(4px);
  z-index: 50;
  padding: 20px;
}
.win.show { display: flex; }
.win-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: linear-gradient(135deg, #AF52DE, #5AC8FA);
  border-radius: 28px;
  padding: 34px 24px 22px;
  text-align: center;
  box-shadow: 0 18px 40px rgba(175, 82, 222, 0.4);
  animation: pop 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes pop { from { transform: scale(0.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.win-trophy { font-size: 48px; }
.win-title { font-size: 28px; font-weight: 900; color: #fff; letter-spacing: 1px; margin-top: 8px; }
.win-time {
  display: inline-flex; align-items: center; gap: 8px;
  margin-top: 12px;
  padding: 6px 20px;
  background: rgba(255, 255, 255, 0.18);
  border-radius: 20px;
  font-size: 20px; font-weight: 700; color: #fff;
}
.win-actions { display: flex; gap: 10px; margin-top: 20px; }
.win-actions button {
  flex: 1;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
  border-radius: 12px;
  padding: 12px;
  font-family: var(--font);
  font-size: 14px; font-weight: 700;
  cursor: pointer;
}
.win-actions button.primary { background: #fff; color: #AF52DE; border: none; }
.win-close {
  position: absolute; top: 12px; right: 14px;
  border: none; background: transparent;
  color: rgba(255, 255, 255, 0.8); font-size: 18px; cursor: pointer;
}
[dir="rtl"] .win-close { right: auto; left: 14px; }

@media (max-width: 480px) {
  .game-wrap { padding: 4px 12px 20px; gap: 10px; }
}
