:root {
  color-scheme: dark;
  --ink: #030b12;
  --panel: rgba(4, 20, 32, 0.92);
  --panel-deep: rgba(2, 12, 21, 0.98);
  --panel-soft: rgba(8, 31, 45, 0.9);
  --line: rgba(135, 207, 222, 0.44);
  --line-strong: rgba(190, 242, 249, 0.9);
  --text: #f7fbfd;
  --muted: #9eb8c4;
  --accent: #78dccc;
  --accent-blue: #85d9eb;
  --accent-ink: #062526;
  --success: #88edb8;
  --warning: #f1d397;
  --error: #ff9a92;
  --hairline: 1px;
  --radius: 3px;
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100dvh;
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background: var(--ink);
}

.app-shell {
  user-select: none;
  -webkit-user-select: none;
}

.orientation-guard {
  display: none;
}

.preload-screen {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 9px;
  padding: 32px;
  color: var(--text);
  background:
    linear-gradient(90deg, rgba(1, 8, 15, 0.92), rgba(1, 10, 18, 0.72)),
    url("https://flsc495.xyz/background/menu_lighthouse_station.png") center / cover no-repeat;
  text-align: center;
}

.preload-screen::before {
  content: "";
  position: absolute;
  inset: clamp(18px, 4vw, 46px);
  border: 1px solid rgba(133, 217, 235, 0.28);
  pointer-events: none;
}

.preload-badge {
  display: grid;
  place-items: center;
  width: 66px;
  height: 66px;
  border: 1px solid rgba(133, 217, 235, 0.74);
  background:
    linear-gradient(135deg, rgba(57, 188, 199, 0.24), rgba(4, 18, 30, 0.92));
  box-shadow:
    inset 0 0 18px rgba(80, 217, 212, 0.14),
    0 0 20px rgba(120, 220, 204, 0.24);
  color: #a7f0e6;
  font: 800 18px/1 Consolas, "Courier New", monospace;
  letter-spacing: 0;
  filter: drop-shadow(0 0 20px rgba(120, 220, 204, 0.34));
}

.preload-badge span::before {
  content: "<";
  margin-right: 2px;
  color: #5fcbd7;
}

.preload-badge span::after {
  content: ">";
  margin-left: 2px;
  color: #5fcbd7;
}

.preload-screen .panel-kicker {
  margin: 7px 0 0;
}

.preload-screen h1 {
  width: auto;
  margin: 0 0 10px;
  padding: 0;
  font-size: clamp(31px, 4vw, 48px);
}

.preload-screen h1::after {
  display: none;
}

.preload-status {
  min-height: 24px;
  margin: 0;
  color: #c7dbe3;
}

.preload-progress {
  position: relative;
  width: min(440px, calc(100vw - 64px));
  height: 6px;
  margin-top: 7px;
  overflow: hidden;
  border: 1px solid rgba(133, 217, 235, 0.48);
  background: rgba(1, 9, 16, 0.76);
}

.preload-progress span {
  display: block;
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-blue));
  box-shadow: 0 0 16px rgba(120, 220, 204, 0.42);
  transition: width 160ms ease;
}

.preload-meta {
  display: flex;
  width: min(440px, calc(100vw - 64px));
  justify-content: space-between;
  color: var(--muted);
  font: 700 11px/1.4 "Segoe UI", sans-serif;
}

.preload-screen[data-state="error"] .preload-status {
  color: var(--error);
}

.is-preloading .orientation-guard {
  display: none;
}

img {
  user-select: none;
  -webkit-user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
}

button,
textarea,
input {
  font: inherit;
}

textarea,
input[type="text"] {
  user-select: text;
  -webkit-user-select: text;
}

button {
  min-height: 40px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--text);
  background: rgba(5, 25, 39, 0.9);
  cursor: pointer;
  transition:
    color 150ms ease,
    border-color 150ms ease,
    background 150ms ease,
    transform 150ms ease;
}

button:hover:not(:disabled),
button:focus-visible {
  border-color: var(--line-strong);
  outline: none;
  color: #ffffff;
  background: rgba(18, 68, 79, 0.95);
  transform: translateY(-1px);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.34;
}

.primary-action {
  border-color: rgba(130, 225, 210, 0.76);
  background: rgba(17, 78, 79, 0.94);
}

.quiet-action {
  color: var(--muted);
}

.app-shell,
.menu-view,
.game-view {
  min-height: 100dvh;
}

