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

:root {
  --bg: #05060f;
  --panel-bg: rgba(10, 18, 40, 0.75);
  --panel-border: #1e3a6e;
  --accent: #2e8fff;
  --text-dim: #4d7fc4;
  --text-bright: #eaf4ff;
}

html, body {
  height: 100%;
}

body {
  background: radial-gradient(ellipse at 50% 30%, #0a1128 0%, var(--bg) 65%);
  color: var(--text-bright);
  font-family: "Segoe UI", "Arial", sans-serif;
  overflow: hidden;           /* у страницы-игры нет скролла */
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---------- Фоновые декорации ---------- */
.bg-decor {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
}
.decor {
  position: absolute;
  filter: blur(6px);
  opacity: 0.45;
}
.d1 { width: 130px; top: 4%;  right: 3%;  fill: #43c527; transform: rotate(18deg); }
.d2 { width: 150px; bottom: 8%; right: 5%; fill: #43c527; transform: rotate(-12deg); }
.d3 { width: 140px; bottom: 4%; left: 3%;  fill: #8e44e0; transform: rotate(9deg); }
.d4 { width: 90px;  top: 30%;  left: 2%;  fill: #8e44e0; transform: rotate(-20deg); }

/* ---------- Сцена: обёртка всего интерфейса ---------- */
#stage { position: relative; }

/* Режим «вписать в экран» (телефоны и маленькие окна):
 * раскладка фиксируется как на ПК и масштабируется целиком */
html.fit .logo { display: none; }
html.fit .board-wrap { height: 720px; }
html.fit #stage { transform-origin: center center; }

/* Заглушка «поверни телефон» в портретной ориентации */
#rotateOverlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: radial-gradient(ellipse at 50% 40%, #0a1128 0%, #04050e 70%);
  color: #b8d4f5;
  font-size: 24px;
  font-weight: 700;
  line-height: 1.6;
  padding: 24px;
}
html.portrait-lock #rotateOverlay { display: flex; }
.rotate-icon {
  font-size: 64px;
  margin-bottom: 18px;
  animation: rotateHint 2s ease-in-out infinite;
}
@keyframes rotateHint {
  0%, 55%, 100% { transform: rotate(0deg); }
  25%, 35% { transform: rotate(-90deg); }
}

/* ---------- Логотип ---------- */
.logo {
  position: absolute;
  top: 22px;
  left: 34px;
  z-index: 5;
  user-select: none;
  line-height: 0.95;
}
.logo-line1 {
  font-size: 34px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 1px;
  color: #fff;
  text-shadow: 0 2px 0 #1a2c55, 0 0 18px rgba(46, 143, 255, 0.8);
}
.logo-line2 {
  font-size: 46px;
  font-weight: 900;
  font-style: italic;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #ff4747, #ffb300, #3fd23f, #2e8fff, #b44bff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 0 12px rgba(46, 143, 255, 0.55));
}

/* ---------- Основная раскладка ---------- */
.layout {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 30px;
  z-index: 1;
}

.panel-col {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 180px;
}
.left-col  { align-items: stretch; }
.right-col { align-items: stretch; }

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: 0 0 22px rgba(20, 60, 140, 0.35), inset 0 0 30px rgba(20, 50, 120, 0.15);
  text-align: center;
}

.panel-title {
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(46, 143, 255, 0.7);
  margin-bottom: 8px;
}

.hidden { display: none !important; }

.stats .stat { padding: 8px 0; }

.daily-badge {
  margin-top: 10px;
  padding: 6px 8px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #ffd66b;
  background: rgba(255, 190, 60, 0.12);
  border: 1px solid rgba(255, 190, 60, 0.4);
  text-shadow: 0 0 8px rgba(255, 190, 60, 0.6);
}
.stats .stat + .stat { border-top: 1px solid rgba(46, 100, 190, 0.35); }
.stat-label {
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--accent);
  text-shadow: 0 0 8px rgba(46, 143, 255, 0.6);
}
.stat-value {
  font-size: 27px;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 12px rgba(160, 210, 255, 0.55);
}

#nextCanvas, #holdCanvas { display: block; margin: 0 auto; }

/* ---------- Игровое поле ---------- */
/* Круг занимает всю высоту окна и масштабируется вместе с ним */
.board-wrap {
  position: relative;
  height: min(calc(100vh - 16px), 62vw);
  aspect-ratio: 1 / 1;
}
#board { display: block; width: 100%; height: 100%; touch-action: none; }

/* ---------- Кнопка «в меню» на экране результата ---------- */
.menu-link {
  display: inline-block;
  margin-top: 14px;
  padding: 8px 22px;
  background: none;
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  color: #9db8dd;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.menu-link:hover { color: #fff; border-color: var(--accent); }

/* ---------- Тост «перейти в полный экран» ---------- */
.fs-toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 18px;
  border-radius: 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 24px rgba(30, 90, 200, 0.55);
  font-size: 15px;
  font-weight: 600;
  color: #d6e8ff;
}
.fs-close {
  border: none;
  background: none;
  color: #7fb4ef;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.fs-close:hover { color: #fff; }

/* ---------- Панель просмотра реплея ---------- */
.replay-bar {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  border-radius: 999px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 18px rgba(30, 90, 200, 0.5);
  font-size: 16px;
  font-weight: 700;
  color: #d6e8ff;
}
.replay-live {
  color: #ff5b4d;
  animation: replayBlink 1.1s ease-in-out infinite;
}
@keyframes replayBlink { 50% { opacity: 0.25; } }
.replay-bar button {
  border: none;
  background: none;
  color: #7fb4ef;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}
.replay-bar button:hover { color: #fff; }

/* ---------- Вкладки таблицы рекордов ---------- */
.lb-tabs {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-bottom: 4px;
}
.lb-tab {
  padding: 8px 18px;
  font-size: 14px;
  font-weight: 700;
  color: #9db8dd;
  background: rgba(10, 24, 55, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 999px;
  cursor: pointer;
}
.lb-tab.active {
  color: #fff;
  border-color: var(--accent);
  background: rgba(46, 143, 255, 0.25);
  box-shadow: 0 0 10px rgba(46, 143, 255, 0.5);
}

/* Кнопка просмотра повтора в таблице */
.lb-watch {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--panel-border);
  background: rgba(46, 143, 255, 0.18);
  color: #7fc0ff;
  font-size: 11px;
  cursor: pointer;
  transition: box-shadow 0.15s;
}
.lb-watch:hover {
  color: #fff;
  box-shadow: 0 0 10px rgba(46, 143, 255, 0.8);
}

/* ---------- Стартовый экран ---------- */
.mode-switch {
  display: inline-flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 2px;
  padding: 4px;
  border-radius: 22px;
  background: rgba(5, 12, 30, 0.9);
  border: 1px solid var(--panel-border);
  margin: 2px 0 10px;
  max-width: 420px;
}
.mode-opt {
  padding: 9px 16px;
  border: none;
  border-radius: 999px;
  background: none;
  color: #9db8dd;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1px;
  cursor: pointer;
  transition: color 0.15s, background 0.15s, box-shadow 0.15s;
}
.mode-opt.active {
  color: #fff;
  background: linear-gradient(180deg, #3f9dff, #1b5fd0);
  box-shadow: 0 0 16px rgba(46, 143, 255, 0.7);
}
.daily-hint {
  font-size: 13px;
  color: #9db8dd;
  min-height: 18px;
}
.controls-title {
  margin-top: 20px;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: #4d7fc4;
}
.controls-grid {
  display: grid;
  grid-template-columns: auto auto;
  gap: 7px 16px;
  justify-content: center;
  align-items: center;
  margin-top: 10px;
  font-size: 14px;
  color: #b8d4f5;
  text-align: left;
}
.controls-grid .keys {
  text-align: right;
  white-space: nowrap;
  color: #dfe9ff;
}
kbd {
  display: inline-block;
  min-width: 20px;
  padding: 3px 7px;
  margin: 0 1px;
  border-radius: 6px;
  background: #0d1c3d;
  border: 1px solid #2c4a86;
  border-bottom-width: 2px;
  color: #dfe9ff;
  font-family: "Segoe UI", monospace;
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* ---------- Кнопки опций ---------- */
.opt-buttons {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}
.opt-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid var(--panel-border);
  background: radial-gradient(circle at 35% 30%, #14264d, #0a1430);
  color: var(--accent);
  font-size: 22px;
  font-weight: 800;
  cursor: pointer;
  transition: box-shadow 0.15s, transform 0.1s;
  box-shadow: 0 0 10px rgba(30, 90, 200, 0.4);
}
.opt-btn:hover {
  box-shadow: 0 0 18px rgba(46, 143, 255, 0.8);
  transform: scale(1.06);
}
.opt-btn:active { transform: scale(0.96); }
.opt-btn.on {
  color: #fff;
  border-color: var(--accent);
  background: radial-gradient(circle at 35% 30%, #1d4a8f, #123060);
  box-shadow: 0 0 18px rgba(46, 143, 255, 0.9);
}

/* ---------- Оверлей (старт / пауза / конец игры / справка) ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(3, 6, 16, 0.72);
  border-radius: 50%;
  z-index: 4;
}
.overlay.hidden { display: none; }
.overlay-box {
  text-align: center;
  padding: 34px 44px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  box-shadow: 0 0 40px rgba(30, 90, 220, 0.5);
  max-width: 480px;
  max-height: 96%;
  overflow-y: auto;
  /* тонкий скроллбар в цветах панелей (Chrome 121+, Firefox) */
  scrollbar-width: thin;
  scrollbar-color: #2c4a86 transparent;
}
/* то же для Safari и старых Chromium */
.overlay-box::-webkit-scrollbar,
#lbBox::-webkit-scrollbar { width: 8px; }
.overlay-box::-webkit-scrollbar-track,
#lbBox::-webkit-scrollbar-track { background: transparent; margin: 8px 0; }
.overlay-box::-webkit-scrollbar-thumb,
#lbBox::-webkit-scrollbar-thumb {
  background: #2c4a86;
  border-radius: 8px;
}
.overlay-box::-webkit-scrollbar-thumb:hover,
#lbBox::-webkit-scrollbar-thumb:hover { background: #3f66b5; }

/* Скроллится только список рекордов; заголовок, вкладки и кнопки на месте.
 * По горизонтали не скроллим: вертикальный скроллбар отъедает 8px,
 * иначе таблица «не влезает» и вылезает нижняя полоса прокрутки. */
#lbBox {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: min(52vh, 460px);
  scrollbar-width: thin;
  scrollbar-color: #2c4a86 transparent;
}

/* ---------- Экран настроек ---------- */
.set-title {
  margin: 14px 0 8px;
  font-weight: 800;
  letter-spacing: 1px;
  color: #dfe9ff;
}
.keys-grid {
  display: grid;
  grid-template-columns: auto 86px 86px;
  gap: 6px 10px;
  justify-content: center;
  align-items: center;
  font-size: 13px;
  color: #b8d4f5;
}
.keys-grid .set-label { text-align: right; }
.key-slot {
  padding: 6px 4px;
  font: inherit;
  font-size: 13px;
  white-space: nowrap;
  overflow: hidden;
  color: #dfe9ff;
  background: #0d1c3d;
  border: 1px solid #2c4a86;
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s;
}
.key-slot:hover { border-color: var(--accent); }
.key-slot.listening {
  border-color: #f2b705;
  color: #ffe27a;
  box-shadow: 0 0 10px rgba(242, 183, 5, 0.5);
}
.set-note {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.5;
  color: #7e97bd;
}
.speed-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
}
.speed-row input[type="range"] {
  width: 220px;
  accent-color: var(--accent);
}
.speed-row b {
  min-width: 2ch;
  color: #ffd66b;
  font-size: 16px;
}
.overlay-title {
  font-size: 30px;
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  text-shadow: 0 0 16px rgba(46, 143, 255, 0.9);
  margin-bottom: 14px;
}
.overlay-text {
  font-size: 16px;
  line-height: 1.7;
  color: #b8d4f5;
  margin-bottom: 20px;
}
.overlay-btn {
  font-size: 19px;
  font-weight: 800;
  letter-spacing: 2px;
  padding: 12px 42px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(180deg, #3f9dff, #1b5fd0);
  box-shadow: 0 0 20px rgba(46, 143, 255, 0.8);
  transition: transform 0.1s, box-shadow 0.15s;
}
.overlay-btn:hover { transform: scale(1.05); box-shadow: 0 0 30px rgba(70, 160, 255, 1); }
.overlay-btn:active { transform: scale(0.97); }
.overlay-btn.small { font-size: 15px; padding: 10px 20px; letter-spacing: 1px; }
.overlay-btn:disabled { opacity: 0.5; cursor: default; transform: none; }

/* ---------- Таблица рекордов ---------- */
/* Приветствие с именем на стартовом экране */
.hello {
  margin: 0 0 12px;
  font-size: 16px;
  color: #9fc3ff;
  cursor: pointer;
  user-select: none;
}
.hello:hover { color: #cfe4ff; }
.hello b { color: #ffd66b; }
.hello input {
  width: 180px;
  padding: 6px 12px;
  font-size: 15px;
  text-align: center;
  color: #fff;
  background: rgba(5, 12, 30, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  outline: none;
}
.hello input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(46, 143, 255, 0.5);
}

.lb-save {
  display: flex;
  gap: 10px;
  justify-content: center;
  align-items: center;
  margin: 16px 0 6px;
}
.lb-save input {
  width: 200px;
  padding: 10px 14px;
  font-size: 16px;
  color: #fff;
  background: rgba(5, 12, 30, 0.9);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  outline: none;
}
.lb-save input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(46, 143, 255, 0.5);
}
.lb-note {
  font-size: 17px;
  color: #ffd66b;
  text-shadow: 0 0 10px rgba(255, 190, 60, 0.6);
}
.lb-table {
  margin: 12px auto 0;
  border-collapse: collapse;
  min-width: 320px;
  font-size: 15px;
  color: #d6e8ff;
}
.lb-table th {
  color: var(--accent);
  font-size: 13px;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-bottom: 1px solid rgba(46, 100, 190, 0.5);
  /* шапка не уезжает при скролле списка внутри #lbBox */
  position: sticky;
  top: 0;
  background: rgba(12, 22, 47, 0.97);
}
.lb-table th, .lb-table td {
  padding: 5px 12px;
  text-align: left;
}
.lb-table td:first-child, .lb-table th:first-child { text-align: right; color: var(--text-dim); }
.lb-table td:nth-child(3) { font-weight: 700; color: #fff; }
.lb-table tr.lb-me td {
  background: rgba(46, 143, 255, 0.22);
  color: #fff;
}
.lb-table tr.lb-me td:first-child { border-radius: 8px 0 0 8px; }
.lb-table tr.lb-me td:last-child { border-radius: 0 8px 8px 0; }
.lb-empty {
  margin-top: 12px;
  color: #9db8dd;
  font-size: 15px;
  line-height: 1.5;
}

/* ---------- Выбор языка ---------- */
.lang-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0 6px;
}
.lang-btn {
  padding: 10px 22px;
  font-size: 16px;
  font-weight: 600;
  color: #d6e8ff;
  background: rgba(10, 24, 55, 0.85);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow 0.15s, border-color 0.15s;
}
.lang-btn:hover {
  border-color: var(--accent);
  box-shadow: 0 0 12px rgba(46, 143, 255, 0.5);
}
.lang-btn.active {
  border-color: var(--accent);
  background: rgba(46, 143, 255, 0.25);
  color: #fff;
  box-shadow: 0 0 14px rgba(46, 143, 255, 0.6);
}

