:root {
  color-scheme: light;
  --ink: #243138;
  --muted: #65737a;
  --paper: #f8f3ea;
  --mist: #e8f0ec;
  --jade: #2f8a7a;
  --jade-deep: #155e58;
  --lotus: #d86f8f;
  --lotus-soft: #f3c7d0;
  --amber: #f1b84b;
  --cinnabar: #b64236;
  --shadow: rgba(35, 49, 56, 0.18);
  --line: rgba(36, 49, 56, 0.14);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  color: var(--ink);
  font-family:
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
    system-ui, sans-serif;
  background:
    radial-gradient(circle at 18% 12%, rgba(216, 111, 143, 0.18), transparent 26rem),
    linear-gradient(135deg, #d9e9e1 0%, #f8f3ea 42%, #d4e5eb 100%);
  overflow-x: hidden;
}

button,
canvas {
  font: inherit;
}

a {
  color: inherit;
}

.app-shell {
  width: min(1180px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-columns: minmax(0, 860px) 280px;
  gap: 14px;
  align-items: start;
  justify-content: center;
}

.game-card,
.journal-panel {
  border: 1px solid rgba(255, 255, 255, 0.78);
  background: rgba(248, 243, 234, 0.78);
  box-shadow: 0 22px 70px var(--shadow);
  backdrop-filter: blur(18px);
}

.game-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  overflow: hidden;
}

.topbar {
  min-height: 58px;
  padding: 6px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  border-bottom: 1px solid var(--line);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.68), rgba(255, 255, 255, 0.24)),
    repeating-linear-gradient(90deg, rgba(36, 49, 56, 0.04) 0 1px, transparent 1px 34px);
}

.eyebrow {
  margin: 0 0 3px;
  color: var(--jade-deep);
  font-size: 12px;
  line-height: 1;
  letter-spacing: 0;
  font-weight: 700;
}

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

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.12;
  overflow-wrap: anywhere;
}

.brand-lockup {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
}

.brand-title {
  display: flex;
  align-items: center;
}

.title-logo {
  display: block;
  width: min(340px, 100%);
  max-width: 100%;
  height: auto;
  filter: drop-shadow(0 7px 12px rgba(36, 49, 56, 0.18));
}

h2 {
  margin-bottom: 10px;
  font-size: 24px;
  line-height: 1.14;
}

.status-cluster {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-button,
.touch-button,
.primary-button {
  border: 0;
  cursor: pointer;
}

.icon-button,
.touch-button {
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, var(--jade), var(--jade-deep));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.35), 0 10px 22px rgba(21, 94, 88, 0.18);
}

.icon-button {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 900;
}

.image-icon-button {
  width: 44px;
  height: 44px;
  overflow: visible;
  padding: 0;
  background: transparent;
  box-shadow: none;
}

.image-icon-button img {
  display: block;
  width: 44px;
  height: 44px;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 14px rgba(19, 76, 72, 0.2));
}

#restartBtn img {
  width: 38px;
  height: 38px;
}

.icon-button:active,
.touch-button:active,
.primary-button:active {
  transform: translateY(1px);
}

.playfield-wrap {
  position: relative;
  flex: none;
  width: 100%;
  aspect-ratio: 16 / 9;
  min-height: 360px;
  max-height: calc(100vh - 104px);
  background: #cfe3df;
  overflow: hidden;
}

#gameCanvas {
  width: 100%;
  height: 100%;
  min-height: 360px;
  display: block;
  background: #dbece8;
}

.game-guides {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: rgba(248, 243, 234, 0.52);
}

.hud {
  position: absolute;
  z-index: 5;
  pointer-events: none;
}

.hud-top {
  inset: 12px 12px auto 12px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.hud-panel {
  min-height: 44px;
  padding: 8px 10px;
  display: flex;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.68);
  border-radius: 8px;
  background: rgba(251, 246, 238, 0.72);
  box-shadow: 0 12px 26px rgba(36, 49, 56, 0.12);
  backdrop-filter: blur(12px);
}

