/* ============================================================
   RAIDLOG — styles
   Dark charcoal / olive / gold military theme.
   Mobile-first; layout uses minmax(0,1fr) grids + min-width:0
   so nothing can stretch the page sideways on a phone.
   ============================================================ */
:root {
  --bg: #14150f;
  --bg-2: #1c1e16;
  --card: #20221a;
  --card-2: #26281e;
  --line: #3a3d2e;
  --text: #e8e6da;
  --muted: #a3a48f;
  --olive: #6b7248;
  --olive-bright: #8a9455;
  --gold: #c9a227;
  --gold-bright: #e8c33c;
  --red: #b3402f;
  --discord: #5865f2;
  --radius: 10px;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  line-height: 1.45;
  overflow-x: hidden;
}

h1, h2, h3 { margin: 0 0 .5rem; letter-spacing: .02em; }
h2 { font-size: 1.25rem; text-transform: uppercase; }
h3 { font-size: 1rem; margin-top: 1.1rem; }
p { margin: 0 0 .6rem; }

.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }

button, input, select { font: inherit; color: inherit; }

/* ---------- header ---------- */
.site-header {
  background: linear-gradient(180deg, var(--bg-2), var(--bg));
  border-bottom: 2px solid var(--gold);
  padding: .8rem 1rem .6rem;
}
.brand {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: .7rem;
  align-items: center;
  max-width: 860px;
  margin: 0 auto;
  min-width: 0;
}
.brand-icon { border-radius: 8px; }
.brand-text { min-width: 0; }
.brand-title {
  font-size: 1.05rem;
  margin: 0;
  text-transform: uppercase;
  overflow-wrap: break-word;
}
.brand-sep { color: var(--gold); }
.brand-sub { margin: 0; color: var(--muted); font-size: .85rem; }

/* ---------- sticky tab bar ---------- */
.tabbar {
  position: sticky;
  top: 0;
  z-index: 40;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto;
  gap: .4rem;
  align-items: center;
  background: rgba(20, 21, 15, .96);
  border-bottom: 1px solid var(--line);
  padding: .35rem .6rem;
  min-height: 44px;
}
.tab {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .45rem .4rem;
  cursor: pointer;
  text-transform: uppercase;
  font-size: .85rem;
  min-width: 0;
}
.tab-active { border-color: var(--gold); color: var(--gold-bright); }
.tabbar-user { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.tabbar-user img { vertical-align: middle; border-radius: 50%; }

/* ---------- page / cards ---------- */
.page {
  max-width: 860px;
  margin: 0 auto;
  padding: .8rem .7rem 2rem;
  display: grid;
  gap: .9rem;
  min-width: 0;
}
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 1rem;
  min-width: 0;
}
/* Tab views (#/logger, #/stats): exactly one is shown at a time —
   the tabs switch views, there is no scrolling between sections. */
.view {
  display: grid;
  gap: .9rem;
  min-width: 0;
}
/* Public ?u= view: the Kill Logger tab is gone, so the bar collapses
   to just the Stats tab + user chip. */
