:root {
  color-scheme: dark;
  --ink: #f9f1d8;
  --paper: #fff1c5;
  --night: #10111c;
  --panel: rgba(12, 14, 25, 0.96);
  --panel-border: #f0d98e;
  --accent: #f0bd42;
  --danger: #ad4661;
  --sky: #8ed7ef;
  font-family: "Courier New", ui-monospace, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 50% 20%, rgba(52, 63, 91, 0.4), transparent 42%),
    #090a11;
}

body {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 20px;
  color: var(--ink);
}

button {
  font: inherit;
}

.page-shell {
  width: min(1180px, 100%);
}

.game-shell {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  overflow: clip;
  isolation: isolate;
  background: #84cae7;
  border: 4px solid #272b3b;
  box-shadow:
    0 0 0 2px #080910,
    0 24px 70px rgba(0, 0, 0, 0.58);
}

#stage-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.weather-tint {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: rgba(34, 25, 58, 0);
  mix-blend-mode: multiply;
  transition: background 2.4s ease;
}

.game-shell.is-storming .weather-tint {
  background: rgba(37, 25, 65, 0.5);
}

.rain {
  position: absolute;
  inset: -20%;
  z-index: 5;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1s ease;
  background-image: repeating-linear-gradient(
    112deg,
    transparent 0 15px,
    rgba(191, 217, 255, 0.55) 16px 17px,
    transparent 18px 30px
  );
  background-size: 38px 38px;
  animation: rain-fall 0.48s linear infinite;
}

.game-shell.has-rain .rain {
  opacity: 0.5;
}

.lightning {
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  opacity: 0;
  background: #f9f5ff;
}

.lightning.flash {
  animation: lightning-flash 700ms steps(1) both;
}

.magic-vortex {
  position: absolute;
  left: 50%;
  top: 47%;
  z-index: 11;
  width: 48%;
  aspect-ratio: 2 / 1;
  translate: -50% -50%;
  scale: 0.5;
  opacity: 0;
  pointer-events: none;
  border-radius: 50%;
  border: 4px solid rgba(210, 131, 255, 0.88);
  box-shadow:
    0 0 0 8px rgba(109, 59, 171, 0.25),
    0 0 40px #b361ff,
    inset 0 0 35px #6f2bc1;
}

.magic-vortex.active {
  animation: vortex-open 1.2s steps(8) forwards, vortex-pulse 1s ease-in-out 1.2s infinite alternate;
}

.captives {
  position: absolute;
  z-index: 12;
  inset: 13% 20% 31%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 3%;
  opacity: 0;
  pointer-events: none;
}

.captives.active {
  opacity: 1;
}

.captive-card {
  position: relative;
  width: 28%;
  aspect-ratio: 3 / 4;
  margin: 0;
  overflow: hidden;
  border: 3px solid #dfa7ff;
  border-radius: 50% 50% 18% 18%;
  background: #1c102b;
  box-shadow: 0 0 24px rgba(188, 95, 255, 0.78);
  animation: captive-float 1.5s ease-in-out infinite alternate;
}

.captive-card:nth-child(2) {
  animation-delay: -0.5s;
}

.captive-card:nth-child(3) {
  animation-delay: -1s;
}

.captive-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 20%;
  filter: saturate(0.72) contrast(1.08) hue-rotate(8deg);
}

.captives.abducting .captive-card {
  animation: captive-vanish 900ms cubic-bezier(0.58, -0.2, 0.77, 0.4) forwards;
}

.captives.abducting .captive-card:nth-child(2) {
  animation-delay: 100ms;
}

.captives.abducting .captive-card:nth-child(3) {
  animation-delay: 200ms;
}

.hud {
  position: absolute;
  inset: 0 0 auto;
  z-index: 20;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: clamp(10px, 1.7vw, 20px);
  pointer-events: none;
}

.hud.is-hidden {
  display: none;
}

.chapter-label {
  display: flex;
  flex-direction: column;
  padding: 8px 12px;
  color: #16131c;
  background: rgba(255, 241, 197, 0.9);
  border: 2px solid #1d1c28;
  box-shadow: 4px 4px 0 rgba(17, 17, 27, 0.6);
  text-transform: uppercase;
}

.chapter-kicker {
  font-size: clamp(9px, 0.8vw, 12px);
  font-weight: 900;
  letter-spacing: 0.15em;
}

.chapter-name {
  font-size: clamp(10px, 1.05vw, 15px);
  font-weight: 700;
}

.difficulty-badge {
  align-self: flex-start;
  margin-top: 5px;
  padding: 3px 6px;
  color: #fff4c5;
  background: #512d43;
  border: 1px solid #211521;
  font-size: clamp(7px, 0.68vw, 9px);
  font-weight: 900;
  letter-spacing: 0.12em;
  line-height: 1;
  text-shadow: none;
}

.difficulty-badge.is-exploration {
  color: #15251e;
  background: #8be1ad;
  border-color: #d7ffe5;
}

.hud-actions {
  display: flex;
  gap: 8px;
  pointer-events: auto;
}

.icon-button {
  padding: 8px 10px;
  border: 2px solid #e8d694;
  color: #fff3c4;
  background: rgba(15, 16, 28, 0.85);
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.55);
  font-size: clamp(8px, 0.85vw, 12px);
  font-weight: 700;
  cursor: pointer;
}

.icon-button:hover,
.icon-button:focus-visible {
  color: #15131e;
  background: #f0d98e;
}

.dialogue-panel {
  position: absolute;
  z-index: 25;
  right: 3.3%;
  bottom: 3.5%;
  left: 3.3%;
  min-height: 31%;
  display: grid;
  grid-template-columns: clamp(116px, 16vw, 190px) 1fr;
  gap: clamp(13px, 2vw, 25px);
  padding: clamp(14px, 2vw, 24px);
  background: var(--panel);
  border: 3px solid var(--panel-border);
  box-shadow:
    0 0 0 3px rgba(10, 11, 18, 0.9),
    8px 8px 0 rgba(0, 0, 0, 0.45);
  transition: opacity 180ms ease, translate 180ms ease;
}

.dialogue-panel.is-narration {
  grid-template-columns: 1fr;
  inset-inline: 14%;
  min-height: 24%;
}

.dialogue-panel.is-hidden,
.overlay.is-hidden {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}

.dialogue-panel.is-hidden {
  translate: 0 12px;
}

.portrait-frame {
  position: relative;
  align-self: stretch;
  height: clamp(150px, 16vw, 190px);
  min-height: 0;
  overflow: hidden;
  border: 2px solid #d8c484;
  background: #27273a;
  box-shadow: inset 0 0 0 3px #11121c;
}

.is-narration .portrait-frame {
  display: none;
}

.portrait-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
  filter: saturate(0.95) contrast(1.04);
  transition: filter 250ms ease, transform 250ms ease;
}

.portrait-frame.is-osman img {
  object-position: 50% 23%;
}

