:root {
  --text: #f1ece4;
  --dim: rgba(241, 236, 228, .6);
  --faint: rgba(241, 236, 228, .35);
  --line: rgba(241, 236, 228, .14);
  --warm: #f2a874;
  --gutter: clamp(18px, 4vw, 60px);
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: #000;
  color: var(--text);
  font-family: "Archivo", system-ui, sans-serif;
  font-stretch: 92%;
  font-size: 17px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
a { color: inherit; }

/* ---------- picture ---------- */
.stage {
  position: fixed;
  inset: 0;
  overflow: hidden;
  opacity: 0;
  transition: opacity 1.6s ease, filter .5s ease;
}
.is-ready .stage { opacity: 1; }
.bg, .scene {
  /* slow camera push-in toward the TV */
  transform-origin: 62% 48%;
  animation: drift 38s ease-in-out infinite alternate;
}
.bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 55%;
}
@keyframes drift { to { transform: scale(1.06); } }

.scene { position: absolute; pointer-events: none; }
.scene > * { position: absolute; }

/* whole room dips darker when the TV picture changes */
.fx-dark { inset: 0; background: #000; opacity: var(--dark, 0); }

/* green light spilling from the TV, flickering */
.fx-glow {
  left: 66%; top: 47%;
  width: 78%; height: 105%;
  transform: translate(-50%, -50%);
  background: radial-gradient(closest-side, rgba(120, 255, 170, .2), rgba(120, 255, 170, .06) 45%, transparent 78%);
  mix-blend-mode: screen;
  opacity: var(--flick, .6);
}

/* CRT scanlines + a slow rolling band on the screen */
.fx-screen {
  left: 59.9%; top: 39.4%;
  width: 12.4%; height: 15.5%;
  border-radius: 10% / 13%;
  overflow: hidden;
  background: repeating-linear-gradient(0deg, rgba(0,0,0,.22) 0 1px, transparent 1px 3px);
}
.fx-screen::after {
  content: "";
  position: absolute; inset: 0;
  background: #fff;
  mix-blend-mode: overlay;
  opacity: calc(var(--flick, .6) * .12);
}
.fx-screen i {
  position: absolute;
  left: 0; right: 0; top: 0;
  height: 28%;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.14), transparent);
  animation: roll 7s linear infinite;
}
@keyframes roll { from { transform: translateY(-100%); } to { transform: translateY(460%); } }

/* controller light breathing */
.fx-led {
  left: 47.98%; top: 64.06%;
  width: 2.2%; aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(110, 160, 255, .9), rgba(110, 160, 255, .25) 45%, transparent);
  mix-blend-mode: screen;
  animation: breathe 2.8s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: .35; } }

/* same effects, re-pinned for the tall phone photo */
.scene.tall .fx-glow { left: 69%; top: 50%; width: 80%; height: 48%; }
.scene.tall .fx-screen { left: 62.8%; top: 46.6%; width: 12.5%; height: 6.9%; }
.scene.tall .fx-led { left: 50.3%; top: 58.1%; }

/* moving film grain */
.fx-grain {
  position: absolute;
  inset: -50%;
  pointer-events: none;
  opacity: .1;
  mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain .9s steps(6) infinite;
}
@keyframes grain {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-4%, 3%); }
  40% { transform: translate(3%, -5%); }
  60% { transform: translate(-6%, -2%); }
  80% { transform: translate(5%, 4%); }
  100% { transform: translate(-2%, 6%); }
}

.dim {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(0deg, rgba(0,0,0,.8) 0%, transparent 38%);
  transition: background .4s ease;
}
.state-menu .stage { filter: brightness(.35) saturate(.7); }
.state-menu .dim { background: rgba(0,0,0,.25); }
.state-resumed .dim { background: linear-gradient(0deg, rgba(0,0,0,.7) 0%, transparent 22%); }

