:root {
  --ink: #122c28;
  --pine: #1f4a3a;
  --moss: #6f8e57;
  --moss-light: #a8bf82;
  --sun: #f4b644;
  --paper: #f4e9c8;
  --paper-deep: #e8d7ac;
  --coral: #d96a4a;
  --cream: #fff8e9;
  --shadow: rgba(8, 27, 23, 0.24);
  font-family: "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
  color: var(--paper);
  background: var(--ink);
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

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

body {
  min-width: 320px;
  overflow: hidden;
  background: var(--ink);
}

button, kbd { font: inherit; }

button { cursor: pointer; }

button:focus-visible {
  outline: 3px solid var(--sun);
  outline-offset: 4px;
}

[hidden] { display: none !important; }

.app-shell, .start-screen, .game-screen { min-height: 100vh; width: 100%; }

.start-screen {
  position: relative;
  overflow: hidden;
  background: var(--ink);
  isolation: isolate;
}

.start-screen::before,
.start-screen::after {
  position: absolute;
  z-index: -1;
  content: "";
  border-radius: 50%;
  pointer-events: none;
}

.start-screen::before {
  top: -25vh;
  right: -9vw;
  width: 62vw;
  height: 82vh;
  background: #1d4938;
  opacity: .9;
  clip-path: polygon(32% 0, 100% 0, 100% 70%, 76% 67%, 63% 100%, 27% 73%, 0 77%, 13% 34%);
}

.start-screen::after {
  right: -5vw;
  bottom: -30vh;
  width: 53vw;
  height: 70vh;
  border: 1px solid rgba(168, 191, 130, .25);
  box-shadow: 0 0 0 26px rgba(168, 191, 130, .04), 0 0 0 52px rgba(168, 191, 130, .04);
}

.start-screen__grain {
  position: absolute;
  z-index: -1;
  inset: 0;
  opacity: .12;
  pointer-events: none;
  background-image: radial-gradient(rgba(244, 233, 200, .9) .6px, transparent .8px);
  background-size: 8px 8px;
  mix-blend-mode: soft-light;
}

.start-layout {
  display: grid;
  grid-template-columns: minmax(250px, .78fr) minmax(470px, 1fr);
  gap: clamp(45px, 9vw, 150px);
  align-items: center;
  width: min(1160px, calc(100% - 88px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 72px 0;
}

.intro-column { max-width: 380px; }

.eyebrow {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  color: var(--moss-light);
  font: 700 10px/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .14em;
  text-transform: uppercase;
}

.eyebrow__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--sun);
  box-shadow: 0 0 0 5px rgba(244, 182, 68, .12);
}

.eyebrow--dark { color: var(--pine); }

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

h1 {
  margin-bottom: 24px;
  color: var(--cream);
  font-family: "Arial Rounded MT Bold", "PingFang TC", sans-serif;
  font-size: clamp(64px, 9vw, 118px);
  font-weight: 900;
  letter-spacing: -.08em;
  line-height: .78;
}

h1 em {
  position: relative;
  color: var(--sun);
  font-style: normal;
}

h1 em::after {
  position: absolute;
  right: 0;
  bottom: -18px;
  width: 70%;
  height: 4px;
  content: "";
  background: var(--coral);
  transform: rotate(-3deg);
}

.intro-copy {
  max-width: 320px;
  color: rgba(244, 233, 200, .76);
  font-size: 16px;
  line-height: 1.9;
}

.intro-rule {
  display: flex;
  gap: 7px;
  margin: 34px 0 27px;
}

.intro-rule span { width: 34px; height: 3px; background: var(--moss); }
.intro-rule span:nth-child(2) { width: 12px; background: var(--sun); }
.intro-rule span:nth-child(3) { width: 5px; background: var(--coral); }

.field-note {
  position: relative;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 10px 12px 0 rgba(7, 23, 19, .18);
  transform: rotate(-2deg);
}

.field-note--small { width: min(100%, 290px); padding: 17px 21px 16px 28px; }
.field-note--small::after {
  position: absolute;
  top: 9px;
  right: -8px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  content: "";
  background: var(--coral);
  box-shadow: 0 0 0 4px var(--paper-deep);
}

.field-note__pin {
  position: absolute;
  top: 12px;
  left: 11px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--coral);
}

