/* Hide & Seek — Globe
   Dark by design: the globe is the light source, the UI floats over it. */

:root {
  --bg:          #060b16;
  --bg-deep:     #04070f;
  --panel:       rgba(16, 24, 42, 0.82);
  --panel-line:  rgba(122, 152, 214, 0.22);
  --text:        #e8eefc;
  --muted:       #93a4c4;
  --accent:      #5b9dff;
  --accent-deep: #2f6fd0;
  --ok:          #3ddc84;
  --warn:        #ffb020;
  --error:       #ff6b6b;
  --radius:      14px;
  --shadow:      0 18px 50px rgba(0, 0, 0, 0.55);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
}

/* ─────────────────────────────────── globe ─────────────────────────────────*/

#globe {
  position: fixed;
  inset: 0;
  z-index: 0;
}

/* Darkens the globe behind centred panels so text stays readable. */
#globe-veil {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background: radial-gradient(ellipse at center,
              rgba(4, 7, 15, 0.72) 0%,
              rgba(4, 7, 15, 0.45) 45%,
              rgba(4, 7, 15, 0.15) 100%);
  transition: opacity 0.45s ease;
}

/* On the side-panel screens the globe is the playfield, so lift the veil. */
body[data-screen="hiding"] #globe-veil,
body[data-screen="seeking"] #globe-veil,
body[data-screen="roundEnd"] #globe-veil {
  opacity: 0.25;
}

.globe-tip {
  background: rgba(8, 14, 26, 0.92);
  border: 1px solid var(--panel-line);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
}

/* ────────────────────────────────── screens ────────────────────────────────*/

#app {
  position: relative;
  z-index: 2;
  height: 100%;
}

.screen {
  display: none;
  height: 100%;
  padding: max(16px, env(safe-area-inset-top)) 16px
           max(16px, env(safe-area-inset-bottom));
}

.screen.is-active {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade 0.35s ease;
}

/* Gameplay screens dock the panel to one side and leave the globe clickable. */
.screen--side.is-active {
  justify-content: flex-start;
  pointer-events: none;
}

.screen--side .panel {
  pointer-events: auto;
}

@keyframes fade {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}

/* ─────────────────────────────────── panel ─────────────────────────────────*/

.panel {
  width: min(460px, 100%);
  max-height: 100%;
  overflow-y: auto;
  padding: 26px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px) saturate(140%);
  -webkit-backdrop-filter: blur(18px) saturate(140%);
}

.panel--center { text-align: center; }
.panel--side   { width: min(380px, 100%); }

/* ──────────────────────────────── typography ───────────────────────────────*/

.title {
  margin: 0 0 6px;
  font-size: clamp(30px, 6vw, 40px);
  font-weight: 800;
  letter-spacing: -0.02em;
}

.title__globe { margin-left: 8px; }

.tagline {
  margin: 0 0 22px;
  color: var(--muted);
  line-height: 1.55;
  font-size: 15px;
}

.heading {
  margin: 0 0 14px;
  font-size: 21px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.heading--tight { margin-bottom: 4px; }

.subheading {
  margin: 22px 0 10px;
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
}

.muted { color: var(--muted); line-height: 1.5; }
.small { font-size: 13px; }
.ok    { color: var(--ok); font-weight: 600; }

.error {
  margin: 14px 0 0;
  padding: 10px 12px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.34);
  border-radius: 10px;
  color: var(--error);
  font-size: 14px;
  line-height: 1.45;
}

.target { color: var(--accent); }
.hunted { font-size: 17px; margin: 0 0 4px; }

.you {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--accent);
  border: 1px solid rgba(91, 157, 255, 0.4);
  border-radius: 999px;
  padding: 1px 6px;
  margin-left: 4px;
  vertical-align: middle;
}

/* ─────────────────────────────────── forms ─────────────────────────────────*/

.field { display: block; margin-bottom: 14px; }

.field__label {
  display: block;
  margin-bottom: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
}