.tabbar-public { grid-template-columns: minmax(0, 1fr) auto; }
.notice {
  border-radius: var(--radius);
  padding: .8rem 1rem;
  border: 1px solid var(--gold);
  background: #2a2614;
  min-width: 0;
}
.notice-public { border-color: var(--olive-bright); background: #23281a; }
.notice code { color: var(--gold-bright); }

/* ---------- buttons ---------- */
.btn {
  background: var(--olive);
  border: 1px solid var(--olive-bright);
  border-radius: 8px;
  padding: .55rem 1rem;
  cursor: pointer;
  font-weight: 600;
}
.btn:hover { background: var(--olive-bright); }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn-small { padding: .35rem .7rem; font-size: .85rem; }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-discord { background: var(--discord); border-color: var(--discord); color: #fff; font-size: 1.05rem; padding: .7rem 1.4rem; }
.btn-golive { background: transparent; border-color: var(--gold); color: var(--gold-bright); white-space: nowrap; }
.btn-golive[aria-pressed="true"] { background: var(--gold); color: #14150f; }

/* ---------- forms ---------- */
.field { margin-bottom: .7rem; min-width: 0; }
.field label { display: block; font-size: .85rem; color: var(--muted); margin-bottom: .25rem; }
.field input[type="text"], .field input[type="number"], .field select,
input[type="text"], select {
  width: 100%;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .55rem .6rem;
  min-width: 0;
}
.field-inline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .5rem;
  align-items: center;
}
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .6rem;
}
@media (max-width: 480px) {
  .form-grid { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- profile ---------- */
.profile-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: .7rem;
  align-items: center;
  margin-bottom: .9rem;
}
.avatar { border-radius: 50%; border: 2px solid var(--gold); background: var(--bg-2); }
.profile-name { font-weight: 700; font-size: 1.05rem; overflow-wrap: break-word; }
.profile-id { min-width: 0; }
.golive {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .8rem;
  align-items: center;
  border-top: 1px solid var(--line);
  padding-top: .8rem;
  margin-top: .4rem;
}

/* ---------- guest mode ---------- */
.guest-banner {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .6rem;
  align-items: start;
  margin-top: .9rem;
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  background: #2a2614;
  padding: .7rem .8rem;
}
.guest-banner p { margin: 0; font-size: .9rem; }
.guest-chip {
  margin-top: .7rem;
  display: inline-block;
  border: 1px solid var(--gold);
  color: var(--gold-bright);
  border-radius: 999px;
  padding: .15rem .6rem;
  font-size: .78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.guest-import {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: .8rem;
  align-items: center;
  border: 1px dashed var(--gold);
  border-radius: var(--radius);
  background: #2a2614;
  padding: .7rem .8rem;
  margin-bottom: .9rem;
}
.guest-import p { margin: 0; }

/* ---------- kill logger ---------- */
.section-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: .6rem;
}
.focus-toggle { display: inline-flex; align-items: center; gap: .4rem; cursor: pointer; font-size: .9rem; }
.focus-toggle input { width: 20px; height: 20px; accent-color: var(--gold); }

.btn-deploy {
  width: 100%;
  background: var(--olive);
  font-size: 1.15rem;
  padding: .8rem;
  text-transform: uppercase;
  letter-spacing: .08em;
}
.inraid-banner {
  background: var(--red);
  color: #fff;
  text-align: center;
  font-weight: 800;
  letter-spacing: .25em;
  padding: .45rem;
  border-radius: 8px;
  margin-bottom: .6rem;
  animation: pulse 1.6s ease-in-out infinite;
}
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .65; } }

.kill-counter { text-align: center; margin: .4rem 0; }
.kill-count {
  font-size: 3.2rem;
  font-weight: 800;
  color: var(--gold-bright);
  line-height: 1;
}
.btn-kill {
  width: 100%;
  background: var(--red);
  border-color: #d45a48;
  color: #fff;
  font-size: 1.5rem;
  font-weight: 800;
  padding: 1rem;
  letter-spacing: .12em;
}
.raid-end-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: .6rem;
  margin-top: .7rem;
}
.btn-survived { background: #7a6414; border-color: var(--gold); font-size: 1.05rem; padding: .8rem .4rem; }
.btn-died { background: #5f231b; border-color: var(--red); font-size: 1.05rem; padding: .8rem .4rem; }

/* level pad */
.level-pad, .died-form {
  margin-top: .8rem;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: .7rem;
  background: var(--card-2);
  min-width: 0;
}
.pad-title { font-weight: 700; margin-bottom: .5rem; }
.pad-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .45rem;
}
.pad-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
  margin-top: .5rem;
}
.btn-pad { background: var(--bg-2); border: 1px solid var(--line); padding: .6rem .2rem; font-size: .9rem; }

/* focus mode — applies ONLY inside the Kill Logger section.
   It must never hide other sections or the tab bar: with focus ON the
   player can still open the Stats Tracker via the tabs and come back. */
