* { box-sizing: border-box; }
:root { color-scheme: dark; font-family: Georgia, "Noto Serif CJK SC", "Microsoft YaHei", serif; }
body {
  margin: 0; min-height: 100vh; display: grid; place-items: center; padding: 12px;
  background: radial-gradient(ellipse at top, #40352a, #171815 76%); color: #e4d8b5;
}
.game-layout { width: min(960px, 100%, calc((100dvh - 68px) * 4 / 3)); }
.game-shell {
  width: 100%; aspect-ratio: 4 / 3; container-type: inline-size;
  position: relative; overflow: hidden; border: 2px solid #756348; background: #252520;
  box-shadow: 0 0 0 3px #171815, 0 12px 48px #0009;
}
canvas { width: 100%; height: 100%; display: block; touch-action: none; }
.overlay {
  position: absolute; inset: 0; display: grid; place-items: center;
  padding: 2.5cqw; background: #111810b5;
}
.overlay[hidden] { display: none; }
.overlay[data-phase="menu"] { background: transparent; padding: 0; }
.panel {
  width: 57%; padding: 3.5cqw 4.1cqw; text-align: center;
  background: url("./assets/ui/panel.png") center / 100% 132% no-repeat;
  filter: drop-shadow(0 12px 24px #0009);
}
h1 { margin: 0 0 1cqw; font-size: 3.3cqw; line-height: 1.4; color: #efdfaf; text-shadow: 0 2px 3px #000c; }
p { margin: 0 0 1.4cqw; line-height: 1.7; font-family: system-ui, sans-serif; font-size: 1.5cqw; color: #d1c9b4; }
.game-button {
  display: block; position: relative; width: 84%; height: 6.5cqw; margin: .6cqw auto 0; padding: .6cqw 2cqw;
  border: 0; background: url("./assets/ui/btn-small.png") center / 100% 170% no-repeat;
  color: #f2e4b9; font: 600 1.9cqw Georgia, "Noto Serif CJK SC", serif;
  cursor: pointer; text-shadow: 0 2px 3px #172321; transition: filter .15s, transform .15s;
}
.game-button:hover { filter: brightness(1.2); transform: translateY(-1px); }
.game-button:active { transform: translateY(1px); }
button:focus-visible { outline: 2px solid #f0d689; outline-offset: 2px; }
button:disabled { opacity: .5; cursor: wait; }
.game-button.primary { background-image: url("./assets/ui/btn-start.png"); background-size: 100% 190%; }
.menu-panel { position: absolute; inset: 0 auto 0 0; width: 49%; padding: 0; background: none; filter: none; }
.menu-panel h1 {
  position: absolute; left: 6%; top: 13%; width: 91%; height: 16%; margin: 0;
  display: flex; align-items: center; justify-content: center;
  background: url("./assets/ui/title.png") center / 100% 170% no-repeat;
  font-size: 4cqw; letter-spacing: .24cqw;
}
.menu-panel > p:not(.menu-help) { position: absolute; top: 32%; left: 8%; width: 88%; font-size: 1.55cqw; text-shadow: 0 2px 3px #000; }
.menu-panel .primary { position: absolute; top: 70%; left: 17%; width: 68%; height: 11%; margin: 0; font-size: 2.5cqw; letter-spacing: .6cqw; }
.menu-panel .menu-help { position: absolute; top: 84%; left: 7%; width: 92%; font-size: 1.35cqw; color: #e1d7b8; text-shadow: 0 2px 3px #000; }
.upgrade-panel { width: 65%; padding: 3.8cqw 4.8cqw; }
.upgrade-panel h1 { font-size: 2.7cqw; }
.upgrade-button {
  display: flex; align-items: center; gap: 1.4cqw; width: 100%; height: 8.7cqw;
  margin-top: .8cqw; padding: .9cqw 2.4cqw; text-align: left;
  background-image: url("./assets/ui/btn-start.png"); background-size: 100% 190%;
}
.upgrade-button img { width: 5.8cqw; height: 5.8cqw; flex: none; object-fit: contain; }
.upgrade-button > span { display: block; min-width: 0; line-height: 1.5; }
.option-name { display: block; font-size: 1.95cqw; color: #f5e6b6; }
.option-detail { display: block; font: 1.35cqw/1.5 system-ui, sans-serif; color: #d2d7c6; }
.result-icon { display: block; width: 16cqw; height: 16cqw; object-fit: contain; margin: .3cqw auto; }
.achievement-toast {
  position: absolute; right: 1.7cqw; bottom: 1.7cqw; z-index: 2;
  display: flex; align-items: center; gap: 1.3cqw; width: 33cqw; padding: 1.3cqw 1.6cqw;
  border: 1px solid #897445; border-left: .4cqw solid #e0bf69; border-radius: .5cqw;
  background: linear-gradient(115deg, #333a2f, #19231f 75%);
  box-shadow: 0 .5cqw 2cqw #0009, inset 0 1px #e9d89e1a;
  font-family: system-ui, sans-serif; pointer-events: none;
  animation: achievement-toast 6s ease both;
}
.achievement-toast[hidden] { display: none; }
.achievement-icon { width: 6.8cqw; height: 6.8cqw; flex: none; object-fit: contain; filter: drop-shadow(0 0 .7cqw #e3b84b40); }
.achievement-copy { display: grid; gap: .3cqw; min-width: 0; }
.achievement-caption { color: #b6c3ae; font-size: 1.1cqw; letter-spacing: .12cqw; }
.achievement-name { color: #f3df9c; font-size: 1.9cqw; line-height: 1.4; }
.achievement-detail { color: #c7cebf; font-size: 1.1cqw; line-height: 1.5; }
@keyframes achievement-toast {
  0% { transform: translateY(calc(100% + 2cqw)); opacity: 0; }
  8%, 91% { transform: translateY(0); opacity: 1; }
  100% { transform: translateY(calc(100% + 2cqw)); opacity: 0; }
}
.game-controls { display: flex; justify-content: flex-end; min-height: 36px; }
.game-controls button {
  width: auto; margin-top: 6px; padding: 5px 12px; font: 13px system-ui, sans-serif;
  background: #293630; border: 1px solid #796d50; border-radius: 3px; color: #d8ceb3; cursor: pointer;
}
.game-controls button:hover { background: #394b42; }
@media (prefers-reduced-motion: reduce) {
  .game-button { transition: none; }
  .achievement-toast { animation: none; }
}
