:root {
  --bg: rgb(13, 16, 21);
  --panel: rgba(22, 26, 34, 0.72);
  --line: rgba(255, 255, 255, 0.08);
  --text: #e2e6ee;
  --dim: #8b94a5;
  --accent: #7fd1b9;
  --warn: #f0a868;
  --radius: 14px;
  --shadow: 0 10px 34px rgba(0, 0, 0, 0.42), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 13px/1.5 ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

#map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  /* The page handles every gesture itself: drag, pinch and scroll. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#map.dragging { cursor: grabbing; }

.panel, .card {
  position: fixed;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(1.4);
  -webkit-backdrop-filter: blur(18px) saturate(1.4);
}
.panel { padding: 12px 14px; }

h1, h2, h3 { margin: 0 0 6px; font-weight: 650; }
h1 { font-size: 16px; letter-spacing: -0.01em; }
h2, h3 { font-size: 10.5px; letter-spacing: 0.09em; text-transform: uppercase; color: var(--dim); }
h3 { margin-top: 14px; }

#left { position: fixed; top: 14px; left: 14px; width: 244px; max-height: calc(100% - 84px); display: flex; flex-direction: column; gap: 10px; }
#left .panel { position: static; }
#you { overflow-y: auto; min-height: 0; }
#hud h1 { margin: 0; white-space: nowrap; }
#hud .links a { white-space: nowrap; }
#hud .links { display: flex; gap: 10px; }
#hud a { color: var(--accent); font-size: 12px; text-decoration: none; }
#hud a:hover { text-decoration: underline; }
#board h2 { margin: 0; }
#left, #right, #nav, #replay, #minimap { z-index: 3; }
#player-count { color: var(--dim); font-size: 11px; }
/* A fixed height, so the leaderboard and chatter share it by proportion. */
#right { position: fixed; top: 14px; right: 14px; width: 264px; height: calc(100% - 222px); display: flex; flex-direction: column; gap: 10px; }
#right .panel { position: static; }
#board { flex: 0 0 auto; max-height: 45%; overflow-y: auto; }
#chat { flex: 1 1 0; min-height: 120px; display: flex; flex-direction: column; }
#chat h2 { margin: 0; }
#chat-tabs { display: flex; gap: 4px; }
#chat-tabs button { padding: 2px 8px; font-size: 11px; background: none; border-color: transparent; color: var(--dim); }
#chat-tabs button.on { background: rgba(255, 255, 255, 0.1); color: var(--text); }
#chat-tabs button.unread::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 5px; border-radius: 50%; background: var(--accent); }
#chat-list { flex: 1 1 auto; min-height: 0; overflow-y: auto; margin-top: 6px; }
#chat-list li { display: block; padding: 3px 4px; font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; }
#chat-list li.obituary { color: var(--warn); }
#chat-list li.official { background: rgba(127, 209, 185, 0.1); border-radius: 8px; }
/* The newest official announcement, kept above the feed. */
#chat-official { margin: 8px 0 0; padding: 7px 9px; border: 1px solid rgba(127, 209, 185, 0.35); border-radius: 10px; background: rgba(127, 209, 185, 0.09); font-size: 12.5px; line-height: 1.4; overflow-wrap: anywhere; max-height: 30%; overflow-y: auto; flex: none; }
.badge { display: inline-block; padding: 0 7px; border-radius: 999px; background: var(--accent); color: #08110e; font-size: 10px; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; vertical-align: 1px; }
#chat-list li.leak { background: rgba(240, 168, 104, 0.09); }
#chat-list li.empty { color: var(--dim); }
#chat-list .tools { display: flex; gap: 4px; margin-top: 3px; }
#chat-list .tools button, #chat-thread button { padding: 1px 8px; font-size: 11px; }
#chat-form { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
#chat-form input { flex: 1 1 120px; margin: 0; }
#chat-to { flex: 1 0 100%; color: var(--dim); font-size: 12px; }
#chat-to button { padding: 0 6px; font-size: 12px; }

/* Speech bubbles sit on the map at the speaker's stones. */
#bubbles { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 2; }
.bubble {
  position: absolute;
  top: 0;
  left: 0;
  max-width: 220px;
  padding: 5px 10px;
  border-radius: 12px 12px 12px 3px;
  background: rgba(22, 26, 34, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  font-size: 12px;
  line-height: 1.35;
  overflow-wrap: anywhere;
  will-change: transform, opacity;
}
.bubble.obituary { border-color: rgba(240, 168, 104, 0.5); color: var(--warn); }
.bubble.leak { border-color: rgba(240, 168, 104, 0.5); }
#nav { bottom: 14px; left: 14px; display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 8px; border-radius: 999px; color: var(--dim); font-variant-numeric: tabular-nums; white-space: nowrap; }
#nav button { width: 26px; height: 26px; padding: 0; }
#nav #panels-btn { display: none; width: auto; height: 26px; padding: 0 12px; margin-left: 4px; }
#panels-btn.unread::after { content: ""; display: inline-block; width: 6px; height: 6px; margin-left: 6px; border-radius: 50%; background: var(--accent); }
#scale { display: flex; flex-direction: column; gap: 2px; min-width: 64px; margin: 0 4px; font-size: 11px; }
#scale-bar { height: 5px; border: 1px solid var(--dim); border-top: none; border-radius: 0 0 2px 2px; }
#readout:empty { display: none; }
/* The coordinate readout would run under the replay bar on narrower windows. */
@media (max-width: 1180px) { #readout { display: none; } }
#replay { bottom: 14px; left: 50%; transform: translateX(-50%); display: flex; align-items: center; gap: 12px; padding: 7px 16px; border-radius: 999px; white-space: nowrap; }
#replay-slider { width: min(38vw, 420px); accent-color: var(--accent); }
#minimap { position: fixed; right: 14px; bottom: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--panel); box-shadow: var(--shadow); backdrop-filter: blur(18px); cursor: pointer; }

.row { display: flex; justify-content: space-between; align-items: center; gap: 8px; min-height: 24px; }
.row > span:first-child { color: var(--dim); }
b { font-weight: 600; font-variant-numeric: tabular-nums; }
#bid-value { display: inline-block; min-width: 30px; text-align: center; }

label { display: block; color: var(--dim); font-size: 11px; margin-top: 8px; }
input:not([type="range"]) {
  display: block;
  width: 100%;
  margin-top: 3px;
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--text);
  font: inherit;
  transition: border-color 0.15s;
}
input:not([type="range"]):focus { border-color: rgba(127, 209, 185, 0.6); outline: none; }

button {
  padding: 5px 11px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: background 0.15s, transform 0.08s;
}
button:hover { background: rgba(255, 255, 255, 0.14); }
button:active { transform: scale(0.96); }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
#signin button, #account > button { width: 100%; margin-top: 8px; }
#join-btn { margin-top: 0 !important; background: rgba(127, 209, 185, 0.16); border-color: rgba(127, 209, 185, 0.3); }
#register-btn, #signin-btn { background: rgba(127, 209, 185, 0.16); border-color: rgba(127, 209, 185, 0.3); }
#register-btn:hover, #signin-btn:hover { background: rgba(127, 209, 185, 0.26); }
#bid-down, #bid-up { width: 26px; height: 26px; padding: 0; }

.note { margin: 7px 0 0; color: var(--dim); font-size: 12px; overflow-wrap: anywhere; }
.note:empty { display: none; }
.note.good { color: var(--accent); }
.note.bad { color: var(--warn); }

.list { list-style: none; margin: 0; padding: 0; }
.list li { display: flex; align-items: center; gap: 8px; padding: 3px 6px; border-radius: 8px; font-variant-numeric: tabular-nums; transition: background 0.12s; }
.list li.link { cursor: pointer; }
.list li.link:hover { background: rgba(255, 255, 255, 0.08); }
.list li.self { background: rgba(127, 209, 185, 0.13); }
.swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.list .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .rank { color: var(--dim); width: 22px; text-align: right; }
.list .empty { color: var(--dim); }

/* Stone and territory details: a hover tip and a pinned card. */
.card {
  top: 0;
  left: 0;
  padding: 9px 12px;
  border-radius: 12px;
  max-width: 260px;
  color: var(--dim);
  font-size: 12px;
  pointer-events: none;
  z-index: 5;
  will-change: transform;
}
.card.pinned { pointer-events: auto; border-color: rgba(255, 255, 255, 0.18); }
.card-head { display: flex; align-items: center; gap: 8px; margin-bottom: 3px; color: var(--text); font-size: 13px; }
.card-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 9px; }
.card-actions button { font-size: 12px; padding: 3px 10px; }

[hidden] { display: none !important; }

@media (max-width: 760px) {
  /* No room for a side column: the leaderboard and chatter open as a sheet instead. */
  #right, #minimap { display: none; }
  body.panels-open #right { display: flex; top: 110px; left: 14px; right: 14px; bottom: 124px; width: auto; height: auto; }
  #nav #panels-btn { display: inline-block; }
  #left { width: 176px; }
  /* Stack the replay bar above the zoom controls instead of beside them. */
  #replay { left: 14px; right: 14px; bottom: 64px; transform: none; }
  #replay-slider { flex: 1; width: auto; min-width: 0; }
}