.menu-view,
.game-view {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  background-position: center;
  background-size: cover;
}

.menu-view {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 330px);
  align-items: end;
  gap: clamp(46px, 7vw, 112px);
  padding: clamp(42px, 6.8vw, 106px);
  background-image: url("https://flsc495.xyz/background/menu_lighthouse_station.png");
}

.easter-egg-dock {
  position: absolute;
  right: max(18px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 4;
  display: grid;
  justify-items: center;
  gap: 3px;
}

.easter-egg-button {
  width: 62px;
  min-height: 62px;
  padding: 5px;
  overflow: hidden;
  border-color: rgba(151, 213, 226, 0.3);
  border-radius: 50%;
  background: rgba(3, 17, 28, 0.72);
}

.easter-egg-button img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: contain;
}

.easter-egg-button:hover:not(:disabled),
.easter-egg-button:focus-visible {
  border-color: var(--accent);
  background: rgba(11, 48, 59, 0.9);
}

.easter-egg-button[data-cooldown="true"] {
  opacity: 0.62;
}

.easter-egg-button.is-popping {
  animation: easter-pop 520ms cubic-bezier(0.22, 1, 0.36, 1);
}

.easter-egg-cooldown {
  min-height: 14px;
  color: #d5e7ed;
  font: 700 10px/1.2 "Segoe UI", sans-serif;
  text-shadow: 0 1px 5px #000;
}

@keyframes easter-pop {
  0% {
    transform: translateY(0) scale(1);
  }
  38% {
    transform: translateY(-15px) scale(1.12);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

.menu-shade,
.scene-shade {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
}

.menu-shade {
  background:
    linear-gradient(90deg, rgba(1, 8, 15, 0.9), rgba(1, 10, 18, 0.08) 60%),
    linear-gradient(0deg, rgba(1, 8, 15, 0.88), transparent 56%);
}

.scene-shade {
  background:
    linear-gradient(0deg, rgba(1, 7, 13, 0.72), transparent 43%),
    linear-gradient(90deg, rgba(1, 8, 15, 0.2), transparent 28%, transparent 72%, rgba(1, 8, 15, 0.18));
}

.brand-block {
  align-self: end;
  max-width: 680px;
  padding: 0 0 10px 20px;
  border-left: 1px solid rgba(120, 220, 204, 0.64);
}

.brand-badge {
  width: 64px;
  height: 64px;
  object-fit: contain;
  filter: drop-shadow(0 0 18px rgba(97, 213, 237, 0.42));
}

.eyebrow,
.panel-kicker {
  margin: 13px 0 8px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  position: relative;
  width: max-content;
  margin-bottom: 16px;
  padding-bottom: 18px;
  font-size: clamp(58px, 6.7vw, 92px);
  line-height: 1;
  letter-spacing: 0;
  text-shadow: 0 4px 22px rgba(0, 0, 0, 0.56);
}

h1::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  width: min(100%, 430px);
  height: 1px;
  background: linear-gradient(90deg, var(--accent), transparent);
}

.subtitle {
  max-width: 570px;
  margin-bottom: 22px;
  color: #d5e7ed;
  font-size: 19px;
  line-height: 1.65;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.72);
}

.menu-progress {
  color: var(--muted);
  font-size: 13px;
}

.menu-actions {
  display: grid;
  align-self: end;
  gap: 0;
  padding: 8px 0 8px 18px;
  border-left: 1px solid rgba(137, 207, 222, 0.18);
}

.menu-actions button {
  position: relative;
  min-height: 50px;
  padding: 0 18px 0 30px;
  border: 0;
  border-bottom: 1px solid rgba(151, 213, 226, 0.25);
  color: #dcecf2;
  background: linear-gradient(90deg, rgba(4, 18, 29, 0.72), rgba(4, 18, 29, 0.32));
  text-align: left;
  backdrop-filter: blur(5px);
}

.menu-actions button::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 8px;
  width: 8px;
  height: 1px;
  background: var(--accent);
  transform: translateY(-50%);
  transition: width 150ms ease;
}

.menu-actions button:hover:not(:disabled),
.menu-actions button:focus-visible {
  padding-left: 36px;
  border-bottom-color: var(--accent);
  background: linear-gradient(90deg, rgba(11, 48, 59, 0.94), rgba(7, 31, 44, 0.58));
  transform: none;
}