.hud-caption {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.lives {
  display: grid;
  grid-template-columns: repeat(5, 16px);
  grid-auto-rows: 16px;
  width: 100px;
  gap: 5px;
  align-items: center;
  justify-content: start;
}

.life-token {
  position: relative;
  width: 16px;
  height: 16px;
  display: inline-block;
  filter: drop-shadow(0 3px 4px rgba(126, 57, 76, 0.2));
}

.life-token::before,
.life-token::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;
  width: 10px;
  height: 10px;
  border-radius: 80% 20% 80% 20%;
  background: linear-gradient(135deg, #ffe5ed, var(--lotus));
  transform-origin: 0 0;
}

.life-token::before {
  transform: rotate(-45deg) translate(-50%, -50%);
}

.life-token::after {
  transform: rotate(45deg) translate(-50%, -50%);
}

.life-token i {
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 11px;
  height: 6px;
  border-radius: 50% 50% 45% 45%;
  background: linear-gradient(180deg, #fff6fb, #ef8faa);
  transform: translateX(-50%);
}

.life-token.empty {
  filter: grayscale(1);
  opacity: 0.28;
}

.energy-panel {
  min-width: 194px;
}

.energy-track {
  width: 104px;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(36, 49, 56, 0.13);
  box-shadow: inset 0 1px 2px rgba(36, 49, 56, 0.18);
}

.energy-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--jade), var(--amber), var(--lotus));
  transition: width 120ms linear;
}

.energy-text,
.metric-panel strong {
  color: var(--jade-deep);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.scene-banner {
  position: absolute;
  z-index: 4;
  left: 50%;
  top: 86px;
  min-width: 250px;
  max-width: min(520px, calc(100% - 28px));
  padding: 10px 18px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  color: #fff;
  text-align: center;
  background: linear-gradient(135deg, rgba(21, 94, 88, 0.88), rgba(182, 66, 54, 0.8));
  box-shadow: 0 18px 34px rgba(21, 44, 51, 0.18);
  transform: translate(-50%, -130%);
  opacity: 0;
  transition: transform 380ms ease, opacity 380ms ease;
}

.scene-banner.show {
  transform: translate(-50%, 0);
  opacity: 1;
}

.scene-banner span {
  display: block;
  font-size: 18px;
  font-weight: 900;
}

.scene-banner small {
  display: block;
  margin-top: 3px;
  opacity: 0.86;
}

.knowledge-toast {
  position: absolute;
  z-index: 6;
  right: 18px;
  top: 92px;
  width: min(300px, calc(100% - 36px));
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, rgba(36, 49, 56, 0.88), rgba(47, 138, 122, 0.86));
  box-shadow: 0 18px 38px rgba(18, 42, 48, 0.2);
}

.knowledge-toast span {
  display: block;
  color: #f8d987;
  font-size: 12px;
  font-weight: 800;
}

.knowledge-toast strong {
  display: block;
  margin-top: 4px;
  line-height: 1.25;
}

.float-note {
  position: absolute;
  z-index: 6;
  left: 50%;
  bottom: 116px;
  padding: 8px 12px;
  border-radius: 8px;
  color: #fff;
  background: rgba(36, 49, 56, 0.82);
  box-shadow: 0 14px 28px rgba(36, 49, 56, 0.18);
  transform: translateX(-50%);
  pointer-events: none;
  white-space: nowrap;
}

.touch-controls {
  position: absolute;
  z-index: 7;
  right: 16px;
  bottom: 16px;
  display: none;
  gap: 10px;
}

.touch-button {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  font-size: 26px;
  font-weight: 900;
}

.modal {
  position: absolute;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(36, 49, 56, 0.2), rgba(36, 49, 56, 0.54)),
    radial-gradient(circle at 50% 30%, rgba(255, 245, 225, 0.22), transparent 32rem);
}

.modal[hidden],
.knowledge-toast[hidden],
.float-note[hidden] {
  display: none;
}

.modal-inner {
  width: min(520px, 100%);
  max-height: min(calc(100vh - 48px), calc(100% - 40px));
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(248, 243, 234, 0.88)),
    repeating-linear-gradient(0deg, rgba(47, 138, 122, 0.05) 0 1px, transparent 1px 30px);
  box-shadow: 0 24px 70px rgba(21, 44, 51, 0.26);
}

.modal-inner p {
  color: var(--muted);
  line-height: 1.7;
}

.intro-modal .modal-inner {
  width: min(620px, calc(100% - 56px));
  max-height: none;
  overflow: visible;
  padding: 16px 20px 14px;
  text-align: center;
}

