:root {
  color-scheme: dark;
  --bg: #07090d;
  --panel: #10141b;
  --line: #222a36;
  --text: #e8edf4;
  --dim: #8793a4;
  --accent: #ffb020;
  --good: #36d399;
  --bad: #f2555a;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 ui-monospace, "JetBrains Mono", Menlo, Consolas, monospace;
}

header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--line);
}

.brand { font-weight: 700; letter-spacing: 2px; }
.brand span { color: var(--accent); }
.meta { display: flex; gap: 12px; align-items: center; color: var(--dim); }

main {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 1fr);
  min-height: calc(100vh - 50px);
  min-height: calc(100dvh - 50px); /* mobile browsers: exclude the collapsing toolbar */
}

#globe-wrap { position: relative; min-height: 420px; overflow: hidden; }
#globe { position: absolute; inset: 0; }
/* Covers the globe until the player starts the clock */
#start {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  text-align: center;
  background: radial-gradient(ellipse at center, rgba(7, 9, 13, .62) 0%, rgba(7, 9, 13, .25) 55%, rgba(7, 9, 13, 0) 80%);
  pointer-events: none; /* the globe underneath stays draggable */
}
#start p { margin: 0; font-size: 22px; font-weight: 700; }
#start button { font-size: 18px; padding: 12px 36px; }
#start small { color: var(--dim); }

#globe-caption {
  position: absolute;
  left: 0; right: 0; bottom: 26px;
  text-align: center;
  color: var(--accent);
  font-weight: 700;
  text-shadow: 0 0 6px #000;
  pointer-events: none;
}

#panel {
  padding: 16px;
  background: var(--panel);
  border-left: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#status { display: flex; align-items: center; gap: 16px; }
.score-box {
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 4px 12px;
  text-align: center;
}
.score-box small { display: block; color: var(--dim); font-size: 10px; letter-spacing: 1px; }
.score-box b { font-size: 24px; }
.score-box.plain { border-color: var(--line); }
#attempts { font-size: 22px; letter-spacing: 4px; }

