@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

/* ═══════════════════════════════════════
   HackTheFlag — Design System v4
   Large · Responsive · Readable
═══════════════════════════════════════ */
:root {
  /* Backgrounds */
  --bg:       #09090f;
  --surface:  #0f1117;
  --card:     #141821;
  --raised:   #1a1f2e;
  --overlay:  #1e2535;

  /* Borders */
  --border:   #1e2535;
  --border2:  #263044;
  --border3:  #2e3d55;

  /* Text */
  --t1: #f1f5f9;
  --t2: #94a3b8;
  --t3: #64748b;
  --t4: #3d4f68;

  /* Accent colors */
  --cyan:   #38bdf8;
  --cyan2:  #0ea5e9;
  --cyan3:  #0369a1;
  --cglow:  rgba(56,189,248,0.15);
  --cglow2: rgba(56,189,248,0.07);

  --green:  #34d399;
  --green2: #10b981;
  --green3: #059669;
  --gglow:  rgba(52,211,153,0.12);

  --amber:  #fbbf24;
  --amber2: #f59e0b;
  --aglow:  rgba(251,191,36,0.12);

  --red:    #f87171;
  --red2:   #ef4444;
  --rglow:  rgba(248,113,113,0.12);

  --indigo: #818cf8;

  /* Typography */
  --font: 'Inter', system-ui, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;

  /* Layout */
  --sidebar:  270px;
  --topbar-h: 64px;
  --r:  8px;
  --r2: 14px;
  --r3: 20px;

  /* Shadows */
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.4);
  --shadow:    0 4px 20px rgba(0,0,0,0.45);
  --shadow-lg: 0 16px 48px rgba(0,0,0,0.65);
}

/* ── Fluid base font: 16px @ 768px → 18px @ 1440px ── */
html {
  font-size: clamp(15px, 1.1vw, 18px);
}

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg);
  color: var(--t1);
  font-family: var(--font);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  line-height: 1.55;
}

/* ─────────────────────────────────────
   APP SHELL
───────────────────────────────────── */
.app { display: flex; min-height: 100vh; }

/* ─────────────────────────────────────
   SIDEBAR
───────────────────────────────────── */
.sidebar {
  width: var(--sidebar);
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 28px 24px 22px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.logo-mark {
  font-size: clamp(17px, 1.4vw, 20px);
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.3px;
}
.logo-mark span { color: var(--cyan); }

.logo-sub {
  font-size: clamp(12px, 0.85vw, 14px);
  color: var(--t3);
  margin-top: 4px;
}

.sidebar-nav { flex: 1; padding: 18px 14px; }

.nav-section { margin-bottom: 10px; }

.nav-label {
  font-size: clamp(11px, 0.75vw, 12px);
  font-weight: 600;
  letter-spacing: 0.5px;
  color: var(--t4);
  text-transform: uppercase;
  padding: 6px 10px 10px;
  display: block;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 12px;
  border-radius: var(--r);
  color: var(--t3);
  text-decoration: none;
  font-size: clamp(14px, 1vw, 15px);
  font-weight: 500;
  transition: color 0.15s, background 0.15s;
  margin-bottom: 3px;
}
.nav-item:hover { background: var(--overlay); color: var(--t2); }
.nav-item.active { background: var(--cglow2); color: var(--cyan); font-weight: 600; }

.nav-icon {
  width: 22px;
  font-size: clamp(15px, 1.1vw, 17px);
  flex-shrink: 0;
  text-align: center;
  opacity: 0.85;
}

.sidebar-footer {
  padding: 18px 24px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.status-dot {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: clamp(12px, 0.85vw, 14px);
  color: var(--t3);
  font-weight: 500;
}

/* ─────────────────────────────────────
   DOTS
───────────────────────────────────── */
.dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--t4);
  flex-shrink: 0;
}
.dot.live {
  background: var(--green);
  box-shadow: 0 0 7px var(--green);
  animation: dot-pulse 2.5s ease-in-out infinite;
}
.dot.idle { background: var(--amber); }
.dot.dead { background: var(--red); }

