:root {
  color-scheme: dark;
  --bg: #0e111a;
  --ink: #fff6e8;
  --muted: #b7bdca;
  --panel: rgba(21, 25, 37, 0.92);
  --panel-strong: #171c2a;
  --line: rgba(255, 255, 255, 0.14);
  --gold: #ffbf52;
  --orange: #ff7a37;
  --red: #ff5a66;
  --green: #66dd91;
  --blue: #71a7ff;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.42);
  font-family:
    "Microsoft YaHei", "PingFang SC", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  min-height: 100%;
  background: var(--bg);
  overflow: hidden;
}

body {
  margin: 0;
  min-height: 100dvh;
  overflow: hidden;
  color: var(--ink);
  background:
    radial-gradient(circle at 50% -10%, rgba(255, 191, 82, 0.24), transparent 290px),
    linear-gradient(180deg, #121623 0%, #0a0d14 100%);
}

button {
  border: 0;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.phone-game {
  position: relative;
  width: min(100%, 440px);
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 10px calc(92px + env(safe-area-inset-bottom));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background:
    linear-gradient(180deg, rgba(113, 167, 255, 0.08), transparent 38%),
    linear-gradient(180deg, #151927 0%, #0f121b 100%);
}

.topbar {
  display: grid;
  grid-template-columns: 42px 1fr 42px auto;
  gap: 8px;
  align-items: center;
  flex: 0 0 auto;
  margin-bottom: 0;
}

.icon-btn,
.day-badge,
.resource,
.dialogue,
.bars,
.codex details {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.icon-btn {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  color: var(--gold);
  font-size: 24px;
}

.sound-btn {
  font-size: 18px;
}

.sound-btn.on {
  color: var(--green);
  border-color: rgba(102, 221, 145, 0.45);
}

.kicker {
  margin: 0;
  color: var(--gold);
  font-size: 11px;
  letter-spacing: 0;
}

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

h1 {
  margin: 2px 0 0;
  font-size: 22px;
  line-height: 1.05;
  letter-spacing: 0;
}

.day-badge {
  padding: 7px 9px;
  border-radius: 12px;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
}

.day-badge span {
  color: var(--gold);
  font-size: 18px;
}

.resource-strip {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  flex: 0 0 auto;
  gap: 6px;
  margin-bottom: 0;
}

.resource {
  position: relative;
  min-height: 42px;
  padding: 5px 7px 5px 32px;
  border-radius: 14px;
  overflow: hidden;
}

.resource::before {
  position: absolute;
  left: 9px;
  top: 11px;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-size: 14px;
}

.resource.coin::before {
  content: "¥";
  color: var(--gold);
}

.resource.leg::before {
  content: "🍗";
}

.resource.fame::before {
  content: "★";
  color: var(--blue);
}

.resource span {
  display: block;
  color: var(--muted);
  font-size: 10px;
}

.resource b {
  display: block;
  margin-top: 3px;
  font-size: clamp(14px, 3.8vw, 17px);
  line-height: 1;
  white-space: nowrap;
}

.scene-card {
  position: relative;
  flex: 0 0 clamp(118px, 18dvh, 155px);
  min-height: 0;
  overflow: hidden;
  border: 1px solid rgba(255, 191, 82, 0.28);
  border-radius: 22px;
  background: #131722;
  box-shadow: var(--shadow);
}

.scene-art {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  filter: saturate(1.08) contrast(1.05);
}

.scene-vignette {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 9, 13, 0.16), rgba(7, 9, 13, 0.08) 36%, rgba(7, 9, 13, 0.68)),
    radial-gradient(circle at 50% 68%, transparent 0 120px, rgba(0, 0, 0, 0.28) 260px);
  pointer-events: none;
}

.gate-sign,
.floating-tag,
.cart-token {
  position: absolute;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: rgba(14, 17, 26, 0.78);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
}

.gate-sign {
  left: 14px;
  top: 10px;
  padding: 6px 9px;
  border-radius: 999px;
  color: var(--gold);
  font-size: 12px;
  font-weight: 800;
}

.npc-portrait {
  position: absolute;
  right: 14px;
  bottom: 48px;
  width: 56px;
  height: 56px;
  border: 3px solid rgba(255, 255, 255, 0.78);
  border-radius: 20px;
  background: #222838;
  object-fit: cover;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.42);
  animation: bob 2.1s ease-in-out infinite;
}

.cart-token {
  left: 50%;
  bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 122px;
  padding: 7px 11px;
  border-radius: 999px;
  transform: translateX(-50%);
  font-weight: 900;
}

.cart-token img {
  width: 34px;
  height: 34px;
  filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.35));
}

.floating-tag {
  padding: 5px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 800;
}

