:root {
  --bg: #08110d;
  --bg-deep: #040a07;
  --panel: rgba(16, 27, 21, 0.92);
  --panel-strong: rgba(11, 20, 16, 0.97);
  --line: rgba(163, 136, 82, 0.5);
  --line-soft: rgba(196, 173, 121, 0.28);
  --text: #f4ead2;
  --muted: #d5c8a6;
  --accent: #d2b16f;
  --accent-2: #6fa67d;
  --accent-3: #9cc7b2;
  --shadow: rgba(0, 0, 0, 0.42);
}

* { box-sizing: border-box; }

html {
  background: var(--bg-deep);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif JP", serif;
  background:
    radial-gradient(circle at top, rgba(168, 125, 61, 0.16), transparent 24%),
    radial-gradient(circle at bottom right, rgba(76, 120, 91, 0.18), transparent 26%),
    linear-gradient(180deg, rgba(8, 17, 13, 0.94), rgba(4, 10, 7, 0.98)),
    repeating-linear-gradient(
      45deg,
      rgba(255, 255, 255, 0.015) 0,
      rgba(255, 255, 255, 0.015) 10px,
      transparent 10px,
      transparent 20px
    );
  position: relative;
}

body::before,
body::after {
  content: "";
  position: fixed;
  left: 0;
  width: 100%;
  height: 18px;
  pointer-events: none;
  opacity: 0.75;
  background:
    radial-gradient(circle at 9px 9px, transparent 0 5px, rgba(210, 177, 111, 0.75) 5px 6px, transparent 6px),
    linear-gradient(90deg, transparent 0 14px, rgba(210, 177, 111, 0.75) 14px 22px, transparent 22px 36px);
  background-size: 36px 18px;
  z-index: 0;
}

body::before { top: 0; }
body::after { bottom: 0; transform: scaleY(-1); }

button,
input,
textarea,
select {
  font: inherit;
}

.app {
  position: relative;
  z-index: 1;
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 36px;
}

.hero-panel {
  position: relative;
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: end;
  padding: 28px 30px;
  margin-bottom: 20px;
  background:
    linear-gradient(135deg, rgba(36, 55, 43, 0.95), rgba(16, 27, 21, 0.98)),
    linear-gradient(0deg, rgba(244, 234, 210, 0.06), rgba(244, 234, 210, 0.06));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 20px 64px var(--shadow), inset 0 0 0 1px rgba(255, 248, 230, 0.05);
  overflow: hidden;
}

.hero-panel::before,
.hero-panel::after {
  content: "";
  position: absolute;
  inset: 12px;
  border-radius: 18px;
  border: 1px solid var(--line-soft);
  pointer-events: none;
}

.hero-panel::after {
  inset: auto 22px 12px auto;
  width: 112px;
  height: 112px;
  border-radius: 50%;
  border: 1px solid rgba(210, 177, 111, 0.16);
  background:
    radial-gradient(circle, transparent 49%, rgba(210, 177, 111, 0.3) 50% 51%, transparent 52%),
    conic-gradient(from 0deg, rgba(210, 177, 111, 0.32) 0 25%, transparent 25% 50%, rgba(210, 177, 111, 0.32) 50% 75%, transparent 75% 100%);
  opacity: 0.65;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.82rem;
}

h1 {
  margin: 0;
  font-size: clamp(2.2rem, 4vw, 3.5rem);
  letter-spacing: 0.04em;
  text-shadow: 0 2px 16px rgba(0, 0, 0, 0.35);
}

.lead {
  max-width: 900px;
  margin: 12px 0 0;
  line-height: 1.9;
  color: var(--muted);
}

.hero-ornament {
  margin: 14px 0 0;
  color: #e7d5a8;
  letter-spacing: 0.08em;
  font-size: 0.95rem;
  opacity: 0.9;
}

.hero-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: end;
}

button {
  min-width: 180px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 1px solid rgba(214, 183, 118, 0.55);
  background:
    linear-gradient(180deg, rgba(110, 80, 42, 0.95), rgba(65, 49, 27, 0.98));
  color: var(--text);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.26), inset 0 1px 0 rgba(255, 245, 220, 0.15);
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.15s ease, box-shadow 0.15s ease;
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
  box-shadow: 0 14px 28px rgba(0, 0, 0, 0.32), inset 0 1px 0 rgba(255, 245, 220, 0.2);
}

.content-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 20px;
}

.game-panel,
.side-panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(15, 24, 20, 0.97), rgba(9, 15, 12, 0.96));
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
}

.game-panel::before,
.side-panel::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 18px;
  border: 1px solid var(--line-soft);
  pointer-events: none;
}

.game-panel {
  padding: 14px;
}

#game-container {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 604px;
  border-radius: 16px;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 0%, rgba(154, 121, 63, 0.18), transparent 28%),
    linear-gradient(180deg, #08100c, #0f1713);
}

#game-container canvas {
  display: block;
  max-width: 100%;
  height: auto !important;
}

.side-panel {
  padding: 18px;
}

.panel-block + .panel-block {
  margin-top: 18px;
}

.panel-block {
  position: relative;
  padding: 18px 16px;
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(27, 40, 31, 0.96), rgba(15, 23, 18, 0.98));
  border: 1px solid rgba(184, 154, 99, 0.24);
}

