:root {
  --bg: #0b1a17;
  --panel: #12302a;
  --panel-2: #183d35;
  --text: #f3efe2;
  --muted: #a9b8b0;
  --gold: #d9b45a;
  --accent: #3fbf8f;
  --danger: #d9665a;
}

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

html, body { height: 100%; }

body {
  background: radial-gradient(ellipse at top, #16382f 0%, var(--bg) 65%);
  color: var(--text);
  font-family: "Segoe UI", Tahoma, "Noto Kufi Arabic", Arial, sans-serif;
  overflow: hidden;
  user-select: none;
}

.kiosk {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto 1fr auto;
  gap: 2vh;
  padding: 3vh 3vw;
}

/* ---------- header ---------- */
.top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 2vw;
}
.location { text-align: right; }
.city { font-size: clamp(22px, 3.4vw, 56px); font-weight: 700; color: var(--gold); }
.city-en { font-size: clamp(14px, 1.6vw, 26px); color: var(--muted); direction: ltr; text-align: right; }
.clock .time {
  font-size: clamp(48px, 9vw, 150px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  letter-spacing: 0.02em;
  line-height: 1;
}
.dates { text-align: left; }
.hijri { font-size: clamp(18px, 2.4vw, 40px); color: var(--gold); font-weight: 600; }
.greg { font-size: clamp(14px, 1.7vw, 28px); color: var(--text); margin-top: 0.4vh; }
.dates-en { font-size: clamp(11px, 1.2vw, 20px); color: var(--muted); direction: ltr; text-align: left; }

/* ---------- countdowns ---------- */
.next {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2vw;
}
.next-block {
  background: var(--panel);
  border: 1px solid rgba(217, 180, 90, 0.25);
  border-radius: 18px;
  padding: 2vh 2vw;
  text-align: center;
}
.next-block.iqama { border-color: rgba(63, 191, 143, 0.35); }
.next-block .label { font-size: clamp(16px, 2vw, 34px); color: var(--muted); }
.next-block .countdown {
  font-size: clamp(40px, 6.5vw, 110px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  color: var(--gold);
  line-height: 1.15;
}
.next-block.iqama .countdown { color: var(--accent); }
.next-block .sub { font-size: clamp(13px, 1.4vw, 24px); color: var(--muted); }
.next-block.urgent { animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { background: var(--panel-2); } }

/* ---------- prayer cards ---------- */
.prayers {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 1.2vw;
  min-height: 0;
}
.prayer {
  background: var(--panel);
  border-radius: 16px;
  padding: 2vh 0.8vw;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.8vh;
  border: 2px solid transparent;
  transition: background 0.3s, border-color 0.3s;
}
.prayer .name { font-size: clamp(18px, 2.4vw, 42px); font-weight: 700; }
.prayer .name-en { font-size: clamp(11px, 1.1vw, 18px); color: var(--muted); }
.prayer .adhan {
  font-size: clamp(22px, 3.2vw, 56px);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  direction: ltr;
  white-space: nowrap;
}
.prayer .iqama-time { font-size: clamp(12px, 1.4vw, 24px); color: var(--accent); direction: rtl; }
.prayer .iqama-time span { direction: ltr; unicode-bidi: isolate; font-variant-numeric: tabular-nums; }
.prayer.sunrise { opacity: 0.7; }
.prayer.current { background: var(--panel-2); }
.prayer.next { border-color: var(--gold); background: var(--panel-2); }
.prayer.passed { opacity: 0.55; }

/* ---------- footer ---------- */
.bottom {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 2vw;
  font-size: clamp(12px, 1.1vw, 18px);
  color: var(--muted);
}
.controls { display: flex; align-items: center; gap: 12px; }
.btn {
  background: var(--gold);
  color: #1a1a1a;
  border: none;
  border-radius: 10px;
  padding: 10px 18px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}
.btn.ghost { background: transparent; color: var(--text); border: 1px solid var(--muted); }
.btn:active { transform: scale(0.97); }
.volume { direction: ltr; display: flex; align-items: center; gap: 8px; color: var(--text); }
.volume input { width: clamp(120px, 14vw, 240px); accent-color: var(--gold); cursor: pointer; }
#volValue { min-width: 3.5em; direction: ltr; font-variant-numeric: tabular-nums; }

/* ---------- overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(5, 14, 12, 0.92);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 10;
  cursor: pointer;
  text-align: center;
}
.overlay.hidden { display: none; }
.overlay-box { padding: 4vh 4vw; }
.overlay-kind { font-size: clamp(22px, 3.5vw, 60px); color: var(--muted); }
.overlay-title { font-size: clamp(48px, 10vw, 180px); font-weight: 800; color: var(--gold); }
.overlay-sub { font-size: clamp(14px, 2vw, 32px); color: var(--text); margin-top: 1vh; }
.overlay-hint { margin-top: 4vh; color: var(--muted); font-size: clamp(12px, 1.3vw, 20px); }
.overlay.alert.iqama .overlay-title { color: var(--accent); }

/* ---------- portrait (vertical screens, phones) ----------
   Width is the short side here, so sizes follow vw more strongly and the six
   prayers become full-width rows: name · adhan time · iqama time. */
@media (orientation: portrait) {
  .kiosk { gap: 1.6vh; padding: 2.5vh 4vw; grid-template-columns: minmax(0, 1fr); }
  .kiosk > *, .top > *, .next > *, .prayer > * { min-width: 0; }

  .top { grid-template-columns: 1fr 1fr; grid-template-areas: "clock clock" "loc dates"; gap: 1vh 4vw; }
  .clock { grid-area: clock; text-align: center; }
  .location { grid-area: loc; }
  .dates { grid-area: dates; }
  .clock .time { font-size: clamp(48px, 14vw, 220px); white-space: nowrap; }
  .city { font-size: clamp(20px, 5.5vw, 80px); }
  .city-en { font-size: clamp(12px, 3vw, 40px); }
  .hijri { font-size: clamp(16px, 4.4vw, 64px); }
  .greg { font-size: clamp(13px, 3.2vw, 46px); }
  .dates-en { font-size: clamp(10px, 2.4vw, 32px); }

  .next { gap: 3vw; }
  .next-block { padding: 1.5vh 2vw; }
  .next-block .label { font-size: clamp(13px, 3.4vw, 50px); }
  .next-block .countdown { font-size: clamp(28px, 8vw, 130px); white-space: nowrap; }
  .next-block .sub { font-size: clamp(11px, 2.6vw, 36px); }

  .prayers { grid-template-columns: minmax(0, 1fr); grid-auto-rows: minmax(0, 1fr); gap: 1.2vh; }
  .prayer {
    display: grid;
    grid-template-columns: 1.2fr 1fr 1fr;
    grid-template-areas: "name adhan iqama" "name-en adhan iqama";
    align-items: center;
    justify-items: center;
    gap: 0 3vw;
    padding: 1vh 4vw;
  }
  .prayer .name { grid-area: name; justify-self: start; font-size: clamp(20px, 6vw, 90px); align-self: end; }
  .prayer .name-en { grid-area: name-en; justify-self: start; font-size: clamp(11px, 2.6vw, 36px); align-self: start; }
  .prayer .adhan { grid-area: adhan; font-size: clamp(22px, 6.5vw, 100px); white-space: nowrap; }
  .prayer .iqama-time { grid-area: iqama; font-size: clamp(12px, 3.2vw, 48px); white-space: nowrap; }

  .bottom { flex-direction: column; gap: 1vh; font-size: clamp(11px, 2.2vw, 28px); text-align: center; }
  .controls { flex-wrap: wrap; justify-content: center; }
  .volume input { width: clamp(120px, 30vw, 360px); }

  .overlay-kind { font-size: clamp(20px, 6vw, 90px); }
  .overlay-title { font-size: clamp(48px, 20vw, 300px); }
  .overlay-sub { font-size: clamp(14px, 4vw, 60px); }
  .overlay-hint { font-size: clamp(12px, 3vw, 40px); }
}

/* Short landscape screens (phones on their side): let the page scroll instead of clipping */
@media (orientation: landscape) and (max-height: 500px) {
  body { overflow: auto; }
  .kiosk { height: auto; min-height: 100vh; }
  .prayer .adhan { font-size: clamp(16px, 2.7vw, 56px); }
}

/* Very narrow portrait phones: stack the two countdowns */
@media (orientation: portrait) and (max-width: 420px) {
  body { overflow: auto; }
  .kiosk { height: auto; min-height: 100vh; }
  .next { grid-template-columns: 1fr; }
}
