/* APORIA — full-screen screens: title, case select, debrief. */

.screen {
  position: absolute;
  inset: 0;
  pointer-events: auto;
  overflow: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  animation: screen-in .3s steps(4);
}
.screen::before { /* CRT scanlines + vignette over the 3D backdrop */
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    repeating-linear-gradient(0deg, rgba(0, 0, 0, .22) 0 2px, transparent 2px 4px),
    radial-gradient(ellipse at 50% 45%, rgba(6, 10, 20, .15) 0%, rgba(6, 10, 20, .7) 62%, rgba(6, 10, 20, .94) 100%);
  z-index: -1;
}
@keyframes screen-in { from { opacity: 0; } to { opacity: 1; } }

/* ── logo ─────────────────────────────────────────────────────────────── */
.logo-block { display: grid; justify-items: center; gap: 10px; }
.logo-row { display: flex; align-items: center; gap: clamp(10px, 2vw, 22px); }
.logo-badge {
  display: grid;
  place-items: center;
  padding: 8px;
  background: var(--bg1);
  box-shadow: inset 0 0 0 2px var(--line-hi), var(--notch), 5px 6px 0 0 rgba(0, 0, 0, .55);
  animation: bob 2.4s steps(2) infinite;
}
.logo-badge .px-icon { display: block; width: clamp(48px, 7vw, 76px); height: auto; }
.logo {
  position: relative;
  margin: 0 -.16em 0 0;
  font-size: clamp(54px, 11vw, 128px);
  font-weight: 900;
  line-height: .95;
  letter-spacing: .16em;
  color: var(--cyan);
  text-shadow:
    0 3px 0 #22c3e2,
    0 6px 0 #138aa6,
    0 9px 0 #0b5b6e,
    0 12px 0 #073542,
    -3px 0 0 var(--outline), 3px 0 0 var(--outline), 0 -3px 0 var(--outline),
    -3px 12px 0 var(--outline), 3px 12px 0 var(--outline), 0 15px 0 var(--outline),
    8px 20px 0 rgba(0, 0, 0, .55);
}
.logo::after { /* highlight band + scanlines clipped to the glyphs */
  content: attr(data-text);
  position: absolute;
  inset: 0;
  color: transparent;
  text-shadow: none;
  background:
    linear-gradient(180deg, rgba(235, 252, 255, .85) 0 18%, transparent 18% 100%),
    repeating-linear-gradient(180deg, transparent 0 5px, rgba(3, 20, 27, .28) 5px 7px);
  -webkit-background-clip: text;
  background-clip: text;
  pointer-events: none;
}
.logo-sub {
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: clamp(12px, 1.8vw, 18px);
  font-weight: 800;
  letter-spacing: .5em;
  margin-right: -.5em;
  color: var(--yellow);
  text-shadow: 2px 2px 0 var(--outline);
  white-space: nowrap;
}
.logo-sub::before, .logo-sub::after {
  content: "";
  width: clamp(18px, 5vw, 56px);
  height: 4px;
  background: var(--yellow);
  box-shadow: 2px 2px 0 var(--outline);
}
.logo-block.is-small { justify-items: start; gap: 2px; }
.logo-block.is-small .logo-row { gap: 10px; }
.logo-block.is-small .logo-badge { padding: 4px; animation: none; box-shadow: inset 0 0 0 2px var(--line-hi), var(--notch2), 3px 3px 0 rgba(0, 0, 0, .5); }
.logo-block.is-small .logo-badge .px-icon { width: 30px; }
.logo-block.is-small .logo { font-size: 30px; letter-spacing: .12em; text-shadow: 0 3px 0 #138aa6, 0 5px 0 #073542, 3px 7px 0 rgba(0, 0, 0, .6); }
.logo-block.is-small .logo-sub { font-size: 10px; letter-spacing: .32em; gap: 6px; }
.logo-block.is-small .logo-sub::before, .logo-block.is-small .logo-sub::after { display: none; }

/* ── title ────────────────────────────────────────────────────────────── */
.screen-title {
  display: grid;
  place-items: center;
  padding: 24px 16px 56px;
}
.title-wrap {
  display: grid;
  justify-items: center;
  gap: 18px;
  width: min(560px, 100%);
}
.tagline {
  margin: 4px 0 0;
  color: var(--ink-dim);
  text-align: center;
  letter-spacing: .06em;
  text-shadow: 2px 2px 0 var(--outline);
}
.title-form {
  width: min(440px, 100%);
  padding: 18px 20px 20px;
  display: grid;
  gap: 8px;
  margin-top: 6px;
}
.title-form .btn { margin-top: 8px; width: 100%; }
.title-form.shake { animation: shake .32s steps(4); }
.field-label {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .2em;
  text-transform: uppercase;
  color: var(--cyan);
}
.field-help { font-size: 13px; color: var(--ink-faint); margin: 0; }
.form-error { min-height: 1.2em; margin: 0; color: var(--red); font-size: 14px; font-weight: 700; }
.form-error:empty { min-height: 0; }
.input-row {
  display: flex;
  align-items: center;
  background: #040812;
  box-shadow: inset 0 0 0 2px var(--line), inset 0 4px 0 rgba(0, 0, 0, .5);
}
.input-row:focus-within { box-shadow: inset 0 0 0 2px var(--cyan), inset 0 4px 0 rgba(0, 0, 0, .5), 0 0 0 2px var(--cyan-3); }
.input-prompt { padding-left: 12px; color: var(--cyan); font-weight: 900; font-size: 20px; animation: blink 1s steps(2) infinite; }
.text-input {
  flex: 1;
  min-width: 0;
  padding: 11px 12px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
  caret-color: var(--yellow);
}
.text-input::placeholder { color: var(--ink-faint); font-weight: 400; }
.title-meta { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; justify-content: center; }
.title-controls {
  font-size: 13px;
  color: var(--ink-dim);
  text-align: center;
  text-shadow: 1px 1px 0 var(--outline);
}
.press-start {
  position: fixed;
  left: 0; right: 0; bottom: 16px;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .4em;
  color: var(--yellow);
  animation: blink 1.1s steps(2) infinite;
  pointer-events: none;
}

/* ── case select ──────────────────────────────────────────────────────── */
.screen-cases { padding: 18px clamp(14px, 3vw, 40px) 40px; }
.cases-head {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  margin: 0 auto 22px;
  max-width: 1200px;
}
.cases-player {
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 14px;
  font-size: 13px;
  letter-spacing: .12em;
}
.player-name { font-size: 16px; color: var(--yellow); letter-spacing: .04em; }
.cases-tools { margin-left: auto; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.cases-intro { max-width: 1200px; margin: 0 auto 18px; }
.cases-intro p { margin-top: 6px; text-shadow: 1px 1px 0 var(--outline); }
.case-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(300px, 100%), 1fr));
  gap: 26px 22px;
  max-width: 1200px;
  margin: 0 auto;
}
.case-card {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px 18px 16px;
  text-align: left;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  font-size: 15px;
  animation: slide-up .32s steps(4) both;
  animation-delay: calc(var(--i, 0) * 70ms);
  transition: transform .12s steps(2);
}
.case-card::before { /* folder tab */
  content: "";
  position: absolute;
  top: -10px; left: 16px;
  width: 92px; height: 10px;
  background: var(--yellow);
  box-shadow: 0 -3px 0 var(--outline), -3px 0 0 var(--outline), 3px 0 0 var(--outline);
}
.case-card:hover, .case-card:focus-visible {
  transform: translate(-3px, -3px);
  box-shadow: inset 0 0 0 2px var(--cyan), inset 0 4px 0 0 rgba(255, 255, 255, .03), var(--notch), 9px 11px 0 0 rgba(0, 0, 0, .55);
}
.case-card.is-done::before { background: var(--green); }
.case-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.case-num {
  font-size: 12px;
  font-weight: 900;
  letter-spacing: .2em;
  color: var(--yellow);
}
.case-stars { color: var(--yellow); letter-spacing: .15em; font-size: 16px; text-shadow: 2px 2px 0 var(--outline); }
.case-title {
  font-size: 21px;
  line-height: 1.15;
  text-transform: uppercase;
  letter-spacing: .06em;
  text-shadow: 2px 2px 0 var(--outline);
}
.case-loc { font-size: 13px; color: var(--cyan); }
.case-summary { color: var(--ink-dim); margin: 0; flex: 1; }
.case-foot {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 10px;
  margin-top: 2px;
  box-shadow: 0 -2px 0 var(--line);
}
.case-best { display: flex; align-items: center; gap: 8px; font-weight: 800; font-size: 14px; }
.case-best.is-new { color: var(--ink-faint); font-size: 12px; letter-spacing: .14em; }
.case-go { font-weight: 900; letter-spacing: .14em; color: var(--cyan); font-size: 13px; }
.case-card:hover .case-go { animation: blink .6s steps(2) infinite; }

