/* ═══════════════════════════════════════════════════════════════
   SUDOKU ARCADE — BASE STYLES
   Variables · Reset · Layout · Menu · Panels · Buttons · Overlay
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --panel-soft: #f4f4f4;
  --text: #111111;
  --muted: #666666;
  --line: #111111;
  --line-soft: #cfcfcf;
  --accent: #111111;
  --accent-inverse: #ffffff;
  --shadow: 0 14px 34px rgba(0, 0, 0, 0.08);
  --radius-xl: 24px;
  --radius-lg: 18px;
  --radius-md: 14px;
  --radius-sm: 10px;
  --cell-size: min(9vw, 58px);
  --transition-fast: 140ms ease;
  --transition-med: 220ms ease;
}

/* ── Reset ───────────────────────────────────────────────────── */
* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

body {
  display: flex;
  justify-content: center;
  overflow-x: hidden;
}

button, input { font: inherit; }
button { cursor: pointer; }

/* ── App shell ───────────────────────────────────────────────── */
.app-shell {
  width: min(100%, 1100px);
  min-height: 100vh;
  padding: calc(16px + env(safe-area-inset-top, 0px)) 16px calc(24px + env(safe-area-inset-bottom, 0px));
}

/* ── Topbar ──────────────────────────────────────────────────── */
.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 14px;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border: 2px solid var(--line);
  border-radius: 16px;
  display: grid;
  place-items: center;
  font-size: 28px;
  font-weight: 700;
  background: var(--panel);
}

.brand-copy h1 {
  margin: 0 0 3px;
  font-size: 30px;
  line-height: 1;
}

.brand-copy p {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.topbar-best {
  padding: 12px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  box-shadow: var(--shadow);
  font-size: 14px;
  white-space: nowrap;
}

/* ── Panel base ──────────────────────────────────────────────── */
.panel {
  border: 2px solid var(--line);
  border-radius: var(--radius-xl);
  background: var(--panel);
  box-shadow: var(--shadow);
}

/* ── Menu grid ───────────────────────────────────────────────── */
.menu-grid {
  display: grid;
  gap: 16px;
  grid-template-columns: 1.15fr 0.85fr;
}

/* ── Hero panel ──────────────────────────────────────────────── */
.hero-panel {
  padding: 20px;
  min-height: 520px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
}

.hero-title {
  margin: 0 0 8px;
  font-size: clamp(32px, 5vw, 54px);
  line-height: 0.95;
}

.hero-subtitle {
  margin: 0 0 20px;
  max-width: 620px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.5;
}

.hero-footer {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin-top: 20px;
}

/* ── Play cards ──────────────────────────────────────────────── */
.play-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.play-card {
  border: 2px solid var(--line);
  background: var(--panel);
  border-radius: 22px;
  padding: 18px;
  min-height: 138px;
  text-align: left;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.play-card:hover {
  transform: translateY(-2px);
  background: var(--panel-soft);
}

.play-card strong {
  display: block;
  font-size: 24px;
  margin-bottom: 8px;
}

.play-card span {
  display: block;
  color: var(--muted);
  line-height: 1.4;
}

.play-card-wide {
  grid-column: 1 / -1;
}

/* ── Mini cards ──────────────────────────────────────────────── */
.mini-card, .stats-card {
  border: 2px solid var(--line);
  border-radius: 18px;
  background: var(--panel);
  padding: 14px;
}

.mini-card-label, .stats-card-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.mini-card-value, .stats-card-value {
  font-size: 28px;
  font-weight: 700;
}

.mini-card-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}

.mini-card-plays {
  border-color: var(--accent);
}

/* ── Side panel ──────────────────────────────────────────────── */
.side-panel {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 520px;
}

.side-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.side-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.side-stack {
  display: grid;
  gap: 12px;
  margin-top: 10px;
}

.side-note {
  border: 2px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: var(--panel-soft);
}

.side-note strong {
  display: block;
  margin-bottom: 8px;
  font-size: 18px;
}

/* ── Difficulty / Stats / Time-select panels ─────────────────── */
.difficulty-panel, .stats-panel {
  padding: 20px;
}

.difficulty-panel h2, .stats-panel h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.difficulty-panel p, .stats-panel p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.back-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
}

.back-row-copy h2 { margin: 0 0 6px; }
.back-row-copy p  { margin: 0; }

.difficulty-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.diff-card {
  border: 2px solid var(--line);
  border-radius: 22px;
  background: var(--panel);
  padding: 18px;
  min-height: 180px;
  text-align: left;
  transition: transform var(--transition-fast), background var(--transition-fast);
}