.field-note p { margin: 0; font-size: 12px; line-height: 1.7; }
.field-note strong { font-size: 13px; }

.selection-card {
  position: relative;
  padding: clamp(27px, 4vw, 48px);
  color: var(--ink);
  background: var(--paper);
  box-shadow: 20px 25px 0 rgba(6, 22, 18, .2);
  transform: rotate(1.2deg);
}

.selection-card::before {
  position: absolute;
  inset: 10px;
  border: 1px solid rgba(31, 74, 58, .22);
  content: "";
  pointer-events: none;
}

.selection-card__topline, .journal-panel__header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  color: var(--pine);
  font: 700 10px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: .1em;
}

.selection-card__mark { color: var(--coral); }

.selection-card h2 {
  margin: 24px 0 8px;
  font-family: "Arial Rounded MT Bold", "PingFang TC", sans-serif;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -.07em;
}

.selection-card__hint { margin-bottom: 25px; color: rgba(18, 44, 40, .68); font-size: 13px; }

.avatar-picker {
  display: grid;
  grid-template-columns: repeat(5, minmax(52px, 1fr));
  gap: 10px;
  margin-bottom: 26px;
}

.avatar-card {
  position: relative;
  min-width: 0;
  padding: 8px 5px 10px;
  color: var(--pine);
  border: 1px solid rgba(31, 74, 58, .16);
  background: rgba(255, 248, 233, .45);
  transition: transform .2s ease, background .2s ease, border-color .2s ease;
}

.avatar-card:hover { transform: translateY(-4px); border-color: var(--moss); }
.avatar-card[aria-selected="true"] { color: var(--cream); border-color: var(--pine); background: var(--pine); transform: translateY(-5px) rotate(-2deg); }
.avatar-card img { display: block; width: min(100%, 66px); margin: 0 auto 5px; image-rendering: auto; }
.avatar-card span { display: block; overflow: hidden; font-size: 12px; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.avatar-card__tick { position: absolute; top: 4px; right: 5px; color: var(--sun); font: 700 11px ui-monospace, monospace; }

.primary-button, .secondary-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 52px;
  padding: 0 18px 0 21px;
  color: var(--cream);
  border: 0;
  background: var(--coral);
  font-weight: 800;
  letter-spacing: .04em;
  transition: transform .2s ease, background .2s ease;
}