@keyframes dot-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* ─────────────────────────────────────
   MAIN CONTENT
───────────────────────────────────── */
.main {
  flex: 1;
  margin-left: var(--sidebar);
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ─────────────────────────────────────
   TOPBAR
───────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 2.5vw, 40px);
  position: sticky;
  top: 0;
  z-index: 50;
}

.topbar-title {
  font-size: clamp(15px, 1.1vw, 18px);
  font-weight: 600;
  color: var(--t1);
}

.topbar-right { display: flex; align-items: center; gap: 18px; }

.topbar-clock {
  font-family: var(--mono);
  font-size: clamp(12px, 0.85vw, 14px);
  color: var(--t3);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

.topbar-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 5px 13px;
  border-radius: 20px;
  font-size: clamp(11px, 0.8vw, 13px);
  font-weight: 600;
  letter-spacing: 0.4px;
  border: 1px solid;
}
.badge-live { border-color: rgba(52,211,153,0.4); color: var(--green); background: var(--gglow); }
.badge-off  { border-color: var(--border2); color: var(--t3); background: transparent; }
.badge-warn { border-color: rgba(251,191,36,0.35); color: var(--amber); background: var(--aglow); }

/* ─────────────────────────────────────
   PAGE
───────────────────────────────────── */
.page {
  padding: clamp(24px, 3vw, 48px) clamp(20px, 3vw, 48px);
  flex: 1;
}

.page-header { margin-bottom: clamp(20px, 2vw, 32px); }

.page-title {
  font-size: clamp(22px, 1.8vw, 28px);
  font-weight: 700;
  color: var(--t1);
  letter-spacing: -0.4px;
}

.page-subtitle {
  font-size: clamp(13px, 0.95vw, 15px);
  color: var(--t3);
  margin-top: 5px;
}

/* ─────────────────────────────────────
   CARDS
───────────────────────────────────── */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

.card-header {
  padding: clamp(14px, 1.2vw, 20px) clamp(16px, 1.5vw, 24px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(255,255,255,0.01);
}

.card-title {
  font-size: clamp(13px, 0.9vw, 15px);
  font-weight: 600;
  color: var(--t2);
}

.card-body { padding: clamp(16px, 1.5vw, 24px); }

/* ─────────────────────────────────────
   STATS ROW
───────────────────────────────────── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: clamp(10px, 1vw, 16px);
  margin-bottom: clamp(16px, 1.5vw, 24px);
}

.stat {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--r2);
  padding: clamp(18px, 1.6vw, 28px) clamp(18px, 1.6vw, 26px);
}

.stat-label {
  font-size: clamp(12px, 0.85vw, 14px);
  font-weight: 500;
  color: var(--t3);
  margin-bottom: 10px;
}

.stat-value {
  font-size: clamp(28px, 2.4vw, 38px);
  font-weight: 700;
  color: var(--t1);
  line-height: 1;
  letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
}
.stat-value.accent { color: var(--cyan); }
.stat-value.danger { color: var(--red); }
.stat-value.warn   { color: var(--amber); }
.stat-value.timer  {
  font-family: var(--mono);
  font-size: clamp(22px, 1.8vw, 28px);
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}

.stat-sub { font-size: clamp(11px, 0.78vw, 13px); color: var(--t4); margin-top: 7px; }

/* ─────────────────────────────────────
   BUTTONS
───────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: clamp(10px, 0.85vw, 13px) clamp(16px, 1.3vw, 22px);
  border-radius: var(--r);
  font-family: var(--font);
  font-size: clamp(13px, 0.9vw, 15px);
  font-weight: 600;
  cursor: pointer;
  border: 1px solid transparent;
  transition: all 0.15s;
  text-decoration: none;
  white-space: nowrap;
  line-height: 1;
  letter-spacing: 0.1px;
}

.btn-primary {
  background: var(--cyan2);
  color: #fff;
  border-color: var(--cyan2);
}
.btn-primary:hover {
  background: #38bdf8;
  border-color: #38bdf8;
  box-shadow: 0 0 20px rgba(56,189,248,0.35);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--t2);
  border-color: var(--border2);
}
.btn-ghost:hover {
  border-color: var(--border3);
  color: var(--t1);
  background: var(--overlay);
}

.btn-danger {
  background: transparent;
  color: var(--red);
  border-color: rgba(248,113,113,0.3);
}
.btn-danger:hover {
  background: var(--rglow);
  border-color: rgba(248,113,113,0.5);
}

.btn-success {
  background: var(--green2);
  color: #fff;
  border-color: var(--green2);
}
.btn-success:hover {
  background: var(--green);
  box-shadow: 0 0 20px rgba(52,211,153,0.35);
  transform: translateY(-1px);
}

.btn-full { width: 100%; }

/* ─────────────────────────────────────
   FORM FIELDS
───────────────────────────────────── */
.field { margin-bottom: clamp(16px, 1.3vw, 22px); }

.label {
  display: block;
  font-size: clamp(13px, 0.9vw, 15px);
  font-weight: 500;
  color: var(--t2);
  margin-bottom: 8px;
}

.label .hint-text {
  font-size: clamp(11px, 0.78vw, 13px);
  font-weight: 400;
  color: var(--t3);
  margin-left: 6px;
}

.input {
  background: var(--raised);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--t1);
  font-family: var(--font);
  font-size: clamp(14px, 0.95vw, 16px);
  padding: clamp(10px, 0.85vw, 14px) clamp(12px, 1vw, 16px);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  width: 100%;
  caret-color: var(--cyan);
}
.input:focus {
  border-color: var(--cyan2);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.14);
}
.input::placeholder { color: var(--t4); }

