:root {
  --navy: #061f50;
  --blue: #155cbe;
  --deep-blue: #062564;
  --gold: #ffe8b4;
  --orange: #ffad40;
  --white: #ffffff;
  --shadow: rgba(0, 0, 0, .38);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--white);
  background: var(--navy) url("assets/rgl_background.png") center top / cover fixed no-repeat;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(6, 31, 80, .05), rgba(6, 31, 80, .28));
}

button, input, select {
  font: inherit;
}

button {
  cursor: pointer;
  border: 0;
}

button:disabled,
input:disabled,
select:disabled {
  opacity: .58;
  cursor: not-allowed;
}

.app-shell {
  position: relative;
  width: min(100%, 620px);
  min-height: 100svh;
  margin: 0 auto;
  padding: calc(170px + var(--safe-top)) 22px calc(30px + var(--safe-bottom));
}

.controls-card {
  width: 100%;
  padding: 18px;
  border: 1px solid rgba(240, 220, 180, .42);
  border-radius: 24px;
  background: rgba(5, 24, 70, .44);
  box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
}

.main-buttons,
.small-grid,
.selectors-top {
  display: grid;
  gap: 12px;
}

.main-buttons { grid-template-columns: 1fr 1fr; }
.small-grid { grid-template-columns: 1fr 1fr; margin-top: 14px; gap: 10px 12px; }
.selectors-top { grid-template-columns: 92px 1fr; margin-bottom: 8px; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  border-radius: 16px;
  color: var(--white);
  font-weight: 800;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,.55);
  box-shadow: 0 7px 0 rgba(0,0,0,.22), 0 11px 18px rgba(0,0,0,.26), inset 0 1px 0 rgba(255,255,255,.26);
  transition: transform .08s ease, box-shadow .08s ease, filter .12s ease;
  user-select: none;
  -webkit-user-select: none;
}

.btn:active {
  transform: translateY(3px) scale(.985);
  box-shadow: 0 3px 0 rgba(0,0,0,.22), 0 7px 12px rgba(0,0,0,.24), inset 0 1px 0 rgba(255,255,255,.2);
}

.btn-play,
.btn-stop {
  height: 124px;
  flex-direction: column;
  border: 1px solid rgba(255, 232, 170, .55);
  letter-spacing: .5px;
}

.btn-play { background: linear-gradient(#39d367, #0a8d35); }
.btn-stop { background: linear-gradient(#ff695f, #b81812); }
.btn-play span,
.btn-stop span { font-size: 34px; line-height: 1; }
.btn-play strong,
.btn-stop strong { display: block; margin-top: 8px; font-size: 25px; }

.info-btn {
  min-height: 52px;
  padding: 0 10px 3px;
  background: linear-gradient(#155cbe, #062564);
  border: 1px solid rgba(255, 232, 170, .7);
  font-size: 13px;
}

.volume-box {
  margin-top: 16px;
  text-align: center;
}

.volume-box label {
  display: block;
  margin-bottom: 5px;
  font-size: 22px;
  font-weight: 600;
  text-shadow: 0 2px 4px rgba(0,0,0,.55);
}

.ios-note {
  margin: 5px 0 0;
  color: rgba(255,255,255,.82);
  font-size: 11px;
}

.slider {
  width: 100%;
  accent-color: #ffad40;
}


.guard-box {
  margin-top: 12px;
  padding: 10px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255, 232, 180, .46);
  background: rgba(255, 255, 255, .09);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.12);
  color: rgba(255, 255, 255, .94);
  text-align: left;
}

.guard-box strong {
  display: block;
  margin-bottom: 2px;
  color: var(--gold);
  font-size: 13px;
  letter-spacing: .2px;
}

.guard-box span {
  display: block;
  font-size: 12px;
  line-height: 1.35;
}

.archive-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: 22px;
  border: 1px solid rgba(245, 205, 120, .58);
  background: linear-gradient(90deg, rgba(4,29,80,.82), rgba(10,58,130,.82));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.14), 0 14px 28px rgba(0,0,0,.25);
}

.archive-head {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 12px;
  align-items: center;
}

.archive-texts h1 {
  margin: 0 0 1px;
  font-size: 24px;
  line-height: 1.1;
}

.archive-now-title,
.archive-now-meta,
.status {
  margin: 0;
  overflow-wrap: anywhere;
}

.archive-now-title {
  color: var(--gold);
  font-size: 14px;
  font-weight: 700;
}

.archive-now-meta {
  margin-top: 2px;
  color: rgba(255,255,255,.9);
  font-size: 12px;
  white-space: pre-line;
}

.archive-play {
  width: 64px;
  height: 64px;
  min-height: 64px;
  border-radius: 50%;
  background: linear-gradient(#ffad40, #cd4616);
  border: 2px solid rgba(255,235,190,.86);
  font-size: 27px;
}

.archive-play.playing {
  background: linear-gradient(#ffd568, #e26621);
}

.archive-progress {
  padding-top: 10px;
}

.time-row {
  display: flex;
  justify-content: space-between;
  margin-top: -2px;
  color: rgba(255,244,216,.9);
  font-size: 11px;
  font-weight: 800;
}

.status {
  padding: 10px 0 2px;
  color: rgba(255,255,255,.9);
  font-size: 12px;
}

.choose-btn { width: 100%; margin-top: 8px; }

.selectors-panel {
  padding-top: 8px;
}

select {
  width: 100%;
  min-height: 50px;
  padding: 0 28px 0 10px;
  border-radius: 16px;
  border: 2px solid rgba(255, 212, 120, .82);
  color: #051c4e;
  background: linear-gradient(#ffffff, #fff4dc);
  font-weight: 800;
  white-space: normal;
  box-shadow: inset 0 1px 0 rgba(255,255,255,.8), 0 4px 12px rgba(0,0,0,.16);
}

#archiveEpisode { margin-top: 0; }

.panel-dialog {
  width: min(100%, 720px);
  height: 100dvh;
  max-width: none;
  max-height: none;
  margin: 0 auto;
  padding: 0;
  border: 0;
  color: var(--white);
  background: var(--navy);
}

.panel-dialog::backdrop { background: rgba(0,0,0,.55); }

.panel-top {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  align-items: center;
  min-height: calc(62px + var(--safe-top));
  padding: var(--safe-top) 12px 8px;
  background: var(--navy);
}

.panel-top button,
.panel-top a {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  border-radius: 14px;
  color: var(--white);
  background: transparent;
  font-size: 22px;
  text-decoration: none;
  font-weight: 800;
}

.panel-top a { padding: 0 10px; font-size: 14px; background: rgba(255,255,255,.1); }
.panel-top strong { font-size: 20px; }

.panel-dialog iframe {
  display: block;
  width: 100%;
  height: calc(100dvh - 62px - var(--safe-top));
  border: 0;
  background: #fff;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 380px) {
  .app-shell { padding-left: 14px; padding-right: 14px; }
  .controls-card { padding: 14px; }
  .btn-play, .btn-stop { height: 108px; }
  .btn-play strong, .btn-stop strong { font-size: 22px; }
  .archive-head { grid-template-columns: 1fr 58px; }
  .archive-play { width: 58px; height: 58px; min-height: 58px; }
  .selectors-top { grid-template-columns: 84px 1fr; }
}

@media (min-width: 760px) {
  body { background-size: auto 100%; }
}
