* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  background: #1d2b1f;
  color: #1c241e;
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}

#app {
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

#stage-wrap {
  position: relative;
  width: min(100%, calc((100vh - 16px) * 1.5));
  aspect-ratio: 3 / 2;
  border-radius: 14px;
  overflow: hidden;
  border: 4px solid #141d15;
  box-shadow: 0 14px 40px rgba(0,0,0,.45);
  background: #4e8c45;
}

canvas#game { width: 100%; height: 100%; display: block; }
canvas#fx2d { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none; }
#reconnect-banner {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  background: #ffeaa7; border: 2px solid #222; border-radius: 8px;
  padding: 4px 12px; font-size: .82rem; font-weight: 700; z-index: 20;
}
.hidden { display: none !important; }

/* ── Overlays ────────────────────────────────── */
.overlay {
  position: absolute;
  inset: 0;
  background: rgba(20,30,22,.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  overflow-y: auto;
}

.card {
  background: #fdfaf0;
  border: 3px solid #222;
  border-radius: 16px;
  box-shadow: 0 6px 0 #222;
  padding: 18px 22px;
  width: 100%;
  max-width: 700px;
}

h1 { font-size: 1.65rem; text-align: center; margin-bottom: 6px; }
h2 { font-size: 1rem; margin-bottom: 5px; }
h3 { font-size: .9rem; margin-bottom: 7px; }

.subtitle { text-align: center; font-size: .88rem; color: #465047; margin-bottom: 12px; }

.field-label { display: block; font-size: .84rem; font-weight: 700; margin-bottom: 4px; }

input[type="text"], select {
  width: 100%;
  padding: 7px 10px;
  border: 2.5px solid #222;
  border-radius: 8px;
  font-size: .93rem;
  background: #fff;
  font-family: inherit;
}

/* ── Menu ────────────────────────────────── */
.menu-card { max-width: 620px; }

.menu-split { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin-top: 11px; }

.panel {
  background: #f3eedb;
  border: 2px solid #222;
  border-radius: 10px;
  padding: 11px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}
.panel p { font-size: .82rem; color: #465047; flex: 1; }

.code-input { text-transform: uppercase; letter-spacing: .22em; text-align: center; font-weight: 700; }

.controls-note {
  margin-top: 11px;
  display: flex;
  justify-content: space-around;
  flex-wrap: wrap;
  gap: 7px;
  font-size: .8rem;
  color: #3a423b;
}

.error-msg {
  margin-top: 9px;
  background: #ffe0dd;
  border: 2px solid #c9382c;
  color: #8f1d14;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: .84rem;
  text-align: center;
}

/* ── Buttons ────────────────────────────────── */
.btn {
  cursor: pointer;
  font-family: inherit;
  font-weight: 700;
  font-size: .93rem;
  padding: 8px 13px;
  border: 2.5px solid #222;
  border-radius: 9px;
  box-shadow: 0 3px 0 #222;
  background: #fff;
  transition: transform .06s;
}
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #222; }
.btn.primary  { background: #ff9d2e; color: #1b1407; }
.btn.secondary{ background: #5bc0eb; color: #0e202b; }
.btn.danger   { background: #f26457; color: #fff; }
.btn.small    { padding: 5px 9px; font-size: .8rem; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Lobby ────────────────────────────────── */
.lobby-card { max-width: 760px; padding: 14px 18px; }

.lobby-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 7px;
  flex-wrap: wrap;
}
.lobby-header-left { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

.tag { font-size: .7rem; font-weight: 700; letter-spacing: .08em; color: #555; }
.room-code {
  font-size: 1.3rem;
  letter-spacing: .18em;
  background: #ffeaa7;
  padding: 2px 7px;
  border: 2px solid #222;
  border-radius: 6px;
}
.copy-ok { color: #217a36; font-size: .8rem; font-weight: 700; }

/* Map Selector */
.map-selector { margin-bottom: 12px; }
.map-selector h3 { margin-bottom: 8px; }

.map-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 9px;
}

.map-card {
  display: flex;
  flex-direction: column;
  border: 2.5px solid #ccc;
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  background: #fff;
}
.map-card input[type="radio"] { display: none; }
.map-card.active, .map-card:hover {
  border-color: #ff9d2e;
  box-shadow: 0 3px 0 #ff9d2e;
}
.map-card.host-only-locked { pointer-events: none; opacity: .75; }

.map-preview {
  width: 100%;
  aspect-ratio: 3/2;
  position: relative;
  overflow: hidden;
}
.park-preview  { background: #63aa4f; }
.city-preview  { background: #7d8a74; }
.canyon-preview{ background: #cf935d; }

.map-mini {
  position: absolute;
  inset: 0;
  /* drawn via JS canvas thumbnails */
}

.map-info {
  padding: 7px 9px 8px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.map-info strong { font-size: .84rem; }
.map-info small  { font-size: .73rem; color: #555; }

.diff-badge {
  font-size: .68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
  align-self: flex-start;
}
.diff-easy   { color: #217a36; background: #d6ffe1; }
.diff-medium { color: #8a6200; background: #fff3c4; }
.diff-hard   { color: #c0392b; background: #ffe0de; }

/* Seats */
.seats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.team-col { border: 2.5px solid #222; border-radius: 10px; padding: 9px; }
.red-col  { background: #ffecea; }
.blue-col { background: #e9f4ff; }

.seat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
  border: 2px solid #222;
  border-radius: 8px;
  padding: 6px 9px;
  margin-bottom: 7px;
}
.seat-row:last-child { margin-bottom: 0; }
.seat-row.mine { background: #fff5cc; }
.seat-title { font-size: .82rem; font-weight: 700; }
.seat-occupant { font-size: .78rem; color: #555; }

.lobby-footer {
  margin-top: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 9px;
}
.lobby-settings { display: flex; gap: 9px; font-size: .83rem; font-weight: 700; }
.lobby-settings label { display: flex; align-items: center; gap: 5px; }
.lobby-settings select { width: auto; padding: 3px 7px; font-size: .82rem; }

.chat-box { margin-top: 9px; border: 2px solid #222; border-radius: 8px; background: #fff; padding: 7px; }
.chat-log { height: 60px; overflow-y: auto; font-size: .78rem; margin-bottom: 5px; user-select: text; }
.chat-form { display: flex; gap: 5px; }
.chat-form input { padding: 4px 7px; font-size: .82rem; }

/* ── HUD ────────────────────────────────── */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 10px 13px;
}

.hud-top { display: flex; justify-content: center; align-items: center; gap: 13px; }

.score-pill, .timer-pill {
  background: rgba(253,250,240,.94);
  border: 2.5px solid #222;
  border-radius: 999px;
  padding: 4px 13px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: .97rem;
  box-shadow: 0 3px 0 #222;
}

.team-dot { width: 11px; height: 11px; border-radius: 50%; border: 2px solid #222; }
.team-dot.red  { background: #e8483c; }
.team-dot.blue { background: #2c82e8; }

.coin-glyph {
  width: 14px; height: 14px;
  border-radius: 50%;
  background: #ff9d1c;
  border: 2px solid #222;
  display: inline-block;
}

.hud-bottom { display: flex; justify-content: space-between; align-items: flex-end; gap: 9px; }

.seat-legend {
  background: rgba(253,250,240,.93);
  border: 2.5px solid #222;
  border-radius: 10px;
  padding: 5px 11px;
  font-size: .84rem;
  font-weight: 700;
  box-shadow: 0 3px 0 #222;
}
.rush-badge {
  background: #ff4757;
  color: #fff;
  border: 1.5px solid #222;
  border-radius: 6px;
  padding: 1px 5px;
  font-size: .72rem;
  font-weight: 800;
}
.timer-pill.rush { background: #fff0c2; border-color: #d63031; }
.coop-keys { display: flex; gap: 4px; margin-top: 4px; }
.ck-pill {
  font-size: .68rem; font-weight: 800; padding: 1px 6px;
  border: 1.5px solid #888; border-radius: 5px; background: #eee; color: #666;
}
.ck-pill.on { background: #ffd166; border-color: #222; color: #1c1c1c; }

.sub-note { font-size: .76rem; font-weight: 400; color: #4c554d; }

.hud-actions { display: flex; align-items: center; gap: 5px; pointer-events: auto; }
.shout-bar { display: flex; gap: 3px; }

.shout-btn, .icon-btn {
  cursor: pointer;
  background: rgba(253,250,240,.94);
  border: 2px solid #222;
  border-radius: 8px;
  padding: 4px 7px;
  font-size: .74rem;
  font-weight: 700;
  font-family: inherit;
}

.ping-badge {
  background: rgba(20,28,22,.8);
  color: #b7f7c2;
  padding: 4px 7px;
  border-radius: 6px;
  font-size: .74rem;
  font-weight: 700;
}

#shout-toast {
  position: absolute;
  top: 54px;
  left: 50%;
  transform: translateX(-50%);
  background: #ffeaa7;
  border: 2.5px solid #222;
  border-radius: 10px;
  padding: 5px 13px;
  font-weight: 700;
  font-size: .93rem;
  box-shadow: 0 3px 0 #222;
}

#reclaim-banner {
  position: absolute;
  top: 54px;
  right: 13px;
  background: #fff;
  border: 2.5px solid #222;
  border-radius: 10px;
  padding: 6px 9px;
  font-size: .78rem;
  pointer-events: auto;
}

/* ── Results ────────────────────────────────── */
.results-card { max-width: 500px; text-align: center; }

.res-scores { display: grid; grid-template-columns: 1fr 1fr; gap: 11px; margin: 13px 0; }
.res-box { border: 2.5px solid #222; border-radius: 10px; padding: 11px; display: flex; flex-direction: column; gap: 4px; }
.res-box strong { font-size: 2rem; }

.res-actions { margin-top: 13px; display: flex; justify-content: center; align-items: center; gap: 9px; }