.diff-card:hover {
  transform: translateY(-2px);
  background: var(--panel-soft);
}

.diff-card strong {
  display: block;
  font-size: 24px;
  margin-bottom: 10px;
}

.diff-card span {
  color: var(--muted);
  line-height: 1.5;
}

/* ── Stats grid ──────────────────────────────────────────────── */
.stats-grid {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

/* ── Buttons ─────────────────────────────────────────────────── */
.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.btn {
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--text);
  border-radius: 999px;
  padding: 11px 16px;
  transition: transform var(--transition-fast), background var(--transition-fast), color var(--transition-fast);
}

.btn:hover { transform: translateY(-1px); }
.btn-primary { background: var(--accent); color: var(--accent-inverse); }
.btn-ghost   { background: var(--panel-soft); }

/* ── Time select ─────────────────────────────────────────────── */
.time-select-block {
  margin: 18px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.time-select-label { font-size: 15px; font-weight: 700; }

.time-select-row {
  display: flex;
  align-items: center;
  gap: 14px;
}

.time-input {
  width: 90px;
  border: 2px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--text);
  font-size: 28px;
  font-weight: 700;
  text-align: center;
  padding: 10px 8px;
  -moz-appearance: textfield;
}

.time-input::-webkit-inner-spin-button,
.time-input::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.time-input:focus {
  outline: none;
  border-color: var(--accent);
}

.time-select-hint  { color: var(--muted); font-size: 14px; }
.time-select-note  { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.5; }

/* ── Overlay ─────────────────────────────────────────────────── */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.84);
  backdrop-filter: blur(4px);
  display: none;
  place-items: center;
  padding: 20px;
  z-index: 50;
}

.overlay.is-visible {
  display: grid;
  animation: fadeUp 180ms ease;
}

.overlay-card {
  width: min(100%, 440px);
  border: 2px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: var(--shadow);
  padding: 24px;
  text-align: center;
}

.overlay-icon {
  width: 78px;
  height: 78px;
  border: 2px solid var(--line);
  border-radius: 999px;
  display: grid;
  place-items: center;
  margin: 0 auto 14px;
  font-size: 36px;
  font-weight: 700;
}

.overlay-card h3 { margin: 0 0 8px; font-size: 30px; }
.overlay-card p  { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }

.overlay-badges {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.overlay-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

/* ── Ad slot ─────────────────────────────────────────────────── */
.ad-slot {
  margin-top: 20px;
  padding: 14px;
  border: 2px dashed var(--line-soft);
  border-radius: var(--radius-md);
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  background: var(--panel-soft);
}

/* ── Toast ───────────────────────────────────────────────────── */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(16px);
  opacity: 0;
  pointer-events: none;
  background: var(--accent);
  color: var(--accent-inverse);
  padding: 12px 16px;
  border-radius: 999px;
  transition: opacity var(--transition-med), transform var(--transition-med);
  z-index: 60;
  font-size: 14px;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* ── Mobile digit input ──────────────────────────────────────── */
.mobile-digit-input {
  position: fixed;
  left: -9999px;
  top: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* ── Utilities ───────────────────────────────────────────────── */
.loading-copy {
  text-align: center;
  color: var(--muted);
  font-size: 16px;
}

.hidden { display: none !important; }

/* ── Keyframes ───────────────────────────────────────────────── */
@keyframes fadeUp {
  0%   { opacity: 0; transform: translateY(12px); }
  100% { opacity: 1; transform: translateY(0); }
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 980px) {
  .menu-grid            { grid-template-columns: 1fr; }
  .stats-grid           { grid-template-columns: 1fr; }
  .difficulty-grid      { grid-template-columns: 1fr; }
  .play-grid            { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hero-footer          { grid-template-columns: 1fr; }
}

@media (max-width: 720px) {
  .topbar               { flex-direction: column; align-items: stretch; }
  .back-row             { flex-direction: column; align-items: stretch; }
  .button-row           { width: 100%; }
  .button-row .btn      { flex: 1 1 0; }
  .overlay-actions .btn { flex: 1 1 0; }
  .hero-panel, .side-panel, .difficulty-panel, .stats-panel { padding: 16px; }
  .play-grid            { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 420px) {
  .app-shell            { padding-left: 12px; padding-right: 12px; }
  .brand                { align-items: flex-start; }
  .brand-mark           { width: 48px; height: 48px; font-size: 24px; }
  .brand-copy h1        { font-size: 24px; }
  .brand-copy p         { font-size: 13px; }
  .topbar-best          { width: 100%; text-align: center; }
  .overlay-card h3      { font-size: 26px; }
  .play-grid            { grid-template-columns: 1fr; }
}
