/* ==========================================================================
   MAFIA HOST PANEL — MOBILE-FIRST STYLESHEET
   Clean, high-contrast dark tactical UI with vivid Yellow/Red alert states
   ========================================================================== */

:root {
  --bg-base: #0f1117;
  --bg-surface: #181b24;
  --bg-elevated: #212634;
  --bg-card-hover: #282e3e;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border-subtle: rgba(255, 255, 255, 0.1);
  --accent-primary: #e11d48;
  --accent-primary-hover: #be123c;
  --accent-secondary: #3b82f6;
  --color-success: #10b981;
  --color-yellow: #facc15;
  --color-yellow-text: #111827;
  --color-red: #ef4444;
  --color-red-dark: #b91c1c;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-card: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100vh;
  background-color: var(--bg-base);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 15px;
  line-height: 1.45;
  overflow-x: hidden;
  transition: background-color 0.2s ease;
}

/* Sharp screen flash states for Timer */
body.screen-alert-yellow {
  background-color: #eab308 !important;
}
body.screen-alert-yellow .app-container {
  background-color: rgba(17, 24, 39, 0.92);
  box-shadow: 0 0 0 5px #facc15, 0 0 40px rgba(250, 204, 21, 0.85);
}

body.screen-alert-red {
  background-color: #dc2626 !important;
}
body.screen-alert-red .app-container {
  background-color: rgba(17, 24, 39, 0.92);
  box-shadow: 0 0 0 5px #ef4444, 0 0 45px rgba(239, 68, 68, 0.95);
}

.app-container {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding-bottom: 96px;
  transition: box-shadow 0.2s ease, background-color 0.2s ease;
}

/* ==========================================================================
   TOP NAVIGATION BAR
   ========================================================================== */
.top-navbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(24, 27, 36, 0.96);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.brand-group {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, #e11d48, #9f1239);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(225, 29, 72, 0.4);
}

.session-title-wrap {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.session-current-name {
  font-weight: 700;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sync-indicator {
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 4px;
}

.sync-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-success);
  display: inline-block;
}

.nav-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn {
  height: 38px;
  padding: 0 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.icon-btn:hover {
  background: var(--bg-card-hover);
}

.icon-btn:active {
  transform: scale(0.96);
}

.icon-btn.eye-active {
  background: rgba(250, 204, 21, 0.18);
  border-color: var(--color-yellow);
  color: var(--color-yellow);
}

.lang-switch {
  display: inline-flex;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
  height: 38px;
}

.lang-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  padding: 0 9px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
}

.lang-btn.active {
  background: var(--accent-primary);
  color: #ffffff;
}

/* ==========================================================================
   MAIN SECTION TABS (Игровой стол / Таймер)
   ========================================================================== */
.main-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px 12px 6px;
}