.tag-risk {
  left: 14px;
  bottom: 50px;
  color: var(--red);
}

.tag-heat {
  left: 14px;
  bottom: 81px;
  color: var(--gold);
}

@keyframes bob {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

.bars {
  display: grid;
  flex: 0 0 auto;
  gap: 4px;
  margin: 0;
  padding: 6px 9px;
  border-radius: 16px;
}

.mini-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  flex: 0 0 auto;
  gap: 6px;
  margin: 0;
}

.mini-stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 28px;
  padding: 4px 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
}

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

.mini-stats b {
  color: var(--gold);
  font-size: 13px;
}

.bar-row {
  display: grid;
  grid-template-columns: 42px 1fr 34px;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 11px;
}

.bar-row b {
  color: var(--ink);
  text-align: right;
}

.bar {
  height: 8px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}

.bar i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ffe08a, var(--orange));
  transition: width 0.28s ease;
}

.bar.green i {
  background: linear-gradient(90deg, #9dffc0, var(--green));
}

.bar.red i {
  background: linear-gradient(90deg, #ff99a2, var(--red));
}

.dialogue {
  position: relative;
  z-index: 2;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 9px;
  border-radius: 18px;
}

.speaker-line {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 9px;
  align-items: center;
  margin-bottom: 6px;
}

.speaker-line img {
  width: 42px;
  height: 42px;
  border-radius: 13px;
  background: #252b3b;
  object-fit: cover;
}

.speaker-line span {
  display: block;
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.speaker-line h2 {
  margin: 2px 0 0;
  font-size: 16px;
  line-height: 1.18;
}

#eventText {
  margin-bottom: 6px;
  color: #d9dfeb;
  font-size: 13px;
  line-height: 1.55;
}

.choices {
  display: grid;
  gap: 6px;
}

.choice {
  width: 100%;
  min-height: 42px;
  padding: 7px 9px;
  border: 1px solid rgba(255, 191, 82, 0.3);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(255, 191, 82, 0.17), rgba(255, 122, 55, 0.08));
  text-align: left;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.choice:active,
.skill-dock button:active,
.icon-btn:active {
  transform: scale(0.98);
}

.choice strong {
  display: block;
  margin-bottom: 2px;
  color: var(--ink);
  font-size: 13px;
}

.choice small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.choice-effects {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  margin-top: 4px;
}

.delta {
  display: inline-flex;
  align-items: center;
  min-height: 18px;
  padding: 2px 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--muted);
  font-size: 9px;
  font-weight: 900;
}

.delta.good {
  background: rgba(102, 221, 145, 0.16);
  color: #9dffc0;
}

.delta.bad {
  background: rgba(255, 90, 102, 0.16);
  color: #ffadb5;
}

.skill-dock {
  position: absolute;
  left: 50%;
  bottom: 0;
  z-index: 8;
  display: grid;
  grid-template-rows: auto 1fr;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px 6px;
  width: min(100%, 440px);
  padding: 5px 10px max(6px, env(safe-area-inset-bottom));
  border-top: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(13, 16, 24, 0.94);
  box-shadow: 0 -18px 44px rgba(0, 0, 0, 0.46);
  transform: translateX(-50%);
  backdrop-filter: blur(16px);
}

.dock-label {
  grid-column: 1 / -1;
  color: var(--gold);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.skill-dock button {
  min-height: 42px;
  padding: 4px 2px;
  border-radius: 14px;
  background: linear-gradient(180deg, #273149, #171d2d);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 8px 18px rgba(0, 0, 0, 0.25);
}

.skill-dock button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.85);
  opacity: 0.48;
  transform: none;
}

.skill-dock button.spent b::after {
  content: " ✓";
  color: var(--green);
}

.skill-dock span {
  display: block;
  margin-bottom: 1px;
  font-size: 18px;
}

.skill-dock b {
  font-size: 12px;
}

.codex {
  flex: 0 0 auto;
  margin: 0;
}

.codex details {
  border-radius: 16px;
  padding: 6px 10px;
}

.codex summary {
  color: var(--gold);
  cursor: pointer;
  font-size: 12px;
  font-weight: 900;
}

.codex p,
.codex li {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.codex ol {
  max-height: 90px;
  overflow: auto;
  margin-bottom: 0;
  padding-left: 20px;
}

.toast {
  position: fixed;
  left: 50%;
  top: 16px;
  z-index: 20;
  width: min(calc(100% - 24px), 390px);
  padding: 11px 13px;
  border: 1px solid rgba(255, 191, 82, 0.38);
  border-radius: 14px;
  background: rgba(20, 24, 36, 0.95);
  color: var(--ink);
  box-shadow: var(--shadow);
  transform: translateX(-50%);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -10px);
}

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  overflow: hidden;
  background: #0d111a;
}