#rules { color: var(--dim); font-size: 12px; margin-top: -6px; }
#hints-left { color: var(--dim); font-size: 12px; margin-bottom: 6px; }
#hints button { padding: 7px 10px; }
#hints button.armed { border-color: var(--accent); color: var(--accent); }
.loan { color: var(--dim); font-style: normal; font-size: 10px; }
#board-note { color: var(--dim); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 5px 8px; border-bottom: 1px solid var(--line); }
th { color: var(--dim); font-weight: 400; font-size: 12px; }
td.locked { color: #3a4352; }
td.fresh { color: var(--accent); }
#bio { color: var(--accent); min-height: 1.4em; }

#guess-form { display: flex; gap: 8px; }
.combo { position: relative; flex: 1; }

input, button {
  font: inherit;
  color: var(--text);
  background: #0a0d12;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
}
input { width: 100%; }
input:focus { outline: none; border-color: var(--accent); }
button { cursor: pointer; background: var(--accent); color: #111; border-color: var(--accent); font-weight: 700; }
button.ghost { background: transparent; color: var(--text); border-color: var(--line); font-weight: 400; }
button.chip { background: transparent; color: var(--text); border-color: var(--line); font-weight: 400; padding: 4px 10px; }
button:disabled, input:disabled { opacity: .45; cursor: default; }

#suggest {
  position: absolute;
  z-index: 5;
  left: 0; right: 0; top: 100%;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  background: #0a0d12;
  border: 1px solid var(--line);
  border-radius: 8px;
  max-height: 220px;
  overflow: auto;
}
#suggest li { padding: 6px 8px; border-radius: 6px; cursor: pointer; }
#suggest li.active, #suggest li:hover { background: var(--line); }

#wrong { color: var(--bad); min-height: 1.4em; }

#result h2 { margin: 0 0 4px; }
#result h3 { margin: 18px 0 6px; font-size: 14px; }
#result p { margin: 0 0 10px; color: var(--dim); }
.demo { color: var(--dim); font-weight: 400; font-size: 11px; margin-left: 6px; }
pre {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: #0a0d12;
  border: 1px solid var(--line);
  border-radius: 8px;
  white-space: pre-wrap;
}
.row { display: flex; gap: 8px; flex-wrap: wrap; }

#board { margin: 0; padding: 0; list-style: none; }
#board li {
  display: grid;
  grid-template-columns: 24px 1fr 46px;
  gap: 8px;
  align-items: center;
  padding: 3px 0;
  color: var(--dim);
}
#board li.mine { color: var(--text); font-weight: 700; }
.bar { position: relative; height: 20px; background: #0a0d12; border-radius: 4px; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; background: #2b3545; }
#board li.mine .bar i { background: var(--accent); }
.bar span { position: relative; padding-left: 6px; line-height: 20px; font-size: 12px; color: var(--text); }
#board li.mine .bar span { color: #111; }

#fit-btn { position: absolute; z-index: 3; top: 12px; left: 12px; padding: 6px 10px; background: rgba(10, 13, 18, .85); }
#attribution { position: absolute; right: 10px; bottom: 8px; font-size: 10px; color: var(--dim); pointer-events: none; }
#spells tbody tr { cursor: pointer; }
#spells tbody tr:hover { background: #161c26; }

/* Stops on the globe: a pin at the true spot, a label pushed clear of its neighbours */
.anchor { width: 0; height: 0; transition: opacity .2s; }
.anchor > * { position: absolute; left: 0; top: 0; }
.pin {
  width: 8px; height: 8px;
  margin: -4px 0 0 -4px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .7);
}
.leader {
  height: 2px;
  margin-top: -1px;
  background: rgba(255, 255, 255, .75);
  transform-origin: 0 50%;
}
.stop {
  min-width: 22px;
  padding: 1px 6px;
  border-radius: 11px;
  background: var(--accent);
  color: #111;
  font: 700 12px/20px ui-monospace, Consolas, monospace;
  text-align: center;
  white-space: nowrap;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, .55);
}
.picking .stop { pointer-events: auto; cursor: pointer; outline: 2px solid #fff; }
.stop.named { background: #fff; }

dialog {
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  max-width: 520px;
  width: calc(100% - 32px);
}
dialog::backdrop { background: rgba(0, 0, 0, .7); }
dialog h2 { margin: 0 0 4px; }
dialog p { margin: 0 0 12px; color: var(--dim); }
#tribe-list { display: flex; flex-wrap: wrap; gap: 8px; }

@media (max-width: 800px) {
  main { grid-template-columns: 1fr; }
  #globe-wrap { height: 46vh; height: 46dvh; min-height: 300px; }
  #panel { border-left: 0; border-top: 1px solid var(--line); }
  /* Keep the guess box directly under the globe; a long career table would push it off screen. */
  #wrong, #bio { min-height: 0; }
  input { font-size: 16px; } /* below 16px iOS zooms the page on focus */
}

.row.end { justify-content: flex-end; margin-top: 14px; }
#tribe-list button.armed { border-color: var(--accent); color: var(--accent); }
#tribe-list { max-height: 50vh; overflow: auto; }
#dev-login { margin-top: 12px; }
#dev-login input { flex: 1; }
#account-note { color: var(--bad); min-height: 1.2em; }
#count-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 14px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}
#count-cta button { white-space: nowrap; }
@media (max-width: 800px) {
  .brand { letter-spacing: 1px; }
  .meta { gap: 6px; }
}

footer { padding: 14px 16px; border-top: 1px solid var(--line); color: var(--dim); font-size: 12px; }
a { color: var(--accent); }
a.brand { color: var(--text); text-decoration: none; }

/* Plain text pages: privacy, terms */
.doc article { max-width: 720px; margin: 0 auto; padding: 24px 16px 60px; }
.doc h1 { margin: 0 0 4px; }
.doc h2 { margin: 28px 0 6px; font-size: 17px; }
.doc p { margin: 0 0 12px; }
.doc .dim { color: var(--dim); }
.doc code { background: #10141b; padding: 1px 5px; border-radius: 4px; }

/* Google draws its button in an iframe. Under a dark colour scheme the browser
   gives that iframe an opaque white backdrop, which shows as white corners. */
#google-btn { color-scheme: light; margin-top: 6px; }

#tribe-search { margin-bottom: 10px; }
#tribe-empty { color: var(--dim); }
/* iOS adds its own rounded search styling */
input[type="search"] { -webkit-appearance: none; appearance: none; }
button { -webkit-tap-highlight-color: transparent; touch-action: manipulation; }
header { gap: 8px; }
.meta { flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 800px) {
  header { padding: 10px 12px; }
  .brand { font-size: 14px; white-space: nowrap; }
  button.chip { padding: 4px 8px; font-size: 13px; max-width: 42vw; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  #status { flex-wrap: wrap; gap: 10px; }
  #attempts { font-size: 18px; letter-spacing: 2px; }
  #hints .row { gap: 6px; }
  #hints button { flex: 1 1 calc(50% - 6px); }
  #count-cta { flex-direction: column; align-items: stretch; }
  dialog { max-height: 86vh; max-height: 86dvh; overflow: auto; }
  #spells th, #spells td { padding: 5px 4px; }
  #start p { font-size: 18px; padding: 0 12px; }
}
@media (max-width: 800px) {
  /* One row: the club name gives way first, then the label */
  .meta { flex-wrap: nowrap; min-width: 0; }
  #puzzle-no { white-space: nowrap; font-size: 13px; }
  button.chip { max-width: 34vw; flex-shrink: 1; }
  #account-btn { flex-shrink: 0; }
}
@media (max-width: 360px) {
  #puzzle-no { display: none; } /* very narrow phones: the brand and two buttons need the row */
}

#start > * { pointer-events: auto; }
#start p { text-shadow: 0 2px 12px #000; }