input[type="text"] {
  width: 100%;
  padding: 12px 14px;
  font-size: 16px;            /* 16px stops iOS zooming on focus */
  font-family: inherit;
  color: var(--text);
  background: rgba(8, 13, 24, 0.75);
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input[type="text"]:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(91, 157, 255, 0.18);
}

.input--code {
  text-transform: uppercase;
  letter-spacing: 0.34em;
  font-weight: 700;
  text-align: center;
  font-size: 20px;
}

.toggle {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 16px 0;
  font-size: 14px;
  color: var(--muted);
  cursor: pointer;
  line-height: 1.45;
}

.toggle input { margin-top: 2px; accent-color: var(--accent); }

/* ─────────────────────────────────── buttons ───────────────────────────────*/

.btn {
  display: block;
  width: 100%;
  padding: 13px 18px;
  font-size: 15px;
  font-weight: 650;
  font-family: inherit;
  color: var(--text);
  background: rgba(48, 68, 110, 0.6);
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.18s ease, opacity 0.18s ease;
}

.btn:hover:not(:disabled)  { background: rgba(64, 90, 145, 0.75); }
.btn:active:not(:disabled) { transform: translateY(1px); }

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn--primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-deep));
  border-color: transparent;
  color: #fff;
}

.btn--primary:hover:not(:disabled) {
  background: linear-gradient(180deg, #6da8ff, #3a7ada);
}

.btn--ghost {
  background: transparent;
  color: var(--muted);
}

.btn--small { padding: 9px 14px; font-size: 13px; }

.stack > * + * { margin-top: 12px; }

.divider {
  position: relative;
  text-align: center;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.divider::before,
.divider::after {
  content: "";
  position: absolute;
  top: 50%;
  width: calc(50% - 26px);
  height: 1px;
  background: var(--panel-line);
}

.divider::before { left: 0; }
.divider::after  { right: 0; }

/* ─────────────────────────────────── share ─────────────────────────────────*/

.share {
  padding: 18px;
  margin-bottom: 8px;
  text-align: center;
  background: rgba(91, 157, 255, 0.08);
  border: 1px solid rgba(91, 157, 255, 0.24);
  border-radius: 12px;
}

.share__label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.11em;
  color: var(--muted);
}

.share__code {
  margin: 6px 0 14px;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.share .muted { margin: 10px 0 0; }

/* ─────────────────────────────────── players ───────────────────────────────*/

.players { list-style: none; margin: 0; padding: 0; }

.players__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  margin-bottom: 7px;
  background: rgba(9, 15, 28, 0.55);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  font-size: 15px;
}

.players--compact { margin-top: 14px; }
.players--compact .players__item { padding: 8px 11px; font-size: 14px; }

.players__name   { font-weight: 600; }
.players__status { font-size: 13px; color: var(--muted); white-space: nowrap; }

.pill {
  display: inline-block;
  padding: 2px 9px;
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  background: rgba(91, 157, 255, 0.14);
  border-radius: 999px;
}

/* ─────────────────────────────────── picker ────────────────────────────────*/

.picker { position: relative; margin: 14px 0; }

.results {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  max-height: 260px;
  overflow-y: auto;
  border-radius: 10px;
}

.results__item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: rgba(9, 15, 28, 0.85);
  border: 1px solid var(--panel-line);
  border-top: none;
  cursor: pointer;
  font-size: 15px;
}

.results__item:first-child { border-top: 1px solid var(--panel-line); border-radius: 10px 10px 0 0; }
.results__item:last-child  { border-radius: 0 0 10px 10px; }
.results__item:hover       { background: rgba(40, 60, 100, 0.9); }

.results__item.is-disabled {
  opacity: 0.38;
  cursor: not-allowed;
  text-decoration: line-through;
}

.results__flag { font-size: 20px; line-height: 1; }

.selected {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 14px;
  background: rgba(91, 157, 255, 0.1);
  border: 1px solid rgba(91, 157, 255, 0.3);
  border-radius: 12px;
}

.selected__country {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
}

.selected__flag { font-size: 30px; line-height: 1; }

