:root {
  --tile-w: 120px;
  --tile-h: 150px;
  --gap: 6px;
  --bg: #1e2530;
  --tile-bg: #2c3543;
  --tile-border: #3e4a5e;
  --text: #e6e9ef;
  --muted: #98a2b3;
  --accent: #7cc5ff;
  --forward: #5cd49a;
  --back: #ef6f6c;
  --piece: #ffd166;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  background: var(--bg);
  padding: 12px 16px;
  border-bottom: 1px solid var(--tile-border);
}

.topbar h1 {
  margin: 0 0 8px;
  font-size: 18px;
  font-weight: 600;
}

.players, .dice {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-bottom: 8px;
}

.players label, .dice label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

.players input[type="text"],
.dice input[type="number"] {
  background: var(--tile-bg);
  color: var(--text);
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  padding: 4px 8px;
  font-size: 14px;
  width: 140px;
}

.dice input[type="number"] { width: 64px; }

.dice button {
  background: var(--accent);
  color: #0d1117;
  border: none;
  border-radius: 4px;
  padding: 6px 14px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.dice button:hover { filter: brightness(1.1); }

.dice button.danger {
  background: transparent;
  color: var(--back);
  border: 1px solid var(--back);
}

.position {
  margin: 0;
  font-size: 14px;
  color: var(--accent);
}

.board {
  display: grid;
  grid-template-columns: repeat(11, var(--tile-w));
  grid-auto-rows: var(--tile-h);
  gap: var(--gap);
  padding: 16px;
  justify-content: start;
}

.tile {
  position: relative;
  background: var(--tile-bg);
  border: 1px solid var(--tile-border);
  border-radius: 6px;
  padding: 4px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  overflow: hidden;
}

.tile.start { background: #324259; }
.tile.action-forward { border-color: var(--forward); }
.tile.action-back { border-color: var(--back); }

.tile .num {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(0,0,0,0.4);
  padding: 1px 5px;
  border-radius: 8px;
}

.tile .img-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 14px;
  margin-bottom: 2px;
  overflow: hidden;
}

.tile img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  image-rendering: -webkit-optimize-contrast;
}

.tile .label {
  font-size: 11px;
  text-align: center;
  line-height: 1.15;
  color: var(--text);
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 2px;
}

.tile select {
  width: 100%;
  background: #1a212c;
  color: var(--text);
  border: 1px solid var(--tile-border);
  border-radius: 4px;
  font-size: 11px;
  padding: 2px;
  margin-top: 2px;
}

.tile.has-piece {
  outline: 3px solid var(--piece);
  outline-offset: -3px;
}

.placeholder-icon {
  font-size: 32px;
  color: var(--muted);
}

.tile .img-wrap,
.tile .label {
  cursor: pointer;
}

.tile.pinned {
  outline: 2px dashed var(--accent);
  outline-offset: -2px;
}

.details-popover {
  position: absolute;
  z-index: 50;
  min-width: 220px;
  max-width: 320px;
  max-height: 70vh;
  overflow-y: auto;
  background: #11161f;
  color: var(--text);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 10px 12px 12px;
  font-size: 12px;
  line-height: 1.35;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  pointer-events: none;
}

.details-popover.pinned {
  pointer-events: auto;
  border-color: var(--piece);
}

.details-popover.hidden {
  display: none;
}

.details-popover .details-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent);
  margin: 0 0 6px;
}

.details-popover.pinned .details-title {
  color: var(--piece);
}

.details-popover .details-note {
  font-style: italic;
  color: var(--muted);
  margin: 0 0 8px;
}

.details-popover ul {
  margin: 0;
  padding-left: 18px;
}

.details-popover li {
  margin: 1px 0;
}

.details-popover .details-empty {
  color: var(--muted);
  font-style: italic;
}

.details-popover .details-hint {
  margin-top: 8px;
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