.input-flag {
  background: var(--raised);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--t1);
  font-family: var(--mono);
  font-size: clamp(15px, 1.1vw, 18px);
  font-weight: 500;
  padding: clamp(12px, 1vw, 16px) clamp(14px, 1.1vw, 18px);
  outline: none;
  width: 100%;
  transition: border-color 0.15s, box-shadow 0.15s;
  caret-color: var(--cyan);
  letter-spacing: 0.5px;
}
.input-flag:focus {
  border-color: var(--cyan2);
  box-shadow: 0 0 0 3px rgba(14,165,233,0.14);
}
.input-flag::placeholder {
  color: var(--t4);
  font-weight: 400;
  font-size: clamp(13px, 0.9vw, 15px);
}

textarea.input { height: clamp(88px, 7vw, 120px); resize: vertical; line-height: 1.55; }

/* ─────────────────────────────────────
   TABLES
───────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; }
thead tr { border-bottom: 1px solid var(--border); }

th {
  padding: clamp(11px, 0.9vw, 15px) clamp(14px, 1.2vw, 20px);
  font-size: clamp(12px, 0.82vw, 14px);
  font-weight: 600;
  color: var(--t3);
  text-align: left;
  white-space: nowrap;
}

td {
  padding: clamp(13px, 1vw, 18px) clamp(14px, 1.2vw, 20px);
  font-size: clamp(13px, 0.9vw, 15px);
  border-bottom: 1px solid var(--border);
  color: var(--t2);
}

tbody tr:hover td { background: rgba(255,255,255,0.015); }
tbody tr.banned td { opacity: 0.35; text-decoration: line-through; }
tbody tr:last-child td { border-bottom: none; }

.rank-badge {
  font-size: clamp(14px, 1vw, 17px);
  font-weight: 700;
  color: var(--t3);
  font-variant-numeric: tabular-nums;
}
.rank-badge.gold   { color: #f59e0b; }
.rank-badge.silver { color: #94a3b8; }
.rank-badge.bronze { color: #b45309; }

.team-name {
  font-size: clamp(14px, 1vw, 16px);
  font-weight: 600;
  color: var(--t1);
}

.score-value {
  font-family: var(--mono);
  font-size: clamp(14px, 1vw, 16px);
  font-weight: 600;
  color: var(--cyan);
  font-variant-numeric: tabular-nums;
}

/* ─────────────────────────────────────
   TAGS
───────────────────────────────────── */
.tag {
  display: inline-flex;
  align-items: center;
  padding: clamp(3px, 0.3vw, 5px) clamp(8px, 0.65vw, 11px);
  border-radius: 5px;
  font-size: clamp(11px, 0.78vw, 13px);
  font-weight: 600;
  letter-spacing: 0.2px;
  border: 1px solid;
  white-space: nowrap;
}
.tag-ok   { color: var(--green);  background: var(--gglow);  border-color: rgba(52,211,153,0.25); }
.tag-err  { color: var(--red);    background: var(--rglow);  border-color: rgba(248,113,113,0.25); }
.tag-warn { color: var(--amber);  background: var(--aglow);  border-color: rgba(251,191,36,0.25); }
.tag-dim  { color: var(--t3);     background: rgba(255,255,255,0.03); border-color: var(--border); }
.tag-blue { color: var(--indigo); background: rgba(129,140,248,0.1);  border-color: rgba(129,140,248,0.2); }