.selected__name {
  font-size: 17px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.selected .btn { width: auto; flex: 0 0 auto; }

.locked {
  padding: 16px;
  background: rgba(61, 220, 132, 0.08);
  border: 1px solid rgba(61, 220, 132, 0.28);
  border-radius: 12px;
}

.locked p { margin: 0 0 4px; }

/* ─────────────────────────────────── seeking ───────────────────────────────*/

.round-head { margin-bottom: 12px; }
.round-head .pill { margin-bottom: 8px; }

.dots { display: flex; gap: 8px; margin: 4px 0 12px; }

.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: transparent;
}

.dot--spent { background: var(--accent); opacity: 0.35; border-color: transparent; }

.log { list-style: none; margin: 14px 0 0; padding: 0; }

.log__item {
  display: grid;
  grid-template-columns: 20px 26px 1fr auto auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  margin-bottom: 7px;
  background: rgba(9, 15, 28, 0.6);
  border: 1px solid var(--panel-line);
  border-left: 4px solid var(--heat, var(--panel-line));
  border-radius: 10px;
  font-size: 14px;
}

.log__item--correct {
  border-left-color: var(--ok);
  background: rgba(61, 220, 132, 0.1);
}

.log__n    { color: var(--muted); font-size: 12px; }
.log__flag { font-size: 18px; line-height: 1; }
.log__name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.log__dist { font-variant-numeric: tabular-nums; color: var(--text); font-weight: 600; }
.log__hit  { color: var(--ok); font-weight: 700; }

.log__dir {
  min-width: 30px;
  padding: 2px 6px;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  background: rgba(122, 152, 214, 0.14);
  border-radius: 6px;
}

/* ────────────────────────────────── results ────────────────────────────────*/

.reveal {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  margin-bottom: 18px;
  background: rgba(61, 220, 132, 0.09);
  border: 1px solid rgba(61, 220, 132, 0.3);
  border-radius: 12px;
}

.reveal__flag    { font-size: 40px; line-height: 1; }
.reveal__country { font-size: 22px; font-weight: 700; }

.results-table { list-style: none; margin: 0; padding: 0; }

.results-table__row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 13px;
  margin-bottom: 7px;
  background: rgba(9, 15, 28, 0.55);
  border: 1px solid var(--panel-line);
  border-radius: 10px;
  font-size: 15px;
}

.results-table__rank {
  width: 22px;
  font-weight: 800;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.results-table__row:first-child .results-table__rank { color: var(--warn); }

.results-table__name   { flex: 1 1 auto; font-weight: 600; min-width: 0; }
.results-table__detail { font-size: 13px; color: var(--muted); white-space: nowrap; }

.results-table__pts {
  font-weight: 800;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  min-width: 52px;
  text-align: right;
}

.winner {
  margin: 0 0 18px;
  font-size: 19px;
  text-align: center;
}

/* ──────────────────────────────── misc chrome ──────────────────────────────*/

.spinner {
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border: 3px solid rgba(122, 152, 214, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.toast {
  position: fixed;
  left: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  z-index: 20;
  padding: 12px 18px;
  max-width: min(420px, calc(100vw - 32px));
  background: rgba(16, 24, 42, 0.96);
  border: 1px solid var(--panel-line);
  border-radius: 11px;
  box-shadow: var(--shadow);
  font-size: 14px;
  animation: fade 0.25s ease;
}

.toast--error { border-color: rgba(255, 107, 107, 0.45); color: var(--error); }

/* ────────────────────────────────── responsive ─────────────────────────────*/

@media (max-width: 720px) {
  .screen--side.is-active {
    align-items: flex-end;
    justify-content: center;
  }

  /* On phones the panel becomes a bottom sheet so the globe keeps the top half. */
  .screen--side .panel {
    width: 100%;
    max-height: 62vh;
    border-radius: var(--radius) var(--radius) 0 0;
  }

  .panel { padding: 20px; }
  .share__code { font-size: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen.is-active { animation: none; }
  .spinner { animation-duration: 2s; }
  .toast { animation: none; }
}