.menu-actions button:hover:not(:disabled)::before,
.menu-actions button:focus-visible::before {
  width: 18px;
}

.game-view {
  background-color: var(--ink);
  background-image: url("https://flsc495.xyz/background/startup_black.png");
}

.top-bar {
  position: absolute;
  top: 24px;
  left: 38px;
  z-index: 9;
  width: max-content;
  max-width: calc(100vw - 68px);
  padding: 8px 22px 9px 16px;
  border-left: 2px solid var(--accent);
  border-bottom: 1px solid rgba(133, 217, 235, 0.2);
  background: linear-gradient(90deg, rgba(2, 15, 26, 0.9), rgba(2, 15, 26, 0.12));
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.76);
  backdrop-filter: blur(4px);
}

.chapter-meta {
  display: flex;
  align-items: baseline;
  gap: 18px;
}

#chapter-label {
  font-weight: 700;
}

#progress-label {
  color: var(--muted);
  font-size: 12px;
}

.stage {
  position: absolute;
  inset: 0 0 184px;
  overflow: hidden;
}

.character-sprite {
  position: absolute;
  bottom: -7%;
  left: 50%;
  width: min(45vw, 680px);
  height: min(91vh, 1020px);
  object-fit: contain;
  object-position: bottom center;
  filter: drop-shadow(0 18px 26px rgba(0, 0, 0, 0.48));
  transform: translateX(-50%);
  animation: sprite-in 220ms ease-out;
}

.character-sprite[data-character="lux"] {
  left: 31%;
}

.character-sprite[data-character="nova"] {
  left: 69%;
  filter:
    drop-shadow(0 0 22px rgba(104, 224, 242, 0.32))
    drop-shadow(0 18px 26px rgba(0, 0, 0, 0.4));
}

.character-sprite[data-character="terminal"] {
  bottom: 28%;
  left: 50%;
  width: 170px;
  height: 170px;
  filter: drop-shadow(0 0 30px rgba(87, 223, 255, 0.48));
}

@keyframes sprite-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

.dialogue-panel {
  position: absolute;
  right: 5.5%;
  bottom: 26px;
  left: 5.5%;
  z-index: 12;
  min-height: 184px;
  padding: 42px 96px 55px 48px;
  border: 1px solid rgba(164, 226, 237, 0.64);
  border-radius: var(--radius);
  background: linear-gradient(
    100deg,
    rgba(2, 16, 28, 0.97),
    rgba(7, 33, 48, 0.93) 68%,
    rgba(3, 20, 32, 0.97)
  );
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    inset 0 -36px 0 rgba(1, 10, 17, 0.46),
    0 18px 46px rgba(0, 0, 0, 0.56);
  backdrop-filter: blur(9px) saturate(118%);
}

.dialogue-panel::before,
.dialogue-panel::after {
  content: "";
  position: absolute;
  top: 10px;
  bottom: 10px;
  width: 9px;
  border-block: 1px solid rgba(161, 229, 238, 0.72);
  pointer-events: none;
}

.dialogue-panel::before {
  left: 10px;
  border-left: 2px solid var(--accent-blue);
}

.dialogue-panel::after {
  right: 10px;
  border-right: 2px solid var(--accent-blue);
}

.speaker-name {
  position: absolute;
  top: -23px;
  left: 32px;
  display: grid;
  min-width: 154px;
  min-height: 42px;
  place-items: center;
  padding: 8px 24px;
  border: 1px solid rgba(170, 231, 239, 0.78);
  color: var(--accent-blue);
  background: linear-gradient(100deg, rgba(8, 42, 56, 0.98), rgba(4, 20, 32, 0.99));
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.38);
}

.dialogue-text {
  max-height: 86px;
  margin: 0;
  overflow-y: auto;
  white-space: pre-line;
  font-size: 18px;
  line-height: 1.78;
  text-shadow: 0 2px 5px rgba(0, 0, 0, 0.7);
}

.top-actions {
  position: absolute;
  right: 14px;
  bottom: 0;
  left: 14px;
  display: flex;
  min-height: 38px;
  justify-content: flex-end;
  gap: 0;
  border-top: 1px solid rgba(137, 207, 220, 0.18);
}

.top-actions button {
  position: relative;
  min-width: 68px;
  min-height: 37px;
  padding: 1px 13px 0;
  border: 0;
  border-left: 1px solid rgba(137, 207, 220, 0.2);
  border-radius: 0;
  color: #adc5ce;
  background: transparent;
  font: 700 10px/1 "Segoe UI", sans-serif;
  letter-spacing: 0.08em;
}

