:root {
  --radius: 24px;
  --shadow: 0 20px 60px rgba(23, 18, 61, 0.28);
  --shadow-soft: 0 10px 30px rgba(39, 20, 86, 0.18);
  --sidebar-width: 300px;
  --transition: 0.22s ease;
  --bottom-nav-height: 68px;
}

body[data-theme="dark"] {
  --bg: #0d1026;
  --bg-2: #131739;
  --bg-3: #1c2254;
  --card: rgba(26, 31, 74, 0.82);
  --card-2: rgba(35, 42, 96, 0.9);
  --card-3: rgba(25, 74, 110, 0.82);
  --text: #f4f7ff;
  --muted: #b7c2ef;
  --line: rgba(158, 180, 255, 0.16);
  --accent: #7c3aed;
  --accent-2: #06b6d4;
  --accent-3: #22c55e;
  --accent-4: #f59e0b;
  --danger: #ef4444;
  --warning: #fbbf24;
  --sidebar-top: #0a0d22;
  --sidebar-bottom: #14183b;
  --table-head: rgba(31, 37, 86, 0.95);
  --section-row: rgba(52, 61, 138, 0.72);
  --input-bg: rgba(15, 20, 50, 0.88);
  --chip-bg: rgba(124, 58, 237, 0.18);
  --chip-text: #d9c7ff;
  --badge-bg: rgba(6, 182, 212, 0.16);
  --badge-text: #a8f1ff;
  --bottom-nav-bg: rgba(10, 13, 34, 0.96);
}

body[data-theme="light"] {
  --bg: #eef2ff;
  --bg-2: #f6f7ff;
  --bg-3: #dff7ff;
  --card: rgba(255, 255, 255, 0.84);
  --card-2: rgba(255, 255, 255, 0.94);
  --card-3: rgba(236, 250, 255, 0.92);
  --text: #1b1d38;
  --muted: #6672a7;
  --line: rgba(97, 114, 194, 0.12);
  --accent: #7c3aed;
  --accent-2: #0891b2;
  --accent-3: #16a34a;
  --accent-4: #ea580c;
  --danger: #dc2626;
  --warning: #b45309;
  --sidebar-top: #4338ca;
  --sidebar-bottom: #0ea5e9;
  --table-head: rgba(242, 245, 255, 0.96);
  --section-row: rgba(227, 238, 255, 0.95);
  --input-bg: rgba(255, 255, 255, 0.96);
  --chip-bg: rgba(124, 58, 237, 0.1);
  --chip-text: #5b21b6;
  --badge-bg: rgba(8, 145, 178, 0.1);
  --badge-text: #0f5f73;
  --bottom-nav-bg: rgba(255, 255, 255, 0.97);
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  min-height: 100%;
  font-family: Inter, Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at 0% 0%, rgba(124, 58, 237, 0.16), transparent 30%),
    radial-gradient(circle at 100% 0%, rgba(6, 182, 212, 0.14), transparent 28%),
    radial-gradient(circle at 100% 100%, rgba(34, 197, 94, 0.1), transparent 30%),
    linear-gradient(180deg, var(--bg-3), var(--bg-2) 30%, var(--bg));
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
}

body {
  transition: background var(--transition), color var(--transition);
}

.hidden {
  display: none !important;
}

/* ─── APP LAYOUT ─────────────────────────────────────────── */
.app {
  min-height: 100vh;
  display: grid;
  grid-template-columns: var(--sidebar-width) 1fr;
}

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  background:
    radial-gradient(circle at 20% 0%, rgba(255, 255, 255, 0.12), transparent 26%),
    radial-gradient(circle at 100% 20%, rgba(255, 255, 255, 0.08), transparent 22%),
    linear-gradient(180deg, var(--sidebar-top), var(--sidebar-bottom));
  color: #fff;
  padding: 28px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  border-right: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset -1px 0 0 rgba(255,255,255,0.04);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.brand {
  padding-bottom: 18px;
  border-bottom: 1px solid rgba(255,255,255,0.1);
}

.brand h1 {
  margin: 0;
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.brand p {
  margin: 10px 0 0;
  color: rgba(255,255,255,0.75);
  font-size: 14px;
  line-height: 1.5;
}

.user-card {
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.1);
  backdrop-filter: blur(16px);
  color: #fff;
  padding: 18px;
  border-radius: 20px;
}

/* ─── BUTTONS ─────────────────────────────────────────────── */
.nav-btn,
.primary-btn,
.ghost-btn,
.danger-btn {
  width: 100%;
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 15px;
  font-weight: 800;
  transition: var(--transition);
  touch-action: manipulation;
}

