:root {
  color-scheme: dark;
  --bg: #111711;
  --ink: #f7f2d7;
  --muted: #b7b08d;
  --panel: rgba(23, 31, 23, 0.94);
  --panel-2: rgba(31, 44, 31, 0.92);
  --line: #a47d43;
  --line-soft: rgba(164, 125, 67, 0.46);
  --accent: #f2b35d;
  --green: #77c871;
  --blue: #76b5e8;
  --red: #ef7463;
  --shadow: rgba(0, 0, 0, 0.38);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
  margin: 0;
}

body {
  background:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    radial-gradient(circle at 20% 10%, rgba(119, 200, 113, 0.18), transparent 28rem),
    #0f1410;
  background-size: 28px 28px, 28px 28px, auto, auto;
  color: var(--ink);
  font-family:
    "Malgun Gothic",
    "Apple SD Gothic Neo",
    system-ui,
    sans-serif;
  letter-spacing: 0;
}

button,
a {
  font: inherit;
}

button {
  color: inherit;
}

.monster-app {
  width: min(1480px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 16px;
  margin-bottom: 14px;
}

.back-link,
.sound-button,
.quick-actions button,
.move-pad button {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--line);
  background: #171d15;
  color: var(--ink);
  text-decoration: none;
  box-shadow: 0 4px 0 #070a07;
  cursor: pointer;
}

.back-link,
.sound-button {
  padding: 0 16px;
}

.back-link:focus-visible,
.sound-button:focus-visible,
.capsule-card:focus-visible,
.move-pad button:focus-visible,
.quick-actions button:focus-visible {
  outline: 3px solid #f6e58d;
  outline-offset: 3px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(1.25rem, 3vw, 2.15rem);
  line-height: 1.15;
}

h2 {
  margin-bottom: 0;
  font-size: 1rem;
  line-height: 1.25;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 410px);
  gap: 14px;
  align-items: start;
}

.play-panel,
.side-panel,
.panel-block {
  border: 2px solid var(--line-soft);
  background: var(--panel);
  box-shadow: 0 16px 36px var(--shadow);
}

.play-panel {
  padding: 12px;
}

.hud-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.hud-strip div {
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(247, 242, 215, 0.16);
  background: rgba(0, 0, 0, 0.22);
}

.hud-strip span,
.panel-heading span,
.objective-card small,
.dex-row small,
.log-list {
  color: var(--muted);
}

.hud-strip span {
  display: block;
  margin-bottom: 5px;
  font-size: 0.75rem;
}

.hud-strip strong {
  display: block;
  overflow: hidden;
  font-size: 1.04rem;
  line-height: 1.1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.canvas-wrap {
  position: relative;
  overflow: hidden;
  border: 3px solid #080b08;
  background: #263b26;
}

#field {
  display: block;
  width: 100%;
  aspect-ratio: 48 / 31;
  image-rendering: pixelated;
  touch-action: none;
}

.field-tip {
  position: absolute;
  left: 12px;
  bottom: 12px;
  max-width: min(520px, calc(100% - 24px));
  padding: 8px 10px;
  border: 1px solid rgba(247, 242, 215, 0.22);
  background: rgba(9, 13, 9, 0.72);
  color: var(--ink);
  font-size: 0.8rem;
}

.mobile-controls {
  display: none;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  margin-top: 10px;
}

.move-pad {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.move-pad button {
  min-width: 0;
  padding: 0 8px;
}

.move-pad button[data-move="up"] {
  grid-column: 2;
}

.move-pad button[data-move="left"] {
  grid-column: 1;
}

.move-pad button[data-move="down"] {
  grid-column: 2;
}

.move-pad button[data-move="right"] {
  grid-column: 3;
}

.quick-actions {
  display: grid;
  gap: 8px;
}

.quick-actions button {
  padding: 0 10px;
}

.side-panel {
  display: grid;
  max-height: calc(100dvh - 100px);
  gap: 10px;
  overflow: auto;
  padding: 10px;
  scrollbar-color: var(--line) rgba(0, 0, 0, 0.2);
}

.panel-block {
  padding: 12px;
  background: var(--panel-2);
}

.panel-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-heading span {
  flex: 0 0 auto;
  font-size: 0.78rem;
}

.capsule-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.capsule-card {
  min-height: 74px;
  border: 2px solid rgba(247, 242, 215, 0.14);
  background: rgba(0, 0, 0, 0.24);
  cursor: pointer;
}

.capsule-card.is-selected {
  border-color: var(--accent);
  background: rgba(242, 179, 93, 0.14);
}

.capsule-card span {
  display: block;
  font-size: 0.8rem;
  font-weight: 800;
}

.capsule-card small {
  color: var(--muted);
  font-size: 0.72rem;
}

.capsule-icon {
  width: 34px;
  height: 34px;
  margin: 0 auto 5px;
  border: 3px solid #111;
  border-radius: 50%;
  background:
    linear-gradient(var(--capsule-color) 0 47%, #111 47% 55%, #f7f2d7 55%),
    #f7f2d7;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.2);
}

.objective-card {
  padding: 10px;
  border: 1px solid rgba(247, 242, 215, 0.16);
  background: rgba(0, 0, 0, 0.22);
}

.objective-card strong {
  display: block;
  margin-bottom: 4px;
  color: var(--accent);
}

.objective-bar {
  height: 10px;
  margin-top: 8px;
  border: 1px solid rgba(247, 242, 215, 0.16);
  background: rgba(0, 0, 0, 0.35);
}

.objective-bar span {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--green), var(--accent));
}

.region-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.region-pill {
  min-height: 54px;
  padding: 8px;
  border: 1px solid rgba(247, 242, 215, 0.14);
  background: rgba(0, 0, 0, 0.2);
}

.region-pill.is-active {
  border-color: var(--accent);
}

.region-pill.is-locked {
  opacity: 0.52;
}

.region-pill strong,
.region-pill small {
  display: block;
}

.region-pill small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 0.72rem;
}

.dex-list {
  display: grid;
  max-height: 260px;
  gap: 6px;
  overflow: auto;
  padding-right: 4px;
}

.dex-row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  padding: 7px;
  border: 1px solid rgba(247, 242, 215, 0.12);
  background: rgba(0, 0, 0, 0.16);
}

.dex-dot {
  width: 24px;
  height: 24px;
  border: 2px solid #111;
  border-radius: 50%;
  background: var(--dot);
}

.dex-row strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dex-row small {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  font-size: 0.72rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dex-row.is-unknown {
  opacity: 0.56;
}

.log-list {
  display: grid;
  max-height: 150px;
  gap: 6px;
  margin: 0;
  overflow: auto;
  padding-left: 20px;
  font-size: 0.8rem;
}

.log-list li::marker {
  color: var(--accent);
}

@media (max-width: 1060px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .side-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: none;
  }
}

@media (max-width: 720px) {
  .monster-app {
    padding: 10px;
  }

  .topbar {
    grid-template-columns: 1fr auto;
  }

  .back-link {
    grid-column: 1 / -1;
    justify-self: start;
  }

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

  .side-panel {
    grid-template-columns: 1fr;
  }

  .mobile-controls {
    display: grid;
  }

  .field-tip {
    display: none;
  }

  .capsule-grid,
  .region-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 430px) {
  .topbar {
    gap: 10px;
  }

  .sound-button,
  .back-link {
    min-height: 40px;
    padding: 0 12px;
  }

  h1 {
    font-size: 1.18rem;
  }

  .mobile-controls {
    grid-template-columns: 1fr;
  }
}