.portrait-frame.is-angry img {
  filter: saturate(1.1) contrast(1.15) brightness(0.9);
  transform: scale(1.03);
}

.portrait-frame.is-frightened img {
  filter: saturate(0.65) brightness(0.83) contrast(1.12);
}

.portrait-glare {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(120deg, rgba(255, 255, 255, 0.16), transparent 28% 100%);
}

.portrait-frame.speaking {
  animation: portrait-speak 180ms steps(2) infinite;
}

.dialogue-content {
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.dialogue-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 25px;
}

.speaker {
  color: var(--accent);
  font-size: clamp(14px, 1.7vw, 23px);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-shadow: 2px 2px 0 #4b3410;
}

.dialogue-progress {
  color: #8f91a4;
  font-size: clamp(9px, 0.8vw, 11px);
}

.dialogue-text {
  min-height: 3.9em;
  margin: clamp(8px, 1.1vw, 13px) 0 0;
  color: #fffbed;
  font-size: clamp(15px, 1.75vw, 24px);
  font-weight: 700;
  line-height: 1.48;
  letter-spacing: 0.01em;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.7);
}

.is-narration .dialogue-text {
  display: grid;
  place-items: center;
  min-height: 4.5em;
  text-align: center;
  font-style: italic;
}

.dialogue-footer {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  color: #9293a4;
  font-size: clamp(8px, 0.75vw, 11px);
}

.next-button {
  width: 34px;
  height: 28px;
  flex: 0 0 auto;
  border: 0;
  color: #f3d77d;
  background: transparent;
  cursor: pointer;
  animation: arrow-bob 700ms steps(2) infinite;
}

.next-button.is-typing {
  animation: none;
  opacity: 0.35;
}

.overlay {
  position: absolute;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 7%;
  opacity: 1;
  transition: opacity 450ms ease;
}

.start-screen {
  overflow: hidden;
  place-items: center start;
  padding: clamp(28px, 5vw, 68px);
  background:
    linear-gradient(90deg, rgba(7, 8, 17, 0.96) 0%, rgba(9, 10, 22, 0.85) 25%, rgba(10, 9, 21, 0.42) 46%, rgba(8, 7, 18, 0.06) 66%),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.start-screen::before,
.start-screen::after {
  content: "";
  position: absolute;
  image-rendering: pixelated;
}

.start-screen::before {
  inset: 0;
  background:
    radial-gradient(circle at 74% 70%, transparent 0 23%, rgba(116, 42, 154, 0.16) 39%, transparent 57%),
    linear-gradient(180deg, rgba(9, 8, 21, 0.08), rgba(5, 6, 14, 0.3));
  opacity: 1;
}

.start-screen::after {
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent 0 3px, rgba(17, 16, 29, 0.08) 4px);
  pointer-events: none;
}

.title-card,
.menu-card,
.end-card {
  position: relative;
  z-index: 2;
  width: min(620px, 87%);
  padding: clamp(22px, 4vw, 48px);
  text-align: center;
  background: rgba(13, 14, 25, 0.91);
  border: 3px solid #f0d98e;
  box-shadow:
    8px 8px 0 rgba(6, 7, 12, 0.8),
    inset 0 0 0 3px rgba(240, 217, 142, 0.12);
}

.title-card h1 {
  margin: 10px 0 12px;
  color: #fff6da;
  font-size: clamp(32px, 6vw, 76px);
  line-height: 0.9;
  letter-spacing: -0.08em;
  text-transform: uppercase;
  text-shadow:
    4px 4px 0 #7a3c46,
    8px 8px 0 #241927;
}

.title-card h1 span {
  color: #f0bd42;
}

.start-screen .title-card {
  width: min(470px, 42vw);
  padding: clamp(24px, 3.2vw, 42px);
  translate: 0 36px;
  text-align: left;
  background: linear-gradient(135deg, rgba(10, 11, 22, 0.95), rgba(17, 13, 29, 0.82));
  border-color: #e5cd83;
  backdrop-filter: blur(2px);
}

.start-screen .title-card::after {
  content: "";
  position: absolute;
  inset: 8px;
  z-index: -1;
  pointer-events: none;
  border: 1px solid rgba(240, 217, 142, 0.22);
}

.start-screen .primary-button {
  margin-left: 0;
}

.menu-settings-button {
  display: block;
  width: min(340px, 100%);
  min-height: 38px;
  margin: 7px 0 0;
  padding: 8px 14px;
  color: #d8c8ef;
  background: rgba(38, 25, 56, 0.82);
  border: 2px solid #8d70b2;
  font-size: clamp(8px, 0.9vw, 11px);
  font-weight: 900;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 4px 4px 0 #080911;
}

.menu-settings-button:hover,
.menu-settings-button:focus-visible {
  color: #17131b;
  background: #d8bf70;
  border-color: #fff0ad;
}

.menu-archive-button {
  color: #f1dca0;
  background: rgba(55, 34, 45, 0.86);
  border-color: #b58a68;
}

