/* Pray Time -- a calm, self-paced game that teaches the five daily prayers.
   Design goals match the sister games (speak-with-me, juz-amma): a soft,
   low-arousal palette (indigo / sky / cream), big rounded tap targets, one
   clear thing on screen at a time, no flashing, and reduced-motion support.
   Deliberately non-addictive: no score, points, stars, streaks or timers. */

:root {
  --bg:        #f3f1ea;   /* warm cream, low glare */
  --panel:     #fffdf8;
  --ink:       #353347;   /* soft near-black, not pure #000 */
  --muted:     #87859a;
  --line:      #e4ddcf;
  --indigo:    #6f6ac4;   /* primary calm accent */
  --indigo-dim:#5751a6;
  --sky:       #7fa9cf;   /* secondary accent */
  --sand:      #e3c489;   /* warm tertiary (prayer-time sun) */
  --gold:      #c79a4a;
  --shadow:    0 6px 18px rgba(53, 51, 71, 0.09);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "Segoe UI Rounded", "Hiragino Maru Gothic ProN",
               "Segoe UI", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body { display: flex; justify-content: center; }

.app {
  position: relative;
  width: 100%;
  max-width: 560px;
  min-height: 100%;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: env(safe-area-inset-top) 0 env(safe-area-inset-bottom);
}

/* ---- Screen switching ------------------------------------------------- */
.screen { display: none; flex: 1; flex-direction: column; padding: 18px; }
.screen.is-active { display: flex; }
[hidden] { display: none !important; }

/* ====================== HOME / CHARACTER PICKER ====================== */
.home { align-items: center; }
.home-head { text-align: center; margin: 18px 0 14px; }
.home-head h1 { font-size: clamp(26px, 7vw, 36px); font-weight: 800; letter-spacing: 0.2px; }
.tagline { color: var(--muted); margin-top: 6px; font-size: clamp(14px, 4vw, 17px); }

.pick-label {
  font-size: clamp(15px, 4.4vw, 18px);
  font-weight: 700;
  color: var(--indigo-dim);
  margin: 6px 0 12px;
  text-align: center;
}

.char-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  width: 100%;
  max-width: 460px;
}
.char-card {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 20px;
  padding: 12px 6px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.char-card:hover { border-color: var(--sky); }
.char-card:active { transform: scale(0.97); }
.char-card.is-selected { border-color: var(--indigo); background: #f6f4ff; }
.char-card canvas { width: 76px; height: 96px; }
.char-card .name { font-size: clamp(13px, 4vw, 16px); font-weight: 800; }
.char-card .age  { font-size: 12px; color: var(--muted); }

/* ====================== TOP BARS ====================== */
.play-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.icon-btn {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 14px;
  color: var(--ink);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  padding: 8px 12px;
  cursor: pointer;
  min-height: 44px;
}
.icon-btn:hover { border-color: var(--indigo); }
.bar-title { font-size: 16px; font-weight: 800; color: var(--indigo-dim); text-align: center; flex: 1; }

/* ====================== PRAYER PICKER ====================== */
.prayer-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
}
.prayer-card {
  background: var(--panel);
  border: 3px solid var(--line);
  border-radius: 20px;
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  cursor: pointer;
  font-family: inherit;
  color: var(--ink);
  text-align: left;
  box-shadow: var(--shadow);
  transition: border-color 0.15s ease, transform 0.08s ease;
}
.prayer-card:hover { border-color: var(--indigo); }
.prayer-card:active { transform: scale(0.98); }
.prayer-card .pic { font-size: 40px; line-height: 1; flex: none; }
.prayer-card .info { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.prayer-card .pname { font-size: clamp(18px, 5.4vw, 22px); font-weight: 800; }
.prayer-card .pdesc { font-size: 14px; color: var(--muted); }
.prayer-card .prak {
  font-size: 13px;
  font-weight: 800;
  color: var(--indigo-dim);
  background: #efeefb;
  border-radius: 12px;
  padding: 4px 10px;
  flex: none;
}

/* ====================== CHARACTER STAGE ====================== */
.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px 0 10px;
}
.char-canvas {
  width: min(58vw, 240px);
  height: min(46vh, 280px);
  background: linear-gradient(180deg, #eef3fb 0%, #f7f2e8 100%);
  border-radius: 28px;
  border: 2px solid var(--line);
  box-shadow: var(--shadow);
}

/* ====================== CARDS (niat / movement) ====================== */
.card {
  background: var(--panel);
  border: 2px solid var(--line);
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 18px;
  margin: 0 auto;
  width: 100%;
  max-width: 460px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}
.pos-name { font-size: clamp(19px, 5.4vw, 24px); font-weight: 800; color: var(--indigo-dim); }
.instruction { font-size: clamp(14px, 4vw, 16px); color: var(--muted); line-height: 1.5; max-width: 30ch; }
.arabic {
  font-size: clamp(24px, 7.5vw, 34px);
  line-height: 1.7;
  color: var(--ink);
  font-family: "Traditional Arabic", "Scheherazade New", "Amiri", "Geeza Pro", serif;
}
.translit { font-size: clamp(15px, 4.4vw, 18px); font-weight: 700; color: var(--ink); line-height: 1.5; }
.meaning { font-size: clamp(13px, 3.8vw, 15px); color: var(--muted); font-style: italic; line-height: 1.5; max-width: 32ch; }

/* ====================== TASBIH 1·2·3 COUNTER ====================== */
.tasbih {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}
.tasbih-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(15px, 4.4vw, 18px);
  color: #fff;
  background: var(--sky);
  border: none;
  border-radius: 18px;
  padding: 12px 26px;
  min-height: 52px;
  cursor: pointer;
  transition: transform 0.08s ease, background 0.15s ease;
}
.tasbih-btn:hover { background: #6c97bd; }
.tasbih-btn:active { transform: scale(0.96); }
.tasbih-btn.is-done { background: var(--indigo); }
.tasbih-dots { display: flex; gap: 12px; }
.tasbih-dots .dot {
  width: 34px; height: 34px;
  border-radius: 50%;
  border: 3px solid var(--line);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 15px; color: var(--muted);
  background: #fff;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.12s ease;
}
.tasbih-dots .dot.on {
  background: var(--indigo);
  border-color: var(--indigo);
  color: #fff;
  transform: scale(1.08);
}

/* ====================== BUTTONS ====================== */
.round-btn {
  font-family: inherit;
  font-weight: 700;
  font-size: clamp(15px, 4.4vw, 18px);
  border-radius: 18px;
  padding: 14px 22px;
  min-height: 54px;
  cursor: pointer;
  border: 2px solid transparent;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  transition: transform 0.08s ease, background 0.15s ease, border-color 0.15s ease;
}
.round-btn:active { transform: scale(0.97); }
.round-btn.soft { background: var(--panel); border-color: var(--line); color: var(--ink); }
.round-btn.soft:hover { border-color: var(--sky); }
.round-btn.go { background: var(--indigo); color: #fff; }
.round-btn.go:hover { background: var(--indigo-dim); }
.round-btn.go:disabled { background: #c8c6dd; cursor: default; }
.round-btn.go:disabled:active { transform: none; }

#start { margin-top: 18px; min-width: 160px; }

.btn-row { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; margin-top: 4px; }
.next-row { display: flex; gap: 12px; margin-top: 6px; flex-wrap: wrap; justify-content: center; }

.text-btn {
  margin-top: 16px;
  background: none;
  border: none;
  color: var(--muted);
  font-family: inherit;
  font-size: 14px;
  cursor: pointer;
  padding: 8px 12px;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.text-btn:hover { color: var(--indigo-dim); }
.text-btn.home { display: inline-block; text-decoration: none; font-size: 13px; margin-top: 12px; }

/* ====================== POSITION RAIL ====================== */
.rail {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 8px;
}
.rail .rdot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--line);
}
.rail .rdot.done { background: var(--sky); }
.rail .rdot.now  { background: var(--indigo); transform: scale(1.5); }

/* ====================== DONE ====================== */
.done { align-items: center; justify-content: center; gap: 6px; text-align: center; }
.done-title { font-size: clamp(22px, 6.4vw, 30px); font-weight: 800; color: var(--indigo-dim); margin-top: 8px; }
.done-sub { color: var(--muted); font-size: clamp(15px, 4.4vw, 18px); max-width: 26ch; }
.done-btns { display: flex; flex-direction: column; gap: 12px; margin-top: 18px; width: 100%; max-width: 320px; }

/* ====================== SETTINGS / GROWN-UPS SHEET ====================== */
.sheet {
  position: absolute;
  inset: 0;
  z-index: 30;
  background: rgba(53, 51, 71, 0.35);
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.sheet-card {
  background: var(--panel);
  border-radius: 24px;
  padding: 24px;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 50px rgba(53,51,71,0.25);
  display: flex;
  flex-direction: column;
  gap: 14px;
  max-height: 90vh;
  overflow-y: auto;
}
.sheet-card h2 { font-size: 22px; }
.sheet-intro, .sheet-note { font-size: 14px; color: var(--muted); line-height: 1.55; }
.sheet-note strong { color: var(--ink); }
.prayer-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prayer-table th, .prayer-table td { text-align: left; padding: 7px 6px; border-bottom: 1px solid var(--line); }
.prayer-table th { color: var(--indigo-dim); font-size: 13px; }
.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: 16px;
}
.row.toggle input { width: 22px; height: 22px; accent-color: var(--indigo); }
.about { font-size: 14px; color: var(--muted); line-height: 1.55; }
.about summary { cursor: pointer; color: var(--indigo-dim); font-weight: 700; }
.about p { margin-top: 8px; }

/* ====================== FOOTER ====================== */
.foot {
  text-align: center;
  font-size: 10px;
  color: var(--muted);
  opacity: 0.6;
  padding: 8px;
}

/* ---- Gentle motion: a soft fade when a card's content changes. -------- */
@keyframes fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}
.card.swap { animation: fadein 0.28s ease-out; }

/* Respect reduced motion (OS setting). */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}
