:root {
  --navy: #062b47;
  --navy-deep: #031d31;
  --blue: #075d8f;
  --paper: #fff8e8;
  --paper-dark: #f4e3bb;
  --gold: #f4b521;
  --orange: #ee801b;
  --red: #c9432e;
  --green: #2b855c;
  --ink: #0a304c;
  --muted: #5d6a72;
  --white: #fff;
  --shadow: 0 18px 50px rgba(3, 29, 49, .14);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(244,181,33,.10), transparent 25rem),
    #f6f2e8;
  font-family: "Trebuchet MS", "Segoe UI", Arial, sans-serif;
}

button, input { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { color: inherit; }

.topbar {
  min-height: 92px;
  padding: 10px clamp(20px, 5vw, 76px);
  background: rgba(255,255,255,.96);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 24px;
  border-bottom: 1px solid rgba(6,43,71,.12);
  position: sticky;
  top: 0;
  z-index: 50;
  backdrop-filter: blur(14px);
}

.brand img { display: block; width: min(245px, 42vw); max-height: 70px; object-fit: contain; }

.top-actions { display: flex; gap: 12px; align-items: stretch; }

.sound-toggle, .score-card {
  border: 1px solid rgba(6,43,71,.15);
  background: #f8f4ea;
  border-radius: 14px;
  min-height: 52px;
}

.sound-toggle {
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 800;
}

.sound-toggle > span:first-child { color: var(--orange); font-size: 1.4rem; }
.score-card { min-width: 92px; padding: 7px 16px; text-align: center; }
.score-card span { display: block; color: var(--muted); text-transform: uppercase; font-size: .65rem; letter-spacing: .12em; font-weight: 800; }
.score-card strong { font-size: 1.45rem; color: var(--red); line-height: 1; }

.hero {
  min-height: 660px;
  padding: 82px clamp(22px, 6vw, 92px) 76px;
  color: var(--white);
  background:
    linear-gradient(90deg, rgba(3,29,49,.98) 0%, rgba(6,43,71,.96) 46%, rgba(6,43,71,.65) 100%),
    repeating-linear-gradient(0deg, transparent 0 39px, rgba(255,255,255,.02) 40px),
    var(--navy);
  display: grid;
  grid-template-columns: minmax(0, .85fr) minmax(420px, 1.15fr);
  align-items: center;
  gap: clamp(42px, 7vw, 110px);
  overflow: hidden;
}

.hero-copy { max-width: 660px; position: relative; z-index: 2; }
.eyebrow, .section-kicker { margin: 0 0 9px; text-transform: uppercase; letter-spacing: .16em; font-size: .75rem; font-weight: 900; color: var(--orange); }
.hero .eyebrow { color: var(--gold); }

.hero h1 {
  margin: 0;
  font-family: Impact, "Arial Narrow", sans-serif;
  font-size: clamp(3.5rem, 6.7vw, 7.3rem);
  line-height: .89;
  text-transform: uppercase;
  letter-spacing: .015em;
  font-weight: 900;
  text-shadow: 0 5px 0 rgba(0,0,0,.12);
}

.hero h1 span { color: var(--gold); }
.hero-lead { max-width: 600px; margin: 28px 0 22px; font-size: clamp(1rem, 1.4vw, 1.22rem); line-height: 1.65; color: #eaf2f5; }
.case-tags { display: flex; flex-wrap: wrap; gap: 9px; margin-bottom: 30px; }
.case-tags span { padding: 8px 12px; border: 1px solid rgba(255,255,255,.26); border-radius: 999px; font-size: .78rem; font-weight: 800; background: rgba(255,255,255,.07); }

.primary-action, .check-button, .primary-modal-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  border: 0;
  border-radius: 12px;
  padding: 16px 22px;
  background: var(--gold);
  color: var(--navy-deep);
  text-decoration: none;
  font-weight: 950;
  text-transform: uppercase;
  letter-spacing: .04em;
  cursor: pointer;
  box-shadow: 0 6px 0 #bd7318;
  transition: transform .15s ease, box-shadow .15s ease;
}

.primary-action:hover, .check-button:hover, .primary-modal-button:hover { transform: translateY(-2px); box-shadow: 0 8px 0 #bd7318; }
.primary-action:active, .check-button:active, .primary-modal-button:active { transform: translateY(3px); box-shadow: 0 3px 0 #bd7318; }

.hero-visual { position: relative; min-height: 455px; }
.photo-frame {
  position: absolute;
  inset: 5% -9% 4% 2%;
  transform: rotate(2deg);
  padding: 13px 13px 45px;
  background: #f7eedb;
  border-radius: 8px;
  box-shadow: 0 30px 70px rgba(0,0,0,.4);
}
.photo-frame::before { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(120deg, rgba(255,255,255,.18), transparent 38%); }
.photo-frame img { width: 100%; height: 100%; object-fit: cover; display: block; border-radius: 3px; filter: saturate(.92) contrast(1.04); }
.evidence-label { position: absolute; bottom: 15px; right: 22px; color: #6e614c; font: 800 .8rem/1 "Courier New", monospace; text-transform: uppercase; letter-spacing: .12em; }
.cipher-note {
  position: absolute;
  left: -5%;
  bottom: 1%;
  transform: rotate(-6deg);
  width: 275px;
  padding: 22px 24px;
  background: #ffe6a5;
  color: var(--navy);
  font: 900 2rem/1.35 Georgia, serif;
  text-align: center;
  box-shadow: 0 16px 30px rgba(0,0,0,.28);
  border: 1px solid #c99c4b;
}
.cipher-note::before { content: "CÓDIGO"; display: block; margin-bottom: 4px; font: 900 .64rem/1 "Courier New", monospace; letter-spacing: .28em; color: var(--red); }
.cipher-note span { display: block; white-space: nowrap; }

.page-section, .case-progress { width: min(1160px, calc(100% - 40px)); margin-inline: auto; }

.briefing {
  margin-top: -32px;
  position: relative;
  z-index: 4;
  padding: 31px 34px;
  display: grid;
  grid-template-columns: auto 1fr minmax(220px, .34fr);
  gap: 25px;
  align-items: center;
  background: var(--paper);
  border: 1px solid #eadbb5;
  border-radius: 18px;
  box-shadow: var(--shadow);
}
.briefing-icon { width: 58px; height: 58px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: var(--navy); font: 900 2rem/1 Georgia, serif; box-shadow: inset 0 0 0 5px rgba(255,255,255,.45); }
.briefing h2, .game-stage h2, .detective-tools h2, dialog h2 { margin: 0 0 8px; font: 900 clamp(1.7rem, 3.1vw, 2.7rem)/1.05 Georgia, serif; color: var(--navy); }
.briefing p, .game-stage p, .detective-tools p { margin: 0; line-height: 1.65; color: #4f5e67; }
.mission-rule { padding-left: 22px; border-left: 2px dashed #d5bf87; }
.mission-rule strong { display: block; margin-bottom: 4px; text-transform: uppercase; color: var(--red); letter-spacing: .08em; }
.mission-rule span { font-size: .9rem; color: #57646b; line-height: 1.45; }

.case-progress { margin-top: 72px; margin-bottom: 45px; display: grid; grid-template-columns: auto 1fr auto 1fr auto; align-items: center; }
.progress-step { display: flex; gap: 10px; align-items: center; color: var(--ink); text-decoration: none; }
.progress-step > span { width: 42px; height: 42px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); border: 4px solid #fff; box-shadow: 0 0 0 2px var(--gold); font-weight: 950; }
.progress-step small, .progress-step strong { display: block; }
.progress-step small { color: #78838a; font-size: .68rem; text-transform: uppercase; letter-spacing: .1em; }
.progress-step strong { font-size: .9rem; }
.progress-step.locked { opacity: .42; pointer-events: none; }
.progress-step.done > span { background: var(--green); color: #fff; box-shadow: 0 0 0 2px var(--green); }
.progress-line { height: 2px; margin: 0 18px; background: repeating-linear-gradient(90deg, #c6bda9 0 8px, transparent 8px 14px); }

.game-stage {
  position: relative;
  margin-bottom: 38px;
  padding: clamp(26px, 4vw, 50px);
  background: #fff;
  border: 1px solid #e8dfcb;
  border-radius: 22px;
  box-shadow: 0 14px 40px rgba(8,43,69,.09);
  overflow: hidden;
}
.game-stage::before { content: ""; position: absolute; top: 0; left: 0; width: 8px; height: 100%; background: var(--gold); }
.stage-heading { display: grid; grid-template-columns: auto 1fr auto; gap: 20px; align-items: start; margin-bottom: 34px; }
.stage-number { color: #dccca8; font: 900 3.4rem/1 Impact, sans-serif; }
.stage-points { padding: 8px 12px; color: var(--green); background: #e9f6ef; border-radius: 999px; font-weight: 900; font-size: .76rem; white-space: nowrap; }

.decoder-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(290px, .8fr); gap: 24px; }
.secret-paper {
  position: relative;
  min-height: 260px;
  padding: 38px 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(rgba(116,84,32,.035) 1px, transparent 1px),
    linear-gradient(90deg, rgba(116,84,32,.035) 1px, transparent 1px),
    #fff4d7;
  background-size: 22px 22px;
  border: 1px solid #e1c789;
  box-shadow: 5px 6px 0 #e8dcc2;
  transform: rotate(-.5deg);
}
.secret-paper > p, .word-bank-wrap > p, .assembled-message > p { margin-bottom: 18px; text-align: center; text-transform: uppercase; letter-spacing: .14em; color: #8b7651; font: 900 .72rem/1 "Courier New", monospace; }
.pin { position: absolute; top: 12px; width: 13px; height: 13px; border-radius: 50%; background: var(--red); box-shadow: 1px 2px 4px rgba(0,0,0,.35); }
.pin-left { left: 17px; }.pin-right { right: 17px; }
.symbol-code { display: flex; justify-content: center; flex-wrap: wrap; gap: clamp(7px, 1vw, 14px); color: var(--navy); font: 900 clamp(1.65rem, 3.2vw, 3rem)/1 Georgia, serif; }
.symbol-code span { min-width: .75em; text-align: center; }
.answer-slots { display: flex; gap: clamp(5px, .8vw, 10px); justify-content: center; margin-top: 22px; }
.answer-slots i { width: clamp(19px, 3vw, 38px); height: 2px; background: #bba56d; }

.decoder-key { padding: 27px; border-radius: 15px; color: #fff; background: var(--navy); box-shadow: inset 0 0 0 3px rgba(255,255,255,.07); }
.decoder-key h3 { margin: 0 0 22px; color: var(--gold); font: 900 1.2rem Georgia, serif; text-align: center; }
.key-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.key-grid > span { min-height: 52px; padding: 7px 12px; display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 7px; border-radius: 8px; background: rgba(255,255,255,.09); }
.key-grid b { font: 900 1.35rem Georgia, serif; text-align: center; }.key-grid i { color: #7f9aad; font-style: normal; }.key-grid strong { color: var(--gold); text-align: center; }

.answer-form { margin-top: 28px; }
.answer-form label { display: block; margin-bottom: 9px; font-weight: 900; color: var(--navy); }
.answer-row { display: flex; gap: 12px; }
.answer-row input { min-width: 0; flex: 1; padding: 15px 17px; border: 2px solid #d5d8d8; border-radius: 11px; background: #fff; text-transform: uppercase; font-weight: 900; letter-spacing: .08em; outline: none; }
.answer-row input:focus { border-color: var(--gold); box-shadow: 0 0 0 4px rgba(244,181,33,.18); }
.answer-row input.correct { border-color: var(--green); background: #f0faf5; }
.answer-row input.wrong { border-color: var(--red); animation: shake .3s linear; }
.check-button { padding: 14px 19px; font-size: .82rem; }

.feedback { min-height: 26px; margin-top: 11px !important; font-weight: 800; }
.feedback.success { color: var(--green); }.feedback.error { color: var(--red); }
.hint-button { margin-top: 5px; padding: 8px 0; border: 0; background: transparent; color: var(--blue); font-weight: 900; cursor: pointer; }
.hint-button span { display: inline-grid; place-items: center; width: 24px; height: 24px; margin-right: 6px; border-radius: 50%; background: #dcedf5; }
.hint-box { margin-top: 9px; padding: 13px 16px; border-left: 4px solid var(--gold); background: #fff8df; color: #625533; line-height: 1.5; }

.locked-stage { min-height: 270px; }
.locked-stage .stage-content { filter: blur(4px); opacity: .24; pointer-events: none; user-select: none; }
.stage-lock { position: absolute; inset: 0; z-index: 4; display: grid; place-content: center; justify-items: center; text-align: center; background: rgba(255,255,255,.34); }
.stage-lock > span { width: 46px; height: 46px; display: grid; place-items: center; margin-bottom: 10px; border-radius: 50%; background: var(--navy); color: var(--gold); }
.stage-lock strong, .stage-lock small { display: block; }.stage-lock strong { color: var(--navy); font-size: 1.05rem; }.stage-lock small { margin-top: 5px; color: #68747b; }
.game-stage.unlocked .stage-lock { display: none; }.game-stage.unlocked .stage-content { filter: none; opacity: 1; pointer-events: auto; user-select: auto; }

.word-puzzle { display: grid; grid-template-columns: 1fr 1fr; gap: 22px; }
.assembled-message, .word-bank-wrap { min-height: 210px; padding: 25px; border-radius: 15px; }
.assembled-message { background: var(--navy); color: #fff; }
.assembled-message > p { color: #9bb4c3; }
.message-line { min-height: 80px; display: flex; flex-wrap: wrap; align-content: center; justify-content: center; gap: 8px; }
.empty-message { color: #829fad; font-style: italic; }
.selected-word { padding: 8px 11px; border-radius: 7px; background: var(--gold); color: var(--navy); border: 0; font-weight: 950; cursor: pointer; }
.word-bank-wrap { background: #f4ead5; border: 1px dashed #cdbb91; }
.word-bank { display: flex; justify-content: center; align-content: center; flex-wrap: wrap; gap: 10px; }
.word-bank button { padding: 11px 15px; border: 2px solid #d1b978; border-radius: 9px; background: #fffaf0; color: var(--navy); font-weight: 950; cursor: pointer; box-shadow: 0 3px 0 #c5ad70; }
.word-bank button:hover { transform: translateY(-1px); }
.word-bank button:disabled { opacity: .25; box-shadow: none; transform: none; cursor: default; }
.stage-actions { display: flex; justify-content: flex-end; gap: 11px; margin-top: 20px; }
.secondary-button { padding: 13px 17px; border: 2px solid #bbc7cc; background: #fff; border-radius: 11px; color: var(--navy); font-weight: 900; cursor: pointer; }

.scene-wrap { position: relative; width: 100%; border: 11px solid #f3e5c5; border-radius: 15px; background: #e6d9bb; overflow: hidden; box-shadow: 0 12px 28px rgba(4,32,52,.15); }
.scene-wrap img { display: block; width: 100%; height: auto; }
.scene-wrap::after { content: ""; position: absolute; inset: 0; pointer-events: none; box-shadow: inset 0 0 50px rgba(6,43,71,.2); }
.location-pin { position: absolute; z-index: 2; display: flex; align-items: center; gap: 7px; border: 0; background: transparent; cursor: pointer; color: #fff; filter: drop-shadow(0 3px 5px rgba(0,0,0,.45)); }
.location-pin span { width: 38px; height: 38px; display: grid; place-items: center; border-radius: 50%; background: var(--red); border: 3px solid #fff; font-weight: 950; }
.location-pin small { padding: 5px 8px; border-radius: 5px; background: rgba(3,29,49,.88); font-weight: 900; }
.location-pin:hover span, .location-pin:focus-visible span { background: var(--gold); color: var(--navy); transform: scale(1.12); }
.pin-shelf { left: 8%; top: 22%; }.pin-window { right: 12%; top: 30%; }.pin-book { left: 49%; bottom: 12%; }
.location-pin.correct-pin span { background: var(--green); }.location-pin.wrong-pin { animation: shake .3s linear; }
.found-ring { position: absolute; z-index: 1; left: 21%; right: 22%; bottom: 1%; height: 30%; border: 7px solid var(--gold); border-radius: 50%; box-shadow: 0 0 0 5px rgba(255,255,255,.7), 0 0 30px rgba(244,181,33,.8); opacity: 0; transform: scale(.8); transition: .35s ease; pointer-events: none; }
.found-ring.visible { opacity: 1; transform: scale(1); }
.scene-caption { margin-top: 12px !important; font-size: .88rem; text-align: center; }

.detective-tools { margin-top: 60px; margin-bottom: 70px; padding: 33px 38px; color: #fff; background: var(--navy); border-radius: 18px; display: flex; justify-content: space-between; align-items: center; gap: 30px; box-shadow: var(--shadow); }
.detective-tools h2 { color: #fff; font-size: 2rem; }.detective-tools p:not(.section-kicker) { color: #c5d5dd; max-width: 650px; }
.solution-button { flex: none; padding: 14px 18px; border: 2px solid var(--gold); border-radius: 10px; background: transparent; color: var(--gold); font-weight: 900; cursor: pointer; }
.solution-button:hover { color: var(--navy); background: var(--gold); }

footer { padding: 40px clamp(22px, 6vw, 92px); background: #031a2b; color: #9fb0ba; display: grid; grid-template-columns: 250px 1fr auto; gap: 30px; align-items: center; font-size: .85rem; line-height: 1.55; }
footer img { width: 230px; max-height: 76px; object-fit: contain; background: #fff; border-radius: 8px; padding: 4px; }
footer a { color: var(--gold); font-weight: 900; text-decoration: none; }

dialog { border: 0; border-radius: 20px; box-shadow: 0 30px 90px rgba(0,0,0,.46); }
dialog::backdrop { background: rgba(3,20,33,.78); backdrop-filter: blur(3px); }
.solution-modal { width: min(680px, calc(100% - 28px)); padding: 32px; background: var(--paper); }
.modal-top { display: flex; justify-content: space-between; gap: 20px; }
.close-modal { width: 40px; height: 40px; border: 0; border-radius: 50%; background: #eadfc5; color: var(--navy); font-size: 1.8rem; cursor: pointer; }
.solution-steps { padding: 0; margin: 25px 0; list-style: none; }
.solution-steps li { display: grid; grid-template-columns: auto 1fr; gap: 15px; padding: 18px 0; border-top: 1px dashed #cfbea0; }
.solution-steps li > span { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 50%; background: var(--navy); color: var(--gold); font-weight: 950; }
.solution-steps strong { color: var(--navy); }.solution-steps p { margin: 5px 0 0; color: #5d6a70; line-height: 1.5; }
.primary-modal-button { width: 100%; }

.victory-modal { width: min(540px, calc(100% - 28px)); padding: 38px; text-align: center; background: var(--paper); overflow: visible; }
.victory-badge { width: 78px; height: 78px; margin: -75px auto 18px; display: grid; place-items: center; border: 7px solid var(--paper); border-radius: 50%; background: var(--green); color: #fff; font-size: 2.2rem; box-shadow: 0 8px 25px rgba(0,0,0,.26); }
.victory-modal > p:not(.section-kicker) { color: #59676e; line-height: 1.55; }
.final-score { display: flex; flex-direction: column; margin: 22px auto; width: 180px; padding: 17px; border-radius: 50%; background: #fff0c6; border: 2px dashed #d9aa37; }
.final-score span, .final-score small { font-size: .72rem; text-transform: uppercase; letter-spacing: .08em; color: #79683e; }.final-score strong { font: 900 2.8rem/1 Georgia, serif; color: var(--red); }
.victory-modal blockquote { margin: 20px 0; padding: 14px; color: var(--navy); border-block: 1px solid #dfceb0; font: italic 1rem/1.5 Georgia, serif; }

.toast { position: fixed; z-index: 100; left: 50%; bottom: 24px; transform: translate(-50%, 25px); padding: 12px 18px; border-radius: 999px; background: var(--navy-deep); color: #fff; font-weight: 900; opacity: 0; pointer-events: none; transition: .25s ease; box-shadow: 0 12px 30px rgba(0,0,0,.3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes shake { 25% { transform: translateX(-5px); } 50% { transform: translateX(5px); } 75% { transform: translateX(-3px); } }

@media (max-width: 900px) {
  .hero { min-height: auto; grid-template-columns: 1fr; padding-top: 58px; }
  .hero-copy { max-width: 720px; }
  .hero-visual { min-height: 470px; }
  .photo-frame { right: 0; }
  .briefing { grid-template-columns: auto 1fr; }.mission-rule { grid-column: 2; }
  .decoder-layout, .word-puzzle { grid-template-columns: 1fr; }
  footer { grid-template-columns: 1fr; text-align: center; justify-items: center; }
}

@media (max-width: 640px) {
  .topbar { min-height: 74px; padding: 8px 14px; }.brand img { width: 165px; max-height: 56px; }.sound-label { display: none; }.sound-toggle { padding: 0 13px; }.score-card { min-width: 72px; padding-inline: 9px; }
  .hero { padding: 50px 20px 54px; gap: 25px; }.hero h1 { font-size: clamp(3.1rem, 17vw, 5.3rem); }.hero-visual { min-height: 325px; }.photo-frame { inset: 3% -10% 4% 0; }.cipher-note { left: -3%; width: 190px; padding: 14px; font-size: 1.35rem; }
  .page-section, .case-progress { width: min(100% - 24px, 1160px); }
  .briefing { margin-top: -20px; padding: 24px; grid-template-columns: 1fr; }.briefing-icon { display: none; }.mission-rule { grid-column: 1; padding: 15px 0 0; border-left: 0; border-top: 2px dashed #d5bf87; }
  .case-progress { margin-top: 48px; }.progress-step div { display: none; }.progress-line { margin-inline: 8px; }
  .game-stage { padding: 26px 20px; }.game-stage::before { width: 5px; }.stage-heading { grid-template-columns: auto 1fr; gap: 12px; }.stage-number { font-size: 2.4rem; }.stage-points { grid-column: 2; justify-self: start; }
  .secret-paper { padding-inline: 12px; min-height: 220px; }.symbol-code { gap: 7px; font-size: 1.65rem; }.answer-slots { gap: 4px; }.answer-slots i { width: 20px; }
  .key-grid { gap: 7px; }.key-grid > span { padding-inline: 7px; }
  .answer-row { flex-direction: column; }.check-button { width: 100%; }
  .stage-actions { flex-direction: column-reverse; }.stage-actions button { width: 100%; }
  .scene-wrap { border-width: 5px; }.location-pin small { display: none; }.location-pin span { width: 33px; height: 33px; }.pin-book { left: 47%; bottom: 10%; }
  .detective-tools { flex-direction: column; align-items: stretch; padding: 27px 24px; }.solution-button { width: 100%; }
  footer { padding-inline: 22px; }
  .solution-modal, .victory-modal { padding: 25px 20px; }
}

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