.intro-modal h2 {
  margin-bottom: 6px;
  font-size: 22px;
}

.intro-modal .modal-inner > p {
  max-width: 520px;
  margin-inline: auto;
  margin-bottom: 0;
  font-size: 14px;
  line-height: 1.45;
}

.intro-modal .quick-guide {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  max-width: 500px;
  margin: 10px auto 6px;
  text-align: left;
}

.intro-modal .quick-guide div {
  padding: 9px;
}

.intro-modal .quick-guide p {
  font-size: 12px;
  line-height: 1.45;
}

.intro-modal .art-action-button {
  margin-inline: auto;
  width: min(190px, 54vw);
  min-height: 62px;
}

.quick-guide {
  display: grid;
  gap: 8px;
  margin: 14px 0 18px;
}

.quick-guide div,
.guide-panel {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.56);
}

.quick-guide span,
.guide-panel h3,
.item-guide span {
  color: var(--jade-deep);
  font-weight: 900;
}

.quick-guide span {
  display: block;
  margin-bottom: 4px;
  font-size: 13px;
}

.quick-guide p {
  margin: 0;
  font-size: 13px;
}

.primary-button {
  min-width: 132px;
  min-height: 44px;
  padding: 10px 18px;
  border-radius: 8px;
  color: #fff;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cinnabar), var(--lotus), var(--jade));
  box-shadow: 0 14px 28px rgba(182, 66, 54, 0.24);
}

.image-button {
  position: relative;
  border: 0;
  padding: 0;
  color: #fff;
  background: transparent;
  cursor: pointer;
}

.image-button img {
  display: block;
  width: 100%;
  height: auto;
  pointer-events: none;
}

.art-action-button {
  width: min(230px, 70vw);
  min-height: 76px;
  filter: drop-shadow(0 14px 24px rgba(36, 49, 56, 0.22));
  transform-origin: center;
}

.art-action-button span {
  position: absolute;
  left: 50%;
  top: 50%;
  padding: 4px 14px;
  border-radius: 999px;
  color: #fffdf4;
  font-size: 19px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 4px rgba(59, 34, 26, 0.42);
  background: rgba(31, 105, 96, 0.28);
  transform: translate(-50%, -42%);
  pointer-events: none;
  white-space: nowrap;
}

.art-action-button:hover {
  filter: drop-shadow(0 16px 28px rgba(36, 49, 56, 0.28)) saturate(1.05);
}

.settlement-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 8px;
  margin: 16px 0;
}

.settlement-grid div,
.settlement-list {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
}

.settlement-grid span,
.settlement-list span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.settlement-grid strong {
  display: block;
  margin-top: 5px;
  color: var(--jade-deep);
  font-size: 22px;
}

.settlement-list p {
  margin: 5px 0 0;
}

.journal-panel {
  min-height: 0;
  max-height: calc(100vh - 32px);
  overflow: auto;
  padding: 12px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.journal-head h2 {
  margin: 0;
  font-size: 20px;
}

.developer-panel {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.58);
  box-shadow: 0 10px 24px rgba(36, 49, 56, 0.06);
}

.developer-panel h3 {
  margin: 0 0 8px;
  color: var(--jade-deep);
  font-size: 15px;
}

.developer-panel dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.developer-panel div {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 8px;
  align-items: baseline;
}

.developer-panel dt,
.developer-panel dd {
  margin: 0;
  font-size: 12px;
  line-height: 1.45;
}

.developer-panel dt {
  color: var(--muted);
  font-weight: 800;
}

.developer-panel dd {
  color: var(--ink);
  font-weight: 800;
}

.guide-panel {
  display: grid;
  gap: 7px;
}

.guide-panel h3 {
  margin: 0;
  font-size: 16px;
}

.guide-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px 10px;
  align-items: center;
  padding-top: 4px;
}

.control-grid span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.control-grid strong {
  min-width: 74px;
  padding: 4px 7px;
  border-radius: 6px;
  color: var(--ink);
  text-align: center;
  background: rgba(47, 138, 122, 0.12);
  font-size: 12px;
}

.item-guide {
  display: grid;
  gap: 7px;
}

.item-guide div {
  display: grid;
  grid-template-columns: 18px minmax(64px, auto) minmax(0, 1fr);
  gap: 7px;
  align-items: center;
}

