:root {
  --bg1: #cfeeff;
  --bg2: #eaf8ff;
  --text: #050505;
  --green: #07847e;
  --red: #b53b63;
  --purple: #71526d;
  --border: rgba(80, 95, 95, .75);
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Cairo", "Segoe UI", Arial, Helvetica, sans-serif;
  background: #111;
  overflow: hidden;
  color: var(--text);
  font-feature-settings: "tnum" 1, "lnum" 1;
}

body[dir="rtl"] .clock,
body[dir="rtl"] .countdown,
body[dir="rtl"] .azan,
body[dir="rtl"] .sun-row b,
body[dir="rtl"] .version { direction: ltr; unicode-bidi: isolate; }

.screen {
  width: 100vw;
  height: 100vh;
  display: grid;
  place-items: center;
  padding-bottom: 3vh;
  background:
    radial-gradient(circle at center, rgba(255,255,255,.55), transparent 55%),
    linear-gradient(160deg, var(--bg1), var(--bg2));
}

.arch {
  position: relative;
  width: min(92vw, 62vh);
  height: 94vh;
  padding: 4.4vh 4.2vh 3vh;
  display: flex;
  flex-direction: column;
  gap: 1.2vh;
  text-align: center;
  background:
    radial-gradient(circle at 50% 25%, rgba(255,255,255,.45), transparent 45%),
    repeating-radial-gradient(circle at center, transparent 0 30px, rgba(0,0,0,.035) 31px 33px);
  border: 1.4vh solid var(--border);
  border-radius: 50% 50% 2vh 2vh / 19% 19% 2vh 2vh;
  box-shadow: inset 0 0 0 .4vh rgba(255,255,255,.45), 0 0 3vh rgba(0,0,0,.4);
  overflow: hidden;
}

.arch::before {
  content: "";
  position: absolute;
  inset: 1.2vh;
  border: .28vh solid rgba(255,255,255,.7);
  border-radius: 50% 50% 1.3vh 1.3vh / 18% 18% 1.3vh 1.3vh;
  pointer-events: none;
}

.bismillah {
  font-size: 4.6vh;
  line-height: 1;
  margin: 0;
}

.clock {
  font-weight: 800;
  font-size: 6.4vh;
  letter-spacing: .04em;
  line-height: 1;
  margin: 0;
}

.date-line {
  font-size: 3.4vh;
  font-weight: 700;
  letter-spacing: .02em;
  line-height: 1.15;
  margin: 0;
  padding: 0 1vh;
}

.table-head, .prayer-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: baseline;
  padding: 0 4vh;
}

.table-head {
  font-size: 2.6vh;
  margin: 0;
  font-weight: 600;
  opacity: .55;
  text-transform: uppercase;
  letter-spacing: .15em;
}

.prayers {
  display: flex;
  flex-direction: column;
  gap: .4vh;
  margin: 0;
}

.prayer-row {
  font-size: 4.2vh;
  line-height: 1.15;
  font-weight: 500;
}

.prayer-row .name { font-weight: 600; }
.prayer-row .azan { color: var(--red); font-weight: 800; text-align: right; }
.prayer-row.past .azan { color: var(--purple); }
.prayer-row.past .name { color: var(--purple); }
.table-head { padding-left: 4vh; padding-right: 4vh; }
.table-head span:last-child { text-align: right; }

.hijri-row {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 1.4vh;
  margin: 0;
  font-size: 3.4vh;
  font-weight: 700;
  line-height: 1.1;
  white-space: nowrap;
}

.hijri-row #hijri-day,
.hijri-row #hijri-year {
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.sun-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: baseline;
  gap: 2vh;
  margin: 0;
  font-size: 2.2vh;
  opacity: .85;
}

.sun-cell {
  display: flex;
  align-items: baseline;
  gap: .6vh;
  justify-content: center;
}

.sun-cell .time {
  font-size: 3.4vh;
  font-weight: 900;
  padding: 0 .4vh;
}

.prayer-row .name,
.prayer-row.past .name { transition: color .2s; }

/* Highlight next prayer (portrait) */
.prayer-row.next {
  position: relative;
}
.prayer-row.next .name,
.prayer-row.next .azan {
  color: var(--green);
  font-weight: 900;
}
.prayer-row.next::before {
  content: "";
  position: absolute;
  inset: -.4vh -2vh;
  background: rgba(7, 132, 126, .1);
  border-radius: 1vh;
  z-index: -1;
}