.settings-screen {
  z-index: 92;
  padding: clamp(18px, 4vw, 52px);
  background:
    linear-gradient(110deg, rgba(7, 8, 16, 0.94), rgba(24, 12, 35, 0.78)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.difficulty-screen {
  z-index: 94;
  padding: clamp(16px, 4vw, 50px);
  background:
    linear-gradient(110deg, rgba(7, 8, 16, 0.94), rgba(24, 12, 35, 0.82)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.difficulty-card {
  width: min(820px, 96%);
  padding: clamp(22px, 3.5vw, 42px);
  color: #f8f0dc;
  text-align: center;
  background: rgba(12, 13, 24, 0.96);
  border: 3px solid #e5cd83;
  box-shadow:
    8px 8px 0 rgba(4, 5, 10, 0.85),
    inset 0 0 0 3px rgba(240, 217, 142, 0.1);
}

.difficulty-card h2 {
  margin: 6px 0 8px;
  color: #fff6da;
  font-size: clamp(34px, 5vw, 58px);
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #6e3746;
}

.difficulty-lead {
  margin: 0 0 22px;
  color: #aeadbf;
  font-size: clamp(10px, 1vw, 13px);
}

.difficulty-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(12px, 2.2vw, 22px);
}

.difficulty-option {
  display: flex;
  min-height: 180px;
  flex-direction: column;
  justify-content: center;
  gap: 10px;
  padding: clamp(18px, 3vw, 30px);
  color: #f8f0dc;
  text-align: left;
  background: #242536;
  border: 3px solid #5f6072;
  box-shadow: 5px 5px 0 #07080e;
  cursor: pointer;
  transition: translate 150ms ease, border-color 150ms ease, background 150ms ease;
}

.difficulty-option:hover,
.difficulty-option:focus-visible {
  translate: 0 -4px;
  border-color: #fff0ad;
  outline: none;
}

.difficulty-option.is-normal:hover,
.difficulty-option.is-normal:focus-visible {
  background: #483040;
}

.difficulty-option.is-exploration:hover,
.difficulty-option.is-exploration:focus-visible {
  background: #203e35;
  border-color: #8be1ad;
}

.difficulty-option-label {
  color: #d8bf70;
  font-size: clamp(8px, 0.75vw, 10px);
  font-weight: 900;
  letter-spacing: 0.14em;
}

.difficulty-option strong {
  color: #fff4c5;
  font-size: clamp(23px, 3vw, 38px);
  line-height: 1;
}

.difficulty-option > span:last-child {
  color: #c7c6d1;
  font-size: clamp(10px, 1vw, 13px);
  line-height: 1.55;
}

.difficulty-back {
  margin-top: 22px;
}

.image-archive-screen {
  z-index: 95;
  padding: clamp(14px, 3vw, 38px);
  background:
    linear-gradient(110deg, rgba(7, 8, 16, 0.96), rgba(24, 12, 35, 0.86)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.image-archive-card {
  width: min(1120px, 98%);
  max-height: 96%;
  overflow: hidden;
  padding: clamp(18px, 2.5vw, 30px);
  color: #f8f0dc;
  background: rgba(12, 13, 24, 0.97);
  border: 3px solid #e5cd83;
  box-shadow:
    8px 8px 0 rgba(4, 5, 10, 0.85),
    inset 0 0 0 3px rgba(240, 217, 142, 0.1);
}

.image-archive-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  padding-bottom: 16px;
  border-bottom: 2px solid #4a4359;
}

.image-archive-header h2 {
  margin: 5px 0 0;
  color: #fff6da;
  font-size: clamp(28px, 4vw, 48px);
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #6e3746;
}

.image-archive-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.12fr) minmax(300px, 0.88fr);
  gap: clamp(16px, 2.4vw, 28px);
  padding-top: 20px;
}

.image-archive-preview {
  min-width: 0;
  margin: 0;
}

.image-archive-preview-frame {
  display: grid;
  height: min(52vh, 455px);
  place-items: center;
  overflow: hidden;
  padding: 8px;
  background:
    linear-gradient(45deg, #171827 25%, transparent 25% 75%, #171827 75%),
    linear-gradient(45deg, #171827 25%, #202232 25% 75%, #171827 75%);
  background-position: 0 0, 8px 8px;
  background-size: 16px 16px;
  border: 2px solid #696577;
  box-shadow: inset 0 0 0 4px #090a11;
}

.image-archive-preview-frame img,
#image-archive-preview {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  object-fit: contain;
  object-position: center;
  image-rendering: auto;
}

.image-archive-preview figcaption {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 5px 12px;
  padding: 14px 15px;
  background: #202130;
  border: 2px solid #4b4c5d;
  border-top: 0;
}

.image-archive-preview figcaption span {
  grid-row: 1 / 3;
  align-self: center;
  padding: 7px 8px;
  color: #17131b;
  background: #e5cd83;
  font-size: 10px;
  font-weight: 900;
}

.image-archive-preview figcaption strong {
  color: #fff4c5;
  font-size: clamp(14px, 1.5vw, 20px);
}

.image-archive-preview figcaption p {
  grid-column: 2;
  margin: 0;
  color: #b9b8c5;
  font-size: clamp(9px, 0.85vw, 11px);
  line-height: 1.45;
}

.image-archive-grid {
  display: grid;
  max-height: min(64vh, 560px);
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  gap: 9px;
  overflow: auto;
  padding: 0 8px 8px 0;
}

.image-archive-category {
  grid-column: 1 / -1;
  margin: 4px 0 1px;
  color: #d8bf70;
  font-size: 10px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.image-archive-thumb {
  display: grid;
  min-width: 0;
  grid-template-columns: 56px 1fr;
  align-items: center;
  gap: 9px;
  padding: 7px;
  color: #d7d4df;
  text-align: left;
  background: #242536;
  border: 2px solid #4d4e60;
  box-shadow: 3px 3px 0 #07080e;
  cursor: pointer;
}

.image-archive-thumb:hover,
.image-archive-thumb:focus-visible,
.image-archive-thumb.selected {
  color: #fff4c5;
  background: #383143;
  border-color: #e5cd83;
  outline: none;
}

.image-archive-thumb img {
  width: 56px;
  height: 45px;
  object-fit: contain;
  object-position: center;
  background: #12131d;
  border: 1px solid #747184;
}

.image-archive-thumb.is-portrait img {
  object-position: center;
}

.image-archive-thumb span {
  min-width: 0;
  overflow: hidden;
  font-size: clamp(8px, 0.74vw, 10px);
  font-weight: 900;
  line-height: 1.35;
  text-overflow: ellipsis;
}

.settings-card {
  width: min(790px, 96%);
  max-height: 94%;
  overflow: auto;
  padding: clamp(20px, 3vw, 34px);
  color: #f8f0dc;
  background: rgba(12, 13, 24, 0.95);
  border: 3px solid #e5cd83;
  box-shadow:
    8px 8px 0 rgba(4, 5, 10, 0.85),
    inset 0 0 0 3px rgba(240, 217, 142, 0.1);
}

.settings-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding-bottom: 18px;
  border-bottom: 2px solid #4a4359;
}

.settings-header h2 {
  margin: 6px 0 0;
  color: #fff6da;
  font-size: clamp(28px, 4vw, 46px);
  line-height: 1;
  text-transform: uppercase;
  text-shadow: 3px 3px 0 #6e3746;
}

.settings-layout {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  gap: clamp(18px, 3vw, 34px);
  padding-top: 22px;
}

.settings-section h3 {
  margin: 0 0 14px;
  color: #d8bf70;
  font-size: clamp(13px, 1.4vw, 18px);
  letter-spacing: 0.16em;
}

.settings-sound-button {
  width: 100%;
  min-height: 42px;
  margin-bottom: 18px;
  color: #17131b;
  background: #f0bd42;
  border: 2px solid #16131c;
  box-shadow: 4px 4px 0 #07080e;
  font-weight: 900;
  cursor: pointer;
}

.settings-sound-button[aria-pressed="false"] {
  color: #d7d2c6;
  background: #343546;
}

.settings-sound-button:hover,
.settings-sound-button:focus-visible {
  filter: brightness(1.14);
}

.volume-control {
  display: grid;
  gap: 9px;
  margin: 0 0 20px;
  color: #e8dfc8;
  font-size: clamp(10px, 1vw, 13px);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.volume-control > span {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.volume-control output {
  color: #f0bd42;
}

.volume-control input[type="range"] {
  width: 100%;
  accent-color: #f0bd42;
  cursor: pointer;
}

.controls-list {
  display: grid;
  gap: 7px;
  margin: 0;
}

.controls-list > div {
  display: grid;
  grid-template-columns: minmax(108px, 0.75fr) 1.25fr;
  align-items: center;
  gap: 12px;
  min-height: 34px;
  padding: 6px 8px;
  background: rgba(50, 48, 68, 0.48);
  border-left: 3px solid #8d70b2;
}

.controls-list dt,
.controls-list dd {
  margin: 0;
}

.controls-list dd {
  color: #c9c3b6;
  font-size: clamp(9px, 1vw, 12px);
}

.controls-list kbd {
  display: inline-block;
  min-width: 28px;
  padding: 4px 6px;
  color: #17131b;
  background: #eee1b6;
  border: 1px solid #fff3c9;
  box-shadow: 2px 2px 0 #6a5c3c;
  text-align: center;
  font: inherit;
  font-size: 10px;
  font-weight: 900;
}

.eyebrow {
  margin: 0;
  color: #d8bf70;
  font-size: clamp(9px, 1vw, 13px);
  font-weight: 900;
  letter-spacing: 0.22em;
}

.subtitle,
.start-note,
.construction-note {
  color: #beb7a8;
}

.subtitle {
  margin: 18px 0 26px;
  font-size: clamp(11px, 1.25vw, 16px);
}

.start-note {
  margin: 16px 0 0;
  font-size: clamp(8px, 0.8vw, 11px);
}

.primary-button,
.secondary-button {
  width: min(340px, 100%);
  min-height: 46px;
  margin: 6px auto;
  padding: 10px 18px;
  border: 2px solid #1a1721;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 4px 4px 0 #080911;
  transition: translate 100ms ease, box-shadow 100ms ease, filter 120ms ease;
}

.primary-button {
  color: #17131b;
  background: #f0bd42;
}

.secondary-button {
  color: #ede7d6;
  background: #2d3041;
}

.primary-button:hover,
.secondary-button:hover,
.primary-button:focus-visible,
.secondary-button:focus-visible {
  filter: brightness(1.12);
  translate: -1px -1px;
  box-shadow: 6px 6px 0 #080911;
}

.primary-button:active,
.secondary-button:active {
  translate: 3px 3px;
  box-shadow: 1px 1px 0 #080911;
}

.pause-screen {
  background:
    linear-gradient(90deg, rgba(7, 8, 16, 0.88), rgba(20, 11, 32, 0.68)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.chapter-select {
  width: min(420px, 100%);
  margin: 14px auto 8px;
  padding: 12px;
  background: rgba(6, 7, 13, 0.62);
  border: 2px solid #64677d;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.035);
}

.chapter-select > span {
  display: block;
  margin-bottom: 9px;
  color: #d8bf70;
  font-size: clamp(8px, 0.85vw, 11px);
  font-weight: 900;
  letter-spacing: 0.16em;
}

.chapter-select > div {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 8px;
}

.chapter-select-button {
  min-height: 38px;
  padding: 8px 10px;
  color: #f4eedc;
  background: #202335;
  border: 2px solid #8b8fa8;
  font-size: clamp(9px, 1vw, 12px);
  font-weight: 900;
  cursor: pointer;
  box-shadow: 3px 3px 0 #080911;
}

.chapter-select-button:hover,
.chapter-select-button:focus-visible {
  color: #17131b;
  background: #f0bd42;
  border-color: #fff0ad;
  translate: -1px -1px;
}

.menu-card h2,
.end-card h2,
.end-card h3 {
  text-transform: uppercase;
}

.menu-card h2 {
  margin: 10px 0 22px;
  font-size: clamp(30px, 4vw, 52px);
}

.end-screen {
  background:
    linear-gradient(135deg, rgba(12, 8, 24, 0.5), rgba(8, 9, 16, 0.92)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.end-card h2 {
  margin: 12px 0 0;
  color: #fff6dc;
  font-size: clamp(32px, 5vw, 66px);
}

.end-card h3 {
  margin: 0 0 22px;
  color: #f0bd42;
  font-size: clamp(18px, 2.5vw, 30px);
  letter-spacing: 0.08em;
}

.mission-card {
  display: grid;
  gap: 8px;
  padding: 14px;
  color: #22202a;
  background: #f5e8bd;
  border: 2px solid #15141b;
  box-shadow: 4px 4px 0 #0b0c12;
}

.mission-label {
  color: #8d3b47;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.18em;
}

.construction-note {
  font-size: clamp(9px, 0.95vw, 13px);
}

.cinema-bars {
  position: absolute;
  inset: 0;
  z-index: 15;
  pointer-events: none;
}

.bar-top,
.bar-bottom {
  position: absolute;
  right: 0;
  left: 0;
  height: 0;
  background: #05060b;
  transition: height 700ms ease;
}

.bar-top {
  top: 0;
}

.bar-bottom {
  bottom: 0;
}

.cinema-bars.active .bar-top,
.cinema-bars.active .bar-bottom {
  height: 7%;
}

.toast {
  position: absolute;
  z-index: 80;
  top: 14%;
  left: 50%;
  translate: -50% -12px;
  padding: 9px 14px;
  color: #17141d;
  background: #f4dda0;
  border: 2px solid #17141d;
  box-shadow: 4px 4px 0 rgba(0, 0, 0, 0.6);
  font-size: clamp(9px, 0.9vw, 12px);
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, translate 180ms ease;
}

.toast.active {
  opacity: 1;
  translate: -50% 0;
}

.achievement-notification {
  position: absolute;
  right: 18px;
  bottom: 18px;
  z-index: 140;
  display: grid;
  width: min(365px, calc(100% - 36px));
  min-height: 78px;
  grid-template-columns: 58px 1fr;
  align-items: center;
  overflow: hidden;
  color: #f3f4f7;
  background: linear-gradient(105deg, rgba(23, 27, 35, 0.98), rgba(34, 40, 51, 0.98));
  border: 2px solid #636e7d;
  box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.62), inset 0 0 0 1px rgba(255, 255, 255, 0.06);
  opacity: 0;
  translate: calc(100% + 36px) 0;
  pointer-events: none;
  transition: opacity 220ms ease, translate 420ms cubic-bezier(0.16, 0.82, 0.25, 1);
}

.achievement-notification::after {
  content: "";
  position: absolute;
  right: 0;
  bottom: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, #7ac7ff, #c69aff, #f3c86b);
}

.achievement-notification.active {
  opacity: 1;
  translate: 0 0;
}

.achievement-medal {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  justify-self: center;
  color: #171a22;
  background: #f3c86b;
  border: 3px solid #fff0ad;
  box-shadow: 0 0 18px rgba(243, 200, 107, 0.32);
  font-size: 23px;
  text-shadow: none;
  rotate: 45deg;
}

.achievement-medal::first-letter {
  rotate: -45deg;
}

.achievement-copy {
  display: flex;
  min-width: 0;
  flex-direction: column;
  gap: 5px;
  padding: 14px 16px 14px 0;
}

.achievement-copy span {
  color: #84cfff;
  font-size: clamp(8px, 0.75vw, 10px);
  font-weight: 900;
  letter-spacing: 0.14em;
}

.achievement-copy strong {
  overflow: hidden;
  color: #fff8df;
  font-size: clamp(13px, 1.35vw, 18px);
  text-overflow: ellipsis;
  white-space: nowrap;
}

.outside-help {
  margin: 15px 0 0;
  color: #777b8c;
  text-align: center;
  font-size: 12px;
}

/* Bölüm 1 — Kavak */

.level-canvas {
  position: absolute;
  inset: 0;
  z-index: 8;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #78cce7;
}

body.chapter-two-playing .level-canvas {
  background: #11162d;
}

body.chapter-three-playing .level-canvas {
  background: #241b3f;
}

body.final-chapter-playing .level-canvas {
  background: #17101f;
}

.level-canvas.is-hidden,
.level-hud.is-hidden,
.tutorial-panel.is-hidden,
.level-outro.is-hidden {
  display: none;
}

.level-hud {
  position: absolute;
  inset: 0;
  z-index: 24;
  pointer-events: none;
  font-weight: 900;
  text-shadow: 2px 2px 0 rgba(0, 0, 0, 0.55);
}

.vitals-panel,
.timer-panel,
.objective-panel {
  position: absolute;
  top: 16px;
  padding: 9px 12px;
  color: #fff5d2;
  background: rgba(15, 17, 27, 0.9);
  border: 2px solid #f0d98e;
  box-shadow: 4px 4px 0 rgba(5, 6, 10, 0.58);
}

.vitals-panel {
  left: 16px;
  width: clamp(170px, 23vw, 260px);
}

.timer-panel {
  left: 50%;
  min-width: 116px;
  translate: -50% 0;
  text-align: center;
}

.timer-panel.is-hidden {
  display: none;
}

.boss-health-track {
  width: 132px;
  height: 9px;
  margin-top: 6px;
  padding: 1px;
  background: #1a111c;
  border: 1px solid #f0d98e;
  box-shadow: inset 0 0 0 1px #07070b;
}

.boss-health-track.is-hidden {
  display: none;
}

.boss-health-track > span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #a31f49, #f05a68, #ffba72);
  box-shadow: 0 0 8px rgba(240, 90, 104, 0.7);
  transition: width 180ms linear, background 220ms ease;
}

body.final-devil-phase .boss-health-track > span {
  background: linear-gradient(90deg, #4d0b72, #a832d1, #f066ff);
  box-shadow: 0 0 11px rgba(204, 70, 255, 0.88);
}

.timer-panel span,
.objective-panel span,
.stamina-row > span {
  display: block;
  color: #b8af9c;
  font-size: clamp(7px, 0.75vw, 10px);
  letter-spacing: 0.1em;
}

.timer-panel strong {
  display: block;
  margin-top: 2px;
  color: #fff0ad;
  font-size: clamp(18px, 2.3vw, 30px);
}

.timer-panel.is-urgent strong {
  color: #ff8080;
  animation: timer-pulse 500ms steps(2) infinite;
}

.objective-panel {
  right: 16px;
  display: grid;
  grid-template-columns: auto auto;
  align-items: center;
  column-gap: 8px;
  text-align: right;
}

.objective-panel .bread-icon {
  grid-row: 1 / 3;
  color: #e4aa44;
  font-size: clamp(18px, 2vw, 27px);
  text-shadow: 2px 2px 0 #6a3e20;
}

.objective-panel strong {
  color: #fff0ad;
  font-size: clamp(14px, 1.6vw, 21px);
}

#xp-counter {
  color: #86d5ae;
}

.level-hearts {
  display: flex;
  gap: 4px;
  min-height: 22px;
}

.pixel-heart {
  position: relative;
  display: inline-block;
  width: clamp(20px, 2.2vw, 28px);
  height: clamp(20px, 2.2vw, 28px);
  color: #4a2e3b;
  font-size: clamp(20px, 2.2vw, 28px);
  line-height: 1;
  filter: drop-shadow(2px 2px 0 #090a10);
}

.pixel-heart::before,
.pixel-heart::after {
  content: "♥";
  position: absolute;
  inset: 0;
}

.pixel-heart::after {
  width: var(--heart-fill, 100%);
  overflow: hidden;
  color: #e95c68;
}

.stamina-row {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  margin-top: 3px;
}

.stamina-track {
  height: 8px;
  overflow: hidden;
  background: #25273a;
  border: 1px solid #080910;
}

.stamina-track span {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #e5bc43, #7bd5a2);
  transition: width 80ms linear;
}

.effect-strip {
  position: absolute;
  top: 88px;
  right: 16px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 5px;
}

.effect-chip {
  padding: 5px 8px;
  color: #15151d;
  background: #f1d989;
  border: 2px solid #17151e;
  box-shadow: 2px 2px 0 rgba(0, 0, 0, 0.45);
  font-size: clamp(7px, 0.8vw, 10px);
  text-shadow: none;
}

.effect-chip.is-ekler {
  color: #211321;
  background: linear-gradient(90deg, #fff4a9, #ff9dcf, #9ee9ff, #fff4a9);
  background-size: 300% 100%;
  animation: ekler-chip-glow 700ms steps(4) infinite;
}

@keyframes ekler-chip-glow {
  to { background-position: 100% 0; }
}

.tutorial-panel {
  position: absolute;
  z-index: 26;
  left: 50%;
  bottom: 24px;
  width: min(560px, 76%);
  translate: -50% 0;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 6px 14px;
  padding: 13px 16px;
  color: #17151d;
  background: rgba(255, 239, 194, 0.95);
  border: 3px solid #17151d;
  box-shadow: 6px 6px 0 rgba(10, 9, 15, 0.55);
}

.tutorial-step {
  grid-row: 1 / 3;
  align-self: center;
  padding: 9px;
  color: #fff3cf;
  background: #8e4450;
  border: 2px solid #17151d;
  font-weight: 900;
}

.tutorial-panel strong {
  font-size: clamp(13px, 1.4vw, 18px);
  text-transform: uppercase;
}

.tutorial-panel p {
  margin: 3px 0 0;
  font-size: clamp(9px, 0.9vw, 12px);
}

.tutorial-progress {
  grid-column: 1 / -1;
  height: 6px;
  overflow: hidden;
  background: #bcae8d;
  border: 1px solid #17151d;
}

.tutorial-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: #5d9b62;
  transition: width 150ms linear;
}

.inventory-screen {
  z-index: 70;
  background: rgba(7, 8, 15, 0.84);
  backdrop-filter: blur(3px);
}

.inventory-card {
  width: min(850px, 94%);
  max-height: 90%;
  overflow: auto;
  padding: clamp(18px, 3vw, 34px);
  background: #11131f;
  border: 3px solid #eed895;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.65);
}

.inventory-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.inventory-header h2 {
  margin: 5px 0 0;
  color: #fff4ce;
  font-size: clamp(25px, 4vw, 48px);
  text-transform: uppercase;
}

.inventory-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(82px, 1fr));
  gap: 10px;
}

.inventory-slot {
  position: relative;
  min-height: 94px;
  padding: 9px 6px;
  border: 2px solid #5e5c69;
  color: #ddd7c6;
  background: #232536;
  cursor: pointer;
}

.inventory-slot:hover,
.inventory-slot:focus-visible,
.inventory-slot.selected {
  border-color: #f0bd42;
  background: #343041;
}

.inventory-slot.is-empty {
  filter: grayscale(1);
  opacity: 0.5;
}

.inventory-slot-icon {
  display: block;
  font-size: 31px;
  line-height: 1.1;
}

.inventory-slot-name {
  display: block;
  margin-top: 6px;
  font-size: 9px;
  text-transform: uppercase;
}

.inventory-slot-count {
  position: absolute;
  top: 5px;
  right: 7px;
  color: #f7db79;
  font-weight: 900;
}

.inventory-detail {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 15px;
  min-height: 94px;
  margin-top: 16px;
  padding: 13px;
  color: #1b1920;
  background: #f0e2b8;
  border: 2px solid #090a0f;
}

.inventory-detail-icon {
  display: grid;
  place-items: center;
  width: 56px;
  aspect-ratio: 1;
  background: #d7c58e;
  border: 2px solid #1c1920;
  font-size: 30px;
}

.inventory-detail p {
  margin: 5px 0 0;
  font-size: 11px;
}

.inventory-use {
  width: auto;
  min-width: 120px;
}

.inventory-use:disabled {
  filter: grayscale(1);
  cursor: not-allowed;
  opacity: 0.45;
}

.chapter-intro {
  z-index: 75;
  background:
    linear-gradient(135deg, rgba(13, 10, 28, 0.5), rgba(6, 8, 15, 0.86)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.chapter-two-intro {
  background:
    linear-gradient(135deg, rgba(8, 10, 27, 0.44), rgba(4, 7, 18, 0.88)),
    url("assets/chapter-two/atakum-storm-city-v1.png") center / cover no-repeat;
}

.chapter-two-intro .chapter-intro-card,
.chapter-two-complete .chapter-complete-card {
  border-color: #aab8e8;
  box-shadow: 8px 8px 0 rgba(2, 4, 13, 0.78), inset 0 0 42px rgba(71, 86, 148, 0.14);
}

.chapter-two-intro .chapter-intro-card h2,
.chapter-two-complete .chapter-complete-card h2 {
  text-shadow: 4px 4px 0 #303a70;
}

.chapter-two-intro .chapter-location {
  color: #9cb7ef;
}

.chapter-intro-card,
.chapter-complete-card {
  width: min(640px, 90%);
  padding: clamp(24px, 4vw, 46px);
  text-align: center;
  background: rgba(13, 15, 24, 0.94);
  border: 3px solid #f0d98e;
  box-shadow: 8px 8px 0 rgba(5, 6, 10, 0.72);
}

.chapter-intro-card h2,
.chapter-complete-card h2 {
  margin: 7px 0 0;
  color: #fff3cf;
  font-size: clamp(42px, 7vw, 88px);
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 4px 4px 0 #36543c;
}

.chapter-location {
  margin: 7px 0 20px;
  color: #79cfa4;
  font-weight: 900;
  letter-spacing: 0.25em;
}

.chapter-brief {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 9px 14px;
  margin: 0 auto 20px;
  padding: 14px;
  color: #22202a;
  background: #f0e2b8;
  border: 2px solid #08090e;
  text-align: left;
  font-size: clamp(9px, 1vw, 13px);
}

.chapter-brief span {
  color: #914550;
  font-weight: 900;
}

.level-fail-screen {
  z-index: 78;
  background:
    linear-gradient(rgba(45, 8, 24, 0.72), rgba(9, 9, 15, 0.92)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.fail-card h2 {
  color: #ff8b8b;
}

.restart-meter {
  height: 8px;
  margin-top: 18px;
  overflow: hidden;
  background: #252735;
  border: 1px solid #dac981;
}

.restart-meter span {
  display: block;
  width: 100%;
  height: 100%;
  background: #e56e6e;
  transform-origin: left;
  animation: restart-countdown 2.2s linear forwards;
}

.level-outro {
  position: absolute;
  z-index: 65;
  right: 5%;
  bottom: 5%;
  left: 5%;
  display: grid;
  grid-template-columns: clamp(120px, 17vw, 190px) 1fr;
  gap: 20px;
  min-height: 32%;
  padding: 18px;
  color: #fff7df;
  background: rgba(12, 14, 24, 0.97);
  border: 3px solid #f0d98e;
  box-shadow: 7px 7px 0 rgba(0, 0, 0, 0.6);
}

.level-outro-portrait {
  height: clamp(150px, 16vw, 190px);
  overflow: hidden;
  border: 2px solid #d8c484;
}

.level-outro-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 50% 18%;
}

.level-outro-copy {
  position: relative;
  display: flex;
  flex-direction: column;
}

.level-outro-copy > span {
  color: #87d8f0;
  font-size: clamp(16px, 1.8vw, 23px);
  font-weight: 900;
  letter-spacing: 0.08em;
}

.level-outro-copy p {
  margin: 14px 45px 10px 0;
  font-size: clamp(15px, 1.7vw, 23px);
  font-weight: 700;
  line-height: 1.5;
}

.level-outro-copy .next-button {
  position: absolute;
  right: 0;
  bottom: 0;
}

.final-letter-scene {
  z-index: 60;
  overflow: hidden;
  padding: clamp(14px, 3vw, 34px);
  pointer-events: none;
  background: rgba(2, 2, 7, 0);
  transition: background-color var(--letter-fade-duration, 3.4s) ease-in;
}

.final-letter-scene.is-dark {
  background: rgba(2, 2, 7, 0.985);
}

.final-letter-scene.is-envelope-visible {
  pointer-events: auto;
}

.letter-envelope-stage {
  position: relative;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  perspective: 1100px;
}

.letter-envelope-stage.is-hidden {
  display: none;
}

.letter-envelope {
  position: relative;
  z-index: 2;
  width: clamp(240px, 39vw, 390px);
  aspect-ratio: 1.55 / 1;
  padding: 0;
  color: #4f3029;
  background: transparent;
  border: 0;
  filter: drop-shadow(0 19px 14px rgba(0, 0, 0, 0.55));
  cursor: pointer;
  transform-style: preserve-3d;
  transition: filter 220ms ease, transform 220ms ease;
}

.letter-envelope:hover,
.letter-envelope:focus-visible {
  filter: drop-shadow(0 22px 17px rgba(0, 0, 0, 0.64)) brightness(1.06);
  outline: 3px solid #f1d58b;
  outline-offset: 9px;
  transform: translateY(-5px);
}

.envelope-shadow,
.envelope-back,
.envelope-paper-peek,
.envelope-front,
.envelope-flap,
.envelope-seal,
.envelope-instruction {
  position: absolute;
  display: block;
}

.envelope-shadow {
  z-index: -2;
  right: 6%;
  bottom: -13%;
  left: 6%;
  height: 18%;
  background: rgba(0, 0, 0, 0.62);
  border-radius: 50%;
  filter: blur(12px);
}

.envelope-back {
  z-index: 0;
  inset: 0;
  background: #d6a76d;
  border: 4px solid #825039;
  box-shadow: inset 0 0 0 4px rgba(255, 231, 181, 0.2);
}

.envelope-paper-peek {
  z-index: 1;
  top: 11%;
  right: 8%;
  bottom: 8%;
  left: 8%;
  background:
    repeating-linear-gradient(0deg, transparent 0 19px, rgba(98, 71, 49, 0.11) 19px 20px),
    #f4e7c8;
  border: 2px solid #b9996f;
  transition: transform 850ms cubic-bezier(0.16, 0.82, 0.27, 1);
}

.envelope-front {
  z-index: 3;
  inset: 0;
  background:
    linear-gradient(34deg, #c89056 0 49.5%, transparent 50%),
    linear-gradient(-34deg, #e0b174 0 49.5%, transparent 50%);
  border: 4px solid #825039;
  clip-path: polygon(0 27%, 50% 70%, 100% 27%, 100% 100%, 0 100%);
}

.envelope-flap {
  z-index: 4;
  inset: 0;
  background: linear-gradient(165deg, #e7bd82, #c89459);
  border: 4px solid #825039;
  clip-path: polygon(0 0, 100% 0, 50% 61%);
  transform-origin: 50% 1%;
  backface-visibility: hidden;
  transition: transform 720ms cubic-bezier(0.45, 0.02, 0.2, 1);
}

.envelope-seal {
  z-index: 5;
  top: 48%;
  left: 50%;
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #f2c98f;
  background: #7f2532;
  border: 3px double #d98d73;
  border-radius: 50%;
  font-family: Georgia, serif;
  font-size: 22px;
  font-weight: 900;
  transform: translate(-50%, -50%);
  transition: opacity 180ms ease;
}

.envelope-instruction {
  top: calc(100% + 25px);
  left: 50%;
  width: max-content;
  color: #f4dda1;
  font-size: clamp(9px, 1vw, 12px);
  font-weight: 900;
  letter-spacing: 0.16em;
  text-shadow: 2px 2px 0 #000;
  transform: translateX(-50%);
  animation: letter-prompt-pulse 1.1s steps(2) infinite;
}

.birthday-letter {
  position: absolute;
  z-index: 6;
  width: min(760px, 94%);
  max-height: 94%;
  overflow: auto;
  padding: clamp(22px, 2.7vw, 34px);
  color: #3c2b25;
  background:
    linear-gradient(rgba(255, 250, 229, 0.68), rgba(236, 216, 173, 0.6)),
    repeating-linear-gradient(0deg, #efe0bc 0 29px, #ddc89b 29px 30px);
  border: 2px solid #af8c5c;
  box-shadow:
    0 24px 52px rgba(0, 0, 0, 0.68),
    inset 0 0 46px rgba(117, 72, 34, 0.13);
  opacity: 0;
  pointer-events: none;
  transform: translateY(42%) scale(0.44) rotate(-2deg);
  transform-origin: 50% 78%;
  transition:
    opacity 420ms ease 500ms,
    transform 980ms cubic-bezier(0.16, 0.82, 0.25, 1) 430ms;
}

.letter-paper-inner {
  position: relative;
  z-index: 1;
}

.birthday-letter::before,
.birthday-letter::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.birthday-letter::before {
  inset: 8px;
  border: 1px solid rgba(103, 68, 42, 0.27);
}

.birthday-letter::after {
  top: 15px;
  right: 18px;
  width: 54px;
  height: 54px;
  border: 2px solid rgba(125, 54, 58, 0.27);
  border-radius: 50%;
}

.birthday-letter p {
  margin: 0 0 1.05em;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(13px, 1.3vw, 17px);
  line-height: 1.5;
}

.birthday-letter p:first-child {
  font-size: clamp(18px, 2.1vw, 26px);
  font-weight: 700;
}

.letter-signoff {
  text-align: right;
}

.letter-signoff strong {
  display: inline-block;
  margin-top: 5px;
  color: #6f2730;
  font-size: 1.25em;
}

.letter-continue {
  display: block;
  margin: 8px auto 0;
  padding: 10px 16px;
  color: #f8e6b6;
  background: #6f2730;
  border: 2px solid #3c1c24;
  box-shadow: 3px 3px 0 rgba(56, 29, 24, 0.35);
  font-size: clamp(9px, 0.9vw, 12px);
  font-weight: 900;
  cursor: pointer;
}

.letter-continue:hover,
.letter-continue:focus-visible {
  color: #3c1c24;
  background: #efdba2;
  outline: 2px solid #6f2730;
  outline-offset: 3px;
}

.letter-envelope-stage.is-open .envelope-flap {
  transform: rotateX(178deg);
}

.letter-envelope-stage.is-open .envelope-seal,
.letter-envelope-stage.is-open .envelope-instruction {
  opacity: 0;
}

.letter-envelope-stage.is-open .envelope-paper-peek {
  transform: translateY(-72%);
}

.letter-envelope-stage.is-open .letter-envelope {
  pointer-events: none;
  animation: envelope-move-aside 900ms ease 620ms forwards;
}

.letter-envelope-stage.is-open .birthday-letter {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1) rotate(0);
}

.letter-envelope-stage.is-leaving .birthday-letter {
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(0.97);
  transition: opacity 360ms ease, transform 360ms ease;
}

@keyframes envelope-move-aside {
  to {
    opacity: 0;
    transform: translateY(58%) scale(0.72);
  }
}

@keyframes letter-prompt-pulse {
  50% {
    opacity: 0.55;
    transform: translateX(-50%) translateY(3px);
  }
}

.chapter-complete {
  z-index: 80;
  background:
    linear-gradient(135deg, rgba(34, 24, 8, 0.46), rgba(7, 9, 14, 0.9)),
    url("assets/menu/main-menu-cover-v1.png") center / cover no-repeat;
  image-rendering: pixelated;
}

.chapter-two-complete {
  background:
    linear-gradient(135deg, rgba(9, 10, 30, 0.42), rgba(4, 7, 17, 0.91)),
    url("assets/chapter-two/atakum-storm-city-v1.png") center / cover no-repeat;
}

.chapter-three-complete {
  background:
    linear-gradient(135deg, rgba(31, 15, 42, 0.38), rgba(10, 7, 18, 0.9)),
    url("assets/chapter-three/japan-survival-arena-v1.png") center / cover no-repeat;
}

.chapter-three-complete .chapter-complete-card {
  border-color: #e0b662;
  box-shadow: 8px 8px 0 rgba(25, 5, 16, 0.76), inset 0 0 42px rgba(164, 57, 60, 0.16);
}

.chapter-three-complete .chapter-complete-card h2 {
  text-shadow: 4px 4px 0 #9e3b43;
}

.final-chapter-complete {
  background:
    linear-gradient(135deg, rgba(25, 9, 28, 0.3), rgba(7, 5, 12, 0.86)),
    url("assets/final-chapter/japanese-house-boss-arena-v1.png") center / cover no-repeat;
}

.final-chapter-complete .chapter-complete-card {
  border-color: #f0c97c;
  box-shadow: 8px 8px 0 rgba(19, 4, 22, 0.78), inset 0 0 52px rgba(238, 171, 93, 0.12);
}

.final-chapter-complete .chapter-complete-card h2 {
  color: #fff0bd;
  font-size: clamp(26px, 4.5vw, 56px);
  text-shadow: 4px 4px 0 #6f2e65;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin: 22px 0;
}

.result-grid div {
  padding: 13px 7px;
  color: #17161c;
  background: #f0e2b8;
  border: 2px solid #14131a;
}

.result-grid span,
.result-grid strong {
  display: block;
}

.result-grid span {
  color: #8e4450;
  font-size: 9px;
  font-weight: 900;
}

.result-grid strong {
  margin-top: 5px;
  font-size: clamp(15px, 2vw, 23px);
}

.chapter-stop-note {
  color: #b8b3a5;
  font-size: 11px;
}

@keyframes timer-pulse {
  50% { scale: 1.08; }
}

@keyframes restart-countdown {
  to { scale: 0 1; }
}

kbd {
  padding: 2px 6px;
  border: 1px solid #4f5366;
  border-bottom-width: 3px;
  color: #c9cbd4;
  background: #20222d;
}

@keyframes lightning-flash {
  0%, 12%, 25% { opacity: 0; }
  5%, 18% { opacity: 0.92; }
  30% { opacity: 0.18; }
  100% { opacity: 0; }
}

@keyframes rain-fall {
  to { transform: translate3d(-18px, 38px, 0); }
}

@keyframes arrow-bob {
  50% { translate: 0 3px; }
}

@keyframes portrait-speak {
  50% { translate: 0 -1px; }
}

@keyframes vortex-open {
  to { opacity: 1; scale: 1; rotate: 720deg; }
}

@keyframes vortex-pulse {
  to { filter: brightness(1.5); box-shadow: 0 0 55px #d38cff, inset 0 0 45px #7b32c8; }
}

@keyframes captive-float {
  to { translate: 0 -8px; }
}

@keyframes captive-vanish {
  45% { filter: brightness(2) saturate(0); }
  100% { opacity: 0; scale: 0.12; translate: 0 -150px; filter: brightness(3); }
}

@media (max-width: 760px) {
  body {
    padding: 0;
    background: #070810;
  }

  .page-shell {
    width: 100%;
  }

  .game-shell {
    border-width: 0;
    min-height: 100dvh;
    aspect-ratio: auto;
  }

  .start-screen {
    place-items: end center;
    padding: 18px;
    background:
      linear-gradient(0deg, rgba(7, 8, 17, 0.97) 0%, rgba(8, 8, 18, 0.78) 33%, rgba(8, 7, 18, 0.08) 62%),
      url("assets/menu/main-menu-cover-v1.png") 72% center / cover no-repeat;
  }

  .start-screen .title-card {
    width: 100%;
    padding: 22px;
    translate: 0;
    text-align: left;
  }

  .start-screen .title-card h1 {
    font-size: clamp(38px, 13vw, 58px);
  }

  .settings-screen {
    padding: 14px;
  }

  .settings-card {
    width: 100%;
    max-height: 96%;
    padding: 18px;
  }

  .settings-header {
    align-items: center;
  }

  .settings-header .icon-button {
    white-space: nowrap;
  }

  .settings-layout {
    grid-template-columns: 1fr;
    gap: 15px;
  }

  .difficulty-screen {
    padding: 14px;
  }

  .difficulty-card {
    width: 100%;
    max-height: 96%;
    overflow: auto;
    padding: 19px;
  }

  .difficulty-options {
    grid-template-columns: 1fr;
  }

  .difficulty-option {
    min-height: 126px;
  }

  .image-archive-screen {
    padding: 10px;
  }

  .image-archive-card {
    width: 100%;
    max-height: 98%;
    overflow: auto;
    padding: 15px;
  }

  .image-archive-header {
    align-items: center;
  }

  .image-archive-header .icon-button {
    white-space: nowrap;
  }

  .image-archive-layout {
    grid-template-columns: 1fr;
  }

  .image-archive-preview-frame {
    height: min(38vh, 280px);
  }

  .image-archive-grid {
    max-height: none;
    grid-template-columns: 1fr;
    overflow: visible;
    padding-right: 0;
  }

  .achievement-notification {
    right: 10px;
    bottom: 10px;
    width: calc(100% - 20px);
  }

  body.chapter-playing .game-shell {
    min-height: 0;
    aspect-ratio: 16 / 9;
  }

  #stage-canvas {
    object-fit: cover;
  }

  .dialogue-panel {
    grid-template-columns: 92px 1fr;
    min-height: 220px;
    bottom: 18px;
  }

  .portrait-frame {
    height: 166px;
  }

  .dialogue-text {
    font-size: 14px;
  }

  .hud-actions {
    flex-direction: column;
    align-items: flex-end;
  }

  .outside-help {
    display: none;
  }

  .vitals-panel,
  .timer-panel,
  .objective-panel {
    top: 8px;
    padding: 6px 7px;
  }

  .vitals-panel {
    left: 8px;
    width: 128px;
  }

  .objective-panel,
  .effect-strip {
    right: 8px;
  }

  .level-hearts {
    gap: 1px;
  }

  .pixel-heart {
    width: 19px;
    height: 19px;
    font-size: 19px;
  }

  .stamina-row > span {
    display: none;
  }

  .stamina-row {
    grid-template-columns: 1fr;
  }

  .timer-panel {
    top: 58px;
  }

  .effect-strip {
    top: 65px;
  }

  .tutorial-panel {
    bottom: 15px;
    width: 92%;
  }

  .inventory-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .inventory-detail {
    grid-template-columns: auto 1fr;
  }

  .inventory-use {
    grid-column: 1 / -1;
    width: 100%;
  }

  .level-outro {
    right: 3%;
    bottom: 3%;
    left: 3%;
    grid-template-columns: 92px 1fr;
    gap: 12px;
  }

  .level-outro-portrait {
    height: 150px;
  }

  .level-outro-copy p {
    font-size: 14px;
  }

  .final-letter-scene {
    padding: 8px;
  }

  .letter-envelope {
    width: min(260px, 72vw);
  }

  .birthday-letter {
    width: 96%;
    max-height: 96%;
    padding: 19px 17px;
  }

  .birthday-letter p {
    font-size: 12px;
    line-height: 1.48;
  }

  .birthday-letter p:first-child {
    font-size: 18px;
  }

  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

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