:root {
  --bg: #1e1e1e;
  --bg-2: #262626;
  --card: #2a2a2a;
  --card-2: #303030;
  --line: #3a3a3a;
  --text: #ffffff;
  --muted: #9a9a9a;
  --accent: #17d6d6;
  --accent-dim: rgba(23, 214, 214, 0.15);
  --reel-h: clamp(46px, 8.5vh, 84px); /* высота строки масштабируется под экран */
  --reel-rows: 5;      /* видимых строк */
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "Montserrat", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
}

body {
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Точечная сетка на фоне (как на брендовом баннере) */
.bg-grid {
  position: fixed;
  inset: 0;
  z-index: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.05) 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
}

.topbar, .stage { position: relative; z-index: 1; }

/* Шапка */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 32px;
}
.brand {
  font-weight: 800;
  font-size: 20px;
  letter-spacing: 0.5px;
}
.brand::after { content: "."; color: var(--accent); }

.ghost-btn {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 9px 16px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: color .15s, border-color .15s;
}
.ghost-btn:hover { color: var(--text); border-color: var(--accent); }
.gear { color: var(--accent); }

.topbar-actions { display: flex; align-items: center; gap: 10px; }
/* Счётчик прокруток: «Прокрутка 1 / 3» */
.round-counter {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
  padding: 9px 4px;
  white-space: nowrap;
}
.round-counter #roundNum { color: var(--accent); font-weight: 800; }
.round-label { margin-right: 6px; }

/* Сцена */
.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 10px 24px 24px;
}
/* Барабаны: пять колонок в ряд */
.reels {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: clamp(10px, 1.6vw, 24px);
  width: 100%;
  max-width: 1500px;
}
.reel-card {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.reel-window {
  position: relative;
  width: 100%;
  box-sizing: content-box; /* высота = ровно rows * reel-h, рамка не крадёт пиксели */
  height: calc(var(--reel-h) * var(--reel-rows));
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
}
.reel-strip {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  will-change: transform;
}
.reel-item {
  height: var(--reel-h);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 10px;
  font-size: clamp(14px, 1.45vw, 22px);
  font-weight: 600;
  line-height: 1.15;
  text-align: center;
  color: #cfcfcf;
  overflow: hidden;
}
/* Длинное «Фамилия Имя» переносится на вторую строку, дальше — многоточие. */
.reel-item > span {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}
.reel-item.is-empty { color: #6a6a6a; }
.reel-item.is-winner { color: var(--accent); }
/* Центральное окно-выделение */
.reel-center {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(var(--reel-h) * 2);
  height: var(--reel-h);
  border-top: 2px solid var(--accent);
  border-bottom: 2px solid var(--accent);
  background: var(--accent-dim);
  pointer-events: none;
}
.reel-fade {
  position: absolute;
  left: 0;
  right: 0;
  height: calc(var(--reel-h) * 2);
  pointer-events: none;
  z-index: 2;
}
.reel-fade.top    { top: 0;    background: linear-gradient(var(--card), rgba(42,42,42,0)); }
.reel-fade.bottom { bottom: 0; background: linear-gradient(rgba(42,42,42,0), var(--card)); }

.reel-card.won .reel-window { border-color: var(--accent); }

.winner {
  margin-top: clamp(10px, 1.8vh, 20px);
  min-height: 3.6em; /* место под три строки — сцена не прыгает при появлении имени */
  width: 100%;
  font-size: clamp(16px, 1.7vw, 26px);
  font-weight: 700;
  line-height: 1.2;
  color: var(--accent);
  text-align: center;
  overflow-wrap: anywhere;
  opacity: 0;
  transform: translateY(6px);
  transition: opacity .35s, transform .35s;
}
.winner.show { opacity: 1; transform: translateY(0); }

/* Большая кнопка */
.spin-btn {
  margin-top: clamp(14px, 2.4vh, 32px);
  background: var(--accent);
  color: #08302f;
  border: none;
  border-radius: 16px;
  padding: 15px 64px;
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 0.5px;
  cursor: pointer;
  transition: transform .12s, box-shadow .2s, opacity .2s;
  box-shadow: 0 10px 40px rgba(23, 214, 214, 0.25);
}
.spin-btn:hover { transform: translateY(-2px); box-shadow: 0 14px 48px rgba(23, 214, 214, 0.35); }
.spin-btn:active { transform: translateY(0) scale(0.99); }
.spin-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; }

.hint {
  margin-top: 6px;
  color: var(--muted);
  font-size: 15px;
  min-height: 16px;
  text-align: center;
}

/* Панель списков */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10;
}
.panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(520px, 92vw);
  background: var(--bg-2);
  border-left: 1px solid var(--line);
  z-index: 11;
  display: flex;
  flex-direction: column;
  box-shadow: -20px 0 60px rgba(0, 0, 0, 0.4);
}
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 26px;
  border-bottom: 1px solid var(--line);
}
.panel-head h2 { font-size: 20px; font-weight: 700; }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 26px;
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.editor-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.editor-head label { font-size: 16px; font-weight: 700; }
.editor-actions { display: flex; align-items: center; gap: 12px; }
.count {
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
  border-radius: 20px;
  padding: 3px 12px;
}
.file-btn {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 5px 12px;
  cursor: pointer;
  transition: border-color .15s;
}
.file-btn:hover { border-color: var(--accent); }
.file-btn[type="button"] { background: transparent; font-family: inherit; }
.count.over { color: #ff6b6b; }

.editor-note { color: var(--muted); font-size: 13px; line-height: 1.45; margin-bottom: 10px; }
.editor-warn { color: #ffb86b; font-size: 13px; line-height: 1.45; margin-top: 8px; }
.editor-warn:empty { display: none; }
.locked { display: flex; align-items: center; gap: 12px; }
textarea.short { min-height: 120px; }

textarea {
  width: 100%;
  min-height: 200px;
  resize: vertical;
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 14px 16px;
  font-family: inherit;
  font-size: 15px;
  line-height: 1.6;
}
textarea:focus { outline: none; border-color: var(--accent); }

.panel-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  padding: 18px 26px;
  border-top: 1px solid var(--line);
}
.pass-input {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 14px;
  width: 150px;
  margin-right: auto;
}
.pass-input:focus { outline: none; border-color: var(--accent); }
.save-status { color: var(--muted); font-size: 14px; }
.save-status.ok { color: var(--accent); }
.save-status.err { color: #ff6b6b; }
.save-btn {
  background: var(--accent);
  color: #08302f;
  border: none;
  border-radius: 10px;
  padding: 12px 30px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
}
.save-btn:disabled { opacity: 0.6; cursor: not-allowed; }

[hidden] { display: none !important; }

@media (max-width: 720px) {
  /* На телефоне пять колонок остаются, но узкие: мельче шрифт и отступы. */
  body { height: auto; min-height: 100vh; overflow-x: hidden; overflow-y: auto; }
  .topbar { padding: 12px 16px; }
  .topbar-actions { gap: 6px; }
  .topbar .ghost-btn { padding: 8px 11px; }
  .btn-text, .round-label { display: none; }
  .stage { padding: 10px 16px 20px; }
  .reels { gap: 6px; }
  .reel-window { border-radius: 10px; }
  .reel-item { padding: 0 4px; font-size: 11px; }
  .winner { font-size: 12px; }
  .spin-btn { padding: 15px 48px; font-size: 20px; width: 100%; max-width: 360px; }
}