.nav-btn {
  background: rgba(255,255,255,0.06);
  color: #fff;
  text-align: left;
}

.nav-btn:hover,
.nav-btn.active {
  background: linear-gradient(135deg, #8b5cf6, #06b6d4);
  box-shadow: 0 10px 24px rgba(6, 182, 212, 0.22);
  transform: translateY(-1px);
}

.primary-btn {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  box-shadow: 0 12px 28px rgba(124, 58, 237, 0.2);
}

.primary-btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.primary-btn:active {
  transform: translateY(0);
  filter: brightness(0.95);
}

.ghost-btn {
  background: rgba(255,255,255,0.06);
  color: var(--text);
  border: 1px solid var(--line);
}

.ghost-btn:hover {
  background: rgba(255,255,255,0.1);
}

.danger-btn {
  background: rgba(239,68,68,0.14);
  color: #ffe1e1;
  border: 1px solid rgba(239,68,68,0.18);
}

.sidebar-bottom {
  margin-top: auto;
}

/* ─── MAIN CONTENT ────────────────────────────────────────── */
.main {
  padding: 28px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-width: 0;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  margin-bottom: 22px;
}

.topbar h2 {
  margin: 0;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: -0.03em;
}

.topbar p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 16px;
}

/* ─── CARDS ───────────────────────────────────────────────── */
.card {
  background: var(--card);
  backdrop-filter: blur(18px);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px;
  margin-bottom: 20px;
}

.glass {
  background:
    linear-gradient(180deg, var(--card-2), var(--card-3));
}

/* ─── GRIDS ───────────────────────────────────────────────── */
.grid-2,
.grid-3,
.grid-4 {
  display: grid;
  gap: 18px;
}

.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* ─── STATS ───────────────────────────────────────────────── */
.stat {
  background:
    linear-gradient(135deg, rgba(255,255,255,0.05), rgba(255,255,255,0.02));
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: var(--shadow-soft);
  position: relative;
  overflow: hidden;
}

.stat::before {
  content: "";
  position: absolute;
  inset: 0 auto auto 0;
  width: 100%;
  height: 4px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent-4));
  opacity: 0.9;
}

.stat .label {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 8px;
}

.stat .value {
  font-size: 30px;
  font-weight: 900;
}

/* ─── FORMS ───────────────────────────────────────────────── */
label {
  display: block;
  font-size: 14px;
  font-weight: 800;
  margin-bottom: 8px;
}

input,
select,
textarea {
  width: 100%;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--input-bg);
  color: var(--text);
  font-size: 15px;
  outline: none;
  transition: var(--transition);
  -webkit-appearance: none;
  appearance: none;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(124, 58, 237, 0.45);
  box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.08);
}

textarea {
  min-height: 110px;
  resize: vertical;
}

.row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.row > * {
  flex: 1 1 190px;
}

/* ─── FE JUDGE BLOCK ──────────────────────────────────────── */
.form-row {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.form-group {
  flex: 1 1 180px;
  display: flex;
  flex-direction: column;
}

.form-group label {
  margin-bottom: 8px;
}

.form-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.form-actions .primary-btn,
.form-actions .ghost-btn {
  flex: 1 1 140px;
  width: auto;
}

.hint-box {
  background: rgba(251, 191, 36, 0.1);
  border: 1px solid rgba(251, 191, 36, 0.25);
  border-radius: 14px;
  padding: 12px 16px;
  color: var(--warning);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 14px;
}

#feJudgeBlock {
  padding: 0;
}

#feJudgeBlock .card {
  padding: 20px;
}

/* ─── TABLES ──────────────────────────────────────────────── */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.03);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
}

th,
td {
  padding: 14px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
  font-size: 14px;
}

th {
  background: var(--table-head);
  color: var(--muted);
  text-transform: uppercase;
  font-size: 12px;
  letter-spacing: 0.04em;
  font-weight: 900;
}

tbody tr:hover td {
  background: rgba(255,255,255,0.03);
}

.section-row td {
  background: var(--section-row);
  font-weight: 900;
}

/* ─── BADGES & CHIPS ──────────────────────────────────────── */
.badge,
.pill,
.hero-badge,
.chip,
.hero-point {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}

.badge {
  gap: 6px;
  padding: 8px 12px;
  background: var(--badge-bg);
  color: var(--badge-text);
  border: 1px solid rgba(255,255,255,0.05);
}

.pill {
  padding: 7px 12px;
  background: var(--chip-bg);
  color: var(--chip-text);
}