body.focus-on #logger-section { border-color: var(--gold); }
body.focus-on #logger-section .muted.small { display: none; }
body.focus-on .btn-kill { font-size: 2rem; padding: 1.6rem 1rem; }
body.focus-on .kill-count { font-size: 4rem; }
.tip-strip {
  margin-top: .9rem;
  border: 1px dashed var(--olive-bright);
  border-radius: 8px;
  padding: .6rem .8rem;
  text-align: center;
  color: var(--gold-bright);
  min-height: 2.4em;
}

/* ---------- stats ---------- */
.period-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .45rem;
  margin-bottom: .8rem;
}
.btn-period { background: var(--bg-2); border: 1px solid var(--line); padding: .5rem .2rem; }
.btn-period-active { border-color: var(--gold); color: var(--gold-bright); }
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: .5rem;
}
@media (max-width: 560px) {
  .stats-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
.stat {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .55rem .6rem;
  min-width: 0;
}
.stat-label { display: block; font-size: .75rem; color: var(--muted); text-transform: uppercase; }
.stat-value { font-size: 1.3rem; font-weight: 700; color: var(--gold-bright); }
.raid-list { list-style: none; margin: 0; padding: 0; display: grid; gap: .4rem; }
.raid-list li {
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .5rem .7rem;
  font-size: .9rem;
  overflow-wrap: break-word;
}
.tag {
  display: inline-block;
  border-radius: 4px;
  padding: 0 .4rem;
  font-size: .72rem;
  font-weight: 700;
  text-transform: uppercase;
}
.tag-survived { background: #7a6414; color: #fff; }
.tag-died { background: #5f231b; color: #fff; }
.tag-manual { background: var(--card-2); color: var(--muted); border: 1px solid var(--line); }

/* ---------- export / screenshots ---------- */
.export-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin: .6rem 0;
}
@media (max-width: 560px) { .export-actions { grid-template-columns: minmax(0, 1fr); } }
.json-preview {
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: .6rem;
  font-size: .75rem;
  max-height: 220px;
  overflow: auto;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.shot-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .5rem;
  margin-top: .6rem;
}
.shot-grid img { width: 100%; height: auto; border-radius: 8px; border: 1px solid var(--line); display: block; }

/* ---------- footer ---------- */
.site-footer {
  text-align: center;
  font-size: .8rem;
  color: var(--muted);
  padding: .5rem;
}

/* ---------- splash ---------- */
.splash {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(10, 10, 6, .92);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.splash-inner { text-align: center; animation: splash-in .35s ease-out; }
@keyframes splash-in { from { transform: scale(.92); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.splash-small { color: var(--gold-bright); letter-spacing: .35em; font-weight: 700; }
.splash-big {
  font-size: clamp(2.6rem, 13vw, 5rem);
  font-weight: 900;
  color: var(--gold);
  letter-spacing: .06em;
  margin: .3rem 0;
  text-shadow: 0 0 24px rgba(201, 162, 39, .45);
}
.splash-bars span {
  display: block;
  height: 6px;
  background: var(--gold);
  margin: .25rem auto;
  width: min(420px, 80vw);
}
.splash-bars span:last-child { width: min(320px, 64vw); opacity: .7; }

/* ---------- keypad modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(0, 0, 0, .7);
  display: grid;
  place-items: center;
  padding: 1rem;
}
.modal-box {
  background: var(--card);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: 1rem;
  width: min(340px, 100%);
}
.keypad-display {
  text-align: center;
  font-size: 2rem;
  font-weight: 800;
  color: var(--gold-bright);
  background: var(--bg);
  border-radius: 8px;
  padding: .4rem;
  margin-bottom: .6rem;
  min-height: 1.4em;
}
.keypad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: .45rem;
}
.keypad-grid button { font-size: 1.2rem; padding: .7rem 0; }

/* ---------- toast ---------- */
.toast {
  position: fixed;
  left: 50%;
  bottom: 1.2rem;
  transform: translateX(-50%);
  background: var(--card-2);
  border: 1px solid var(--gold);
  color: var(--text);
  border-radius: 8px;
  padding: .6rem 1rem;
  z-index: 120;
  max-width: 92vw;
  text-align: center;
  font-size: .9rem;
}