.start-screen.hidden {
  display: none;
}

.start-bg,
.start-shade {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.start-bg {
  object-fit: cover;
  filter: saturate(1.1) contrast(1.08);
}

.start-shade {
  background:
    radial-gradient(circle at 50% 28%, rgba(255, 191, 82, 0.2), transparent 210px),
    linear-gradient(180deg, rgba(4, 6, 10, 0.28), rgba(4, 6, 10, 0.9));
}

.start-card {
  position: relative;
  width: min(390px, 100%);
  padding: 24px 18px 18px;
  border: 1px solid rgba(255, 191, 82, 0.34);
  border-radius: 24px;
  background: rgba(17, 21, 32, 0.9);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
  text-align: center;
  backdrop-filter: blur(16px);
}

.start-leg {
  width: 78px;
  height: 78px;
  margin-bottom: 8px;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.35));
}

.start-card h2 {
  margin: 4px 0 14px;
  font-size: clamp(28px, 8vw, 38px);
  line-height: 1.08;
}

.start-guide {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 9px;
  margin: 0 0 16px;
}

.start-guide div {
  display: grid;
  gap: 4px;
  min-height: 76px;
  place-items: center;
  padding: 10px 8px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
}

.start-guide span {
  font-size: 26px;
}

.start-guide b {
  font-size: 13px;
}

.start-btn {
  width: 100%;
  min-height: 50px;
  border-radius: 16px;
  background: linear-gradient(180deg, #ffd36d, #ff9d3d);
  color: #211407;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(255, 122, 55, 0.28);
}

.start-tip {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(4, 6, 10, 0.78);
}

.modal.hidden {
  display: none;
}

.modal-card {
  width: min(390px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 191, 82, 0.34);
  border-radius: 22px;
  background: linear-gradient(180deg, #1c2232, #111621);
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.56);
  text-align: center;
}

.modal-card img {
  width: 72px;
  height: 72px;
  margin-bottom: 8px;
}

.modal-card h2 {
  margin: 4px 0 10px;
  font-size: 24px;
}

.ending-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 26px;
  margin-bottom: 8px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(255, 191, 82, 0.15);
  color: var(--gold);
  font-size: 12px;
  font-weight: 900;
}

.modal-card p:not(.kicker) {
  color: var(--muted);
  line-height: 1.72;
}

.modal-card .ending-stats {
  margin: 10px 0 0;
  padding: 9px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.06);
  color: #d9dfeb;
  font-size: 12px;
}

.modal-card button {
  width: 100%;
  min-height: 48px;
  margin-top: 8px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ffd36d, #ff9d3d);
  color: #211407;
  font-weight: 900;
}

@media (min-width: 760px) {
  body {
    display: grid;
    place-items: center;
    padding: 20px;
  }

  .phone-game {
    height: min(900px, calc(100dvh - 40px));
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 28px;
    box-shadow: 0 30px 90px rgba(0, 0, 0, 0.52);
  }
}

@media (max-height: 740px) {
  .phone-game {
    gap: 4px;
    padding-top: max(6px, env(safe-area-inset-top));
    padding-bottom: calc(88px + env(safe-area-inset-bottom));
  }

  .topbar {
    grid-template-columns: 38px 1fr 38px auto;
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    border-radius: 11px;
  }

  h1 {
    font-size: 20px;
  }

  .resource {
    min-height: 38px;
    padding-top: 4px;
    padding-bottom: 4px;
  }

  .scene-card {
    flex-basis: 96px;
  }

  .gate-sign,
  .floating-tag {
    font-size: 10px;
  }

  .npc-portrait {
    width: 48px;
    height: 48px;
    bottom: 42px;
  }

  .cart-token {
    min-width: 108px;
    padding: 5px 9px;
    font-size: 12px;
  }

  .cart-token img {
    width: 28px;
    height: 28px;
  }

  .bars {
    padding: 5px 9px;
  }

  .mini-stats div {
    min-height: 24px;
    padding: 3px 7px;
  }

  .speaker-line {
    grid-template-columns: 36px 1fr;
  }

  .speaker-line img {
    width: 36px;
    height: 36px;
  }

  .speaker-line h2 {
    font-size: 15px;
  }

  #eventText {
    font-size: 12px;
    line-height: 1.45;
  }

  .choice {
    padding: 6px 8px;
  }

  .skill-dock button {
    min-height: 38px;
  }

  .dock-label {
    font-size: 10px;
  }

  .start-card {
    padding: 18px 14px 14px;
  }

  .start-leg {
    width: 58px;
    height: 58px;
  }

  .start-guide div {
    min-height: 62px;
    padding: 7px;
  }
}