.tab-btn {
  height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tab-btn.active {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(225, 29, 72, 0.35);
}

.tab-timer-badge {
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  font-variant-numeric: tabular-nums;
}

.tab-timer-badge.warn {
  background: var(--color-yellow);
  color: var(--color-yellow-text);
  font-weight: 800;
}

.tab-timer-badge.expired {
  background: var(--color-red);
  color: #ffffff;
  font-weight: 800;
}

/* ==========================================================================
   VIEWS & CARDS
   ========================================================================== */
.view-section {
  display: none;
  padding: 8px 12px;
  flex-direction: column;
  gap: 12px;
}

.view-section.active {
  display: flex;
}

.card {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 14px;
  box-shadow: var(--shadow-card);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.card-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.card-subtitle {
  font-size: 12px;
  color: var(--text-muted);
}

/* ==========================================================================
   ROLE SUMMARY QUOTA STRIP (1st Round Helper)
   ========================================================================== */
.role-quota-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 10px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  align-items: center;
  justify-content: space-between;
}

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

.quota-chip {
  font-size: 12px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.quota-chip.complete {
  border-color: rgba(16, 185, 129, 0.5);
  background: rgba(16, 185, 129, 0.12);
  color: #34d399;
}

.quota-chip.over {
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

/* ==========================================================================
   PLAYER TABLE / ROWS (Игровой стол)
   ========================================================================== */
.players-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  transition: all 0.15s ease;
}

.player-row.is-eliminated {
  opacity: 0.58;
  background: rgba(18, 20, 28, 0.75);
  border-color: rgba(239, 68, 68, 0.25);
}

.player-row-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.player-ident {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.player-num-badge {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  font-weight: 800;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.player-row.is-eliminated .player-num-badge {
  text-decoration: line-through;
  color: var(--color-red);
}

.player-name-input {
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  color: var(--text-main);
  font-size: 14px;
  font-weight: 600;
  padding: 4px 6px;
}

.player-name-input:focus {
  outline: none;
  border-color: var(--border-subtle);
  background: var(--bg-elevated);
}

.player-row.is-eliminated .player-name-input {
  text-decoration: line-through;
  color: var(--text-muted);
}

.player-controls-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

/* Fouls Counter Switcher (- count +) */
.foul-switcher {
  display: inline-flex;
  align-items: center;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 2px;
  transition: all 0.15s ease;
}

/* 3 Fouls -> Bright Yellow background */
.foul-switcher.fouls-3 {
  background: var(--color-yellow) !important;
  border-color: #fde047 !important;
  color: var(--color-yellow-text) !important;
  box-shadow: 0 0 12px rgba(250, 204, 21, 0.55);
}

/* 4+ Fouls -> Bright Red background */
.foul-switcher.fouls-4 {
  background: var(--color-red) !important;
  border-color: #f87171 !important;
  color: #ffffff !important;
  box-shadow: 0 0 14px rgba(239, 68, 68, 0.7);
}

.foul-btn {
  width: 28px;
  height: 28px;
  border: none;
  background: rgba(0, 0, 0, 0.2);
  color: inherit;
  border-radius: 6px;
  font-size: 15px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.foul-btn:active {
  transform: scale(0.92);
}

.foul-val {
  min-width: 34px;
  text-align: center;
  font-size: 12px;
  font-weight: 800;
  padding: 0 4px;
  font-variant-numeric: tabular-nums;
}

/* Eliminated Toggle Button */
.elim-btn {
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: all 0.15s ease;
}

.elim-btn.eliminated {
  background: rgba(239, 68, 68, 0.2);
  border-color: var(--color-red);
  color: #fca5a5;
}

/* Role Selector Row inside Player Card */
.player-role-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px dashed rgba(255, 255, 255, 0.07);
}

.current-role-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 9px;
  border-radius: 6px;
  background: var(--bg-elevated);
}

.current-role-pill.role-citizen { color: #93c5fd; background: rgba(59, 130, 246, 0.14); }
.current-role-pill.role-mafia { color: #fca5a5; background: rgba(239, 68, 68, 0.2); }
.current-role-pill.role-don { color: #f5d0fe; background: rgba(192, 38, 211, 0.22); }
.current-role-pill.role-commissar { color: #fde047; background: rgba(234, 179, 8, 0.2); }
.current-role-pill.role-doctor { color: #6ee7b7; background: rgba(16, 185, 129, 0.2); }
.current-role-pill.role-hidden { color: var(--text-muted); background: var(--bg-elevated); }

.role-quick-btns {
  display: flex;
  align-items: center;
  gap: 4px;
}

.role-qbtn {
  height: 30px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 3px;
  transition: all 0.12s ease;
}

.role-qbtn.active {
  border-color: #ffffff;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  font-weight: 700;
}

/* ==========================================================================
   BOTTOM SCOREBOARD (Счётчик Мирных / Мафии под таблицей)
   ========================================================================== */
.bottom-scoreboard {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 45;
  background: rgba(17, 20, 28, 0.96);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-subtle);
  padding: 10px 14px;
}

.scoreboard-inner {
  max-width: 640px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.score-counts-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.score-pill {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 7px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  font-weight: 700;
  font-size: 13px;
}

.score-pill.peaceful {
  border-left: 4px solid #3b82f6;
}

.score-pill.mafia {
  border-left: 4px solid #ef4444;
}

.score-num {
  font-size: 16px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.win-banner {
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-weight: 800;
  font-size: 14px;
  text-align: center;
  letter-spacing: 0.3px;
  animation: pulsePop 0.35s ease;
}

.win-banner.mafia-win {
  background: linear-gradient(135deg, #dc2626, #991b1b);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(220, 38, 38, 0.45);
}

.win-banner.peaceful-win {
  background: linear-gradient(135deg, #059669, #065f46);
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(16, 185, 129, 0.45);
}

@keyframes pulsePop {
  0% { transform: scale(0.96); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

/* ==========================================================================
   TIMER SECTION (Раздел Таймер)
   ========================================================================== */
.timer-card {
  text-align: center;
  padding: 18px 14px;
  border-radius: var(--radius-lg);
  background: var(--bg-surface);
  border: 2px solid var(--border-subtle);
  transition: all 0.2s ease;
}

.timer-card.alert-yellow {
  background: var(--color-yellow) !important;
  border-color: #fef08a !important;
  color: var(--color-yellow-text) !important;
  box-shadow: 0 0 30px rgba(250, 204, 21, 0.8);
}

.timer-card.alert-red {
  background: var(--color-red) !important;
  border-color: #fecaca !important;
  color: #ffffff !important;
  box-shadow: 0 0 35px rgba(239, 68, 68, 0.9);
}

.timer-presets {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.preset-btn {
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: rgba(0, 0, 0, 0.25);
  color: inherit;
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
}

.preset-btn.active {
  border-color: currentColor;
  background: rgba(255, 255, 255, 0.18);
}

.timer-digits {
  font-size: 64px;
  font-weight: 900;
  line-height: 1.05;
  letter-spacing: 2px;
  font-variant-numeric: tabular-nums;
  margin: 8px 0 12px;
}

.timer-status-text {
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  min-height: 20px;
}

.timer-controls {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: 8px;
}

.t-btn {
  height: 46px;
  border-radius: var(--radius-md);
  border: none;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: transform 0.12s ease;
}

.t-btn:active {
  transform: scale(0.96);
}

.t-btn.primary {
  background: #10b981;
  color: #052e16;
}

.t-btn.primary.running {
  background: #f59e0b;
  color: #111827;
}

.t-btn.plus10 {
  background: #3b82f6;
  color: #ffffff;
}

.t-btn.reset {
  background: rgba(0, 0, 0, 0.35);
  color: inherit;
  border: 1px solid rgba(255, 255, 255, 0.25);
}

/* ==========================================================================
   VOTING SECTION (Блок голосования и Перестрелка)
   ========================================================================== */
.alive-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 8px;
}

.alive-num-btn {
  height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-main);
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s ease;
}

.alive-num-btn:active {
  transform: scale(0.94);
}

.alive-num-btn.nominated {
  background: var(--accent-primary);
  border-color: #fb7185;
  color: #ffffff;
}

.nom-order-tag {
  position: absolute;
  top: 2px;
  right: 4px;
  font-size: 10px;
  font-weight: 700;
  opacity: 0.9;
}

.voting-rounds-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.vote-round-box {
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.vote-round-box.shootout-box {
  border-color: rgba(250, 204, 21, 0.5);
  background: rgba(250, 204, 21, 0.06);
}

.vote-round-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.vote-table {
  width: 100%;
  border-collapse: collapse;
}

.vote-table th,
.vote-table td {
  padding: 8px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
}

.vote-table th {
  font-size: 11px;
  text-transform: uppercase;
  color: var(--text-muted);
}

.vote-counter-wrap {
  display: inline-flex;
  align-items: center;
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  padding: 2px;
}

.vote-step-btn {
  width: 32px;
  height: 30px;
  border: none;
  background: var(--bg-elevated);
  color: var(--text-main);
  border-radius: 6px;
  font-size: 16px;
  font-weight: 800;
  cursor: pointer;
}

.vote-count-num {
  min-width: 36px;
  text-align: center;
  font-weight: 800;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
}

.remove-nom-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 15px;
  padding: 4px 8px;
  cursor: pointer;
}

.vote-actions-row {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.btn-next-vote {
  flex: 1;
  height: 44px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-primary);
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.btn-clear-vote {
  height: 44px;
  padding: 0 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-surface);
  color: var(--text-muted);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.vote-result-banner {
  margin-top: 12px;
  padding: 12px;
  border-radius: var(--radius-md);
  font-weight: 700;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.vote-result-banner.eliminated {
  background: rgba(239, 68, 68, 0.16);
  border: 1px solid var(--color-red);
  color: #fecaca;
}

.vote-result-banner.shootout {
  background: rgba(250, 204, 21, 0.16);
  border: 1px solid var(--color-yellow);
  color: #fef08a;
}

/* ==========================================================================
   MODAL / SESSIONS DRAWER
   ========================================================================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(4px);
  display: none;
  align-items: flex-end;
  justify-content: center;
}

.modal-backdrop.open {
  display: flex;
}

.modal-sheet {
  width: 100%;
  max-width: 640px;
  max-height: 90vh;
  overflow-y: auto;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-subtle);
  border-radius: 20px 20px 0 0;
  padding: 18px 16px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--border-subtle);
}

.form-label {
  font-size: 14px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
}

.text-input {
  width: 100%;
  height: 40px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-subtle);
  background: var(--bg-elevated);
  color: var(--text-main);
  padding: 0 12px;
  font-size: 14px;
}

.session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
}

.session-item.current {
  border-color: var(--accent-primary);
  background: rgba(225, 29, 72, 0.12);
}

.session-item-info {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.session-item-title {
  font-weight: 700;
  font-size: 14px;
}

.session-item-meta {
  font-size: 12px;
  color: var(--text-muted);
}

.del-session-btn {
  height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  border: 1px solid rgba(239, 68, 68, 0.4);
  background: rgba(239, 68, 68, 0.14);
  color: #fca5a5;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

@media (min-width: 520px) {
  .modal-backdrop {
    align-items: center;
    padding: 16px;
  }
  .modal-sheet {
    border-radius: 16px;
    border: 1px solid var(--border-subtle);
  }
}
