:root {
  color-scheme: light dark;
  --desk: #243b53;
  --desk-deep: #182c40;
  --paper: #f7f4e9;
  --paper-deep: #ebe6d8;
  --ink: #172534;
  --muted: #596675;
  --line: #9aa3a7;
  --accent: #bd3a31;
  --accent-dark: #86271f;
  --folder: #c5a865;
  --folder-tab: #b5944d;
  --success: #246347;
  --success-bg: #dce8d9;
  --wrong: #8b2823;
  --wrong-bg: #eedbd5;
  --light-text: #fbfaf5;
  --shadow: rgba(7, 20, 31, 0.32);
  --radius: 3px;
  --font: "Aptos", "Segoe UI", Helvetica, Arial, sans-serif;
  --condensed: "Arial Narrow", "Aptos Narrow", "Roboto Condensed", Arial, sans-serif;
  --mono: "Cascadia Mono", "SFMono-Regular", Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --desk: #142739;
    --desk-deep: #0d1c2a;
    --paper: #e7e1d2;
    --paper-deep: #d6cebc;
    --ink: #172534;
    --muted: #52606e;
    --line: #858e91;
    --folder: #b99a56;
    --folder-tab: #a1813f;
    --shadow: rgba(1, 8, 14, 0.5);
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--desk);
}

body {
  min-width: 320px;
  min-height: 100dvh;
  margin: 0;
  overflow-x: hidden;
  background-color: var(--desk);
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.018) 0 1px, transparent 1px 46px),
    repeating-linear-gradient(0deg, rgba(4,16,27,0.04) 0 1px, transparent 1px 46px);
  color: var(--ink);
  font-family: var(--font);
}

button, a { font: inherit; }
button { cursor: pointer; }

button:focus-visible,
a:focus-visible,
.scenario-card:focus-visible {
  outline: 4px solid #f3c856;
  outline-offset: 4px;
}

.game-shell {
  width: min(100%, 880px);
  min-height: 100dvh;
  margin: 0 auto;
  padding: clamp(18px, 4vw, 38px) 18px;
  display: grid;
  align-items: center;
}

.home-screen,
.end-screen {
  position: relative;
  isolation: isolate;
  width: min(100%, 720px);
  margin: auto;
}

.folder {
  position: absolute;
  inset: -30px -24px -22px;
  z-index: 0;
  border: 2px solid rgba(16, 30, 40, 0.55);
  border-radius: var(--radius);
  background: var(--folder);
  box-shadow: 15px 17px 0 rgba(6, 18, 28, 0.18);
  transform: rotate(-1.3deg);
}

.folder::before {
  content: "";
  position: absolute;
  top: -24px;
  left: 18px;
  width: 152px;
  height: 25px;
  border: 2px solid rgba(16, 30, 40, 0.55);
  border-bottom: 0;
  background: var(--folder-tab);
}

.folder span {
  position: absolute;
  right: 22px;
  top: 20px;
  color: rgba(35, 37, 30, 0.62);
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.home-copy,
.end-screen {
  position: relative;
  z-index: 1;
  min-height: min(610px, calc(100dvh - 92px));
  padding: clamp(32px, 7vw, 68px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0 31px,
    rgba(63, 101, 132, 0.12) 31px 32px
  );
  box-shadow: 8px 10px 0 var(--shadow);
}

.home-copy::before,
.end-screen::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: clamp(18px, 5vw, 40px);
  width: 2px;
  background: rgba(189, 58, 49, 0.3);
}