.top-actions button:hover:not(:disabled),
.top-actions button:focus-visible {
  color: #ffffff;
  background: linear-gradient(0deg, rgba(17, 74, 78, 0.72), rgba(12, 48, 61, 0.2));
  transform: none;
}

.top-actions button::after {
  content: "";
  position: absolute;
  right: 13px;
  bottom: 5px;
  left: 13px;
  height: 1px;
  background: var(--accent);
  opacity: 0;
  transform: scaleX(0.45);
  transition:
    opacity 150ms ease,
    transform 150ms ease;
}

.top-actions button:hover::after,
.top-actions button:focus-visible::after,
.top-actions button.is-active::after,
.top-actions button[aria-pressed="true"]::after {
  opacity: 1;
  transform: scaleX(1);
}

#auto-button.is-active,
#auto-button[aria-pressed="true"],
#skip-button.is-active,
#skip-button[aria-pressed="true"] {
  color: #e2fff6;
  background: linear-gradient(0deg, rgba(19, 87, 82, 0.74), rgba(13, 45, 56, 0.28));
  box-shadow: inset 0 1px 0 rgba(151, 239, 222, 0.22);
}

.next-button {
  position: absolute;
  right: 31px;
  bottom: 69px;
  min-width: 0;
  width: 42px;
  min-height: 34px;
  padding: 0 8px;
  border-color: rgba(134, 233, 218, 0.76);
  color: #eafffb;
  background: rgba(18, 82, 79, 0.88);
  font-size: 22px;
  box-shadow: 0 0 14px rgba(118, 225, 210, 0.16);
}

.puzzle-panel,
.choice-panel {
  position: absolute;
  z-index: 18;
  top: 48%;
  left: 50%;
  width: min(820px, calc(100vw - 56px));
  transform: translate(-50%, -50%);
  animation: panel-in 190ms ease-out;
}

.puzzle-panel {
  max-height: calc(100dvh - 86px);
  overflow-y: auto;
  padding: 30px 38px;
  border: 1px solid rgba(137, 215, 230, 0.68);
  border-radius: 2px;
  background:
    linear-gradient(rgba(2, 13, 24, 0.84), rgba(3, 18, 30, 0.92)),
    url("https://flsc495.xyz/ui/code_challenge_panel.png") center / 100% 100% no-repeat;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 22px 64px rgba(0, 0, 0, 0.64);
  backdrop-filter: blur(10px);
}

.choice-panel {
  width: min(690px, calc(100vw - 56px));
  padding: 28px;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  background: rgba(3, 16, 27, 0.9);
  box-shadow: 0 20px 58px rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(9px);
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translate(-50%, -47%);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%);
  }
}

.puzzle-heading {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(137, 215, 230, 0.28);
}

.puzzle-heading img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.puzzle-heading h2 {
  margin-bottom: 0;
  font-size: 23px;
}

.puzzle-description {
  margin: 17px 0 13px;
  color: #c9dce4;
  line-height: 1.65;
}

.code-editor {
  position: relative;
  width: 100%;
  min-height: 205px;
}

.code-highlight,
.code-input {
  width: 100%;
  min-height: 205px;
  padding: 18px;
  border: 1px solid rgba(113, 205, 222, 0.48);
  border-radius: 2px;
  font: 16px/1.55 Consolas, "Courier New", monospace;
  tab-size: 4;
  white-space: pre-wrap;
  overflow-wrap: normal;
}

.code-highlight {
  position: absolute;
  inset: 0;
  z-index: 0;
  margin: 0;
  overflow: hidden;
  color: #f0fff8;
  background:
    linear-gradient(rgba(1, 8, 15, 0.76), rgba(1, 8, 15, 0.76)),
    url("https://flsc495.xyz/ui/code_input_box.png") center / 100% 100% no-repeat;
  pointer-events: none;
}

.python-comment {
  color: #ffd166;
  font-weight: 700;
  text-shadow: 0 0 8px rgba(255, 209, 102, 0.28);
}

.code-input {
  position: relative;
  z-index: 1;
  display: block;
  color: transparent;
  caret-color: #f0fff8;
  background: transparent;
  -webkit-text-fill-color: transparent;
  resize: vertical;
}

.code-input:focus {
  border-color: var(--line-strong);
  outline: none;
}