/* ---------- loading ---------- */
.loading {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 32px;
  padding: 0 var(--gutter) calc(30px + env(safe-area-inset-bottom));
  transition: opacity .3s ease;
}
.state-menu .loading, .state-resumed .loading { opacity: 0; pointer-events: none; }
.tip {
  margin: 0;
  max-width: 44ch;
  color: var(--dim);
  font-size: 15px;
  transition: opacity .4s ease;
}
.tip.fade { opacity: 0; }
.status { display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--dim); }
.spinner {
  width: 14px; height: 14px;
  border-radius: 50%;
  border: 2px solid rgba(241,236,228,.2);
  border-top-color: var(--text);
  animation: spin .9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.is-loaded .spinner { display: none; }
.is-loaded .status { visibility: hidden; }
@keyframes pulse { 50% { opacity: .4; } }

/* loading bar along the bottom edge */
.bar {
  position: absolute;
  left: 0; right: 0; bottom: env(safe-area-inset-bottom);
  height: 4px;
  background: rgba(241, 236, 228, .12);
}
.bar i {
  display: block;
  height: 100%;
  width: 0;
  background: var(--text);
  transition: width .3s ease;
}
.is-loaded .bar { opacity: 0; transition: opacity .6s ease .4s; }

/* ---------- start prompt ---------- */
.start {
  position: fixed;
  left: 50%;
  bottom: calc(118px + env(safe-area-inset-bottom));
  transform: translate(-50%, 10px);
  padding: 15px 28px;
  background: var(--text);
  color: #000;
  font-size: 17px;
  font-weight: 600;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .5s ease, transform .5s ease;
}
.start::after {
  /* slow outline pulse so the eye lands on it */
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid var(--text);
  animation: ring 2s ease-out infinite;
}
@keyframes ring { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: scale(1.18, 1.5); } }
.is-loaded.state-loading .start { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.is-loaded.state-loading { cursor: pointer; }

/* ---------- resumed ---------- */
.resume-bar {
  position: fixed;
  left: var(--gutter); right: var(--gutter);
  bottom: calc(26px + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s ease;
}
.state-resumed .resume-bar { opacity: 1; pointer-events: auto; }
.resume-ca {
  display: flex;
  max-width: 100%;
  padding: 12px 20px;
  background: rgba(0, 0, 0, .55);
  border: 1px solid var(--line);
  align-items: baseline;
  gap: 14px;
  min-width: 0;
  text-align: left;
}
.rc-k { font-size: 13px; font-weight: 600; color: var(--warm); flex: none; }
.rc-v {
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.rc-copy {
  flex: none;
  font-size: 13px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 4px;
}
.resume-ca:hover .rc-copy { text-decoration-color: var(--text); }
.resume-ca.done .rc-copy { color: var(--warm); }
.resume-hint { flex: none; font-size: 13px; color: var(--faint); }

/* ---------- pause menu ---------- */
.pause {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(240px, 340px) minmax(0, 560px) 1fr;
  grid-template-rows: auto 1fr auto;
  column-gap: clamp(40px, 7vw, 120px);
  padding: 26px var(--gutter) calc(24px + env(safe-area-inset-bottom));
  opacity: 0;
  visibility: hidden;
  transition: opacity .25s ease, visibility 0s linear .25s;
}
.state-menu .pause { opacity: 1; visibility: visible; transition: opacity .25s ease; }

.pause-top {
  grid-column: 1 / -1;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
}
.logo { font-weight: 700; font-size: 22px; font-stretch: 78%; }
.clock { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--dim); font-variant-numeric: tabular-nums; }
.sep { width: 3px; height: 3px; border-radius: 50%; background: var(--faint); }

.menu {
  align-self: center;
  display: flex;
  flex-direction: column;
  padding: 30px 0;
}
.menu button {
  text-align: left;
  font-size: clamp(22px, 2.3vw, 30px);
  font-weight: 600;
  font-stretch: 85%;
  line-height: 1.1;
  padding: 9px 14px;
  margin-left: -14px;
  color: var(--dim);
  transition: color .12s ease;
}
.menu button:hover { color: var(--text); }
.menu button.on { background: var(--text); color: #000; }
.menu button.minor { font-size: 16px; font-weight: 500; margin-top: 18px; }

.panels {
  position: relative;
  align-self: center;
  max-height: 100%;
  overflow-y: auto;
  padding: 30px 4px 30px 0;
  scrollbar-width: thin;
}
.back { display: none; }
.panel { display: none; }
.panel.on { display: block; animation: in .22s ease; }
@keyframes in { from { opacity: 0; transform: translateY(6px); } }

.panel h2 {
  margin: 0 0 22px;
  font-size: 14px;
  font-weight: 600;
  color: var(--warm);
}
.panel p { margin: 0 0 1em; color: var(--dim); }
.panel p.big { font-size: clamp(22px, 2.3vw, 28px); line-height: 1.3; color: var(--text); font-weight: 500; }
.panel q { color: var(--text); }
.fine { font-size: 13px; color: var(--faint) !important; margin-top: 16px !important; }

.list { margin: 0; }
.list > div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 24px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}
.list > div:first-child { border-top: 1px solid var(--line); }
.list dt { color: var(--dim); }
.list dd { margin: 0; font-size: 20px; font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; min-width: 0; }
.ca { font-size: 14px; font-weight: 500; text-align: right; overflow-wrap: anywhere; text-decoration: underline; text-decoration-color: var(--faint); text-underline-offset: 4px; }
.ca.done { color: var(--warm); }

.steps { margin: 0; padding: 0 0 0 1.4em; }
.steps li { margin: 0 0 14px; color: var(--dim); padding-left: 6px; }
.steps li::marker { color: var(--faint); font-variant-numeric: tabular-nums; }
.steps b { color: var(--text); font-weight: 600; }

.linklist { list-style: none; margin: 0; padding: 0; }
.linklist a {
  display: block;
  font-size: 26px;
  font-weight: 600;
  font-stretch: 85%;
  padding: 10px 0;
  border-bottom: 1px solid var(--line);
  text-decoration: none;
}
.linklist a:hover { color: var(--warm); }

/* sick note */
.gen { display: grid; grid-template-columns: 1fr 1fr; gap: 14px 18px; margin-bottom: 26px; }
.gen label { display: flex; flex-direction: column; gap: 4px; }
.gen label > span { font-size: 13px; color: var(--faint); }
.gen input, .gen select {
  appearance: none;
  -webkit-appearance: none;
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  padding: 6px 0 8px;
  width: 100%;
}
.gen select { cursor: pointer; }
.gen select option { color: #000; }
.gen input::placeholder { color: var(--faint); }
.gen input:focus, .gen select:focus { outline: none; border-bottom-color: var(--text); }

.sms { margin-bottom: 18px; }
.sms-meta { font-size: 12px; color: var(--faint) !important; text-align: center; margin: 0 0 10px !important; }
.sms-meta.right { text-align: right; margin: 6px 0 0 !important; }
.bubble {
  margin: 0 0 0 auto !important;
  max-width: 88%;
  white-space: pre-line;
  background: #2f7cf6;
  color: #fff !important;
  padding: 12px 15px;
  border-radius: 20px 20px 6px 20px;
  font-size: 16px;
  line-height: 1.4;
}
.row { display: flex; gap: 22px; flex-wrap: wrap; }
.act {
  font-size: 15px;
  font-weight: 600;
  text-decoration: underline;
  text-decoration-color: var(--faint);
  text-underline-offset: 5px;
}
.act:hover { text-decoration-color: var(--text); }
.act.done { color: var(--warm); }

.hints {
  grid-column: 1 / -1;
  display: flex;
  gap: 26px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  font-size: 13px;
  color: var(--faint);
}
kbd {
  display: inline-block;
  min-width: 22px;
  padding: 1px 6px;
  margin-right: 4px;
  border: 1px solid var(--line);
  border-radius: 4px;
  font: inherit;
  font-size: 12px;
  text-align: center;
  color: var(--dim);
}

/* ---------- small screens: list, then panel ---------- */
@media (max-width: 760px) {
  .loading { flex-direction: column; align-items: stretch; gap: 16px; }
  .start { bottom: calc(150px + env(safe-area-inset-bottom)); }
  .tip { font-size: 14px; }
  .bg { object-position: 64% 50%; }
  .bg, .scene { transform-origin: 62% 52%; }

  .pause { grid-template-columns: 1fr; grid-template-rows: auto 1fr; }
  .hints { display: none; }
  .clock span:not(#clock):not(.sep) { display: none; }
  .clock .sep { display: none; }
  .menu { align-self: end; padding-bottom: 10px; }
  .menu button { font-size: 28px; padding: 8px 12px; margin-left: -12px; }
  .menu button.on { background: none; color: var(--dim); }
  .panels { display: none; align-self: stretch; padding-top: 20px; }
  .panel-open .menu { display: none; }
  .panel-open .panels { display: block; }
  .back { display: block; font-size: 15px; color: var(--dim); margin-bottom: 26px; }
  .back::before { content: "‹ "; }
  .gen { grid-template-columns: 1fr; }
  .list dd { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
