:root {
  color-scheme: dark;
  font-family: "Arial Black", "Microsoft YaHei", system-ui, sans-serif;
  --ink: #17231c;
  --cream: #fff4c5;
  --gold: #ffc43d;
  --red: #ee5a48;
  --blue: #5aa7ff;
}

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

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background: #1a2c22;
  touch-action: none;
  user-select: none;
}

body::before {
  position: fixed;
  inset: -28px;
  content: "";
  background:
    linear-gradient(rgba(19, 34, 25, 0.72), rgba(13, 22, 18, 0.9)),
    repeating-linear-gradient(135deg, #2f4737 0 18px, #293f31 18px 36px);
  filter: blur(14px) saturate(0.78);
  transform: scale(1.08);
}

body::after {
  position: fixed;
  inset: 0;
  content: "";
  background:
    linear-gradient(90deg, rgba(7, 14, 10, 0.78), transparent 30%, transparent 70%, rgba(7, 14, 10, 0.78)),
    repeating-linear-gradient(0deg, rgba(255,255,255,0.015) 0 1px, transparent 1px 5px);
  pointer-events: none;
}

.app-shell {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100dvh;
  min-height: 540px;
  padding: max(10px, env(safe-area-inset-top)) 10px max(10px, env(safe-area-inset-bottom));
}

.game-frame {
  position: relative;
  width: min(calc(100dvh * 0.524), 100vw - 20px, 510px);
  aspect-ratio: 430 / 820;
  overflow: hidden;
  border: 2px solid rgba(255, 244, 197, 0.48);
  border-radius: 8px;
  background: #314d3a;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(0, 0, 0, 0.5);
  contain: layout paint;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  background: #314d3a;
  cursor: grab;
}

canvas:active {
  cursor: grabbing;
}

.utility {
  position: absolute;
  z-index: 4;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 7px;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 2px solid rgba(23, 35, 28, 0.86);
  border-radius: 7px;
  color: #17231c;
  background: rgba(255, 244, 197, 0.92);
  box-shadow: 0 3px 0 rgba(23, 35, 28, 0.76);
  font: 900 18px/1 Arial, sans-serif;
  cursor: pointer;
}

.icon-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(23, 35, 28, 0.76);
}

.icon-button[hidden] {
  display: none;
}

.overlay {
  position: absolute;
  z-index: 5;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    linear-gradient(rgba(25, 42, 32, 0.82), rgba(12, 23, 17, 0.96)),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.025) 0 2px, transparent 2px 10px);
  transition: opacity 180ms ease;
}

.overlay[hidden] {
  display: none;
}

.panel {
  width: 100%;
  padding: 28px 22px 22px;
  border: 3px solid #17231c;
  border-radius: 8px;
  color: #17231c;
  background: #fff4c5;
  box-shadow: 0 9px 0 rgba(23, 35, 28, 0.9);
  text-align: center;
}

.eyebrow {
  margin: 0 0 7px;
  color: #50705a;
  font: 800 12px/1.2 "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: clamp(36px, 10vw, 54px);
  line-height: 0.96;
  letter-spacing: 0;
  text-shadow: 3px 3px 0 #ffc43d;
}

.tagline {
  margin: 15px auto 20px;
  color: #3a5544;
  font: 800 14px/1.6 "Microsoft YaHei", sans-serif;
}

.primary-button,
.secondary-button {
  width: 100%;
  min-height: 50px;
  border: 3px solid #17231c;
  border-radius: 7px;
  font: 900 18px/1 "Microsoft YaHei", sans-serif;
  cursor: pointer;
}

.primary-button {
  color: #17231c;
  background: #ffc43d;
  box-shadow: 0 5px 0 #a3601f;
}

.secondary-button {
  margin-top: 12px;
  color: #fff4c5;
  background: #3a5544;
  box-shadow: 0 5px 0 #17231c;
}

.primary-button:active,
.secondary-button:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #17231c;
}

.result-stat {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin: 18px 0;
  color: #3a5544;
  font: 900 14px/1.4 "Microsoft YaHei", sans-serif;
}

.result-stat strong {
  color: #d06b2f;
}

.choice-overlay {
  background: rgba(12, 24, 17, 0.9);
}

.choice-panel {
  padding: 22px 16px 18px;
}

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

.choice-button {
  display: grid;
  grid-template-columns: 42px 1fr;
  align-items: center;
  width: 100%;
  min-height: 62px;
  padding: 8px 12px;
  border: 3px solid #17231c;
  border-radius: 7px;
  color: #17231c;
  background: #ffffff;
  box-shadow: 0 3px 0 #7d8a78;
  text-align: left;
  cursor: pointer;
}

.choice-button:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #7d8a78;
}

.choice-mark {
  font: 900 22px/1 "Arial Black", sans-serif;
  text-align: center;
}

.choice-copy strong,
.choice-copy span {
  display: block;
}

.choice-copy strong {
  font: 900 15px/1.3 "Microsoft YaHei", sans-serif;
}

.choice-copy span {
  margin-top: 3px;
  color: #526457;
  font: 700 11px/1.4 "Microsoft YaHei", sans-serif;
}

.refresh-button {
  min-height: 44px;
  margin-top: 14px;
  font-size: 14px;
}

.refresh-button:disabled {
  color: #858c82;
  background: #465148;
  box-shadow: 0 3px 0 #26332c;
  cursor: not-allowed;
  transform: none;
}

.help-panel {
  max-height: 100%;
  padding: 22px 18px 18px;
  overflow-y: auto;
}

.help-list {
  display: grid;
  gap: 8px;
  margin: 18px 0;
  text-align: left;
}

.help-list div {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(23, 35, 28, 0.22);
}

.help-list strong,
.help-list span {
  display: block;
}

.help-list strong {
  font: 900 13px/1.3 "Microsoft YaHei", sans-serif;
}

.help-list span {
  margin-top: 2px;
  color: #526457;
  font: 700 11px/1.45 "Microsoft YaHei", sans-serif;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

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

  .game-frame {
    width: min(calc(100dvh * 0.524), 100vw);
    max-width: none;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .utility {
    top: max(10px, env(safe-area-inset-top));
  }
}
