:root {
  --bg: #f5f0ff;
  --fg: #2a1f4a;
  --muted: #6b5f8a;
  --card: #ffffff;
  --accent: #7c3aed;
  --accent-2: #f59e0b;
  --accent-fg: #ffffff;
  --ring: #c4b5fd;
  --shadow: 0 10px 30px rgba(60, 30, 120, 0.18);
  --radius: 22px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17122b;
    --fg: #f1ecff;
    --muted: #b8acd9;
    --card: #241c40;
    --ring: #6d4fd1;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "Segoe UI", "Noto Sans", "Noto Sans Arabic", Tahoma, sans-serif;
  -webkit-tap-highlight-color: transparent;
  overflow: hidden;
}
button, select { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

/* HUD */
#hud {
  position: fixed; inset: 0 0 auto 0; z-index: 5;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: max(8px, env(safe-area-inset-top)) 12px 8px;
  background: linear-gradient(90deg, #7c3aed, #db2777);
  color: #fff;
}
.hud-title { font-weight: 800; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.hud-left, .hud-right { display: flex; align-items: center; gap: 8px; }
.stars { background: rgba(255,255,255,.2); padding: 4px 12px; border-radius: 999px; font-weight: 800; white-space: nowrap; }
.icon-btn { background: rgba(255,255,255,.2); border: 0; border-radius: 999px; width: 36px; height: 36px; color: #fff; }
#hud select { background: rgba(255,255,255,.2); color: #fff; border: 0; border-radius: 999px; padding: 6px 10px; max-width: 42vw; }
#hud select option { color: #000; }

/* Stage */
#stage {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  padding: 60px 8px 44px;
}
canvas#game {
  max-width: 100%; max-height: 100%;
  border-radius: 18px; box-shadow: var(--shadow);
  touch-action: none; background: #7cc576;
}
.hint {
  position: fixed; inset: auto 0 max(8px, env(safe-area-inset-bottom)) 0; margin: 0;
  text-align: center; font-weight: 700; color: var(--muted); padding: 0 16px;
}

/* Screens */
.screen {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  padding: 16px; background: rgba(30, 15, 60, 0.55);
  backdrop-filter: blur(3px);
}
.screen[hidden] { display: none; }
#startScreen { background: radial-gradient(circle at 30% 20%, #c4b5fd, #7c3aed 60%, #4c1d95); }
.card {
  background: var(--card); color: var(--fg);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 22px; width: min(560px, 100%);
  max-height: calc(100dvh - 32px); overflow: auto;
}
.start-card { text-align: center; }
.logo { font-size: 3.2rem; line-height: 1; }
h1 { margin: 8px 0 4px; font-size: 1.7rem; }
.sub { margin: 0 0 14px; color: var(--muted); }
.field { display: flex; flex-direction: column; gap: 6px; align-items: stretch; margin: 10px auto; max-width: 320px; font-weight: 700; }
.field select { padding: 10px 12px; border-radius: 14px; border: 2px solid var(--ring); background: var(--card); }
.choose { font-weight: 700; margin: 14px 0 8px; }
.avatars { display: flex; gap: 14px; justify-content: center; margin-bottom: 16px; }
.avatar {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  background: transparent; border: 3px solid transparent; border-radius: 18px; padding: 8px 12px; font-weight: 700;
}
.avatar[aria-pressed="true"] { border-color: var(--accent); background: rgba(124, 58, 237, .08); }
.big-btn {
  background: linear-gradient(90deg, #7c3aed, #db2777); color: var(--accent-fg);
  border: 0; border-radius: 999px; padding: 12px 28px; font-size: 1.15rem; font-weight: 800;
  box-shadow: 0 6px 16px rgba(124, 58, 237, .35);
}
.big-btn:active { transform: translateY(1px); }
.site-link { display: block; margin-top: 12px; color: var(--muted); font-size: .9rem; }

/* Hadith dialog */
.spot-head { display: flex; align-items: center; gap: 10px; }
.spot-icon { font-size: 2.2rem; }
.spot-head h2 { margin: 0; font-size: 1.35rem; }
.hadith-title {
  margin: 14px 0 8px; padding: 14px 16px; border-radius: 16px;
  background: linear-gradient(135deg, rgba(124,58,237,.10), rgba(245,158,11,.12));
  font-size: 1.35rem; line-height: 1.9; font-weight: 700;
}
.meta { color: var(--muted); font-size: .9rem; display: flex; flex-wrap: wrap; gap: 6px 12px; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0 4px; }
.pill { border-radius: 999px; padding: 8px 16px; border: 2px solid var(--accent); background: var(--accent); color: var(--accent-fg); font-weight: 700; }
.pill.ghost { background: transparent; color: var(--accent); }
@media (prefers-color-scheme: dark) { .pill.ghost { color: #c4b5fd; border-color: #8b5cf6; } }
.pill[disabled] { opacity: .5; cursor: not-allowed; }
.note { background: rgba(245, 158, 11, .15); border-radius: 12px; padding: 8px 12px; margin: 10px 0 0; font-size: .92rem; }
.note.small { font-size: .85rem; }
.long { margin-top: 10px; line-height: 1.9; white-space: pre-line; border-top: 1px dashed var(--ring); padding-top: 10px; }
.foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 16px; flex-wrap: wrap; }
.link { color: var(--accent); font-weight: 700; }
@media (prefers-color-scheme: dark) { .link { color: #c4b5fd; } }

/* End screen */
.end-card { text-align: center; }
.end-list { list-style: none; padding: 0; margin: 12px 0 18px; text-align: start; display: grid; gap: 8px; }
.end-list li { background: rgba(124,58,237,.08); border-radius: 14px; padding: 10px 12px; line-height: 1.7; }
.end-list b { display: block; }

@media (max-width: 480px) {
  .hud-title { display: none; }
  .hadith-title { font-size: 1.15rem; }
  h1 { font-size: 1.4rem; }
}