.code-input::selection {
  background: rgba(78, 190, 218, 0.38);
}

.puzzle-actions {
  display: flex;
  gap: 9px;
  margin-top: 13px;
}

.feedback-text {
  min-height: 24px;
  margin: 13px 0 0;
  color: var(--muted);
}

.feedback-text[data-kind="success"] {
  color: var(--success);
}

.feedback-text[data-kind="error"] {
  color: var(--error);
}

.feedback-text[data-kind="hint"] {
  color: var(--warning);
}

.choice-list {
  display: grid;
  gap: 9px;
}

.choice-list button {
  position: relative;
  min-height: 52px;
  border: 0;
  border-block: 1px solid rgba(137, 207, 220, 0.35);
  background: rgba(8, 35, 48, 0.7);
  text-align: left;
}

.choice-list button:hover,
.choice-list button:focus-visible {
  border-color: var(--accent);
  padding-left: 26px;
  background: rgba(19, 75, 78, 0.88);
  transform: none;
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(1, 7, 13, 0.82), rgba(1, 7, 13, 0.68)),
    rgba(1, 7, 13, 0.72);
  backdrop-filter: blur(12px) saturate(76%);
}

.modal-panel {
  width: min(900px, calc(100vw - 48px));
  max-height: calc(100dvh - 48px);
  overflow-y: auto;
  padding: 30px;
  border: 1px solid rgba(139, 214, 227, 0.56);
  border-radius: var(--radius);
  background:
    linear-gradient(115deg, rgba(7, 31, 44, 0.98), rgba(2, 15, 25, 0.99) 60%),
    rgba(4, 19, 31, 0.98);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.12),
    0 30px 90px rgba(0, 0, 0, 0.66);
}

.settings-panel {
  width: min(620px, calc(100vw - 48px));
}

.save-panel {
  width: min(1060px, calc(100vw - 48px));
}

.history-panel {
  width: min(980px, calc(100vw - 48px));
}

.local-save-note {
  display: block;
  max-width: 680px;
  margin-top: 7px;
  color: var(--muted);
  line-height: 1.55;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(137, 215, 230, 0.28);
}

.modal-header h2 {
  margin-bottom: 0;
}

.chapter-list {
  display: grid;
  gap: 10px;
}

.save-slot-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.save-slot {
  display: grid;
  min-height: 122px;
  gap: 7px;
  align-content: start;
  padding: 16px;
  overflow: hidden;
  text-align: left;
  background:
    linear-gradient(135deg, rgba(8, 41, 56, 0.84), rgba(3, 19, 31, 0.94)),
    url("https://flsc495.xyz/ui/chapter_card_sheet.png") center / cover no-repeat;
}

.save-slot .slot-number {
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}