.next-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: .6vh;
  margin: auto 0 0;
  padding-top: 1vh;
}

.countdown {
  font-size: 6.6vh;
  font-weight: 900;
  letter-spacing: .02em;
  line-height: .9;
}

.next-label {
  font-size: 2.6vh;
  font-weight: 700;
  opacity: .8;
}

#next-name {
  font-weight: 900;
}

.status {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  padding: .4vh 1vh;
  font-size: 1.6vh;
  opacity: .65;
  text-align: center;
}

.settings-btn {
  position: fixed;
  top: 1.4vh;
  right: 1.4vh;
  z-index: 10;
  width: 4.6vh;
  height: 4.6vh;
  background: rgba(255, 255, 255, .55);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 2.4vh;
  line-height: 1;
  color: var(--text);
  cursor: pointer;
  opacity: .35;
  transition: opacity .2s, transform .2s;
}

.settings-btn:hover, .settings-btn:focus { opacity: 1; transform: rotate(60deg); }

[dir="rtl"] .settings-btn { right: auto; left: 1.4vh; }

.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .55);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.settings-overlay[hidden] { display: none; }

.settings-panel {
  background: #fdfdfd;
  color: var(--text);
  border-radius: 2vh;
  padding: 3vh 3vh 2vh;
  min-width: 36vh;
  max-width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 2vh 4vh rgba(0, 0, 0, .4);
  font-size: 2vh;
}

.settings-panel h3 {
  margin: 0 0 2vh;
  font-size: 3vh;
  font-weight: 800;
  text-align: center;
}

.setting {
  margin: 1.6vh 0;
}

.setting > label {
  display: block;
  font-weight: 700;
  margin-bottom: .8vh;
  font-size: 1.9vh;
  opacity: .8;
}

.seg {
  display: flex;
  gap: .4vh;
  background: rgba(0, 0, 0, .05);
  border-radius: 1vh;
  padding: .3vh;
}

.seg button {
  flex: 1;
  padding: 1vh 1.4vh;
  border: none;
  background: transparent;
  border-radius: .8vh;
  cursor: pointer;
  font: inherit;
  font-size: 1.9vh;
  font-weight: 600;
  color: var(--text);
  transition: background .15s;
}

.seg button:hover { background: rgba(0, 0, 0, .06); }

.seg button.active {
  background: var(--green);
  color: #fff;
  font-weight: 800;
}

.settings-close {
  display: block;
  width: 100%;
  margin-top: 2vh;
  padding: 1.2vh;
  background: var(--text);
  color: #fff;
  border: none;
  border-radius: 1vh;
  font: inherit;
  font-size: 2vh;
  font-weight: 700;
  cursor: pointer;
}

.settings-close:hover { opacity: .85; }

.city-trigger {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  font: inherit;
  color: inherit;
  cursor: pointer;
  border-bottom: 1px dotted rgba(5, 5, 5, .4);
}

.city-trigger:hover, .city-trigger:focus {
  color: var(--green);
  outline: none;
}

.status-meta { margin-left: .4ch; }

.version {
  margin-left: 1ch;
  opacity: .7;
  font-variant-numeric: tabular-nums;
}

.city-menu {
  position: fixed;
  bottom: 4vh;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 255, 255, .96);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border);
  border-radius: 1.5vh;
  padding: .8vh;
  box-shadow: 0 .5vh 2vh rgba(0, 0, 0, .25);
  z-index: 20;
  max-height: 60vh;
  overflow-y: auto;
  min-width: 28vh;
  font-size: 2.2vh;
}

.city-menu[hidden] { display: none; }

.city-menu button {
  display: block;
  width: 100%;
  padding: .8vh 1.6vh;
  background: none;
  border: none;
  text-align: center;
  font: inherit;
  color: var(--text);
  cursor: pointer;
  border-radius: .8vh;
}

.city-menu button:hover { background: rgba(7, 132, 126, .14); }
.city-menu button.selected {
  background: rgba(7, 132, 126, .22);
  font-weight: 700;
}