/* ─────────────────────────────────────
   TIMER
───────────────────────────────────── */
.timer-display {
  font-family: var(--mono);
  font-size: clamp(36px, 3.5vw, 52px);
  font-weight: 700;
  color: var(--cyan);
  letter-spacing: clamp(2px, 0.3vw, 5px);
  font-variant-numeric: tabular-nums;
  transition: color 0.5s;
}
.timer-display.warn   { color: var(--amber); }
.timer-display.danger { color: var(--red); animation: blink 0.5s infinite; }
@keyframes blink { 50% { opacity: 0.5; } }

/* ─────────────────────────────────────
   MODALS
───────────────────────────────────── */
.modal {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.78);
  z-index: 9000;
  justify-content: center;
  align-items: center;
  backdrop-filter: blur(4px);
  padding: 20px;
}
.modal.open { display: flex; }

.modal-box {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  padding: clamp(24px, 2vw, 36px);
  max-width: 520px;
  width: 100%;
  box-shadow: var(--shadow-lg);
}

.modal-title {
  font-size: clamp(16px, 1.2vw, 20px);
  font-weight: 700;
  color: var(--t1);
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close {
  background: none; border: none;
  color: var(--t3); font-size: clamp(18px, 1.3vw, 22px);
  cursor: pointer; transition: color 0.15s; padding: 2px;
}
.modal-close:hover { color: var(--t1); }

.modal-body {
  font-size: clamp(14px, 1vw, 16px);
  color: var(--t2);
  line-height: 1.7;
  margin-bottom: 22px;
}

.modal-foot { display: flex; justify-content: flex-end; gap: 10px; }

/* ─────────────────────────────────────
   TOASTS
───────────────────────────────────── */
.toast {
  position: fixed;
  bottom: clamp(20px, 2vw, 32px);
  right: clamp(20px, 2vw, 32px);
  padding: clamp(12px, 1vw, 16px) clamp(16px, 1.3vw, 22px);
  background: var(--card);
  border: 1px solid var(--border2);
  border-radius: var(--r2);
  font-size: clamp(13px, 0.9vw, 15px);
  font-weight: 500;
  z-index: 9999;
  transform: translateY(80px);
  opacity: 0;
  transition: all 0.25s cubic-bezier(0.34,1.56,0.64,1);
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 11px;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast-ok   { border-left: 3px solid var(--green); color: var(--t1); }
.toast-err  { border-left: 3px solid var(--red);   color: var(--t1); }
.toast-warn { border-left: 3px solid var(--amber);  color: var(--t1); }

/* ─────────────────────────────────────
   MISC COMPONENTS
───────────────────────────────────── */
.divider { height: 1px; background: var(--border); margin: clamp(18px, 1.5vw, 28px) 0; }

.hint-select {
  background: var(--raised);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  color: var(--t2);
  font-family: var(--font);
  font-size: clamp(13px, 0.9vw, 15px);
  padding: clamp(10px, 0.85vw, 13px) clamp(12px, 1vw, 15px);
  outline: none; width: 100%;
  cursor: pointer; transition: border-color 0.15s;
}
.hint-select:focus { border-color: var(--cyan2); }
.hint-select option { background: var(--surface); }

.section-head {
  font-size: clamp(12px, 0.85vw, 14px);
  font-weight: 600;
  color: var(--t3);
  margin-bottom: clamp(12px, 1vw, 18px);
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}

.hint-card {
  background: var(--raised);
  border: 1px solid var(--border2);
  border-radius: var(--r);
  padding: clamp(14px, 1.2vw, 20px);
  margin-bottom: 12px;
}
.hint-card-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

/* ─────────────────────────────────────
   SCROLLBAR
───────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border3); }

/* ─────────────────────────────────────
   GRIDS
───────────────────────────────────── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: clamp(14px, 1.2vw, 20px); }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: clamp(12px, 1vw, 18px); }

@media(max-width: 860px) { .grid2 { grid-template-columns: 1fr; } }
@media(max-width: 960px) { .grid3 { grid-template-columns: 1fr 1fr; } }
@media(max-width: 640px) { .grid3 { grid-template-columns: 1fr; } }

/* ─────────────────────────────────────
   UTILITIES
───────────────────────────────────── */
.mono  { font-family: var(--mono); }
.green { color: var(--green); }
.red   { color: var(--red); }
.amber { color: var(--amber); }
.cyan  { color: var(--cyan); }
.muted { color: var(--t3); }
.small { font-size: clamp(12px, 0.82vw, 14px); }

.center-page {
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: clamp(20px, 2vw, 36px);
  position: relative;
}

/* ─────────────────────────────────────
   PAGINATION
───────────────────────────────────── */
.pagination { display: flex; justify-content: center; gap: 6px; padding: clamp(14px, 1.2vw, 20px) 0 6px; flex-wrap: wrap; }
.pg-btn {
  padding: clamp(6px, 0.5vw, 9px) clamp(12px, 1vw, 16px);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: var(--r);
  color: var(--t3);
  font-size: clamp(12px, 0.85vw, 14px);
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}
.pg-btn:hover, .pg-btn.active {
  border-color: var(--cyan2);
  color: var(--cyan);
  background: var(--cglow2);
}

/* ─────────────────────────────────────
   PROGRESS BAR
───────────────────────────────────── */
.progress-bar {
  height: 5px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  margin: clamp(6px, 0.5vw, 10px) 0 clamp(18px, 1.5vw, 28px);
}
.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--cyan2), var(--cyan));
  border-radius: 4px;
  transition: width 0.5s ease;
}

/* ─────────────────────────────────────
   FLASH MESSAGES
───────────────────────────────────── */
.flash-ok, .flash-err {
  border-radius: var(--r);
  padding: clamp(12px, 1vw, 16px) clamp(16px, 1.3vw, 20px);
  font-size: clamp(13px, 0.9vw, 15px);
  font-weight: 500;
  margin-bottom: clamp(14px, 1.2vw, 20px);
}
.flash-ok {
  background: rgba(52,211,153,0.05);
  border: 1px solid rgba(52,211,153,0.22);
  color: var(--green);
}
.flash-err {
  background: rgba(248,113,113,0.05);
  border: 1px solid rgba(248,113,113,0.22);
  color: var(--red);
}

/* ─────────────────────────────────────
   SCORE ANIMATION
───────────────────────────────────── */
@keyframes score-bump {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.1); color: var(--cyan); }
  100% { transform: scale(1); }
}
.score-bump { animation: score-bump 0.4s ease; }

/* ─────────────────────────────────────
   RESPONSIVE — MOBILE SIDEBAR
───────────────────────────────────── */
@media(max-width: 768px) {
  :root { --sidebar: 0px; --topbar-h: 56px; }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    width: 260px;
  }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }

  .page {
    padding: 20px 16px;
  }
}