.panel-block::before {
  content: "";
  position: absolute;
  inset: 8px;
  border-radius: 12px;
  border: 1px dashed rgba(184, 154, 99, 0.16);
  pointer-events: none;
}

.panel-block h2 {
  margin: 0 0 12px;
  font-size: 1.02rem;
  color: #f6deb0;
  letter-spacing: 0.06em;
}

.panel-block ul {
  margin: 0;
  padding-left: 1.2rem;
  color: var(--muted);
  line-height: 1.85;
}

.controls-list {
  margin: 0;
  display: grid;
  gap: 10px;
}

.controls-list div {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  color: var(--muted);
}

.controls-list dt {
  color: var(--text);
  font-weight: 700;
}

.controls-list dd {
  margin: 0;
}

.legend-list {
  list-style: none;
  padding: 0;
}

.legend-note {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.7;
}

.legend-list li {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  color: var(--muted);
}

.legend-list li span:last-child {
  line-height: 1.6;
}

.legend-swatch {
  position: relative;
  width: 28px;
  height: 28px;
  flex: 0 0 28px;
  border-radius: 8px;
  display: inline-block;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,0.12), 0 4px 10px rgba(0,0,0,0.25);
}

.legend-swatch::before,
.legend-swatch::after {
  content: "";
  position: absolute;
}

.legend-swatch.hero { background: linear-gradient(180deg, #f8e3a6, #b98b3d); }
.legend-swatch.hero::before {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f2d27e;
  left: 9px;
  top: 4px;
}
.legend-swatch.hero::after {
  width: 16px;
  height: 10px;
  border-radius: 6px;
  background: #7d4121;
  left: 6px;
  top: 14px;
}

.legend-swatch.soldier { background: linear-gradient(180deg, #97c28d, #335f41); }
.legend-swatch.soldier::before {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #8eb48e;
  left: 9px;
  top: 4px;
}
.legend-swatch.soldier::after {
  width: 18px;
  height: 9px;
  border-radius: 6px;
  background: #234231;
  left: 5px;
  top: 15px;
}

.legend-swatch.knight { background: linear-gradient(180deg, #cfe4c8, #587d54); }
.legend-swatch.knight::before {
  width: 12px;
  height: 9px;
  background: #dceec5;
  left: 8px;
  top: 4px;
  clip-path: polygon(0 100%, 50% 0, 100% 100%);
}
.legend-swatch.knight::after {
  width: 18px;
  height: 9px;
  border-radius: 6px;
  background: #3f5f2f;
  left: 5px;
  top: 15px;
}

.legend-swatch.mage { background: linear-gradient(180deg, #b7d7d5, #2e4c57); }
.legend-swatch.mage::before {
  width: 12px;
  height: 12px;
  background: #8ac2b8;
  left: 8px;
  top: 3px;
  clip-path: polygon(50% 0, 100% 100%, 0 100%);
}
.legend-swatch.mage::after {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #e7f8f4;
  right: 4px;
  top: 5px;
}

.legend-swatch.priest { background: linear-gradient(180deg, #f2edd4, #7d684d); }
.legend-swatch.priest::before {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #f9f0a8;
  left: 9px;
  top: 4px;
}
.legend-swatch.priest::after {
  width: 12px;
  height: 12px;
  left: 8px;
  top: 13px;
  background: linear-gradient(90deg, transparent 4px, #ffffff 4px, #ffffff 8px, transparent 8px),
              linear-gradient(180deg, transparent 5px, #ffffff 5px, #ffffff 7px, transparent 7px);
}

.legend-swatch.boss { background: linear-gradient(180deg, #a6c57e, #355544); }
.legend-swatch.boss::before {
  width: 18px;
  height: 12px;
  left: 5px;
  top: 6px;
  background: #588f78;
  clip-path: polygon(50% 0, 100% 40%, 84% 100%, 16% 100%, 0 40%);
}
.legend-swatch.boss::after {
  width: 8px;
  height: 8px;
  left: 10px;
  top: 9px;
  background: radial-gradient(circle, #ffcf5d 0 2px, transparent 3px), radial-gradient(circle, #ffcf5d 0 2px, transparent 3px);
  background-size: 8px 8px;
}

.legend-swatch.sword { background: linear-gradient(180deg, #f9e7a6, #8d6b2b); }
.legend-swatch.sword::before {
  width: 4px;
  height: 17px;
  left: 12px;
  top: 4px;
  background: #dce7eb;
}
.legend-swatch.sword::after {
  width: 14px;
  height: 4px;
  left: 7px;
  top: 16px;
  background: #7f5e21;
  border-radius: 2px;
}

@media (max-width: 1080px) {
  .content-grid {
    grid-template-columns: 1fr;
  }

  .hero-panel {
    align-items: start;
    flex-direction: column;
  }

  .hero-actions {
    justify-content: start;
  }
}

@media (max-width: 640px) {
  .app {
    width: min(100% - 20px, 1320px);
    padding-top: 18px;
  }

  .hero-panel,
  .game-panel,
  .side-panel {
    border-radius: 18px;
  }

  button {
    min-width: 0;
    width: 100%;
  }

  .controls-list div {
    grid-template-columns: 64px 1fr;
  }
}