.hero-badge {
  padding: 8px 12px;
  background: rgba(255,255,255,0.1);
  color: #f2ebff;
  border: 1px solid rgba(255,255,255,0.12);
}

.chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.chip {
  padding: 10px 14px;
  background: var(--chip-bg);
  color: var(--chip-text);
  border: 1px solid rgba(255,255,255,0.04);
}

.hero-point {
  padding: 10px 14px;
  background: rgba(255,255,255,0.08);
  color: #f9fbff;
  border: 1px solid rgba(255,255,255,0.08);
}

/* ─── UTILITY ─────────────────────────────────────────────── */
.muted { color: var(--muted); }
.small { font-size: 13px; }

.warning {
  color: var(--warning);
  font-size: 13px;
  margin-top: 10px;
  font-weight: 700;
}

.no-top { margin-top: 0; }
.mt-14 { margin-top: 14px; }
.mt-18 { margin-top: 18px; }
.mt-20 { margin-top: 20px; }
.space-14 { height: 14px; }
.space-16 { height: 16px; }
.space-18 { height: 18px; }

.category-value {
  font-size: 20px !important;
  font-weight: 900 !important;
}

.score-input {
  width: 80px;
  min-width: 64px;
  padding: 10px 8px;
  text-align: center;
}

.match-result-cell { font-weight: 800; }
.status-ok   { color: var(--accent-3); }
.status-bad  { color: var(--danger); }
.status-draw { color: var(--accent-4); }

input[type="checkbox"] {
  width: 22px;
  height: 22px;
  cursor: pointer;
  flex-shrink: 0;
}

.team-open-btn {
  width: auto;
  min-width: 120px;
  text-align: center;
  padding: 8px 14px;
  font-size: 14px;
  border-radius: 12px;
}

/* ─── AUTH ────────────────────────────────────────────────── */
.auth-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
  background:
    radial-gradient(circle at top right, rgba(6, 182, 212, 0.2), transparent 24%),
    radial-gradient(circle at top left, rgba(124, 58, 237, 0.22), transparent 26%),
    radial-gradient(circle at bottom center, rgba(34, 197, 94, 0.12), transparent 24%),
    linear-gradient(180deg, var(--bg-2), var(--bg));
}

.auth-card {
  width: min(1140px, 100%);
  display: grid;
  grid-template-columns: 1.05fr 1fr;
  background: var(--card);
  backdrop-filter: blur(22px);
  border-radius: 30px;
  overflow: hidden;
  box-shadow: 0 24px 80px rgba(21, 19, 66, 0.26);
  border: 1px solid var(--line);
}

.auth-hero {
  background:
    radial-gradient(circle at top right, rgba(6, 182, 212, 0.28), transparent 30%),
    radial-gradient(circle at bottom left, rgba(124, 58, 237, 0.28), transparent 32%),
    radial-gradient(circle at 70% 60%, rgba(34, 197, 94, 0.14), transparent 24%),
    linear-gradient(180deg, #14183b, #1f2562 55%, #0e7490);
  color: #fff;
  padding: 38px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.auth-hero h1 {
  margin: 18px 0 10px;
  font-size: 48px;
  line-height: 1.02;
  letter-spacing: -0.04em;
  font-weight: 900;
}

.auth-hero p {
  margin: 0 0 18px;
  color: rgba(255,255,255,0.86);
  line-height: 1.6;
  font-size: 16px;
}

.hero-points {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 10px;
}

.auth-panel {
  padding: 38px;
  background: rgba(255,255,255,0.02);
}

.auth-title {
  margin: 0 0 6px;
  font-size: 28px;
  font-weight: 900;
}

.auth-subtitle {
  margin: 0 0 18px;
  color: var(--muted);
}

.switcher {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.switcher button {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
  transition: var(--transition);
}

.switcher button.active {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

/* ─── SUBMISSION CARDS ────────────────────────────────────── */
.submission-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(255,255,255,0.03);
  margin-bottom: 14px;
}

.submission-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ─── FOOTER ──────────────────────────────────────────────── */
.footer {
  margin-top: auto;
  padding: 20px 8px 4px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

.footer-left { font-weight: 800; }
.footer-right { text-align: right; }

/* ─── MODAL ───────────────────────────────────────────────── */
body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(9, 12, 30, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  backdrop-filter: blur(6px);
}

.modal-dialog {
  width: min(1000px, 100%);
  max-height: 90vh;
  overflow-y: auto;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 24px;
  -webkit-overflow-scrolling: touch;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.modal-header h3 {
  margin: 0;
  font-size: 24px;
  font-weight: 900;
}

.modal-close-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 12px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  font-size: 18px;
  font-weight: 800;
  flex-shrink: 0;
}

.modal-footer { margin-top: 18px; }

.modal-list { display: grid; gap: 12px; }

.modal-select-card {
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255,255,255,0.04);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  transition: var(--transition);
}

.modal-select-card:hover {
  border-color: rgba(124, 58, 237, 0.4);
  background: rgba(255,255,255,0.07);
  transform: translateY(-1px);
}

.modal-select-index {
  min-width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  background: var(--chip-bg);
  color: var(--chip-text);
  font-weight: 900;
}

.modal-select-main { flex: 1; }

.modal-grid-2,
.modal-grid-3 {
  display: grid;
  gap: 14px;
}

.modal-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.modal-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.modal-summary-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
}

.compact-stat { margin-bottom: 0; }

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 18px;
  flex-wrap: wrap;
}

.modal-actions .primary-btn,
.modal-actions .ghost-btn {
  width: auto;
  min-width: 140px;
  flex: 1 1 140px;
}

.modal-static-field {
  width: 100%;
  min-height: 50px;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--input-bg);
  color: var(--text);
}