.primary-button:hover { background: #bd5438; transform: translateY(-2px); }
.primary-button__arrow { font-size: 23px; font-weight: 400; }
.selection-card__credit { margin: 17px 0 0; color: rgba(18, 44, 40, .45); font: 10px ui-monospace, monospace; text-align: right; }

.game-screen { position: relative; overflow: hidden; background: #173a30; }
#world-canvas { display: block; width: 100%; height: 100vh; outline: none; }

.game-ui { position: absolute; inset: 0; pointer-events: none; }
.game-ui > * { pointer-events: auto; }

.journal-panel, .control-panel, .overlay-card, .interaction-prompt, .toast {
  border: 1px solid rgba(244, 233, 200, .36);
  box-shadow: 10px 14px 0 rgba(7, 23, 19, .16);
}

.journal-panel {
  position: absolute;
  top: 27px;
  left: 27px;
  width: 238px;
  padding: 18px 19px 16px;
  color: var(--ink);
  background: var(--paper);
  transform: rotate(-1.5deg);
}

.journal-panel__code { color: var(--coral); }
.journal-panel__rule { height: 1px; margin: 15px 0 14px; background: rgba(31, 74, 58, .25); }
.journal-count { display: flex; align-items: baseline; gap: 7px; color: var(--pine); }
.journal-count strong { color: var(--coral); font: 900 36px/1 "Arial Rounded MT Bold", sans-serif; letter-spacing: -.08em; }
.journal-count span { font-size: 12px; font-weight: 700; }
.journal-stamps { display: flex; flex-wrap: wrap; gap: 7px; min-height: 43px; margin-top: 13px; }
.journal-stamp { display: grid; place-items: center; width: 37px; height: 37px; overflow: hidden; border: 2px solid var(--moss); border-radius: 50%; background: rgba(168, 191, 130, .25); transform: rotate(-7deg); }
.journal-stamp:nth-child(2n) { transform: rotate(6deg); }
.journal-stamp img { width: 32px; height: 32px; }
.journal-panel__hint { margin: 13px 0 0; color: rgba(18, 44, 40, .6); font-size: 10px; line-height: 1.6; }
kbd { padding: 2px 4px; color: var(--cream); border-radius: 3px; background: var(--pine); font: 700 10px ui-monospace, monospace; }

.control-panel {
  position: absolute;
  top: 29px;
  right: 29px;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px 10px 11px;
  color: var(--paper);
  background: rgba(18, 44, 40, .83);
  backdrop-filter: blur(6px);
}

.control-panel__sun { display: grid; place-items: center; width: 25px; height: 25px; color: var(--sun); border: 1px solid rgba(244, 182, 68, .6); border-radius: 50%; font-size: 16px; }
.control-panel strong, .control-panel small { display: block; }
.control-panel strong { font-size: 12px; }
.control-panel small { margin-top: 3px; color: rgba(244, 233, 200, .65); font: 10px ui-monospace, monospace; }

.interaction-prompt {
  position: absolute;
  bottom: 38px;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 15px 10px 10px;
  color: var(--ink);
  background: var(--paper);
  font-size: 13px;
  font-weight: 800;
  transform: translateX(-50%);
  animation: prompt-in .3s ease both;
}

.interaction-prompt__key { display: grid; place-items: center; width: 27px; height: 27px; color: var(--cream); background: var(--coral); font: 800 12px ui-monospace, monospace; }

.overlay-card { position: absolute; color: var(--ink); background: var(--paper); }
.overlay-card__close { position: absolute; top: 11px; right: 13px; }
.icon-button { display: grid; place-items: center; width: 28px; height: 28px; padding: 0; color: var(--pine); border: 0; background: transparent; font-size: 25px; line-height: 1; }
.icon-button:hover { color: var(--coral); }

.discovery-card { right: 32px; bottom: 34px; width: min(410px, calc(100% - 48px)); padding: 24px 27px 19px; transform: rotate(1deg); }
.discovery-card__body { display: grid; grid-template-columns: 110px 1fr; gap: 22px; align-items: center; }
.discovery-card__visual { display: grid; place-items: center; width: 110px; height: 110px; border: 1px solid rgba(31, 74, 58, .22); background: rgba(168, 191, 130, .32); }
.discovery-card__visual img { width: 92px; height: 92px; }
.discovery-card__species, .dialogue-card__role { margin: 0 0 5px; color: var(--coral); font: 700 10px ui-monospace, monospace; letter-spacing: .12em; }
.discovery-card h2, .dialogue-card h2 { margin: 0 0 8px; font-family: "Arial Rounded MT Bold", "PingFang TC", sans-serif; font-size: 28px; letter-spacing: -.07em; }
.discovery-card__body p:last-child { margin: 0; color: rgba(18, 44, 40, .74); font-size: 13px; line-height: 1.75; }
.discovery-card__stamp { margin-top: 21px; padding-top: 10px; border-top: 1px dashed rgba(31, 74, 58, .34); color: var(--pine); font: 10px ui-monospace, monospace; }

.dialogue-card { left: 50%; bottom: 34px; width: min(560px, calc(100% - 48px)); padding: 23px 28px 21px; transform: translateX(-50%); }
.dialogue-card__header { display: flex; align-items: center; gap: 13px; margin-bottom: 15px; }
.dialogue-card__avatar { display: grid; place-items: center; width: 54px; height: 54px; overflow: hidden; border: 2px solid var(--moss); border-radius: 50%; background: rgba(168, 191, 130, .34); }
.dialogue-card__avatar img { width: 50px; height: 50px; }
.dialogue-card__avatar--human::before { width: 24px; height: 32px; border-radius: 46% 46% 42% 42%; content: ""; background: var(--coral); box-shadow: 0 -15px 0 -3px var(--sun); }
.dialogue-card__text { min-height: 48px; margin: 0 0 14px; color: rgba(18, 44, 40, .8); font-size: 15px; line-height: 1.8; }
.dialogue-card__actions { display: flex; flex-wrap: wrap; gap: 8px; }
.dialogue-choice, .dialogue-close { min-height: 39px; padding: 0 13px; color: var(--pine); border: 1px solid rgba(31, 74, 58, .35); background: transparent; font-size: 12px; font-weight: 800; }
.dialogue-choice:hover, .dialogue-close:hover { color: var(--cream); border-color: var(--pine); background: var(--pine); }

.toast { position: absolute; top: 98px; left: 50%; padding: 9px 14px; color: var(--cream); background: rgba(18, 44, 40, .88); font-size: 12px; transform: translateX(-50%); }

.loading-overlay { position: absolute; z-index: 5; inset: 0; display: grid; place-items: center; padding: 24px; background: rgba(18, 44, 40, .67); backdrop-filter: blur(9px); }
.loading-note { width: min(430px, 100%); padding: 38px 37px 34px; color: var(--ink); background: var(--paper); box-shadow: 15px 17px 0 rgba(7, 23, 19, .25); transform: rotate(-1deg); }
.loading-note__leaf { display: grid; place-items: center; width: 48px; height: 48px; margin-bottom: 19px; color: var(--cream); border-radius: 55% 45% 55% 45%; background: var(--moss); font-size: 24px; transform: rotate(-20deg); }
.loading-note h2 { margin-bottom: 8px; font-family: "Arial Rounded MT Bold", "PingFang TC", sans-serif; font-size: 30px; letter-spacing: -.06em; }
.loading-note p:not(.eyebrow) { color: rgba(18, 44, 40, .65); font-size: 13px; }
.loading-bar { height: 8px; margin-top: 25px; background: var(--paper-deep); }
.loading-bar span { display: block; width: 0; height: 100%; background: var(--coral); transition: width .3s ease; }
.secondary-button { justify-content: center; margin-top: 25px; background: var(--pine); }
.secondary-button:hover { background: var(--coral); }
.desktop-only-note { display: none; }

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

@media (max-width: 860px) {
  .start-layout { grid-template-columns: 1fr; gap: 42px; width: min(620px, calc(100% - 44px)); padding: 54px 0; }
  .intro-column { max-width: none; }
  .intro-copy { max-width: 520px; }
  .field-note--small { display: none; }
  .selection-card { transform: rotate(0); }
  .journal-panel { top: 16px; left: 16px; }
  .control-panel { top: 16px; right: 16px; }
}

@media (max-width: 560px) {
  body { overflow: auto; }
  .start-layout { width: min(100% - 30px, 430px); padding: 38px 0; }
  h1 { font-size: 68px; }
  .avatar-picker { gap: 5px; }
  .selection-card { padding: 25px 20px; }
  .selection-card__topline { font-size: 8px; }
  .control-panel, .journal-panel { display: none; }
  .desktop-only-note { position: absolute; right: 22px; bottom: 18px; left: 22px; display: block; padding: 9px 12px; color: var(--cream); background: rgba(18, 44, 40, .88); font-size: 11px; text-align: center; }
  .discovery-card, .dialogue-card { right: 16px; bottom: 16px; left: 16px; width: auto; transform: none; }
  .discovery-card__body { grid-template-columns: 78px 1fr; gap: 13px; }
  .discovery-card__visual { width: 78px; height: 78px; }
  .discovery-card__visual img { width: 68px; height: 68px; }
  .discovery-card h2, .dialogue-card h2 { font-size: 23px; }
  .dialogue-card { padding: 20px 20px 18px; }
}

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