
:root {
  color-scheme: dark;
  font-family: "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
  background: #141a17;
  color: #edeee0;
  -webkit-tap-highlight-color: transparent;
  --ink: #101713;
  --panel: #202a23;
  --line: #566451;
  --muted: #aeb9a6;
  --green: #c8eea8;
  --copper: #f0ac85;
  --mono: Consolas, "SFMono-Regular", monospace;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-width: 240px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  display: grid;
  justify-items: center;
  overflow: hidden;
  overscroll-behavior: none;
  background:
    radial-gradient(ellipse at 50% 72%, #48574744, transparent 71%),
    repeating-linear-gradient(0deg, #64766110 0 1px, transparent 1px 32px),
    repeating-linear-gradient(90deg, #64766110 0 1px, transparent 1px 32px),
    #171d1a;
}

.game {
  position: relative;
  isolation: isolate;
  width: min(100vw, 70vh, 36rem);
  width: min(100vw, 70dvh, 36rem);
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background: #29362e;
  box-shadow: 0 0 72px #0d120fe5, 0 0 0 1px #626e5b;
  user-select: none;
}
@media (max-width: 600px) and (orientation: portrait) {
  .game { width: 100%; }
}
canvas { display: block; width: 100%; height: 100%; touch-action: none; }
button { cursor: pointer; font: inherit; color: inherit; touch-action: manipulation; }
button:focus-visible { outline: 3px solid #e3fabb; outline-offset: 3px; }

.hud {
  position: absolute;
  inset: max(12px, env(safe-area-inset-top)) 12px auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 8px 6px;
  pointer-events: none;
}
.hud-info, .icon-button, .loadout {
  border: 1px solid #a4b39a7c;
  background: #202923f5;
  box-shadow: 3px 3px 0 #0e17137a;
}
.hud-info { padding: 8px 10px 9px; min-width: 0; max-width: 100%; justify-self: start; border-left: 3px solid #bcdb9b; }
.hud-location { display: flex; flex-wrap: wrap; align-items: baseline; gap: 3px 8px; }
.hud-location b { color: #f2f2df; font-size: .98rem; font-weight: 900; }
.wave { display: block; color: #c4d8b2; font-size: .75rem; font-weight: 700; }
.hud-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 3px 10px;
  margin-top: 5px;
  color: #b8c3b0;
  font-size: .78rem;
}
.hud-stats strong { color: #f0f0e1; font: 800 1.03em var(--mono); }
.hud-stats #shield strong { color: #b6eeb7; }
.hud-stats #hud-haul { color: #f4c197; }
.hud-stats #hud-pending-value { color: #dac898; }
.hud-score { display: flex; align-items: baseline; gap: 7px; margin-top: 5px; color: #c6d6bc; font-size: .76rem; }
.hud-score strong { color: #d7f7b3; font: 800 1.1rem var(--mono); }
.hud-right { display: grid; justify-items: end; flex: none; gap: 8px; }
.hud-actions { display: flex; gap: 6px; pointer-events: auto; }
.icon-button { width: 39px; height: 39px; display: grid; place-items: center; padding: 8px; }
.icon-button:hover, .secondary:hover { background: #394b3c; }
.icon-button svg { width: 20px; height: 20px; }
#sound[aria-pressed="true"] .sound-off,
#sound[aria-pressed="false"] .sound-on { display: none; }

.loadout {
  min-width: 104px;
  height: 40px;
  padding: 2px 7px 2px 1px;
  display: flex;
  align-items: center;
  border-right: 3px solid #a1bf92;
  pointer-events: none;
}
.loadout img { image-rendering: pixelated; width: 61px; height: 30px; }
.loadout div { display: grid; text-align: right; }
.loadout strong { font: 800 .92rem var(--mono); color: #edf2d6; }
.loadout span { color: #aabf9f; font-size: .68rem; font-weight: 700; }

.notice, .hint {
  max-width: 94%;
  width: max-content;
  text-align: center;
  background: #202a23f7;
  pointer-events: none;
  color: #e9edd6;
}
.notice {
  grid-column: 1 / -1;
  justify-self: center;
  padding: 6px 11px;
  border: 1px solid #aebf9ba0;
  border-left: 3px solid #c5e7a9;
  font-weight: 800;
  font-size: .88rem;
}
.hint {
  position: absolute;
  left: 50%;
  bottom: max(9px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  padding: 6px 12px;
  color: #e4e7d5;
  font-size: .78rem;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-items: safe center;
  padding: 16px;
  overflow: auto;
  background: linear-gradient(180deg, #16211c45, #17221dd9 74%);
}
.overlay[data-mode="ready"] {
  align-items: end;
  padding-bottom: max(8dvh, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, #1b2a2220 15%, #1b2a224c 41%, #17221df2 100%);
}
.panel {
  position: relative;
  width: min(100%, 25rem);
  border: 1px solid #a4b4988f;
  border-top: 3px solid #c7e1a9;
  padding: clamp(15px, 3vh, 24px) clamp(12px, 4vw, 23px) 18px;
  background: linear-gradient(135deg, #303b31fa, #222b24fa 58%);
  box-shadow: 6px 6px 0 #11191485, 0 14px 35px #11171380;
}
.panel::before, .panel::after {
  position: absolute;
  content: "";
  bottom: -1px;
  width: 14px;
  height: 12px;
  border: 2px solid #b4c5a4;
  border-top: 0;
  pointer-events: none;
}
.panel::before { left: -1px; border-right: 0; }
.panel::after { right: -1px; border-left: 0; }

h1 {
  margin: 0;
  font-size: clamp(1.9rem, 8vw, 3.1rem);
  color: #f8f5e4;
  font-weight: 950;
  letter-spacing: .07em;
  line-height: 1.13;
}
.panel p { margin: 9px 0 0; color: #d1dac5; font-size: .92rem; }

.guide, .results { display: grid; gap: 6px; margin: 17px 0 0; }
.guide { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.results { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.guide span, .results div {
  border: 1px solid #a7b79b39;
  border-left: 2px solid #a7c491;
  background: #1d2721;
  padding: 7px 6px;
  font-size: .76rem;
  color: #bdc8b5;
}
.guide strong, .results dd { display: block; color: #edf0dd; font-weight: 800; margin: 3px 0 0; }
.guide span:nth-child(2) { border-left-color: #8fbbbb; }
.guide span:nth-child(3), .results div:nth-child(4) { border-left-color: #db9272; }
.results div:nth-child(4) dd { color: #fac496; }

.scorecard { margin-top: 16px; border: 1px solid #a7c49178; background: #19231d; }
.score-overview, .score-breakdown { display: grid; margin: 0; }
.score-overview { grid-template-columns: 1.25fr 1fr; }
.score-breakdown { grid-template-columns: repeat(3, 1fr); border-top: 1px solid #a7b79b39; }
.scorecard dl div { padding: 7px 8px; min-width: 0; }
.scorecard dl div + div { border-left: 1px solid #a7b79b39; }
.scorecard dt { color: #bac8b4; font-size: .76rem; }
.scorecard dd { margin: 2px 0 0; font: 800 .97rem var(--mono); overflow-wrap: anywhere; }
.score-overview dd { color: #c8eea8; font-size: 1.5rem; }
.score-breakdown div:last-child dd { color: #fac496; }
.panel .score-rule { margin: 0; padding: 3px 8px 8px; color: #aeb9a6; font-size: .72rem; }

.primary, .secondary {
  width: 100%;
  min-height: 42px;
  font-weight: 900;
  letter-spacing: .06em;
}
.primary {
  margin-top: 17px;
  border: 1px solid #eef9cd;
  background: #c8e7a5;
  color: #182419;
  box-shadow: 0 3px 0 #697f58;
}
.primary:hover { background: #d7f2bb; }
.primary:active { translate: 0 2px; box-shadow: 0 1px 0 #697f58; }
.secondary { margin-top: 9px; border: 1px solid #879883; background: #303d32; }
.panel .controls { margin-top: 13px; color: #c0c9b8; font-size: .76rem; letter-spacing: .015em; }

.support-button {
  min-height: 42px;
  padding: 7px 11px;
  border: 1px solid #ffdd8e;
  background: #ecb75d;
  color: #21190b;
  font-weight: 900;
  box-shadow: 0 3px 0 #784c2b;
}
.support-button:hover { background: #ffcc76; }
.support-button.support-active { background: #b2dea0; border-color: #d7f6c6; box-shadow: 0 3px 0 #466042; }
.panel-support { display: grid; justify-items: center; gap: 2px; width: 100%; margin-top: 14px; }
.panel-support small { font-size: .76rem; font-weight: 800; }
.panel-support + .primary { margin-top: 10px; }
#field-support { max-width: 118px; min-height: 34px; font-size: .76rem; line-height: 1.2; pointer-events: auto; }
.text-button {
  min-height: 36px;
  padding: 4px 9px;
  border: 1px solid #82967d;
  background: #2d3b30;
  color: #e6f1d9;
  font-size: .82rem;
  font-weight: 800;
}
.text-button:hover { background: #3d5140; }
#score-upload-retry { margin: 0 8px 8px; }
#score-upload-status:empty, .rank-mine:empty { display: none; }

.toy-dialog {
  width: min(24rem, calc(100vw - 28px));
  max-height: calc(100dvh - 24px);
  padding: 16px;
  overflow: auto;
  border: 1px solid #82967d;
  border-top: 3px solid #c5e2a9;
  background: #202a23;
  color: #edf4df;
  box-shadow: 6px 6px 0 #101914b5;
}
.toy-dialog::backdrop { background: #0e1612cc; }
.toy-dialog-heading { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.toy-dialog h2 { margin: 0; font-size: 1.25rem; }
.toy-dialog p { margin: 10px 0; color: #cbd6c4; font-size: .875rem; }
.toy-dialog .support-button { width: 100%; }
.toy-dialog .toy-status { color: #f3d7a3; }
.toy-dialog button:disabled { opacity: .62; cursor: default; }
.support-conditions { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin: 12px 0; padding: 0; list-style: none; }
.support-conditions li { padding: 7px; background: #17211b; color: #c0ceba; font-size: .78rem; }
.support-conditions li[data-verified="true"] { color: #c7efac; }
.rank-rows { display: grid; gap: 4px; margin: 10px 0; padding: 0; max-height: 48dvh; overflow-y: auto; list-style: none; }
.rank-rows li { display: grid; grid-template-columns: 2.2rem minmax(0, 1fr) auto; gap: 5px; align-items: center; min-height: 34px; padding: 4px 7px; background: #17211b; }
.rank-rows li span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .86rem; }
.rank-rows li img { display: inline-block; width: 24px; height: 24px; margin-right: 5px; object-fit: cover; vertical-align: middle; }
.rank-rows li strong { color: #c6eca0; font-family: var(--mono); }

@media (max-width: 360px) {
  .hud-location { display: grid; }
  .hud-info { padding: 6px 7px; }
  .hud-stats { gap: 4px 7px; }
  .icon-button { width: 35px; height: 35px; }
}
@media (max-height: 470px) {
  .game { width: min(100vw, 95vh, 30rem); }
  .overlay[data-mode="ready"] { align-items: center; padding-bottom: 12px; }
  .panel { padding: 10px; }
  .guide, .results, .primary { margin-top: 10px; }
  .scorecard { margin-top: 10px; }
  .hint { bottom: 4px; }
}