.judge-value { font-size: 18px !important; }

/* ─── LANG SWITCHER ───────────────────────────────────────── */
.lang-switcher,
.floating-lang-switcher {
  display: flex;
  gap: 8px;
}

.lang-switcher { margin-bottom: 8px; }

.floating-lang-switcher {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 1200;
}

.lang-btn {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition: var(--transition);
  touch-action: manipulation;
}

.lang-btn.active,
.lang-btn:hover {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
  border-color: transparent;
}

.sidebar .lang-btn {
  color: #fff;
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}

/* ─── ADMIN REGION SELECT ─────────────────────────────────── */
#adminRegionSelect {
  max-width: 260px;
  margin-bottom: 16px;
}

/* ════════════════════════════════════════════════════════════
   TABLET  ≤ 1100px
════════════════════════════════════════════════════════════ */
@media (max-width: 1100px) {
  .auth-card {
    grid-template-columns: 1fr;
  }

  .auth-hero {
    padding: 28px;
  }

  .auth-hero h1 {
    font-size: 36px;
  }
}

/* ════════════════════════════════════════════════════════════
   MOBILE  ≤ 768px  — Bottom Nav Mode
════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {

  /* ── Layout ── */
  .app {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto;
    padding-bottom: var(--bottom-nav-height);
  }

  /* ── Sidebar → Bottom nav ── */
  .sidebar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    top: auto;
    width: 100%;
    height: var(--bottom-nav-height);
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    padding: 0 8px;
    gap: 4px;
    border-right: none;
    border-top: 1px solid rgba(255,255,255,0.1);
    background:
      linear-gradient(135deg, var(--sidebar-top), var(--sidebar-bottom));
    backdrop-filter: blur(20px);
    z-index: 900;
    box-shadow: 0 -8px 32px rgba(0,0,0,0.3);
    overflow: hidden;
  }

  /* Hide sidebar items except nav buttons */
  .sidebar .brand,
  .sidebar .user-card,
  .sidebar .lang-switcher,
  .sidebar .sidebar-bottom,
  .sidebar .theme-switcher,
  #adminRegionSelect {
    display: none !important;
  }

  /* Nav buttons — compact icon+label style */
  .nav-btn {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 8px 4px;
    font-size: 10px;
    font-weight: 700;
    border-radius: 14px;
    gap: 4px;
    min-width: 0;
    text-align: center;
    letter-spacing: 0;
    background: transparent;
    color: rgba(255,255,255,0.6);
    border: none;
    height: 52px;
  }

  .nav-btn::before {
    font-size: 20px;
    line-height: 1;
  }

  .nav-btn[data-view="dashboard"]::before  { content: "🏠"; }
  .nav-btn[data-view="judging"]::before    { content: "⚖️"; }
  .nav-btn[data-view="results"]::before    { content: "📊"; }
  .nav-btn[data-view="admin"]::before      { content: "⚙️"; }

  .nav-btn:hover,
  .nav-btn.active {
    background: rgba(255,255,255,0.12);
    color: #fff;
    box-shadow: none;
    transform: none;
  }

  .nav-btn.active {
    color: #7dd3fc;
  }

  /* ── Logout → floating top-left ── */
  .sidebar-bottom {
    display: block !important;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    margin: 0;
  }

  .danger-btn {
    width: auto;
    padding: 9px 16px;
    font-size: 13px;
    border-radius: 12px;
  }

  /* ── Main ── */
  .main {
    padding: 14px 14px 20px;
    min-height: calc(100vh - var(--bottom-nav-height));
  }

  /* ── Top bar ── */
  .topbar {
    padding-left: 80px; /* space for logout button */
    margin-bottom: 16px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .topbar p {
    font-size: 14px;
    margin-top: 4px;
  }

  /* ── Cards ── */
  .card {
    padding: 16px;
    border-radius: 18px;
    margin-bottom: 14px;
  }

  /* ── Grids ── */
  .grid-2,
  .grid-3,
  .grid-4 {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .grid-4 { grid-template-columns: repeat(2, 1fr); }

  /* ── Stats ── */
  .stat {
    padding: 14px;
    border-radius: 16px;
  }

  .stat .value {
    font-size: 22px;
  }

  .stat .label {
    font-size: 11px;
  }

  /* ── Forms ── */
  .row {
    flex-direction: column;
    gap: 10px;
  }

  .row > * {
    flex: 1 1 auto;
  }

  .form-row {
    flex-direction: column;
    gap: 10px;
  }

  .form-group {
    flex: 1 1 auto;
  }

  input,
  select {
    padding: 13px 14px;
    font-size: 16px; /* prevents iOS zoom */
    border-radius: 14px;
  }

  /* ── Tables ── */
  .table-wrap {
    border-radius: 14px;
    margin: 0 -2px;
  }

  table {
    min-width: 500px;
    font-size: 13px;
  }

  th,
  td {
    padding: 10px 8px;
    font-size: 13px;
  }

  .score-input {
    width: 64px;
    padding: 8px 4px;
    font-size: 15px;
  }

  input[type="checkbox"] {
    width: 24px;
    height: 24px;
  }

  /* ── Auth ── */
  .auth-shell {
    padding: 14px;
    align-items: flex-start;
    padding-top: 60px;
  }

  .auth-card {
    grid-template-columns: 1fr;
    border-radius: 22px;
  }

  .auth-hero {
    padding: 24px;
  }

  .auth-hero h1 {
    font-size: 30px;
  }

  .auth-panel {
    padding: 24px;
  }

  .auth-title {
    font-size: 22px;
  }

  .switcher {
    gap: 6px;
  }

  .switcher button {
    padding: 10px 6px;
    font-size: 13px;
  }

  /* ── Floating lang ── */
  .floating-lang-switcher {
    top: 12px;
    right: 12px;
  }

  .lang-btn {
    padding: 8px 12px;
    font-size: 12px;
  }

  /* ── Modal ── */
  .modal {
    padding: 0;
    align-items: flex-end;
  }

  .modal-dialog {
    max-height: 92vh;
    border-radius: 24px 24px 0 0;
    padding: 20px 16px;
    width: 100%;
  }

  .modal-header h3 {
    font-size: 18px;
  }

  .modal-grid-2,
  .modal-grid-3 {
    grid-template-columns: 1fr;
  }

  .modal-summary-row {
    grid-template-columns: 1fr 1fr;
  }

  .modal-actions {
    flex-direction: column;
  }

  .modal-actions .primary-btn,
  .modal-actions .ghost-btn {
    width: 100%;
    flex: none;
  }

  /* ── Submission cards ── */
  .submission-card {
    padding: 14px;
    border-radius: 14px;
  }

  /* ── Footer ── */
  .footer {
    flex-direction: column;
    gap: 4px;
    font-size: 12px;
    padding: 12px 4px;
  }

  .footer-right {
    text-align: left;
  }

  /* ── Chips ── */
  .chip {
    padding: 8px 10px;
    font-size: 11px;
  }

  /* ── Category value ── */
  .category-value {
    font-size: 16px !important;
  }

  .team-open-btn {
    min-width: 90px;
    font-size: 13px;
    padding: 6px 10px;
  }
}

/* ════════════════════════════════════════════════════════════
   SMALL PHONE  ≤ 380px
════════════════════════════════════════════════════════════ */
@media (max-width: 380px) {
  .topbar h2 { font-size: 20px; }
  .topbar { padding-left: 70px; }

  .grid-4 { grid-template-columns: 1fr 1fr; }

  .auth-hero h1 { font-size: 26px; }

  .stat .value { font-size: 18px; }

  .nav-btn { font-size: 9px; }
  .nav-btn::before { font-size: 18px; }

  table { min-width: 420px; }

  th, td { padding: 8px 6px; font-size: 12px; }

  .score-input { width: 54px; }
}