/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d1a;
  --surface: #161628;
  --card: #1e1e36;
  --border: #2e2e50;
  --accent: #f5a623;
  --accent-dark: #c98210;
  --text: #e8e8f0;
  --text-muted: #7a7a9a;
  --green: #4caf50;
  --red: #f44336;
  --blue: #2196f3;
  --purple: #9c27b0;
  --radius: 12px;
  --shadow: 0 4px 20px rgba(0,0,0,.5);
}

html, body { height: 100%; font-family: 'Segoe UI', system-ui, sans-serif; background: var(--bg); color: var(--text); font-size: 16px; }

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; font-size: 1rem; }

/* ── Utilities ───────────────────────────────────────────────────────────── */
.hidden { display: none !important; }
.text-muted { color: var(--text-muted); font-size: .85rem; }

/* ── Login page ──────────────────────────────────────────────────────────── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; padding: 1rem; }

.login-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2.5rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow);
  text-align: center;
}

.login-card .logo { font-size: 4rem; margin-bottom: .5rem; line-height: 1; }
.login-card h1 { font-size: 2rem; font-weight: 800; color: var(--accent); letter-spacing: 1px; }
.login-card .subtitle { color: var(--text-muted); margin: .5rem 0 1.5rem; font-size: .95rem; }

.form-group { text-align: left; margin-bottom: 1rem; }
.form-group label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .4rem; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; }
.form-group input {
  width: 100%;
  padding: .75rem 1rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 1rem;
  transition: border-color .2s;
}
.form-group input:focus { outline: none; border-color: var(--accent); }

.btn-primary {
  width: 100%;
  padding: .85rem;
  background: var(--accent);
  color: #000;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  transition: background .2s, transform .1s;
  margin-top: .5rem;
}
.btn-primary:hover { background: var(--accent-dark); }
.btn-primary:active { transform: scale(.98); }

.btn-secondary {
  padding: .6rem 1.2rem;
  background: transparent;
  color: var(--text-muted);
  font-weight: 600;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: .9rem;
  transition: all .2s;
}
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-danger {
  padding: .6rem 1.2rem;
  background: var(--red);
  color: #fff;
  font-weight: 700;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  transition: opacity .2s;
}
.btn-danger:hover { opacity: .85; }

.error-msg { margin-top: .75rem; color: var(--red); font-size: .9rem; background: rgba(244,67,54,.1); padding: .6rem .9rem; border-radius: 6px; border: 1px solid rgba(244,67,54,.3); }

.hint { margin-top: 1.5rem; font-size: .8rem; color: var(--text-muted); background: var(--surface); border-radius: 8px; padding: .75rem 1rem; text-align: left; line-height: 1.6; }

/* ── App layout ──────────────────────────────────────────────────────────── */
.app { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .75rem 1rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  z-index: 1000;
  flex-shrink: 0;
}
.topbar .logo { font-size: 1.5rem; }
.topbar h2 { font-size: 1rem; font-weight: 700; flex: 1; }
.topbar .team-badge {
  font-size: .75rem;
  font-weight: 700;
  padding: .3rem .7rem;
  border-radius: 20px;
  background: var(--accent);
  color: #000;
}
.topbar .team-badge.chicken { background: var(--red); color: #fff; }

/* ── Map ─────────────────────────────────────────────────────────────────── */
#map { flex: 1; z-index: 1; }

/* ── Side panel ──────────────────────────────────────────────────────────── */
.layout { display: flex; flex: 1; overflow: hidden; }
.panel {
  width: 340px;
  flex-shrink: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.panel-header { padding: .85rem 1rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: .9rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .5px; display: flex; align-items: center; justify-content: space-between; }

.panel-content { flex: 1; overflow-y: auto; padding: .5rem; }
.panel-content::-webkit-scrollbar { width: 4px; }
.panel-content::-webkit-scrollbar-track { background: transparent; }
.panel-content::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ── Bar list ────────────────────────────────────────────────────────────── */
.bar-search { padding: .5rem; }
.bar-search input {
  width: 100%;
  padding: .6rem .9rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .9rem;
}
.bar-search input:focus { outline: none; border-color: var(--accent); }

.bar-item {
  padding: .65rem .85rem;
  border-radius: 8px;
  cursor: pointer;
  transition: background .15s;
  border: 1px solid transparent;
  margin-bottom: 2px;
  display: flex;
  align-items: center;
  gap: .6rem;
}
.bar-item:hover { background: var(--card); }
.bar-item .bar-icon { font-size: 1.1rem; flex-shrink: 0; }
.bar-item .bar-info { flex: 1; min-width: 0; }
.bar-item .bar-name { font-weight: 600; font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-item .bar-addr { font-size: .75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bar-item .bar-status { flex-shrink: 0; width: 10px; height: 10px; border-radius: 50%; background: var(--border); }

.bar-item.mine { border-color: rgba(76, 175, 80, .3); background: rgba(76, 175, 80, .07); }
.bar-item.mine .bar-status { background: var(--green); }
.bar-item.others .bar-status { background: var(--blue); }

/* ── Checkin feed ────────────────────────────────────────────────────────── */
.feed-item {
  padding: .6rem .85rem;
  border-radius: 8px;
  background: var(--card);
  margin-bottom: .4rem;
  font-size: .85rem;
  border-left: 3px solid var(--border);
}
.feed-item .feed-team { font-weight: 700; color: var(--accent); }
.feed-item .feed-time { float: right; color: var(--text-muted); font-size: .75rem; }
.feed-item.nearby { border-left-color: var(--accent); background: rgba(245,166,35,.08); }
.feed-item.found { border-left-color: var(--red); background: rgba(244,67,54,.12); }

/* ── Game status bar ─────────────────────────────────────────────────────── */
.status-bar {
  padding: .6rem 1rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 1rem;
  font-size: .85rem;
  flex-shrink: 0;
}
.status-bar .timer { font-weight: 700; font-size: 1rem; color: var(--accent); font-variant-numeric: tabular-nums; }
.status-bar .timer.urgent { color: var(--red); animation: pulse 1s ease-in-out infinite; }

@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .5; } }

.status-dot { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.status-dot.green { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-dot.orange { background: var(--accent); }
.status-dot.red { background: var(--red); }

/* ── Notifications (toast) ───────────────────────────────────────────────── */
#toasts {
  position: fixed;
  top: 70px;
  right: 1rem;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: .5rem;
  pointer-events: none;
}

.toast {
  min-width: 260px;
  max-width: 340px;
  padding: .85rem 1.1rem;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 600;
  box-shadow: var(--shadow);
  animation: slideIn .3s ease;
  pointer-events: all;
  border: 1px solid rgba(255,255,255,.1);
}
.toast.info { background: var(--card); }
.toast.success { background: rgba(76,175,80,.2); border-color: var(--green); color: #a8f0ab; }
.toast.warning { background: rgba(245,166,35,.18); border-color: var(--accent); color: #ffd080; }
.toast.danger { background: rgba(244,67,54,.2); border-color: var(--red); color: #f99; }
.toast .toast-title { font-size: 1rem; margin-bottom: .25rem; }
.toast .toast-body { font-weight: 400; color: var(--text-muted); font-size: .82rem; }

@keyframes slideIn { from { transform: translateX(120%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes slideOut { from { opacity: 1; } to { opacity: 0; transform: scale(.95); } }

/* ── Chicken page ────────────────────────────────────────────────────────── */
.hiding-banner {
  padding: .75rem 1rem;
  background: rgba(244,67,54,.15);
  border-bottom: 1px solid rgba(244,67,54,.3);
  font-size: .9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: .75rem;
  flex-shrink: 0;
}
.hiding-banner.set { background: rgba(76,175,80,.12); border-color: rgba(76,175,80,.3); }

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.6);
  z-index: 10000;
  display: flex; align-items: center; justify-content: center;
  padding: 1rem;
  backdrop-filter: blur(4px);
}
.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow);
}
.modal h3 { font-size: 1.2rem; margin-bottom: .5rem; }
.modal p { color: var(--text-muted); font-size: .9rem; margin-bottom: 1.25rem; line-height: 1.5; }
.modal .modal-actions { display: flex; gap: .75rem; justify-content: flex-end; }

/* ── FOUND overlay ───────────────────────────────────────────────────────── */
#foundOverlay {
  position: fixed; inset: 0;
  background: rgba(244,67,54,.85);
  z-index: 99999;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center;
  padding: 2rem;
  animation: foundPop .5s ease;
}
@keyframes foundPop { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: scale(1); } }
#foundOverlay .found-emoji { font-size: 6rem; margin-bottom: 1rem; }
#foundOverlay h1 { font-size: 2.5rem; font-weight: 900; text-shadow: 0 2px 10px rgba(0,0,0,.3); }
#foundOverlay p { font-size: 1.2rem; margin-top: .5rem; opacity: .9; }
#foundOverlay button { margin-top: 2rem; padding: .85rem 2rem; background: #fff; color: var(--red); font-weight: 800; border: none; border-radius: 8px; font-size: 1rem; cursor: pointer; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 700px) {
  .panel { width: 100%; border-left: none; border-top: 1px solid var(--border); max-height: 40vh; }
  .layout { flex-direction: column; }
}

/* ── Leaflet marker overrides ────────────────────────────────────────────── */
.marker-pin {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  border: 2px solid rgba(0,0,0,.3);
  box-shadow: 0 2px 8px rgba(0,0,0,.4);
}
.marker-pin .inner {
  transform: rotate(45deg);
  font-size: 14px;
  line-height: 1;
}