.item-guide p {
  font-size: 12px;
}

.dot {
  position: relative;
  width: 14px;
  height: 14px;
  border: 2px solid rgba(36, 49, 56, 0.18);
  border-radius: 50%;
  box-shadow: 0 2px 5px rgba(36, 49, 56, 0.12);
}

.dot.coin {
  background: #d39a37;
  border-color: #8c5d25;
}

.dot.coin::after {
  content: "";
  position: absolute;
  inset: 4px;
  border-radius: 2px;
  background: rgba(255, 248, 202, 0.82);
}

.dot.qianshi {
  background: #f4d8ad;
}

.dot.tofu {
  background: #5c4938;
  border-color: #f0c060;
}

.dot.chanyi {
  background: #ffe7bd;
  border-color: #cf8d40;
}

.dot.meat {
  background: #6ea06d;
  border-color: #b45b42;
}

.dot.life {
  background: radial-gradient(circle at 35% 28%, #ffe3ed, #ef8faa 58%, #d6a34f 60%, #8c5d25 100%);
  border-color: #d6a34f;
}

.dot.page {
  border-radius: 4px;
  background: #f5ead0;
  border-color: #896142;
}

.card-list {
  min-height: 0;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-right: 2px;
}

.knowledge-card {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.62);
  box-shadow: 0 10px 24px rgba(36, 49, 56, 0.08);
}

.knowledge-card.locked {
  background: rgba(233, 231, 222, 0.52);
}

.knowledge-card h3 {
  margin: 0 0 7px;
  font-size: 15px;
  line-height: 1.25;
}

.knowledge-card p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.58;
}

.knowledge-card span {
  display: inline-block;
  margin-top: 8px;
  padding: 3px 8px;
  border-radius: 999px;
  color: rgba(15, 97, 92, 0.72);
  background: rgba(47, 138, 122, 0.09);
  font-size: 11px;
  font-weight: 800;
}

.knowledge-card.locked h3 {
  color: rgba(36, 49, 56, 0.36);
}

.knowledge-card.locked p {
  color: rgba(36, 49, 56, 0.56);
}

.fragments {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.fragments span {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  padding: 4px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--jade-deep);
  background: rgba(255, 255, 255, 0.5);
  font-size: 12px;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 1120px) {
  .app-shell {
    grid-template-columns: 1fr;
    width: min(720px, 100%);
    padding: 12px;
  }

  .journal-panel {
    max-height: none;
  }

  .playfield-wrap,
  #gameCanvas {
    min-height: 340px;
  }

}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    height: auto;
    padding: 12px;
  }

  .title-logo {
    width: min(218px, 100%);
  }

  .playfield-wrap,
  #gameCanvas {
    min-height: 390px;
  }

  .hud-top {
    inset: 8px 8px auto 8px;
  }

  .hud-panel {
    min-height: 38px;
    padding: 6px 8px;
  }

  .energy-panel {
    min-width: 170px;
  }

  .energy-track {
    width: 82px;
  }

  .scene-banner {
    top: 118px;
  }

  .touch-controls {
    display: flex;
  }

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

@media (max-width: 480px) {
  .hud-top {
    gap: 6px;
  }

  .metric-panel strong,
  .energy-text {
    font-size: 13px;
  }

  .lives {
    grid-template-columns: repeat(5, 14px);
    grid-auto-rows: 14px;
    width: 82px;
    gap: 3px;
  }

  .life-token {
    width: 14px;
    height: 14px;
  }

  .modal-inner {
    padding: 18px;
  }

  .intro-modal .modal-inner {
    width: min(100%, calc(100vw - 18px));
    padding: 12px;
  }

  .intro-modal .quick-guide {
    grid-template-columns: 1fr;
    gap: 6px;
    margin: 8px 0 6px;
  }

  .intro-modal .quick-guide div {
    padding: 7px;
  }

  .intro-modal h2 {
    font-size: 19px;
  }

  .intro-modal .modal-inner > p,
  .intro-modal .quick-guide p {
    font-size: 11px;
    line-height: 1.35;
  }

  .game-guides {
    grid-template-columns: 1fr;
  }

  .item-guide div {
    grid-template-columns: 18px minmax(0, 1fr);
  }

  .item-guide p {
    grid-column: 2;
  }
}
