@font-face {
  font-family: "Geist";
  src: url("fonts/geist-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "Geist Mono";
  src: url("fonts/geist-mono-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --amber: #d97706;
  --amber-dark: #b45309;
  --panel: rgba(0, 0, 0, 0.85);
  --sans: "Geist", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --mono: "Geist Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #7dd3fc;
  color: #fff;
  font-family: var(--mono);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
  overscroll-behavior: none;
}

#view {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  outline: none;
}

button { font: inherit; color: inherit; cursor: pointer; }
[hidden] { display: none !important; }

/* ---------- shared panel look ---------- */
.panel {
  background: var(--panel);
  border: 2px solid var(--amber);
  border-radius: 4px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

/* ---------- loading ---------- */
#loading {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #7dd3fc;
}
.loading-box { padding: 12px 24px; font-size: 16px; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

.stats {
  position: absolute;
  top: 15px;
  left: 15px;
  padding: 12px 16px;
  min-width: 287px;
}
.stats-row1 { display: flex; align-items: center; gap: 12px; font-size: 18px; line-height: 24px; white-space: nowrap; }
.bone-icon { color: #fcd34d; flex: none; }
.run { color: #d4d4d4; }
.total { color: #fff; }
.total b { color: #facc15; font-weight: 500; }
.timer { color: #fde8a8; margin-left: 4px; }
.stats-row2 { margin-top: 5px; font-size: 15px; line-height: 20px; color: #d4d4d4; white-space: nowrap; }

.right-col {
  position: absolute;
  top: 15px;
  right: 15px;
  width: 288px;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 14px;
}
.minimap { width: 288px; height: 288px; padding: 4px; border-width: 3px; background: #242424; }
.minimap-inner { position: relative; width: 100%; height: 100%; background: #000; }
.minimap canvas { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; }

.board { width: 197px; padding: 9px 12px; font-size: 16px; line-height: 22px; }
.board-row { display: flex; justify-content: space-between; align-items: baseline; }
.board-row + .board-row { margin-top: 5px; }
.dim { color: #a3a3a3; }
.teal { color: #2dd4a8; }
.gold { color: #fde68a; font-weight: 700; }
.gold2 { color: #facc15; font-weight: 500; }

.hint {
  position: absolute;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  font-size: 14px;
  color: #d4d4d4;
  background: rgba(0, 0, 0, 0.62);
  border-color: rgba(217, 119, 6, 0.75);
  white-space: nowrap;
  transition: opacity 0.6s;
}
.hint.fade { opacity: 0; }

/* ---------- CA pill ---------- */
.ca {
  position: fixed;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 12px;
  height: 40px;
  max-width: calc(100vw - 30px);
  padding: 0 14px;
  font-size: 13px;
  color: #e5e5e5;
  white-space: nowrap;
  transition: border-color 0.15s;
}
.ca:hover { border-color: #fbbf24; }
.ca:active { transform: translateX(-50%) scale(0.98); }
.ca-label { color: #fcd34d; font-weight: 700; font-size: 14px; }
.ca-text { overflow: hidden; text-overflow: ellipsis; letter-spacing: 0.01em; }
.ca-icon { flex: none; color: #e5e5e5; }

/* ---------- name tag ---------- */
#nametag {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 8;
  pointer-events: none;
  padding: 10px 18px 11px;
  background: #000;
  border: 5px solid var(--amber-dark);
  border-radius: 2px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 28px;
  line-height: 1;
  letter-spacing: 0.01em;
  will-change: transform;
}

/* ---------- character select ---------- */
#menu {
  position: fixed;
  inset: 0;
  z-index: 15;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 72px 16px 28px;
}
.no-ca #menu { padding-top: 28px; }
.menu-top { text-align: center; }
.title {
  margin: 0;
  padding: 12px 28px 10px;
  font-family: var(--sans);
  font-weight: 800;
  font-size: clamp(26px, 5vw, 46px);
  letter-spacing: 0.04em;
  line-height: 1.05;
}
.subtitle {
  display: inline-block;
  margin: 10px 0 0;
  padding: 4px 12px;
  background: var(--amber);
  color: #000;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.14em;
  border-radius: 2px;
}
.menu-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; pointer-events: auto; }
.cards { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.card {
  width: 204px;
  padding: 12px 14px;
  text-align: left;
  background: rgba(0, 0, 0, 0.78);
  border: 2px solid rgba(217, 119, 6, 0.55);
  border-radius: 4px;
  transition: transform 0.12s, border-color 0.12s, background 0.12s;
}
.card:hover { transform: translateY(-2px); border-color: var(--amber); }
.card.selected { background: rgba(0, 0, 0, 0.92); border-color: #fbbf24; box-shadow: 0 0 0 2px #fbbf24 inset; }
.card-name { display: flex; align-items: center; gap: 8px; font-family: var(--sans); font-weight: 800; font-size: 20px; white-space: nowrap; }
.swatch { width: 14px; height: 14px; border: 2px solid #fff; border-radius: 2px; flex: none; }
.card-tag { margin-top: 4px; font-size: 12px; color: #d4d4d4; }

.start {
  padding: 12px 40px;
  background: var(--amber);
  color: #000;
  font-weight: 800;
  font-size: 18px;
  letter-spacing: 0.1em;
  border: 2px solid #fbbf24;
  border-radius: 4px;
  box-shadow: 0 4px 0 #7c3f06;
  transition: transform 0.08s, box-shadow 0.08s, background 0.12s;
}
.start:hover { background: #f59e0b; }
.start:active { transform: translateY(3px); box-shadow: 0 1px 0 #7c3f06; }
.ghost {
  padding: 12px 22px;
  background: transparent;
  color: #e5e5e5;
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  border: 2px solid rgba(217, 119, 6, 0.8);
  border-radius: 4px;
}
.ghost:hover { border-color: #fbbf24; color: #fff; }
.menu-hint { margin: 0; padding: 4px 10px; font-size: 12px; color: #1f2937; background: rgba(255, 255, 255, 0.55); border-radius: 3px; }

/* ---------- finish screen ---------- */
#win {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
}
.win-box { padding: 26px 34px 28px; text-align: center; min-width: min(420px, calc(100vw - 32px)); }
.win-title { font-family: var(--sans); font-weight: 800; font-size: 26px; letter-spacing: 0.03em; color: #fde68a; }
.win-time { margin-top: 12px; font-size: 52px; font-weight: 700; color: #fff; line-height: 1; }
.win-best { margin-top: 10px; min-height: 20px; font-size: 14px; color: #a3a3a3; }
.win-best.record { color: #2dd4a8; }
.win-actions { margin-top: 22px; display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; }

/* ---------- touch joystick ---------- */
#joy {
  position: fixed;
  z-index: 12;
  width: 124px;
  height: 124px;
  margin: -62px 0 0 -62px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.35);
  border: 2px solid rgba(217, 119, 6, 0.8);
  pointer-events: none;
}
#joyKnob {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 54px;
  height: 54px;
  margin: -27px 0 0 -27px;
  border-radius: 50%;
  background: var(--amber);
  border: 2px solid #fbbf24;
}

/* ---------- smaller screens ---------- */
@media (max-width: 900px), (max-height: 560px) {
  .stats { top: 10px; left: 10px; padding: 8px 10px; min-width: 0; }
  .stats-row1 { font-size: 14px; gap: 8px; line-height: 18px; }
  .stats-row2 { font-size: 11px; line-height: 15px; margin-top: 3px; }
  .right-col { top: 10px; right: 10px; width: 132px; gap: 8px; }
  .minimap { width: 132px; height: 132px; padding: 3px; border-width: 2px; }
  .board { width: 132px; padding: 5px 8px; font-size: 11px; line-height: 16px; }
  .ca { top: auto; bottom: 62px; height: 32px; padding: 0 10px; gap: 8px; font-size: 11px; }
  .ca-label { font-size: 12px; }
  .hint { font-size: 11px; padding: 4px 10px; bottom: 15px; }
  #nametag { font-size: 18px; padding: 6px 12px 7px; border-width: 4px; }
  #menu { padding-top: 24px; padding-bottom: 20px; }
  .card { width: 168px; padding: 8px 10px; }
  .card-name { font-size: 15px; }
  .card-tag { font-size: 11px; }
}
@media (max-width: 520px) {
  .cards { gap: 6px; flex-wrap: nowrap; width: 100%; }
  .card { flex: 1 1 auto; width: auto; min-width: 0; padding: 9px 6px; text-align: center; } /* sized by content, so the long name fits */
  .card-name { justify-content: center; font-size: clamp(11px, 3.4vw, 14px); letter-spacing: -0.01em; }
  .swatch { display: none; }
  .card-tag { display: none; }
}
@media (pointer: coarse) {
  .hint { display: none; }
  .menu-hint { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .start, .hint { transition: none; }
}
