:root {
  --wine: #6f123d;
  --wine-dark: #250818;
  --magenta: #c62467;
  --pink: #ff6fa9;
  --gold: #ffc84a;
  --cream: #fff3d1;
  --ink: #120913;
  --blue: #55c8ff;
  --green: #54d17a;
  --pixel-shadow: 4px 4px 0 #120913;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  background:
    radial-gradient(circle at 50% 0, #7e234c 0, transparent 42%),
    repeating-linear-gradient(135deg, #170712 0 12px, #1c0916 12px 24px);
  color: var(--cream);
  font-family: "Courier New", ui-monospace, monospace;
  min-height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

button { font: inherit; }
button:focus-visible { outline: 4px solid #fff; outline-offset: 3px; }
img { display: block; }

.game-shell {
  position: relative;
  width: min(1180px, 100vw);
  height: min(780px, 100svh);
  overflow: hidden;
  background: var(--ink);
  border: 4px solid #a7446f;
  box-shadow: 0 0 0 4px #2b0a1b, 0 28px 90px #000b;
}

.screen { display: none; position: absolute; inset: 0; }
.screen.is-active { display: flex; animation: screen-in .28s steps(4, end); }
@keyframes screen-in { from { opacity: 0; filter: brightness(.5); } to { opacity: 1; filter: none; } }

.cover-image { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.title-shade { position: absolute; inset: 0; background: linear-gradient(90deg, #170713ed 0 37%, #17071377 60%, #17071322), linear-gradient(0deg, #170713bb, transparent 55%); }

.title-screen, .result-screen, .game-over-screen { align-items: center; padding: clamp(20px, 5vw, 70px); }
.title-card, .result-card, .game-over-card { position: relative; width: min(560px, 94%); text-shadow: 2px 2px #000; }
.eyebrow { color: var(--gold); font-size: .78rem; font-weight: 900; letter-spacing: .14em; text-transform: uppercase; }
.title-card h1 { color: white; font-size: clamp(3rem, 8vw, 6.3rem); line-height: .82; letter-spacing: -.09em; margin: 14px 0 20px; text-transform: uppercase; }
.title-card h1::first-letter { color: var(--pink); }
.subtitle { color: var(--gold); font-size: clamp(1rem, 2.2vw, 1.5rem); font-weight: 900; text-transform: uppercase; }
.mission-copy { max-width: 45ch; color: #f8e9dc; font-family: system-ui, sans-serif; font-size: 1rem; line-height: 1.55; }
.title-actions { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 28px; }
.key-hint { color: #d7a9be; font-size: .72rem; margin-top: 20px; }
kbd { background: #1a0914; border: 1px solid #b97794; border-bottom-width: 3px; padding: 2px 5px; }

.pixel-button {
  border: 3px solid #f2b6cf;
  background: #331225;
  color: white;
  cursor: pointer;
  font-size: .86rem;
  font-weight: 900;
  letter-spacing: .05em;
  padding: 15px 19px;
  text-transform: uppercase;
  box-shadow: var(--pixel-shadow);
  transition: transform .1s, background .1s;
}
.pixel-button:hover { background: #5b1837; transform: translate(-2px, -2px); }
.pixel-button:active { transform: translate(3px, 3px); box-shadow: 1px 1px #120913; }
.pixel-button--primary { background: var(--magenta); border-color: #ff91bc; }
.pixel-button--primary:hover { background: #e12e77; }

.briefing-screen { background: #250818; }
.briefing-art { width: 58%; position: relative; overflow: hidden; }
.briefing-art img { object-position: 38% 50%; }
.briefing-art::after { content: ""; position: absolute; inset: 0; background: linear-gradient(90deg, transparent 55%, #250818); }
.briefing-art img { width: 100%; height: 100%; object-fit: cover; }
.briefing-card { align-self: center; width: 42%; padding: clamp(24px, 5vw, 60px) 5% clamp(24px, 5vw, 60px) 2%; z-index: 1; }
.briefing-card h2, .result-card h2 { color: white; font-size: clamp(2rem, 4.8vw, 4rem); line-height: .95; margin: 15px 0 24px; text-transform: uppercase; }
.briefing-card > p:not(.eyebrow) { font-family: system-ui, sans-serif; line-height: 1.55; color: #f0dbe4; }
.briefing-card .pixel-button { margin-top: 18px; }

.character-screen {
  align-items: center;
  justify-content: center;
  padding: clamp(20px, 4vw, 48px);
  background:
    radial-gradient(circle at 50% 10%, #8a2858 0, transparent 44%),
    repeating-linear-gradient(135deg, #210a19 0 16px, #290d20 16px 32px);
  overflow: auto;
}
.character-panel { width: min(980px, 100%); text-align: center; }
.character-panel h2 { margin: 8px 0 10px; color: white; font-size: clamp(2rem, 5vw, 4rem); line-height: 1; text-transform: uppercase; text-shadow: 4px 4px #120913; }
.character-intro { margin: 0 auto 22px; max-width: 62ch; color: #efd6e1; font-family: system-ui, sans-serif; }
.character-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: clamp(14px, 3vw, 28px); margin-bottom: 24px; }
.character-card { position: relative; display: grid; grid-template-columns: minmax(125px, 42%) 1fr; align-items: center; min-height: 330px; padding: 14px; border: 4px solid #7f3d5c; background: #190a14d9; color: white; cursor: pointer; text-align: left; box-shadow: 6px 6px 0 #10050c; transition: transform .12s, border-color .12s, background .12s; }
.character-card:hover { transform: translateY(-4px); border-color: var(--pink); background: #371128; }
.character-card.is-selected { border-color: var(--gold); background: linear-gradient(135deg, #531737, #1c0a16); box-shadow: 0 0 0 3px #fff2, 7px 7px 0 #10050c; }
.character-portrait { align-self: stretch; min-height: 295px; overflow: hidden; background: linear-gradient(#eee, #ccc); }
.character-portrait img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 28%; image-rendering: pixelated; }
.character-copy { display: grid; gap: 10px; padding: 14px 8px 14px 18px; }
.character-copy strong { color: white; font-size: clamp(1.25rem, 2.5vw, 2rem); line-height: 1; }
.character-copy small { color: var(--gold); font-weight: 900; text-transform: uppercase; }
.character-copy > span { color: #e6cbd7; font-family: system-ui, sans-serif; font-size: .88rem; line-height: 1.45; }
.character-check { position: absolute; top: 12px; right: 12px; display: none; width: 32px; height: 32px; place-items: center; background: var(--gold); color: var(--ink); font-weight: 900; box-shadow: 3px 3px #120913; }
.character-card.is-selected .character-check { display: grid; }
.character-panel > .pixel-button { min-width: 250px; }

.map-screen, .mission-screen { flex-direction: column; }
.hud { height: 84px; flex: 0 0 84px; background: linear-gradient(#4e1732, #280b1b); border-bottom: 4px solid #9b3564; display: flex; align-items: center; padding: 10px 18px; gap: 16px; z-index: 3; }
.identity { display: flex; align-items: center; gap: 12px; min-width: 210px; }
.identity div { display: grid; gap: 4px; }
.identity strong { color: white; text-transform: uppercase; }
.identity span { color: #dca8bd; font-size: .7rem; }
.identity i { font-style: normal; }
.avatar { width: 58px; height: 58px; object-fit: cover; object-position: 50% 22%; border: 3px solid var(--gold); background: white; }
.stats { margin-left: auto; display: flex; gap: 8px; }
.stats > span, .result-stats > span { min-width: 92px; display: grid; text-align: center; background: #150812cc; border: 2px solid #76324f; padding: 7px 12px; }
.stats small, .result-stats small { color: #d49eb5; font-size: .62rem; text-transform: uppercase; }
.stats b { color: var(--gold); font-size: 1.08rem; font-style: normal; }
.stats i { font-style: normal; }
.icon-button { width: 44px; height: 44px; border: 2px solid #9d5273; background: #250918; color: var(--cream); cursor: pointer; font-size: 1.4rem; }

.map-stage { position: relative; flex: 1; min-height: 0; overflow: hidden; background: #142a32; }
.map-image { width: 100%; height: 100%; object-fit: cover; }
.map-vignette { pointer-events: none; position: absolute; inset: 0; box-shadow: inset 0 0 90px #071016cc; background: linear-gradient(180deg, #0003, transparent 20% 70%, #0007); }
.map-pin { position: absolute; left: var(--x); top: var(--y); transform: translate(-50%, -50%); display: grid; justify-items: center; gap: 4px; border: 0; background: transparent; color: white; cursor: pointer; font-size: .72rem; font-weight: 900; text-shadow: 2px 2px #000; }
.pin-icon { width: 42px; height: 42px; display: grid; place-items: center; border: 4px solid white; background: var(--magenta); color: white; box-shadow: var(--pixel-shadow); font-size: 1rem; transition: transform .15s; }
.map-pin:hover .pin-icon { background: #ec3a81; transform: translateY(-5px) scale(1.08); }
.map-pin.is-complete .pin-icon { background: #167d45; color: transparent; }
.map-pin.is-complete .pin-icon::after { content: "✓"; color: white; position: absolute; }
.map-pin.is-complete > span:last-child { color: #c8ffdb; }
.map-footer { height: 46px; flex: 0 0 46px; display: flex; align-items: center; justify-content: center; gap: 20px; padding: 6px 18px; background: #170812; color: #f3cadb; font-size: .77rem; text-align: center; z-index: 2; }
.map-footer button { border: 0; border-bottom: 1px solid #ac728b; background: none; color: #c99aae; cursor: pointer; font-size: .68rem; }

.mission-topbar { height: 68px; flex: 0 0 68px; background: #250918; border-bottom: 3px solid #7c2c50; display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 10px 18px; z-index: 3; }
.back-button { border: 2px solid #8e4968; background: #160711; color: white; padding: 9px 12px; cursor: pointer; font-size: .76rem; }
.mission-progress { width: min(320px, 42vw); display: grid; gap: 7px; text-align: center; color: #ecc6d7; font-size: .7rem; }
.mission-progress > div { height: 12px; padding: 2px; background: #11060d; border: 2px solid #6f324c; }
.mission-progress i { display: block; width: 33%; height: 100%; background: var(--gold); transition: width .25s steps(4, end); }
.hearts { color: #ff4b80; font-size: 1.25rem; letter-spacing: 3px; text-shadow: 2px 2px #000; }
.mission-scene { position: relative; height: 45%; flex: 0 0 45%; min-height: 210px; overflow: hidden; background: #15252c; }
.mission-background { width: 100%; height: 100%; object-fit: cover; }
.mission-background.is-illustration { object-fit: contain; background: radial-gradient(circle, #e7f2e6, #6f9e99 60%, #17252d); }
.scene-gradient { position: absolute; inset: 0; background: linear-gradient(90deg, #120810c7, transparent 55%), linear-gradient(0deg, #120810b8, transparent 50%); }
.mission-location { position: absolute; left: 26px; bottom: 20px; text-shadow: 3px 3px #000; }
.mission-location span { color: var(--gold); font-size: .7rem; text-transform: uppercase; }
.mission-location h2 { margin: 5px 0 0; color: white; font-size: clamp(1.8rem, 4vw, 3.2rem); text-transform: uppercase; }
.dialogue-box { flex: 1; min-height: 0; display: flex; gap: 22px; padding: 20px 24px; background: linear-gradient(135deg, #321022, #1c0915); border-top: 4px solid #a33968; overflow: auto; }
.npc-image { flex: 0 0 150px; width: 150px; height: 150px; object-fit: cover; object-position: 50% 24%; background: white; border: 4px solid var(--gold); box-shadow: var(--pixel-shadow); }
.dialogue-content { flex: 1; min-width: 0; }
.npc-name { margin: 0 0 8px; color: var(--pink); font-size: .74rem; font-weight: 900; text-transform: uppercase; }
.question { margin: 0 0 14px; color: white; font-family: system-ui, sans-serif; font-size: 1.05rem; font-weight: 700; line-height: 1.35; }
.answers { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.answer-button { min-height: 62px; border: 2px solid #80415e; background: #160a12; color: #f4dfe8; cursor: pointer; padding: 10px; text-align: left; font-family: system-ui, sans-serif; font-size: .83rem; font-weight: 650; line-height: 1.25; transition: border-color .1s, background .1s, transform .1s; }
.answer-button:hover:not(:disabled) { border-color: var(--pink); background: #47152d; transform: translateY(-2px); }
.answer-button.correct { border-color: #7cf0a0; background: #104425; color: white; }
.answer-button.wrong { border-color: #ff6b6b; background: #561520; }
.answer-button:disabled { cursor: default; }
.feedback { min-height: 22px; margin: 10px 0 0; color: var(--gold); font-family: system-ui, sans-serif; font-size: .82rem; font-weight: 650; }

.result-screen { justify-content: flex-start; }
.result-card h2 { margin-bottom: 12px; }
.rank { color: var(--gold); font-size: 1.2rem; font-weight: 900; text-transform: uppercase; }
.result-stats { display: flex; gap: 10px; margin: 22px 0; }
.result-stats b { color: white; font-size: 1.4rem; }
.result-card > p:last-of-type { font-family: system-ui, sans-serif; line-height: 1.5; }

.game-over-screen { justify-content: flex-start; }
.game-over-image { object-position: center; }
.game-over-card { padding: clamp(20px, 4vw, 38px); background: #170713dc; border: 4px solid #c4487d; box-shadow: 8px 8px 0 #120913; }
.game-over-card h2 { margin: 12px 0 18px; color: white; font-size: clamp(2rem, 5vw, 4.4rem); line-height: .96; text-transform: uppercase; }
.game-over-card > p:not(.eyebrow) { color: #f4dfe8; font-family: system-ui, sans-serif; line-height: 1.55; }
.game-over-card .pixel-button { margin-top: 14px; }

.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; }

@media (max-width: 760px) {
  body { overflow: auto; display: block; }
  .game-shell { height: 100svh; border-width: 0; }
  .title-shade { background: linear-gradient(0deg, #170713f2 0 52%, #17071366 78%); }
  .title-screen, .result-screen, .game-over-screen { align-items: flex-end; padding: 22px; }
  .title-card h1 { font-size: clamp(2.8rem, 16vw, 4.8rem); }
  .key-hint { display: none; }
  .briefing-screen { flex-direction: column; }
  .briefing-art { width: 100%; height: 40%; }
  .briefing-art::after { background: linear-gradient(0deg, #250818, transparent 50%); }
  .briefing-card { width: 100%; height: 60%; padding: 20px 24px; overflow: auto; }
  .briefing-card h2 { font-size: 2rem; margin: 8px 0 14px; }
  .briefing-card > p:not(.eyebrow) { font-size: .88rem; }
  .character-screen { align-items: flex-start; padding: 18px; }
  .character-panel h2 { font-size: 2rem; }
  .character-intro { font-size: .86rem; }
  .character-grid { grid-template-columns: 1fr; gap: 12px; }
  .character-card { grid-template-columns: 105px 1fr; min-height: 155px; padding: 9px; }
  .character-portrait { min-height: 135px; height: 135px; }
  .character-copy { gap: 5px; padding: 8px 4px 8px 12px; }
  .character-copy > span { font-size: .76rem; }
  .hud { height: 74px; flex-basis: 74px; padding: 8px 10px; }
  .identity { min-width: 0; }
  .avatar { width: 50px; height: 50px; }
  .identity span { display: none; }
  .stats > span { min-width: 55px; padding: 5px; }
  .stats > span:nth-child(2) { display: none; }
  .icon-button { display: none; }
  .map-image { object-position: 50% 50%; }
  .map-pin > span:last-child { font-size: .6rem; }
  .pin-icon { width: 36px; height: 36px; }
  .map-footer { font-size: .65rem; }
  .mission-topbar { height: 60px; flex-basis: 60px; }
  .mission-scene { height: 34%; flex-basis: 34%; }
  .dialogue-box { padding: 14px; gap: 12px; flex-direction: column; }
  .npc-image { width: 72px; height: 72px; flex-basis: 72px; position: absolute; margin-top: -70px; right: 15px; }
  .answers { grid-template-columns: 1fr; }
  .answer-button { min-height: 48px; }
  .hearts { font-size: .9rem; }
  .game-over-card { width: 100%; padding: 20px; }
  .game-over-card h2 { font-size: 2rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