.save-slot strong,
.save-slot .slot-speaker,
.save-slot .slot-preview,
.save-slot time {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.save-slot .slot-speaker,
.save-slot time {
  color: var(--muted);
  font-size: 12px;
}

.save-slot .slot-preview {
  color: #d5e6ec;
  font-size: 13px;
}

.save-slot[data-empty="true"] {
  color: var(--muted);
  background: rgba(4, 20, 32, 0.72);
}

.save-file-actions {
  display: flex;
  justify-content: flex-end;
  gap: 9px;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid rgba(137, 215, 230, 0.24);
}

.history-list {
  display: grid;
  max-height: min(620px, calc(100dvh - 210px));
  overflow-y: auto;
  border-top: 1px solid rgba(137, 215, 230, 0.24);
}

.history-entry {
  position: relative;
  display: grid;
  grid-template-columns: 170px minmax(0, 1fr);
  gap: 18px;
  min-height: 0;
  padding: 17px 64px 17px 14px;
  border: 0;
  border-bottom: 1px solid rgba(137, 215, 230, 0.16);
  border-radius: 0;
  color: inherit;
  background: transparent;
  text-align: left;
  transition:
    background 150ms ease,
    padding-left 150ms ease;
}

.history-entry::before {
  content: "";
  position: absolute;
  top: 14px;
  bottom: 14px;
  left: 0;
  width: 2px;
  background: var(--accent);
  opacity: 0;
}

.history-entry::after {
  content: "LOAD";
  position: absolute;
  top: 50%;
  right: 15px;
  color: var(--accent);
  font: 700 9px/1 "Segoe UI", sans-serif;
  letter-spacing: 0.12em;
  opacity: 0;
  transform: translateY(-50%);
}

.history-entry:hover,
.history-entry:focus-visible {
  padding-left: 22px;
  outline: none;
  background: linear-gradient(90deg, rgba(25, 84, 87, 0.25), rgba(8, 35, 48, 0.08));
  transform: none;
}

.history-entry:hover::before,
.history-entry:focus-visible::before,
.history-entry:hover::after,
.history-entry:focus-visible::after,
.history-entry[data-current="true"]::before {
  opacity: 1;
}

.history-entry[data-current="true"] {
  background: rgba(19, 72, 76, 0.16);
}

.history-meta {
  display: grid;
  align-content: start;
  gap: 5px;
}

.history-meta strong {
  color: var(--accent-blue);
}

.history-meta span {
  color: var(--muted);
  font-size: 11px;
}

.history-entry p {
  margin: 0;
  color: #e0edf2;
  line-height: 1.75;
  white-space: pre-line;
}

.history-empty {
  margin: 0;
  padding: 36px 8px;
  color: var(--muted);
  text-align: center;
}

.chapter-card {
  display: grid;
  min-height: 118px;
  gap: 7px;
  align-content: end;
  padding: 18px 22px;
  border-color: rgba(137, 207, 220, 0.42);
  text-align: left;
  background:
    linear-gradient(90deg, rgba(2, 13, 23, 0.88), rgba(2, 13, 23, 0.28)),
    url("https://flsc495.xyz/ui/chapter_card_sheet.png") center / cover no-repeat;
}

.chapter-card strong {
  font-size: 18px;
}

.chapter-card small {
  color: var(--muted);
}

.chapter-card[data-complete="true"] {
  border-color: rgba(130, 225, 210, 0.74);
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px 0;
  border-top: 1px solid rgba(137, 215, 230, 0.18);
}

.setting-row span {
  display: grid;
  gap: 5px;
}

.setting-row small {
  color: var(--muted);
}

.setting-row input {
  width: 22px;
  height: 22px;
  accent-color: var(--accent);
}

.toast {
  position: fixed;
  z-index: 40;
  top: 24px;
  left: 50%;
  padding: 11px 18px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: rgba(4, 20, 32, 0.96);
  transform: translateX(-50%);
  box-shadow: 0 14px 38px rgba(0, 0, 0, 0.42);
}

.large-text .dialogue-text,
.large-text .puzzle-description,
.large-text .code-input {
  font-size: 21px;
}

.reduced-motion *,
.reduced-motion *::before,
.reduced-motion *::after {
  scroll-behavior: auto !important;
  animation-duration: 0.001ms !important;
  transition-duration: 0.001ms !important;
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .menu-view {
    grid-template-columns: 1fr;
    gap: 24px;
    align-content: end;
    padding: 34px 24px;
  }

  .brand-block {
    align-self: auto;
  }

  h1 {
    font-size: clamp(48px, 15vw, 70px);
  }

  .menu-actions {
    width: min(100%, 420px);
    margin-bottom: 58px;
  }

  .game-view {
    min-height: 100dvh;
  }

  .top-bar {
    top: 14px;
    left: 14px;
    max-width: calc(100vw - 28px);
  }

  .chapter-meta {
    flex-wrap: wrap;
    gap: 4px 12px;
  }

  .stage {
    inset: 0 0 210px;
  }

  .character-sprite[data-character="lux"],
  .character-sprite[data-character="nova"] {
    left: 50%;
    width: min(76vw, 560px);
    height: min(78vh, 760px);
  }

  .dialogue-panel {
    right: 12px;
    bottom: 40px;
    left: 12px;
    min-height: 216px;
    padding: 40px 72px 67px 28px;
  }

  .dialogue-text {
    max-height: 120px;
    font-size: 16px;
  }

  .speaker-name {
    left: 18px;
    min-width: 126px;
  }

  .top-actions {
    right: 10px;
    bottom: 0;
    left: 12px;
    overflow-x: auto;
    flex-wrap: nowrap;
  }

  .top-actions button {
    flex: 0 0 64px;
    min-width: 64px;
    padding-inline: 8px;
  }

  .next-button {
    right: 18px;
    bottom: 76px;
  }

  .puzzle-panel {
    top: 24px;
    bottom: 24px;
    width: calc(100vw - 28px);
    max-height: none;
    padding: 24px 20px;
    transform: translateX(-50%);
  }

  .choice-panel {
    width: calc(100vw - 28px);
  }

  .puzzle-actions {
    flex-wrap: wrap;
  }

  .chapter-list {
    grid-template-columns: 1fr;
  }

  .save-slot-list {
    grid-template-columns: 1fr;
  }

  .save-file-actions {
    flex-wrap: wrap;
  }

  .save-file-actions button {
    flex: 1 1 180px;
  }

  .history-entry {
    grid-template-columns: 1fr;
    gap: 8px;
    padding-right: 56px;
  }

  @keyframes panel-in {
    from {
      opacity: 0;
      transform: translate(-50%, 8px);
    }
    to {
      opacity: 1;
      transform: translate(-50%, 0);
    }
  }
}

@media (orientation: portrait) and (max-width: 700px) {
  .orientation-guard {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 10px;
    padding:
      max(28px, env(safe-area-inset-top))
      max(28px, env(safe-area-inset-right))
      max(28px, env(safe-area-inset-bottom))
      max(28px, env(safe-area-inset-left));
    color: var(--text);
    background:
      linear-gradient(rgba(2, 13, 22, 0.9), rgba(2, 13, 22, 0.96)),
      url("https://flsc495.xyz/background/menu_lighthouse_station.png") center / cover no-repeat;
    text-align: center;
  }

  .orientation-guard::before {
    content: "";
    position: absolute;
    inset: 18px;
    border: 1px solid rgba(133, 217, 235, 0.34);
    pointer-events: none;
  }

  .orientation-guard img {
    width: 72px;
    height: 72px;
    object-fit: contain;
    filter: drop-shadow(0 0 18px rgba(120, 220, 204, 0.32));
  }

  .orientation-guard .panel-kicker {
    margin: 6px 0 0;
  }

  .orientation-guard h2 {
    margin: 0;
    font-size: 28px;
  }

  .orientation-guard p:not(.panel-kicker) {
    max-width: 290px;
    margin: 0 0 8px;
    color: #c7dbe3;
    line-height: 1.7;
  }

  .orientation-guard button {
    min-width: 158px;
  }
}

@media (orientation: landscape) and (max-height: 540px) {
  html,
  body,
  .app-shell,
  .menu-view,
  .game-view {
    width: 100%;
    height: 100dvh;
    min-height: 0;
    overflow: hidden;
  }

  .menu-view {
    grid-template-columns: minmax(0, 1fr) minmax(210px, 28vw);
    align-items: end;
    gap: 28px;
    padding:
      max(18px, env(safe-area-inset-top))
      max(26px, env(safe-area-inset-right))
      max(18px, env(safe-area-inset-bottom))
      max(26px, env(safe-area-inset-left));
  }

  .preload-screen {
    gap: 5px;
    padding: 18px;
  }

  .preload-screen::before {
    inset: 10px;
  }

  .preload-badge {
    width: 42px;
    height: 42px;
  }

  .preload-screen .panel-kicker {
    margin-top: 2px;
    font-size: 9px;
  }

  .preload-screen h1 {
    margin-bottom: 3px;
    font-size: 27px;
  }

  .preload-status {
    min-height: 18px;
    font-size: 12px;
  }

  .brand-block {
    max-width: 520px;
    padding: 0 0 2px 14px;
  }

  .brand-badge {
    width: 40px;
    height: 40px;
  }

  .eyebrow {
    margin: 5px 0 4px;
    font-size: 10px;
  }

  h1 {
    margin-bottom: 8px;
    padding-bottom: 10px;
    font-size: clamp(38px, 8.5vh, 54px);
  }

  .subtitle {
    max-width: 460px;
    margin-bottom: 8px;
    font-size: 14px;
    line-height: 1.45;
  }

  .menu-progress {
    margin-bottom: 0;
    font-size: 10px;
  }

  .menu-actions {
    padding: 3px 0 3px 10px;
    margin-bottom: 0;
  }

  .menu-actions button {
    min-height: 36px;
    padding-left: 25px;
    font-size: 13px;
  }

  .easter-egg-dock {
    right: max(8px, env(safe-area-inset-right));
    bottom: max(5px, env(safe-area-inset-bottom));
  }

  .easter-egg-button {
    width: 42px;
    min-height: 42px;
    padding: 3px;
  }

  .easter-egg-cooldown {
    min-height: 10px;
    font-size: 8px;
  }

  .top-bar {
    top: max(7px, env(safe-area-inset-top));
    left: max(12px, env(safe-area-inset-left));
    max-width: calc(100vw - 24px);
    padding: 5px 14px 5px 10px;
  }

  .chapter-meta {
    gap: 12px;
    font-size: 12px;
  }

  #progress-label {
    font-size: 9px;
  }

  .stage {
    inset: 0 0 112px;
  }

  .character-sprite {
    bottom: -12%;
    width: min(39vw, 420px);
    height: 92vh;
  }

  .character-sprite[data-character="lux"] {
    left: 31%;
  }

  .character-sprite[data-character="nova"] {
    left: 69%;
  }

  .dialogue-panel {
    right: max(10px, env(safe-area-inset-right));
    bottom: max(6px, env(safe-area-inset-bottom));
    left: max(10px, env(safe-area-inset-left));
    min-height: 126px;
    padding: 27px 58px 40px 24px;
  }

  .speaker-name {
    top: -17px;
    left: 20px;
    min-width: 116px;
    min-height: 32px;
    padding: 5px 18px;
    font-size: 13px;
  }

  .dialogue-text {
    max-height: 52px;
    font-size: 14px;
    line-height: 1.55;
  }

  .top-actions {
    right: 8px;
    left: 8px;
    min-height: 33px;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .top-actions::-webkit-scrollbar {
    display: none;
  }

  .top-actions button {
    flex: 0 0 58px;
    min-width: 58px;
    min-height: 32px;
    padding-inline: 5px;
    font-size: 8px;
  }

  .next-button {
    right: 22px;
    bottom: 47px;
    width: 36px;
    min-height: 30px;
    font-size: 18px;
  }

  .puzzle-panel,
  .choice-panel {
    top: 50%;
    bottom: auto;
    width: min(760px, calc(100vw - 28px));
    max-height: calc(100dvh - 16px);
    transform: translate(-50%, -50%);
  }

  .puzzle-panel {
    padding: 14px 20px;
  }

  .puzzle-heading {
    gap: 9px;
    padding-bottom: 8px;
  }

  .puzzle-heading img {
    width: 34px;
    height: 34px;
  }

  .puzzle-heading h2 {
    font-size: 18px;
  }

  .puzzle-heading .panel-kicker {
    margin: 0 0 3px;
    font-size: 9px;
  }

  .puzzle-description {
    margin: 9px 0 7px;
    font-size: 12px;
    line-height: 1.45;
  }

  .code-editor,
  .code-highlight,
  .code-input {
    min-height: 84px;
    height: 24vh;
  }

  .code-highlight,
  .code-input {
    padding: 10px 12px;
    font-size: 13px;
  }

  .puzzle-actions {
    margin-top: 7px;
  }

  .puzzle-actions button {
    min-height: 32px;
    font-size: 12px;
  }

  .feedback-text {
    min-height: 18px;
    margin-top: 7px;
    font-size: 11px;
  }

  .choice-panel {
    padding: 16px 20px;
  }

  .choice-list {
    gap: 6px;
  }

  .choice-list button {
    min-height: 38px;
    font-size: 13px;
  }

  .modal-layer {
    padding:
      max(8px, env(safe-area-inset-top))
      max(10px, env(safe-area-inset-right))
      max(8px, env(safe-area-inset-bottom))
      max(10px, env(safe-area-inset-left));
  }

  .modal-panel,
  .settings-panel,
  .save-panel,
  .history-panel {
    width: min(960px, calc(100vw - 20px));
    max-height: calc(100dvh - 16px);
    padding: 14px 18px;
  }

  .modal-header {
    margin-bottom: 10px;
    padding-bottom: 8px;
  }

  .modal-header .panel-kicker {
    margin: 0 0 3px;
    font-size: 9px;
  }

  .modal-header h2 {
    font-size: 18px;
  }

  .modal-close-button {
    min-height: 32px;
  }

  .save-slot-list {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .save-slot {
    min-height: 86px;
    padding: 10px 12px;
  }

  .save-file-actions {
    margin-top: 10px;
    padding-top: 9px;
  }

  .history-list {
    max-height: calc(100dvh - 104px);
  }

  .history-entry {
    grid-template-columns: 130px minmax(0, 1fr);
    gap: 12px;
    padding-block: 10px;
    font-size: 12px;
  }

  .history-entry p {
    line-height: 1.55;
  }
}

@media (prefers-reduced-motion: reduce) {
  .easter-egg-button.is-popping {
    animation: none;
  }
}
