/* ===== Marathon theme and shared components ===== */
:root{
  --cm-bg:#fff;
  --cm-fg:#222;
  --cm-accent:#2b6cb0;
  --cm-muted:#e9eef5;
  --cm-border:#dbe3ef;
  --cm-h1:#165c2e;        /* заголовок сезона/страницы */
  --cm-h2:#4e6e30;        /* «Турнирная таблица» */
  --cm-h2-badges:#b03060; /* «Бейджи» */
  --cm-h2-journal:#2c3e50;/* «Журнал» */
}

/* ===== Base ===== */
html,body{margin:0;padding:0}
body{
  font-family: Verdana, Arial, Helvetica, sans-serif;
  font-size: 14px;              /* ↑ было 11px */
  color: var(--cm-fg);
  background: var(--cm-bg);
}
a{ color:#1b59c5; text-decoration:none; }
a:hover{ text-decoration:underline; }

/* ===== Top Nav ===== */
.cm-container{max-width:1120px;margin:0 auto;padding:0 16px;}
.cm-nav{
  position:sticky; top:0; z-index:1000;
  background:var(--cm-bg);
  border-bottom:1px solid var(--cm-border);
  box-shadow:0 2px 8px rgba(0,0,0,.04);
}

/* ЛОГОТИП: слева, как у таблицы */
.cm-brand{
  padding:12px 0 6px;
  text-align:left;            /* было center */
}
.cm-brand .cm-logo{
  height:100px;
  width:auto;
  display:block;
}

/* МЕНЮ: под логотипом, выравнивание влево */
.cm-menu{
  display:flex;
  flex-wrap:wrap;
  gap:12px;
  align-items:center;
  list-style:none;
  padding:6px 0 12px;
  margin:0;
  justify-content:flex-start; /* было center */
  font-size:15px;
}

/* .cm-menu .cm-spacer{flex:1 1 auto} */
.cm-menu .cm-spacer{display:none}

.cm-menu a{
  display:inline-block;
  padding:8px 12px;
  border-radius:10px;
  text-decoration:none;
  color:var(--cm-fg);
  border:1px solid transparent;
}
.cm-menu a[aria-selected="true"]{
  border-color:var(--cm-accent);
  background:var(--cm-muted);
  font-weight:600;
}
.cm-menu a:hover{background:var(--cm-muted)}

.cm-main{padding:18px 0;}
.cm-tab[hidden]{display:none !important;}

/* ===== Section titles ===== */
.cm-title{ text-align:center; margin:8px 0 14px; }
.cm-title.h1{ color:var(--cm-h1); font-size:22px; line-height:1.2; }
.cm-title.h2-main{ color:var(--cm-h2); font-size:18px; }
.cm-title.h2-badges{ color:var(--cm-h2-badges); font-size:18px; }
.cm-title.h2-journal{ color:var(--cm-h2-journal); font-size:18px; }
.cm-title.h2-topgames{ color:var(--cm-h2-topgames); font-size:18px; }
.cm-title:focus { outline: none; }

/* ===== Logo ===== */
.cm-brand {
  text-align: center;
  margin: 1px 0;
}

.cm-logo {
  max-width: 200px;
  height: auto;
}

/* ===== Layout wrapper ===== */
.table-wrapper{max-width:1135px;margin:0 auto;padding:0 16px 32px;}
.table-wrapper-left{max-width:1120px;margin:0;padding:0 16px 32px;}

/* ===== Old cell classes (нужны таблицам) ===== */
TD.head{
  background-color:#DADADA; font-size:12px; color:#000; font-weight:bold; text-align:center;
}
TD.ccent, TD.cleft, TD.cright{
  background-color:#F5F5F5; font-size:12px; color:#000;
}
TD.nbgcent{ font-size:12px; color:#000; text-align:center; }
TD.ccent{ text-align:center; }
TD.cright{ text-align:right; }
TD.cleft{ text-align:left; }

/* ===== Tournament table ===== */
.tournament-table{
  width:100%; border-collapse:collapse; font-size:0.95em; background:#fff;
  box-shadow:0 0 6px rgba(0,0,0,.08);
}
.tournament-table th, .tournament-table td{ padding:8px 10px; border:1px solid #ccc; text-align:center; }
.tournament-table th{ background:#e0e0e0; font-weight:bold; }
.tournament-table td.text-left{ text-align:left; background:#f8f8f8; color:#000; }

.tournament-table tr td:first-child { font-weight:700; }

/* 1 место — золото */
.tournament-table tr:nth-child(3) td:first-child {
  background: linear-gradient(180deg,#FFD700 0%,#FFC700 60%,#E6B800 100%);
  color:#000; border:2px solid #E6B800;
}
/* 2 место — серебро */
.tournament-table tr:nth-child(4) td:first-child {
  background: linear-gradient(180deg,#E6E9EE 0%,#D0D6DE 60%,#B8C2CC 100%);
  color:#000; border:2px solid #B8C2CC;
}
/* 3 место — бронза */
.tournament-table tr:nth-child(5) td:first-child {
  background: linear-gradient(180deg,#E8B07A 0%,#D08A4A 60%,#B87333 100%);
  color:#000; border:2px solid #B87333;
}

/* 4–10 места — фиолетово-лиловый градиент */
.tournament-table tr:nth-child(6)  td:first-child { background:#6d28d9; color:#fff; } /* 4 */
.tournament-table tr:nth-child(7)  td:first-child { background:#7c3aed; color:#fff; } /* 5 */
.tournament-table tr:nth-child(8)  td:first-child { background:#8b5cf6; color:#fff; } /* 6 */
.tournament-table tr:nth-child(9)  td:first-child { background:#a78bfa; color:#000; } /* 7 */
.tournament-table tr:nth-child(10) td:first-child { background:#c4b5fd; color:#000; } /* 8 */
.tournament-table tr:nth-child(11) td:first-child { background:#ddd6fe; color:#000; } /* 9 */
.tournament-table tr:nth-child(12) td:first-child { background:#f5f3ff; color:#000; } /* 10 */

/* ===== Badges table ===== */
.badges-table{
  width:100%; border-collapse:collapse; font-size:0.9em; background:#fff;
  box-shadow:0 0 6px rgba(0,0,0,.08);
}
.badges-table th, .badges-table td{ padding:8px 10px; border:1px solid #ccc; text-align:center; }
.badges-table th{ background:#e0e0e0; font-weight:bold; }
.badges-table td.text-left{ text-align:left; background:#f9f9f9; }

/* узкая таблица на 1/3 уровне для центрирования */
#badges-level-1, #badges-level-3 {
  text-align:center;
}

#badges-level-1 .badges-table,
#badges-level-3 .badges-table {
  width:max-content;
  max-width:100%;
  display:inline-table;
  table-layout:auto;
}

#badges-level-1 .badges-table th,
#badges-level-1 .badges-table td,
#badges-level-3 .badges-table th,
#badges-level-3 .badges-table td {
  white-space:nowrap;
}

#badges-level-1 .badges-table td.text-left,
#badges-level-3 .badges-table td.text-left {
  min-width:180px;
}

.badges-note{
  font-style: italic;
  color:#666;
  margin:8px 0 16px;
  text-align:center; /* убери, если надо слева */
}

/* ===== History table ===== */
.history-table{
  width:100%; border-collapse:collapse; font-size:0.95em; background:#fff;
  box-shadow:0 0 6px rgba(0,0,0,.08);
}
.history-table th, .history-table td{ padding:8px 10px; border:1px solid #ccc; text-align:center; }
.history-table th{ background:#e0e0e0; font-weight:bold; }
.history-table td.text-left{ text-align:left; background:#F5F5F5; }

/* ===== Topgames table ===== */
.topgames-table{
  border-collapse:collapse; font-size:0.9em; background:#fff;
  box-shadow:0 0 6px rgba(0,0,0,.08);
  table-layout: auto;
  margin: 0 auto;
}
.topgames-table th, .topgames-table td{ padding:8px 10px; border:1px solid #ccc; text-align:center; }
.topgames-table th{ background:#e0e0e0; font-weight:bold; }
.topgames-table td.text-left{ text-align:left; background:#f9f9f9; }

/* ===== Badges inner tabs ===== */
.tabs{ display:flex; justify-content:center; gap:8px; margin:8px 0 12px; }
.tab{ padding:6px 10px; border:1px solid var(--cm-border); background:#f8fafc; border-radius:8px; cursor:pointer }
.tab.active{ background:var(--cm-muted); border-color:var(--cm-accent); font-weight:600 }
.tabpane{ display:none }
.tabpane.active{ display:block }

/* ===== Journal filters ===== */
.marafilters{ max-width:1024px; margin:8px 0 1px; padding:6px 10px; }
.marafilters-row{ display:flex; justify-content:center; align-items:center; gap:16px; flex-wrap:wrap; }
.marafilters-group{ display:flex; align-items:center; gap:6px; white-space:nowrap; }
.marafilters-label{ color:#444; font-size:12px; margin:0; }
.marafilters-select{ font-size:12px; padding:5px 8px; border:1px solid #ccc; border-radius:5px; background:#fff; color:#000; }

/* ===== Profile & forms ===== */
.profile-top-panel{
  max-width:1120px;
  margin:16px auto 24px;
  padding:12px 16px;
  background:#f7fafc;
  border:1px solid var(--cm-border);
  border-radius:10px;
}
.profile-top-panel-header{
  display:flex; flex-wrap:wrap; gap:10px;
  justify-content:center; text-align:center;
  font-size:14px; line-height:1.5;
}
.profile-top-panel-header span{
  white-space:nowrap; position:relative; padding:0 8px;
}
.profile-top-panel-header span:not(:last-child)::after{
  content:"|";
  position:absolute; right:-6px; color:#999;
}
.profile-top-panel-header a{
  color:var(--cm-accent); font-weight:500;
}
.profile-top-panel-header a:hover{ text-decoration:underline; }

.back-link{
  max-width:1120px; margin:20px auto; text-align:center;
}
.back-link a{
  color:var(--cm-accent); font-weight:500;
  text-decoration:none;
}
.back-link a:hover{ text-decoration:underline; }

.login-form, .request-form{
  max-width:460px; margin:14px auto; padding:16px 18px;
  background:#fff; border:1px solid #e5e9f2; border-radius:12px;
  box-shadow:0 2px 12px rgba(0,0,0,.04);
}
.login-form .form-title{ text-align:center; margin:0 0 12px; }

.form-row{
  display:flex; column-gap:14px; flex-wrap:wrap; align-items:flex-start; margin:0 -4px;
}
.form-row .form-group{ flex:1 1 300px; min-width:260px; padding:0 4px; }

.form-group{ margin:10px 0; }
.form-group label{ display:block; margin-bottom:6px; font-size:13px; color:#444; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select{
  width:100%; padding:8px 10px; font-size:14px; color:#000;
  background:#fff; border:1px solid #cfd7e3; border-radius:8px; outline:none;
}
.form-group input:focus, .form-group select:focus{ border-color:var(--cm-accent); }

.primary-button,
.request-button button,
.submit-button input[type="submit"]{
  display:inline-block; padding:9px 14px; border-radius:10px;
  background:var(--cm-accent); color:#fff; border:1px solid var(--cm-accent);
  font-weight:600; cursor:pointer;
}
.primary-button:hover,
.request-button button:hover,
.submit-button input[type="submit"]:hover{ filter:brightness(0.95); }

.request-button{ text-align:center; margin:8px 0 0; }
.submit-button{ text-align:center; margin-top:14px; }

.bonus-penalty{
  display:flex; gap:18px; align-items:center; flex-wrap:wrap;
  padding:8px 10px; margin:8px 0; background:#f8fafc; border:1px dashed var(--cm-border); border-radius:8px;
}
.bonus-penalty strong{ color:#333; }

.login-error, .form-error{
  max-width:760px; margin:10px auto; padding:10px 12px; border-radius:8px;
  background:#fff5f5; color:#b00020; border:1px solid #ffd0d0;
}

.form-separator {
  border: 0;
  border-top: 1px dashed #cbd5e1;
  margin: 20px 0;
}

.request-form .form-section-title {
  display: flex;
  align-items: center;
  width: 100%;
  gap: 12px;
  margin: 20px 0;
  color: #64748b;
  font-size: 13px;
  text-align: center;
}

.request-form .form-section-title::before,
.request-form .form-section-title::after {
  content: "";
  display: block;
  flex: 1 1 auto;
  min-width: 20px;
  border-top: 1px dashed #cbd5e1;
}

.request-form .form-section-title > span {
  flex: 0 0 auto;
}

/* Заголовки внутри карточек */
.request-form h3, .login-form h3{ margin:4px 0 8px; font-size:18px; }

/* Попап с оценкой игры */
.rate-modal-overlay {
  position: fixed; left: 0; top: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.45);
  display: none;
  z-index: 1000;
}
.rate-modal {
  position: fixed;
  left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  background: #fff;
  width: min(520px, calc(100vw - 32px));
  border-radius: 10px;
  padding: 16px 16px 12px 16px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  display: none;
  z-index: 1001;
}
.rate-modal h3 { margin: 0 0 10px 0; font-size: 16px; }
.rate-modal .rate-title { font-weight: 700; margin-bottom: 10px; }
.rate-modal .rate-row { display: flex; align-items: center; gap: 12px; }
.rate-modal input[type="range"] { width: 100%; }
.rate-modal .rate-value { width: 70px; text-align: right; font-variant-numeric: tabular-nums; }
.rate-modal .rate-actions { display: flex; gap: 10px; justify-content: flex-end; margin-top: 12px; }
.rate-modal .rate-error { color: #b00020; margin-top: 8px; display: none; }
.rate-link { cursor: pointer; text-decoration: underline; }


@media (max-width:720px) {
  /* верхнее меню компактнее */
  .cm-menu .cm-spacer { display:none; }
  .cm-brand { font-size:16px; padding:8px 0 2px; }
  .cm-brand .cm-logo{height:48px;}
  .cm-menu { font-size:13px; gap:6px; }
  .cm-menu a { padding:5px 8px; border-radius:6px; }

  /* формы и панель профиля */
  .login-form, .request-form { margin:10px 12px; }
  .profile-top-panel { margin:12px 12px 6px; }

  /* таблицы компактнее */
  .tournament-table,
  .badges-table,
  .history-table {
    font-size:12px;
    min-width:600px;
  }
  .tournament-table th, .tournament-table td,
  .badges-table th, .badges-table td,
  .history-table th, .history-table td {
    padding:3px 5px;
  }

  /* скролл по горизонтали */
  .table-wrapper {
    overflow-x:auto;
    -webkit-overflow-scrolling:touch;
  }
}

@media (max-width:480px) {
  .tournament-table,
  .badges-table,
  .history-table {
    font-size:11px;
    min-width:300px;
  }
  .tournament-table th, .tournament-table td,
  .badges-table th, .badges-table td,
  .history-table th, .history-table td {
    padding:2px 3px;
  }

  .tournament-table tr:first-child td[colspan] { display:none; }

  .tournament-table tr:nth-child(2) td:nth-child(3),
  .tournament-table tr:nth-child(2) td:nth-child(4),
  .tournament-table tr:nth-child(2) td:nth-child(5) { display:none; }

  .tournament-table tr:nth-child(2) td.head:last-child{
    position:relative; color:transparent;
  }
  .tournament-table tr:nth-child(2) td.head:last-child::after{
    content:"Очки";
    position:absolute; inset:0;
    display:flex; align-items:center; justify-content:center;
    color:#000; font-weight:bold;
  }

  .tournament-table tr:not(:first-child):not(:nth-child(2)) td:nth-child(5),
  .tournament-table tr:not(:first-child):not(:nth-child(2)) td:nth-child(6),
  .tournament-table tr:not(:first-child):not(:nth-child(2)) td:nth-child(7) {
    display:none;
  }
}
.history-table .difficulty-stars {
  color: #f5b301;
  font-size: 1.05em;
  letter-spacing: 1px;
  white-space: nowrap;
}

.history-table .score-value {
  display: block;
  font-weight: 700;
}

.history-table .score-adjustment {
  display: block;
  margin-top: 2px;
  color: #64748b;
  font-size: 11px;
  font-weight: 400;
  line-height: 1.2;
  white-space: nowrap;
}

/* ===== Анонс сезона до начала марафона ===== */
.marathon-coming-soon {
  width: min(900px, calc(100% - 32px));
  margin: clamp(48px, 10vh, 110px) auto;
  padding: clamp(32px, 6vw, 64px);
  box-sizing: border-box;
  text-align: center;
  background:
    radial-gradient(circle at top right, rgba(59, 130, 246, .16), transparent 38%),
    linear-gradient(145deg, #fff 0%, #f7faff 100%);
  border: 1px solid #d8e2f0;
  border-radius: 22px;
  box-shadow: 0 18px 48px rgba(30, 64, 175, .12);
}

.marathon-coming-eyebrow {
  margin: 0 0 14px;
  color: #2563eb;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
}

.marathon-coming-soon h1 {
  max-width: 760px;
  margin: 0 auto;
  color: #172033;
  font-size: clamp(30px, 5vw, 52px);
  line-height: 1.12;
}

.marathon-coming-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  margin-top: clamp(28px, 5vw, 44px);
}

.marathon-coming-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 20px;
  color: #2457a7;
  font-weight: 700;
  text-decoration: none;
  background: #fff;
  border: 1px solid #b9cbea;
  border-radius: 10px;
  transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}

.marathon-coming-action:hover,
.marathon-coming-action:focus-visible {
  border-color: #3b82f6;
  box-shadow: 0 7px 18px rgba(37, 99, 235, .16);
  transform: translateY(-1px);
}

.marathon-coming-action--primary {
  color: #fff;
  background: #356cc5;
  border-color: #356cc5;
}

@media (max-width: 600px) {
  .marathon-coming-soon {
    width: calc(100% - 20px);
    margin: 28px auto;
    padding: 30px 18px;
    border-radius: 16px;
  }

  .marathon-coming-eyebrow {
    font-size: 12px;
  }

  .marathon-coming-actions {
    flex-direction: column;
  }

  .marathon-coming-action {
    width: 100%;
    box-sizing: border-box;
  }
}
