:root {
  --bg: #101515;
  --panel: #f5f0e7;
  --ink: #1d2523;
  --muted: #64706b;
  --line: rgba(29, 37, 35, 0.16);
  --player: #1f8f78;
  --enemy: #c44d58;
  --neutral: #d5bc69;
  --water: #9bc5d4;
  --focus: #f0b84f;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: radial-gradient(circle at top left, #2a4647, var(--bg) 52%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button {
  border: 0;
  border-radius: 8px;
  background: #253631;
  color: #fff;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
  min-height: 48px;
  padding: 0 14px;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

button:not(:disabled):active {
  transform: translateY(1px);
}

.app {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 100svh;
  padding: max(12px, env(safe-area-inset-top)) max(12px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(12px, env(safe-area-inset-left));
}

.topbar,
.status-strip,
.panel {
  background: var(--panel);
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.18);
}

.topbar {
  align-items: center;
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
}

.eyebrow,
.label {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0;
  margin: 0;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.15rem, 3vw, 1.7rem);
  line-height: 1.05;
  margin: 3px 0 0;
}

.icon-button {
  align-items: center;
  display: grid;
  flex: 0 0 48px;
  font-size: 1.35rem;
  padding: 0;
  place-items: center;
  width: 48px;
}

.status-strip {
  display: grid;
  gap: 1px;
  grid-template-columns: repeat(3, 1fr);
  overflow: hidden;
}

.status-strip > div {
  background: rgba(255, 255, 255, 0.32);
  min-width: 0;
  padding: 10px 12px;
}

.status-strip strong {
  display: block;
  font-size: 1rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.layout {
  display: grid;
  flex: 1;
  gap: 12px;
  grid-template-columns: minmax(0, 1fr) minmax(290px, 360px);
  min-height: 0;
}

.map-wrap {
  background: linear-gradient(145deg, #cfe3dc, var(--water));
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  min-height: 360px;
  overflow: hidden;
  position: relative;
}

.map {
  display: block;
  height: 100%;
  min-height: 360px;
  width: 100%;
}

.territory {
  cursor: pointer;
  filter: drop-shadow(0 5px 8px rgba(23, 32, 30, 0.2));
  stroke: rgba(15, 28, 26, 0.68);
  stroke-linejoin: round;
  stroke-width: 3;
  transition: filter 160ms ease, opacity 160ms ease, transform 160ms ease;
}

.territory.player {
  fill: var(--player);
}

.territory.enemy {
  fill: var(--enemy);
}

.territory.neutral {
  fill: var(--neutral);
}

.territory.selected {
  filter: drop-shadow(0 0 0 var(--focus)) drop-shadow(0 0 10px rgba(240, 184, 79, 0.9));
  stroke: #fff4c7;
  stroke-width: 5;
}

.territory.targetable {
  opacity: 0.78;
  stroke-dasharray: 8 7;
}

.troop-badge {
  fill: #fffaf0;
  stroke: rgba(20, 25, 24, 0.25);
  stroke-width: 2;
}

.troop-text,
.name-text {
  fill: #17201e;
  font-weight: 900;
  pointer-events: none;
  text-anchor: middle;
}

.troop-text {
  font-size: 21px;
}

.name-text {
  font-size: 15px;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
  padding: 12px;
}

.selected-card {
  border-bottom: 1px solid var(--line);
  min-height: 92px;
  padding-bottom: 10px;
}

.selected-card strong {
  display: block;
  font-size: 1.35rem;
  line-height: 1.1;
  margin-top: 4px;
}

.selected-card p {
  color: var(--muted);
  line-height: 1.35;
  margin: 6px 0 0;
}

.action-grid {
  display: grid;
  gap: 8px;
  grid-template-columns: 1fr 1fr;
}

.action-grid button:last-child {
  background: #6d4538;
  grid-column: 1 / -1;
}

.dice-tray {
  border-bottom: 1px solid var(--line);
  border-top: 1px solid var(--line);
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr 1fr;
  padding: 10px 0;
}

.dice-row {
  align-items: center;
  display: flex;
  gap: 5px;
  min-height: 34px;
}

.die {
  background: #fff;
  border: 1px solid rgba(29, 37, 35, 0.18);
  border-radius: 7px;
  display: grid;
  font-weight: 900;
  height: 30px;
  place-items: center;
  width: 30px;
}

.log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  margin: 0;
  min-height: 120px;
  overflow: auto;
  padding: 0;
}

.log li {
  background: rgba(255, 255, 255, 0.42);
  border: 1px solid rgba(29, 37, 35, 0.09);
  border-radius: 8px;
  color: #34413d;
  font-size: 0.9rem;
  line-height: 1.3;
  padding: 9px 10px;
}

@media (max-width: 760px) {
  .app {
    gap: 10px;
  }

  .layout {
    grid-template-columns: 1fr;
  }

  .map-wrap {
    min-height: 54svh;
  }

  .map {
    min-height: 54svh;
  }

  .panel {
    max-height: none;
  }

  .selected-card {
    min-height: 78px;
  }

  .log {
    max-height: 160px;
  }
}

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

  .status-strip strong {
    font-size: 0.94rem;
  }

  .map-wrap,
  .map {
    min-height: 48svh;
  }

  .name-text {
    font-size: 13px;
  }

  .troop-text {
    font-size: 19px;
  }
}