/* ── debrief ──────────────────────────────────────────────────────────── */
.screen-debrief { padding: 22px clamp(12px, 3vw, 40px) 48px; }
.debrief-wrap { max-width: 1160px; margin: 0 auto; display: grid; grid-template-columns: minmax(0, 1fr); gap: 22px; }
.debrief-head { display: grid; justify-items: start; gap: 6px; }
.stamp-closed {
  display: inline-block;
  padding: 4px 12px;
  font-weight: 900;
  letter-spacing: .3em;
  color: var(--red);
  box-shadow: inset 0 0 0 3px var(--red);
  transform: rotate(-3deg);
  background: rgba(255, 77, 94, .08);
  animation: stamp .45s steps(4) both;
}
.debrief-top {
  display: grid;
  grid-template-columns: minmax(240px, 340px) 1fr;
  gap: 22px;
}
.rank-card { padding: 18px; display: grid; justify-items: center; gap: 8px; text-align: center; overflow: hidden; }
.rank-kicker { font-size: 12px; font-weight: 900; letter-spacing: .3em; color: var(--ink-dim); }
.rank-stage { position: relative; width: 180px; height: 170px; display: grid; place-items: center; }
.rank-rays {
  position: absolute;
  inset: -40px;
  background: repeating-conic-gradient(from 0deg, rgba(255, 210, 63, .14) 0 10deg, transparent 10deg 20deg);
  animation: spin 16s steps(48) infinite;
  -webkit-mask: radial-gradient(circle, #000 0 40%, transparent 70%);
  mask: radial-gradient(circle, #000 0 40%, transparent 70%);
}
.rank-letter {
  --rc: var(--yellow);
  --rs: var(--yellow-2);
  position: relative;
  font-size: 150px;
  font-weight: 900;
  line-height: 1;
  color: var(--rc);
  text-shadow:
    0 4px 0 var(--rs), 0 8px 0 var(--rs), 0 12px 0 rgba(0, 0, 0, .5),
    -4px 0 0 var(--outline), 4px 0 0 var(--outline), 0 -4px 0 var(--outline), 0 16px 0 var(--outline),
    -4px 12px 0 var(--outline), 4px 12px 0 var(--outline);
  animation: rank-stamp .7s steps(7) both .15s;
}
.rank-letter[data-rank="A"] { --rc: var(--cyan); --rs: var(--cyan-3); }
.rank-letter[data-rank="B"] { --rc: var(--green); --rs: var(--green-2); }
.rank-letter[data-rank="C"] { --rc: var(--orange); --rs: #9a4f0c; }
.rank-letter[data-rank="D"] { --rc: var(--red); --rs: var(--red-2); }
.rank-sparks i {
  position: absolute;
  left: 50%; top: 50%;
  width: 8px; height: 8px;
  background: var(--yellow);
  box-shadow: 2px 2px 0 var(--outline);
  opacity: 0;
  animation: spark .9s steps(6) forwards;
  animation-delay: .7s;
  --a: calc(var(--k) * 45deg);
}
.rank-title { font-size: 17px; font-weight: 900; text-transform: uppercase; letter-spacing: .12em; color: var(--ink); }
.rank-total { font-size: 30px; font-weight: 900; letter-spacing: .04em; }
.total-num { color: var(--yellow); text-shadow: 3px 3px 0 var(--outline); }
@keyframes rank-stamp {
  0% { transform: scale(3.2) rotate(-24deg); opacity: 0; }
  60% { transform: scale(.88) rotate(-4deg); opacity: 1; }
  80% { transform: scale(1.08) rotate(-7deg); }
  100% { transform: scale(1) rotate(-6deg); opacity: 1; }
}
@keyframes stamp { from { transform: scale(2) rotate(-12deg); opacity: 0; } to { transform: rotate(-3deg); opacity: 1; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spark {
  0% { opacity: 1; transform: translate(-50%, -50%) rotate(var(--a)) translateY(0); }
  100% { opacity: 0; transform: translate(-50%, -50%) rotate(var(--a)) translateY(-120px); }
}

.breakdown { padding: 18px 20px; display: grid; gap: 14px; align-content: start; }
.score-bar-label { display: flex; justify-content: space-between; font-size: 14px; margin-bottom: 6px; text-transform: uppercase; letter-spacing: .1em; }
.score-bar-val strong { font-size: 18px; color: var(--ink); }
.score-track {
  position: relative;
  height: 22px;
  background: #040812;
  box-shadow: 0 0 0 2px var(--outline), inset 0 0 0 2px var(--line);
  overflow: hidden;
}
.score-track::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 14px, rgba(1, 3, 9, .6) 14px 16px);
}
.score-fill {
  height: 100%;
  width: 0;
  background: var(--cyan);
  box-shadow: inset 0 -5px 0 rgba(0, 0, 0, .25), inset 0 3px 0 rgba(255, 255, 255, .35);
  animation: fill-bar 1.1s steps(12) forwards .4s;
}
.score-bar.is-int .score-fill { background: var(--green); }
.score-bar.is-lab .score-fill { background: var(--cyan); }
.score-bar.is-ded .score-fill { background: var(--yellow); }
@keyframes fill-bar { to { width: var(--pct); } }
.breakdown-meta { display: flex; gap: 18px; flex-wrap: wrap; font-size: 14px; padding-top: 6px; box-shadow: 0 -2px 0 var(--line); }

.debrief-cols { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; align-items: start; }
.debrief-col { display: grid; gap: 22px; }
.debrief-sec { padding: 18px 20px; }
.review-list, .lab-results, .lessons { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px; }
.review { padding: 10px 12px; background: rgba(0, 0, 0, .25); box-shadow: inset 4px 0 0 var(--red); }
.review.is-good { box-shadow: inset 4px 0 0 var(--green); }
.review-head { display: flex; gap: 10px; font-weight: 800; }
.review-mark { font-weight: 900; width: 1.2em; flex: none; }
.review.is-good .review-mark, .lab-results .is-good .review-mark { color: var(--green); }
.review.is-bad .review-mark, .lab-results .is-bad .review-mark { color: var(--red); }
.review-ans { margin: 4px 0 0 1.9em; font-size: 14px; }
.review-exp { margin: 6px 0 0 1.9em; font-size: 14px; color: var(--ink-dim); }
.lab-results li { display: flex; gap: 10px; align-items: center; padding: 6px 0; box-shadow: 0 2px 0 rgba(42, 58, 99, .5); }
.lab-res-title { flex: 1; min-width: 0; }
.story { font-size: 15px; line-height: 1.6; }
.lessons li, .objectives li { display: flex; gap: 10px; }
.obj-mark { color: var(--yellow); flex: none; }
.concept-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.concept-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 10px;
  border: 0;
  cursor: pointer;
  color: var(--ink);
  background: rgba(180, 140, 255, .1);
  box-shadow: inset 0 0 0 2px rgba(180, 140, 255, .5);
  font-size: 14px;
}
.concept-chip:hover { background: rgba(180, 140, 255, .2); }
.new-tag { font-size: 10px; font-weight: 900; padding: 1px 4px; background: var(--purple); color: var(--outline); letter-spacing: .1em; }
.lb-mode { color: var(--ink-dim); font-size: 12px; letter-spacing: .1em; }
.lb-table td:nth-child(3) { font-weight: 800; }
.lb-table tr.is-me td { background: rgba(255, 210, 63, .16); color: var(--yellow); }
.lb-table tr.is-me td:first-child { box-shadow: inset 4px 0 0 var(--yellow); }
.you-tag { margin-left: 8px; font-size: 10px; font-weight: 900; padding: 1px 5px; color: var(--yellow-ink); background: var(--yellow); }
.debrief-actions { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; padding: 6px 0 10px; }
.debrief-actions .btn { min-width: 200px; }

@media (max-width: 860px) {
  .debrief-top, .debrief-cols { grid-template-columns: minmax(0, 1fr); }
}
.debrief-col { min-width: 0; }
@media (max-width: 520px) {
  .rank-letter { font-size: 120px; }
  .rank-stage { width: 150px; height: 140px; }
  .debrief-sec, .breakdown { padding: 14px; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .screen-title { padding: 10px 16px 30px; }
  .title-wrap { gap: 10px; }
  .logo { font-size: 50px; }
  .logo-badge .px-icon { width: 44px; }
  .tagline, .title-controls { display: none; }
  .title-form { padding: 12px 16px 14px; }
  .press-start { display: none; }
  .rank-stage { width: 150px; height: 140px; }
  .rank-letter { font-size: 120px; }
}
@media (max-width: 520px) {
  .cases-tools { margin-left: 0; }
  .cases-head { gap: 10px; }
}

/* Link back to the hosting website (index.html meta aporia:home) */
.title-home {
  position: absolute;
  top: max(14px, env(safe-area-inset-top, 0px));
  left: max(16px, env(safe-area-inset-left, 0px));
  z-index: 2;
  padding: 7px 12px 6px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: .12em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-dim);
  background: rgba(6, 10, 20, .65);
  box-shadow: inset 0 0 0 2px var(--line), 3px 3px 0 rgba(0, 0, 0, .5);
}
.title-home:hover, .title-home:focus-visible { color: var(--cyan); box-shadow: inset 0 0 0 2px var(--cyan), 3px 3px 0 rgba(0, 0, 0, .5); }

/* ── story: case cards, replay briefing, debrief panels (js/ui/story.js) ── */
.cases-intro { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px 20px; flex-wrap: wrap; }
.cases-intro-text { min-width: 0; }
.replay-intro { flex: none; }
.case-num { display: inline-flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.case-chapter {
  padding: 2px 6px 3px;
  font-size: 11px;
  letter-spacing: .16em;
  color: var(--ink);
  background: rgba(255, 210, 63, .1);
  box-shadow: inset 0 0 0 1px rgba(255, 210, 63, .5);
}
.case-real {
  display: inline-flex;
  align-items: center;
  align-self: flex-start;
  gap: 7px;
  padding: 3px 8px 4px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--orange);
  background: rgba(255, 154, 60, .09);
  box-shadow: inset 0 0 0 1px rgba(255, 154, 60, .5);
}
.case-real-mark { width: 7px; height: 7px; background: currentColor; box-shadow: 2px 2px 0 var(--outline); flex: none; }

.debrief-sec .panel-heading { flex-wrap: wrap; }
.outcome-chip {
  margin-left: auto;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: .14em;
  box-shadow: inset 0 0 0 2px currentColor;
}
.outcome-chip.is-good { color: var(--green); background: rgba(69, 224, 138, .08); }
.outcome-chip.is-bad { color: var(--red); background: rgba(255, 77, 94, .08); }
.epilogue-lines { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.epi-line {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 10px 12px;
  background: rgba(0, 0, 0, .25);
  box-shadow: inset 4px 0 0 var(--green);
}
.epilogue-sec.is-unsolved .epi-line { box-shadow: inset 4px 0 0 var(--red); }
.epi-portrait {
  flex: none;
  display: grid;
  place-items: center;
  width: 38px; height: 38px;
  font-family: var(--emoji);
  font-size: 22px;
  line-height: 1;
  background: linear-gradient(180deg, #23417a, #10213f);
  box-shadow: inset 0 0 0 2px var(--cyan-2), var(--notch2);
}
.epi-body { min-width: 0; }
.epi-speaker { font-size: 12px; font-weight: 900; letter-spacing: .12em; text-transform: uppercase; color: var(--cyan); margin-bottom: 2px; }
.epi-text { margin: 0; font-size: 14px; line-height: 1.55; overflow-wrap: anywhere; }

.behind-sec { box-shadow: inset 0 0 0 2px var(--line), inset 0 4px 0 0 rgba(255, 154, 60, .5), var(--notch), var(--drop); }
.behind-kicker { color: var(--orange); letter-spacing: .12em; }
.behind-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(220px, 1fr); gap: 22px; align-items: start; }
.behind-title { font-size: 17px; line-height: 1.3; letter-spacing: .03em; margin-bottom: 8px; color: var(--ink); text-shadow: 2px 2px 0 var(--outline); }
.behind-summary { font-size: 15px; line-height: 1.6; }
.behind-changed {
  margin-top: 12px;
  padding: 10px 14px;
  background: rgba(255, 210, 63, .07);
  box-shadow: inset 4px 0 0 var(--yellow), inset 0 0 0 1px rgba(255, 210, 63, .25);
}
.behind-changed p { margin: 0; font-size: 14px; }
.source-list { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 10px; }
.source-link {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  padding: 9px 12px 10px;
  color: var(--ink);
  text-decoration: none;
  background: rgba(62, 230, 255, .06);
  box-shadow: inset 0 0 0 2px rgba(62, 230, 255, .35), 3px 4px 0 rgba(0, 0, 0, .45);
}
.source-link:hover { background: rgba(62, 230, 255, .12); box-shadow: inset 0 0 0 2px var(--cyan), 3px 4px 0 rgba(0, 0, 0, .45); }
.source-label { font-weight: 800; font-size: 14px; overflow-wrap: anywhere; }
.source-host { grid-column: 1; font-size: 12px; color: var(--ink-dim); overflow-wrap: anywhere; }
.source-ext { grid-column: 2; grid-row: 1 / span 2; align-self: center; color: var(--cyan); font-weight: 900; font-size: 18px; }
@media (max-width: 860px) {
  .behind-grid { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 520px) {
  .replay-intro .btn-label { font-size: 12px; }
}