.kicker,
.completion-label,
.scenario-label {
  margin: 0;
  color: var(--accent-dark);
  font-family: var(--mono);
  font-size: clamp(12px, 2vw, 14px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 24px 0 20px;
  display: grid;
  width: fit-content;
  font-family: var(--condensed);
  font-size: clamp(52px, 11vw, 96px);
  font-weight: 950;
  letter-spacing: -0.075em;
  line-height: 0.78;
}

h1 span:last-of-type { color: var(--accent); }
h1 i {
  margin: 2px 0 -1px 1.7ch;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 0.38em;
  font-style: normal;
  letter-spacing: 0;
  line-height: 1;
}

.intro {
  max-width: 520px;
  margin: 8px 0 30px;
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 650;
  line-height: 1.42;
}

.primary-button,
.next-button,
.choice {
  min-height: 66px;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  font-family: var(--condensed);
  font-weight: 900;
  letter-spacing: 0.02em;
  transition: transform 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

.primary-button {
  width: min(100%, 220px);
  background: var(--ink);
  color: var(--light-text);
  box-shadow: 5px 6px 0 rgba(189, 58, 49, 0.65);
  font-size: 22px;
}

.primary-button:hover { background: var(--accent-dark); }
.primary-button:active,
.next-button:active,
.choice:active { transform: translateY(2px); box-shadow: none; }

.game-screen {
  width: 100%;
  display: grid;
  gap: 15px;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: var(--light-text);
}

.small-title {
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: inherit;
  font-family: var(--condensed);
  font-size: clamp(21px, 5vw, 30px);
  font-weight: 950;
  letter-spacing: -0.05em;
  text-decoration: none;
}

.small-title span:last-child { color: #f39a90; }
.small-title i { color: #c7d0d8; font-family: var(--mono); font-size: 0.62em; font-style: normal; }

.card-count {
  margin: 0;
  color: var(--light-text);
  font-family: var(--mono);
  font-size: 17px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.scenario-card {
  position: relative;
  min-height: clamp(350px, 55dvh, 480px);
  padding: clamp(28px, 6vw, 54px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: var(--radius);
  background-color: var(--paper);
  background-image: repeating-linear-gradient(
    0deg,
    transparent 0 35px,
    rgba(63, 101, 132, 0.1) 35px 36px
  );
  box-shadow: 9px 10px 0 var(--shadow);
}

.scenario-card::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 clamp(14px, 3vw, 29px);
  width: 2px;
  background: rgba(189, 58, 49, 0.26);
}

.paperclip {
  position: absolute;
  top: -10px;
  right: clamp(22px, 6vw, 55px);
  width: 18px;
  height: 65px;
  border: 3px solid #77828a;
  border-radius: 10px;
  transform: rotate(7deg);
}

.paperclip::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 4px;
  width: 5px;
  height: 45px;
  border: 2px solid #77828a;
  border-radius: 6px;
}

.scenario-card h2 {
  margin: 7px 0 15px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
}

.scenario-text {
  max-width: 34ch;
  margin: 0;
  font-size: clamp(24px, 4.8vw, 38px);
  font-weight: 780;
  letter-spacing: -0.035em;
  line-height: 1.17;
}

.feedback {
  position: relative;
  z-index: 1;
  margin: clamp(24px, 5vh, 42px) calc(clamp(28px, 6vw, 54px) * -1) calc(clamp(28px, 6vw, 54px) * -1);
  padding: 20px clamp(28px, 6vw, 54px) 22px;
  border-top: 2px solid var(--ink);
  background: var(--success-bg);
}

.feedback-wrong { background: var(--wrong-bg); }
.feedback p { margin: 0; }
.feedback-result { color: var(--success); font-size: clamp(22px, 4vw, 28px); font-weight: 900; }
.feedback-wrong .feedback-result { color: var(--wrong); }
.correct-answer { margin-top: 4px !important; font-family: var(--mono); font-size: 13px; font-weight: 800; }
.explanation { max-width: 58ch; margin-top: 8px !important; font-size: clamp(16px, 2.7vw, 19px); font-weight: 620; line-height: 1.36; }

.choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 15px;
}

.choice {
  min-height: 82px;
  padding: 12px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--light-text);
  box-shadow: 5px 6px 0 var(--shadow);
  font-size: clamp(23px, 4vw, 31px);
}

.choice-do { background: #2e604a; }
.choice-ask { background: var(--accent-dark); }
.choice-do:hover { background: #234c3a; }
.choice-ask:hover { background: #6d1f1a; }

kbd {
  min-width: 30px;
  padding: 5px;
  border: 1px solid currentColor;
  border-radius: var(--radius);
  font-family: var(--mono);
  font-size: 13px;
  text-align: center;
}

.next-button {
  width: 100%;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 5px 6px 0 var(--shadow);
  font-size: 22px;
}

.next-button:hover { background: var(--paper-deep); }

.end-screen {
  position: relative;
  align-items: flex-start;
}

.end-screen h2 { margin: 18px 0 0; font-size: clamp(25px, 4vw, 34px); }
.final-score {
  margin: 0;
  color: var(--accent);
  font-family: var(--condensed);
  font-size: clamp(84px, 18vw, 145px);
  font-weight: 950;
  letter-spacing: -0.08em;
  line-height: 0.95;
}

.end-message {
  max-width: 460px;
  margin: 20px 0 30px;
  font-size: clamp(18px, 3vw, 22px);
  font-weight: 650;
  line-height: 1.42;
}

noscript {
  padding: 20px;
  background: var(--paper);
  color: var(--ink);
}

@media (max-width: 620px) {
  .game-shell { padding: 14px 12px; }
  .folder { inset: -18px 0 -12px; transform: rotate(-0.4deg); }
  .folder::before { left: 8px; width: 120px; }
  .folder span { display: none; }
  .home-copy,
  .end-screen { min-height: calc(100dvh - 52px); padding: 32px 28px 30px 44px; }
  .home-copy::before,
  .end-screen::before { left: 24px; }
  h1 { font-size: clamp(46px, 17vw, 72px); }
  .scenario-card { min-height: 52dvh; padding: 35px 24px 28px 41px; }
  .scenario-card::after { left: 24px; }
  .feedback { margin: 25px -24px -28px -41px; padding: 17px 24px 18px 41px; }
  .choices { gap: 9px; }
  .choice { min-height: 76px; padding: 10px 12px; font-size: clamp(21px, 7vw, 27px); }
  kbd { display: none; }
}

@media (max-height: 700px) and (min-width: 621px) {
  .game-shell { padding-block: 15px; }
  .scenario-card { min-height: 350px; }
  .home-copy,
  .end-screen { min-height: calc(100dvh - 70px); }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
