:root {
  color-scheme: light;
  --ink: #2d261f;
  --muted: #756b60;
  --paper: #eee5d5;
  --panel: #fff8e9;
  --line: #c8b899;
  --red: #a84232;
  --green: #3b6f5b;
  --gold: #b47b2e;
  --blue: #335f7b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #e9dec9 0%, #d9c6a8 100%);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
}

button {
  font: inherit;
}

#app {
  width: min(920px, calc(100vw - 28px));
  margin: 0 auto;
  padding: 16px 0 20px;
}

.hud,
.command-bar {
  display: grid;
  gap: 14px;
  background: rgba(255, 248, 233, 0.88);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  box-shadow: 0 12px 28px rgba(56, 42, 28, 0.12);
}

.hud {
  grid-template-columns: 1.1fr 1fr 1fr;
  align-items: center;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.seal {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: var(--red);
  color: #fff6e4;
  font-weight: 800;
  border: 3px double #f3dba9;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: 24px;
  line-height: 1.15;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.resources,
.status-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.resource,
.status-strip div {
  min-width: 0;
  border: 1px solid rgba(120, 98, 70, 0.25);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.42);
  padding: 8px 10px;
}

.resource span,
.status-strip span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.resource strong,
.status-strip strong {
  display: block;
  margin-top: 2px;
  font-size: 17px;
  line-height: 1.2;
  white-space: nowrap;
}

.battle-shell {
  position: relative;
  margin: 14px 0;
  border: 1px solid #a99572;
  border-radius: 8px;
  overflow: hidden;
  background: #c7b08e;
  box-shadow: inset 0 0 0 4px rgba(255, 248, 233, 0.36), 0 16px 38px rgba(54, 38, 22, 0.16);
}

canvas {
  display: block;
  width: 100%;
  aspect-ratio: 720 / 1040;
  touch-action: none;
}

canvas.drag-target {
  cursor: crosshair;
}

.command-bar {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.command-bar h2 {
  margin-bottom: 10px;
  font-size: 15px;
}

.button-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(128px, 1fr));
  gap: 8px;
}

.action-button {
  min-height: 76px;
  border: 1px solid #a89168;
  border-radius: 8px;
  background: #fff6e4;
  color: var(--ink);
  cursor: pointer;
  text-align: left;
  padding: 9px 10px;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.action-button.selected {
  border-color: #3b6f5b;
  background: #ecf6df;
  box-shadow: inset 0 0 0 2px rgba(59, 111, 91, 0.28);
}

.action-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #fffaf0;
}

.action-button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

.action-button.unavailable:not(:disabled) {
  border-style: dashed;
  background: #f3ead9;
  opacity: 0.72;
}

.action-button.unavailable:not(:disabled):hover {
  background: #f7eddb;
}

#unitButtons .action-button {
  touch-action: none;
}

.action-button.dragging {
  border-color: #3b6f5b;
  background: #e8f4df;
  transform: translateY(-1px) scale(0.99);
}

.action-button strong {
  display: block;
  font-size: 14px;
}

.action-button span {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.result-panel {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  text-align: center;
  background: rgba(45, 38, 31, 0.68);
  color: #fff7e8;
}

.result-panel.hidden {
  display: none;
}

.result-panel h2 {
  font-size: 34px;
}

.result-panel button {
  justify-self: center;
  border: 0;
  border-radius: 8px;
  background: #f1c36d;
  color: #2d261f;
  font-weight: 700;
  padding: 10px 18px;
  cursor: pointer;
}

@media (max-width: 860px) {
  #app {
    width: min(100vw - 16px, 1200px);
    padding-top: 8px;
  }

  .hud,
  .command-bar {
    grid-template-columns: 1fr;
  }

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