.city-menu .empty {
  padding: 1vh 1.6vh;
  opacity: .6;
  text-align: center;
}

/* ============== LANDSCAPE LAYOUT ============== */

body.landscape .arch {
  width: min(96vw, 180vh);
  height: 88vh;
  padding: 3vh 5vh 3vh;
  border-radius: 3vh;
  border-width: .8vh;
  background:
    radial-gradient(ellipse at 50% 0%, rgba(255,255,255,.45), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg1));
  display: grid;
  grid-template-areas:
    "bismillah"
    "clock"
    "date"
    "prayers"
    "sun"
    "hijri"
    "next";
  grid-template-rows: auto auto auto auto auto auto auto;
  grid-template-columns: 1fr;
  gap: 1.2vh;
  align-items: center;
  justify-items: center;
}

body.landscape .bismillah { grid-area: bismillah; }
body.landscape .clock { grid-area: clock; }
body.landscape .date-line { grid-area: date; }
body.landscape .prayers { grid-area: prayers; align-self: center; }
body.landscape .sun-row { grid-area: sun; align-self: start; margin-top: 1vh; }
body.landscape .hijri-row { grid-area: hijri; justify-self: center; margin-top: auto; }
body.landscape .next-wrap { grid-area: next; justify-self: center; }

body.landscape .arch::before {
  border-radius: 2.5vh;
}

body.landscape .bismillah {
  font-size: 5.4vh;
  margin: 0;
}

body.landscape .clock {
  font-size: 9vh;
}

body.landscape .date-row {
  display: flex;
  justify-content: center;
  gap: 2vh;
  font-size: 3vh;
  margin: 0;
}

body.landscape .greg-date {
  font-size: 4.2vh;
  margin: 0;
}

body.landscape .table-head { display: none; }

body.landscape .prayers {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.5vw;
  align-items: center;
}

body.landscape .prayer-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1.5vh .5vw;
  border-radius: 2vh;
  background: rgba(255,255,255,.35);
  box-shadow: inset 0 0 0 .2vh rgba(255,255,255,.5);
}

body.landscape .prayer-row .name {
  font-size: 3.4vh;
  font-weight: 700;
  opacity: .75;
  letter-spacing: .03em;
  text-transform: uppercase;
}

body.landscape .prayer-row .azan {
  font-size: 6.6vh;
  text-align: center;
  margin-top: .2vh;
}

body.landscape .prayer-row.past { opacity: .55; }

body.landscape .hijri-row {
  font-size: 2.8vh;
  margin: 0;
  gap: 1vh;
}

body.landscape .hijri-row #hijri-day,
body.landscape .hijri-row #hijri-year {
  font-size: 3.4vh;
}

body.landscape .sun-row {
  margin: 0;
  display: flex;
  gap: 1.5vw;
  justify-content: center;
  width: auto;
  opacity: 1;
}

body.landscape .sun-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1vh 2.5vw;
  border-radius: 1.6vh;
  background: rgba(255,255,255,.3);
  box-shadow: inset 0 0 0 .15vh rgba(255,255,255,.5);
  min-width: 12vh;
}

body.landscape .sun-cell .name {
  font-size: 2.4vh;
  font-weight: 700;
  opacity: .65;
  text-transform: uppercase;
  letter-spacing: .12em;
}

body.landscape .sun-cell .time {
  font-size: 4.4vh;
  font-weight: 800;
  padding: 0;
  margin-top: .2vh;
  color: var(--text);
}

/* Next-prayer highlight (landscape) */
body.landscape .prayer-row.next {
  background: linear-gradient(135deg, var(--green), #099b8c);
  color: #fff;
  transform: scale(1.08);
  box-shadow: 0 1.2vh 3vh rgba(7, 132, 126, .45);
  z-index: 2;
}
body.landscape .prayer-row.next::before { display: none; }
body.landscape .prayer-row.next .name { color: rgba(255,255,255,.85); }
body.landscape .prayer-row.next .azan { color: #fff; }

body.landscape .next-wrap {
  flex-direction: column;
  gap: .4vh;
  align-items: center;
  margin: 0;
  padding: 0;
}

body.landscape .countdown {
  font-size: 8vh;
  line-height: 1;
}

body.landscape .next-label {
  font-size: 2.6vh;
  white-space: nowrap;
}
