:root {
  color-scheme: dark;
  --bg: #101c19;
  --bg-deep: #0b1411;
  --panel: #182721;
  --panel-light: #1d3028;
  --line: #314137;
  --text: #ebece0;
  --muted: #9cae9e;
  --gold: #d6bc80;
  --gold-deep: #b8985a;
  --green: #b4d69b;
  --emerald: #2fd27a;
  --danger: #d97a6a;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--bg);
  background-image: radial-gradient(ellipse at top, #1a2c26 0%, var(--bg) 55%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--text);
  min-width: 320px;
}
button,
input {
  font: inherit;
}
button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-light);
  color: var(--text);
  border-radius: 8px;
  padding: 8px 14px;
  transition:
    border-color 0.15s,
    transform 0.1s;
}
button:hover:not(:disabled) {
  border-color: var(--gold);
}
button:active:not(:disabled) {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: linear-gradient(180deg, #e6ce94, var(--gold-deep));
  color: #1f1a0f;
  border-color: #8f7440;
  font-weight: bold;
  letter-spacing: 0.03em;
}
button.danger {
  border-color: var(--danger);
}
button.link {
  background: none;
  border: none;
  color: var(--muted);
  padding: 4px 6px;
  text-decoration: underline;
}
input {
  background: var(--bg-deep);
  border: 1px solid var(--line);
  color: var(--text);
  border-radius: 8px;
  padding: 9px 11px;
  width: 100%;
}
input:focus {
  outline: none;
  border-color: var(--gold);
}
h1,
h2,
h3 {
  margin: 0 0 8px;
}
h3 {
  color: var(--gold);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
}
.brand {
  letter-spacing: 0.22em;
  font-size: 2rem;
  color: var(--gold);
  text-shadow: 0 2px 0 #3a2e14;
}
.muted {
  color: var(--muted);
}
.emerald {
  width: 16px;
  height: 16px;
  vertical-align: -3px;
  image-rendering: pixelated;
}
.class-icon,
.hero-classes img,
.class-option img {
  width: 34px;
  height: 34px;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 0 3px var(--c, #0000));
}
.mini {
  width: 18px;
  height: 18px;
  vertical-align: -4px;
  object-fit: contain;
}
/* Landing */
.landing {
  max-width: 460px;
  margin: 5vh auto;
  padding: 24px 16px;
  text-align: center;
}
.hero-tiles {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 18px 0 10px;
}
.hero-tiles .tile-svg {
  width: 62px;
  height: 62px;
  border-radius: 6px;
  box-shadow: 0 6px 14px #0008;
  transform: rotate(-2deg);
}
.hero-tiles .tile-svg:nth-child(even) {
  transform: rotate(2deg) translateY(4px);
}
.hero-classes {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 18px;
}
.hero-classes img {
  width: 40px;
  height: 40px;
}
.landing .card {
  text-align: left;
}
.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 10px 30px #0006;
}
.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.tabs button {
  flex: 1;
}
.tabs button.active {
  border-color: var(--gold);
  color: var(--gold);
}
.field-row {
  margin-bottom: 12px;
}
.field-row label {
  display: block;
  color: var(--muted);
  margin-bottom: 4px;
}
.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}
/* Lobby */
.lobby {
  max-width: 560px;
  margin: 5vh auto;
  padding: 16px;
}
.code {
  font-size: 2.2rem;
  letter-spacing: 0.3em;
  font-weight: bold;
  color: var(--gold);
  margin: 8px 0;
}
.players {
  list-style: none;
  padding: 0;
  margin: 0;
}
.players li {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.players li:last-child {
  border-bottom: none;
}
.players li.current .name > span:first-child {
  color: var(--gold);
}
.players li.current {
  background: linear-gradient(90deg, #d6bc8018, transparent);
  border-radius: 6px;
}
.players .name {
  flex: 1;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.players .stat {
  color: var(--muted);
  min-width: 3.2em;
  text-align: right;
  white-space: nowrap;
}
.players .score,
.ranking .score {
  color: var(--green);
  font-weight: bold;
}
.dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--line);
  margin-right: 5px;
  vertical-align: 1px;
}
.dot.on {
  background: var(--emerald);
  box-shadow: 0 0 5px var(--emerald);
}
.badge {
  font-size: 0.72rem;
  color: var(--gold);
  border: 1px solid var(--gold-deep);
  border-radius: 6px;
  padding: 1px 5px;
  vertical-align: 1px;
}
.class-picker {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}
.class-option {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 8px 4px;
  border-color: var(--line);
}
.class-option img {
  width: 44px;
  height: 44px;
}
.class-option span {
  font-size: 0.8rem;
}
.class-option small {
  color: var(--muted);
  font-size: 0.7rem;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.class-option.mine {
  border-color: var(--c);
  box-shadow:
    inset 0 0 0 1px var(--c),
    0 0 10px color-mix(in srgb, var(--c) 40%, transparent);
}
/* Table */
.table {
  display: grid;
  grid-template-columns: 1fr 310px;
  grid-template-rows: auto 1fr;
  height: 100vh;
  height: 100dvh;
}
.topbar {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-wrap: wrap;
}
.topbar .brand {
  font-size: 1.1rem;
  text-shadow: none;
}
.topbar .spacer {
  flex: 1;
}
.topbar .code-small {
  letter-spacing: 0.2em;
  color: var(--green);
  font-weight: bold;
}
.board-wrap {
  position: relative;
  overflow: hidden;
  background: var(--bg-deep);
  background-image:
    radial-gradient(circle at 50% 40%, #16261f 0%, var(--bg-deep) 70%),
    repeating-linear-gradient(0deg, transparent 0 24px, #ffffff05 24px 25px),
    repeating-linear-gradient(90deg, transparent 0 24px, #ffffff05 24px 25px);
  touch-action: none;
  user-select: none;
}
.board-wrap svg.board {
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
}
.board-wrap.dragging svg.board {
  cursor: grabbing;
}
.board-tools {
  position: absolute;
  right: 10px;
  bottom: 10px;
  display: flex;
  gap: 6px;
}
.board-tools button {
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 1.1rem;
}
.status-banner {
  position: absolute;
  left: 10px;
  top: 10px;
  background: #0b1411dd;
  border: 1px solid var(--gold-deep);
  color: var(--gold);
  border-radius: 8px;
  padding: 6px 10px;
  max-width: calc(100% - 20px);
}
.side {
  background: var(--panel);
  border-left: 1px solid var(--line);
  padding: 12px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.side section {
  border-bottom: 1px solid var(--line);
  padding-bottom: 12px;
}
.side section:last-child {
  border-bottom: none;
}
.current-tile {
  display: flex;
  gap: 12px;
  align-items: center;
}
.current-tile .tile-svg {
  width: 116px;
  height: 116px;
  border-radius: 6px;
  flex: none;
  box-shadow: 0 6px 14px #0008;
}
.current-tile .controls {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex: 1;
}
.log {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.85rem;
  color: var(--muted);
}
.log li {
  padding: 3px 0;
  border-bottom: 1px dashed var(--line);
}
/* Board overlays */
.slot {
  fill: #d6bc8014;
  stroke: var(--gold);
  stroke-width: 2;
  stroke-dasharray: 6 5;
  cursor: pointer;
}
.slot:hover {
  fill: #d6bc8040;
}
.ghost {
  opacity: 0.85;
}
.ghost-frame {
  fill: none;
  stroke: var(--gold);
  stroke-width: 4;
}
.last-frame {
  fill: none;
  stroke: #ebece0aa;
  stroke-width: 2;
  pointer-events: none;
}
.spot {
  cursor: pointer;
}
.spot .spot-ring {
  fill: none;
  stroke: var(--c, #fff);
  stroke-width: 2;
  opacity: 0.7;
}
.spot circle:not(.spot-ring) {
  fill: #ebece0dd;
  stroke: #1a1a1a;
  stroke-width: 2;
}
.spot:hover circle:not(.spot-ring) {
  fill: var(--gold);
}
.spot text {
  font-size: 13px;
  font-weight: bold;
  fill: #1a1a1a;
  text-anchor: middle;
  pointer-events: none;
}
#toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #0b1411ee;
  border: 1px solid var(--gold-deep);
  color: var(--text);
  padding: 10px 16px;
  border-radius: 8px;
  opacity: 0;
  transition: opacity 0.2s;
  pointer-events: none;
  max-width: 90vw;
  z-index: 20;
}
#toast.show {
  opacity: 1;
}
dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--gold-deep);
  border-radius: 12px;
  padding: 20px;
  max-width: min(520px, 92vw);
}
dialog::backdrop {
  background: #000a;
}
dialog p {
  line-height: 1.45;
}
.ranking {
  list-style: none;
  padding: 0;
  margin: 0 0 12px;
}
.ranking li {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.ranking .name {
  flex: 1;
}
@media (max-width: 800px) {
  .table {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }
  .board-wrap {
    height: 62vh;
    min-height: 320px;
  }
  .side {
    border-left: none;
    border-top: 1px solid var(--line);
  }
  .class-picker {
    grid-template-columns: repeat(3, 1fr);
  }
  .hero-tiles .tile-svg {
    width: 48px;
    height: 48px;
  }
}
