/* === Сброс и базовые стили === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green-dark:  #1b4332;
  --green-mid:   #2d6a4f;
  --green-light: #40916c;
  --green-pale:  #d8f3dc;
  --card-bg:     #fff;
  --card-border: #bbb;
  --red:         #e63946;
  --black:       #1d1d1d;
  --accent:      #f4a261;
  --correct:     #52b788;
  --wrong:       #e63946;
  --gray:        #6c757d;
  --bg:          #111;
  --text:        #f1faee;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Helvetica Neue', Arial, sans-serif;
  min-height: 100vh;
}

#app { max-width: 720px; margin: 0 auto; padding: 12px 16px 40px; }

/* === Шапка === */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0 14px;
  border-bottom: 1px solid #2a2a2a;
  margin-bottom: 16px;
}
.header h1 { font-size: 18px; letter-spacing: 2px; color: var(--green-pale); }

.session-stats {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  color: var(--green-pale);
}
.stat-pct { color: var(--accent); font-weight: bold; min-width: 40px; }

.btn-reset {
  background: none;
  border: 1px solid #444;
  color: #888;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 16px;
  transition: color .2s;
}
.btn-reset:hover { color: var(--accent); border-color: var(--accent); }

/* === Стол === */
.table-section { margin-bottom: 14px; }
#poker-table { width: 100%; max-width: 600px; display: block; margin: 0 auto; }

/* Сидения на столе */
.seat circle { transition: fill .3s; }
.seat text { pointer-events: none; }

/* === Карты === */
.hand-section {
  text-align: center;
  margin-bottom: 10px;
}
.hand-label { font-size: 11px; color: #888; letter-spacing: 1px; text-transform: uppercase; margin-bottom: 8px; }
.hand-cards { display: flex; justify-content: center; gap: 12px; }

.card {
  width: 64px;
  height: 90px;
  background: var(--card-bg);
  border: 2px solid var(--card-border);
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 22px;
  font-weight: bold;
  box-shadow: 2px 3px 8px rgba(0,0,0,.5);
  user-select: none;
  position: relative;
}
.card .rank { font-size: 26px; line-height: 1; }
.card .suit { font-size: 20px; line-height: 1; }
.card.red  { color: var(--red); }
.card.black { color: var(--black); }

.hand-normalized {
  margin-top: 8px;
  font-size: 20px;
  font-weight: bold;
  color: var(--accent);
  letter-spacing: 2px;
}

/* === Описание ситуации === */
.situation-section { text-align: center; margin-bottom: 16px; }
.situation-text {
  font-size: 15px;
  color: #ccc;
  line-height: 1.5;
}

/* === Кнопки действий === */
.actions-section {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.action-btn {
  padding: 12px 24px;
  border: 2px solid #444;
  background: #1a1a1a;
  color: var(--text);
  border-radius: 8px;
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1px;
  transition: all .18s;
  min-width: 110px;
}
.action-btn:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
  background: #1f1a10;
}
.action-btn:disabled { opacity: .4; cursor: not-allowed; }

.action-btn.selected-correct { border-color: var(--correct); color: var(--correct); background: #0a1f12; }
.action-btn.selected-wrong   { border-color: var(--wrong);   color: var(--wrong);   background: #1f0a0a; }
.action-btn.reveal-correct   { border-color: var(--correct); color: var(--correct); }

/* === Фидбек === */
.feedback-section {
  background: #161616;
  border-radius: 10px;
  padding: 18px 20px;
  border: 1px solid #2a2a2a;
}
.feedback-section.correct { border-color: var(--correct); }
.feedback-section.wrong   { border-color: var(--wrong); }

.feedback-result {
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 6px;
}
.feedback-result.correct { color: var(--correct); }
.feedback-result.wrong   { color: var(--wrong); }

.feedback-action {
  font-size: 14px;
  color: #888;
  margin-bottom: 10px;
}

.feedback-explanation {
  font-size: 14px;
  color: #ddd;
  line-height: 1.6;
  margin-bottom: 10px;
}

.feedback-range {
  font-size: 12px;
  color: #666;
  font-style: italic;
  border-top: 1px solid #2a2a2a;
  padding-top: 8px;
  margin-bottom: 14px;
}

.btn-next {
  display: block;
  width: 100%;
  padding: 12px;
  background: var(--green-mid);
  border: none;
  border-radius: 8px;
  color: var(--green-pale);
  font-size: 15px;
  font-weight: bold;
  cursor: pointer;
  letter-spacing: 1px;
  transition: background .2s;
}
.btn-next:hover { background: var(--green-light); }

/* === Термины (glossary) === */
[data-term] {
  border-bottom: 1px dashed var(--accent);
  cursor: help;
  color: var(--accent);
}

.glossary-popup {
  position: fixed;
  background: #1e1e1e;
  border: 1px solid var(--accent);
  border-radius: 8px;
  padding: 10px 14px;
  max-width: 280px;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 4px 20px rgba(0,0,0,.6);
}
.glossary-term { font-weight: bold; color: var(--accent); font-size: 13px; margin-bottom: 4px; }
.glossary-def  { font-size: 12px; color: #ccc; line-height: 1.5; }

/* === Утилиты === */
.hidden { display: none !important; }

/* ─── Кнопка подсказки ─── */
.hint-row { text-align: center; margin-bottom: 10px; }
.btn-hint { background: none; border: 1px solid #444; color: #888; border-radius: 6px; padding: 5px 14px; font-size: 12px; cursor: pointer; letter-spacing: 0.5px; transition: all .18s; }
.btn-hint:hover { border-color: var(--accent); color: var(--accent); }

/* ─── Модальное окно ─── */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.75); z-index: 2000; display: flex; align-items: center; justify-content: center; padding: 12px; }
.modal-box { background: #161616; border: 1px solid #333; border-radius: 12px; padding: 16px; max-width: 520px; width: 100%; max-height: 90vh; overflow-y: auto; }
.modal-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 10px; }
.modal-header span { font-size: 14px; font-weight: bold; color: var(--accent); }
.modal-close { background: none; border: none; color: #888; font-size: 18px; cursor: pointer; padding: 0 4px; line-height: 1; }
.modal-close:hover { color: #fff; }
.modal-note { font-size: 11px; color: #666; font-style: italic; margin-top: 10px; }

/* ─── Легенда ─── */
.range-legend { display: flex; gap: 12px; margin-bottom: 8px; flex-wrap: wrap; }
.leg { font-size: 11px; display: flex; align-items: center; gap: 4px; }
.leg::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 2px; }
.leg-raise::before  { background: #52b788; }
.leg-call::before   { background: #e9c46a; }
.leg-fold::before   { background: #2a2a2a; border: 1px solid #444; }
.leg-current::before { background: transparent; border: 2px solid #fff; }

/* ─── Грид диапазонов ─── */
.range-grid { display: grid; grid-template-columns: 22px repeat(13, 1fr); gap: 1px; }
.rg-corner, .rg-header { display: flex; align-items: center; justify-content: center; font-size: 8px; font-weight: bold; color: #666; height: 22px; }
.rg-cell { display: flex; align-items: center; justify-content: center; font-size: 7px; font-family: monospace; height: 22px; border-radius: 2px; cursor: default; }
.rg-raise { background: #1d4a30; color: #52b788; }
.rg-3bet  { background: #1d4a30; color: #52b788; }
.rg-call  { background: #3d3010; color: #e9c46a; }
.rg-fold  { background: #1a1a1a; color: #333; }
.rg-current { outline: 2px solid #fff; outline-offset: -1px; color: #fff !important; font-weight: bold; }

/* === Кнопка настроек в шапке === */
.btn-settings {
  background: none;
  border: 1px solid #444;
  color: #888;
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  font-size: 16px;
  transition: color .2s;
}
.btn-settings:hover { color: var(--accent); border-color: var(--accent); }

/* === Экран настроек === */
#settings-screen {
  padding: 24px 0 40px;
}

.settings-title {
  font-size: 20px;
  font-weight: 600;
  color: var(--green-pale);
  margin-bottom: 28px;
  letter-spacing: 0.5px;
}

.settings-group {
  margin-bottom: 24px;
}

.settings-label {
  font-size: 11px;
  color: #888;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 10px;
}

.settings-hint {
  font-size: 12px;
  color: var(--gray);
  margin-top: 6px;
  min-height: 16px;
}

.chip-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  background: #1a1a1a;
  border: 1px solid #444;
  color: var(--text);
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 14px;
  cursor: pointer;
  transition: border-color .15s, color .15s, background .15s;
}
.chip:hover:not(:disabled):not(.active) {
  border-color: #888;
  color: var(--text);
}
.chip.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(244,162,97,.1);
}
.chip:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.btn-start {
  margin-top: 8px;
  padding: 12px 32px;
  background: var(--correct);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background .2s;
}
.btn-start:hover { background: #3da876; }

/* === Экран авторизации === */
#auth-screen {
  display: flex;
  justify-content: center;
  padding: 32px 0 40px;
}

.auth-form {
  width: 100%;
  max-width: 360px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.auth-title {
  font-size: 22px;
  font-weight: 600;
  color: var(--green-pale);
  margin-bottom: 2px;
}

.auth-subtitle {
  font-size: 13px;
  color: #666;
  margin-top: -8px;
  margin-bottom: 6px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.auth-label {
  font-size: 11px;
  color: #888;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.auth-input {
  background: #1a1a1a;
  border: 1px solid #444;
  color: var(--text);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 15px;
  outline: none;
  transition: border-color .15s;
  width: 100%;
}
.auth-input:focus { border-color: var(--accent); }
.auth-input::placeholder { color: #555; }

.auth-error {
  font-size: 13px;
  color: var(--wrong);
  min-height: 18px;
}

.btn-auth-submit {
  margin-top: 0;
  width: 100%;
  padding: 12px;
  background: var(--correct);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s;
}
.btn-auth-submit:hover:not(:disabled) { background: #3da876; }
.btn-auth-submit:disabled { opacity: .5; cursor: not-allowed; }

.btn-auth-toggle {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 13px;
  cursor: pointer;
  padding: 0;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}
.btn-auth-toggle:hover { opacity: .8; }

.auth-divider {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #444;
  font-size: 12px;
}
.auth-divider::before,
.auth-divider::after {
  content: '';
  flex: 1;
  border-top: 1px solid #333;
}

.btn-google {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #fff;
  color: #222;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity .2s;
}
.btn-google:hover:not(:disabled) { opacity: .88; }
.btn-google:disabled { opacity: .5; cursor: not-allowed; }

.btn-guest {
  background: none;
  border: none;
  color: #666;
  font-size: 13px;
  cursor: pointer;
  padding: 4px 0;
  text-align: center;
  transition: color .15s;
}
.btn-guest:hover { color: #999; }

/* === Экран статистики === */
#stats-screen {
  padding: 24px 0 40px;
}

.stats-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}
.stats-header .settings-title { margin-bottom: 0; }

.btn-stats-close {
  background: none;
  border: none;
  color: #888;
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  transition: color .15s;
}
.btn-stats-close:hover { color: var(--text); }

.stats-loading, .stats-empty {
  color: #666;
  font-size: 14px;
  padding: 24px 0;
}
.stats-guest {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 16px;
  padding: 24px 0;
}
.stats-guest p {
  color: #666;
  font-size: 14px;
}

.stats-overview {
  display: flex;
  align-items: baseline;
  gap: 12px;
  margin-bottom: 28px;
}
.stats-overview-pct {
  font-size: 48px;
  font-weight: 700;
  line-height: 1;
}
.stats-overview-label {
  font-size: 14px;
  color: #666;
}

.stats-section {
  margin-bottom: 28px;
}
.stats-section-title {
  font-size: 11px;
  color: #888;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 12px;
}

/* Строки позиций/ситуаций */
.stat-row {
  display: grid;
  grid-template-columns: 64px 1fr 44px 56px;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.stat-row-label {
  font-size: 13px;
  font-family: monospace;
  color: var(--text);
}
.stat-bar-wrap {
  background: #1a1a1a;
  border-radius: 4px;
  height: 8px;
  overflow: hidden;
}
.stat-bar {
  height: 100%;
  border-radius: 4px;
  transition: width .4s ease;
}
.stat-row-pct {
  font-size: 13px;
  font-weight: bold;
  text-align: right;
}
.stat-row-count {
  font-size: 11px;
  color: #555;
  text-align: right;
}

/* Тепловая карта */
.stats-heatmap-legend {
  display: flex;
  gap: 16px;
  font-size: 11px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.stats-heatmap-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
.stats-heatmap {
  display: inline-block;
  min-width: 360px;
}
.heatmap-row {
  display: flex;
}
.hm-corner {
  width: 32px;
  height: 24px;
  flex-shrink: 0;
}
.hm-header {
  width: 32px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 9px;
  font-weight: bold;
  color: #555;
  flex-shrink: 0;
}
.hm-cell {
  width: 32px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 7.5px;
  font-family: monospace;
  font-weight: bold;
  border-radius: 2px;
  cursor: default;
  flex-shrink: 0;
  transition: opacity .15s;
}
.hm-cell:hover { opacity: .75; }

/* Инсайты */
.stats-insights {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.stats-insights li {
  font-size: 13px;
  color: #ccc;
  line-height: 1.5;
  padding: 10px 14px;
  background: #161616;
  border-left: 3px solid var(--accent);
  border-radius: 0 6px 6px 0;
}
.stats-insights li strong { color: var(--accent); }
.stats-insights-good {
  font-size: 13px;
  color: var(--correct);
  padding: 10px 14px;
  background: #0a1f12;
  border-left: 3px solid var(--correct);
  border-radius: 0 6px 6px 0;
}
.stats-heatmap-hint {
  font-size: 11px;
  color: #555;
  margin-top: 8px;
  line-height: 1.4;
}
.stats-heatmap-few {
  font-size: 12px;
  color: #666;
  margin-top: 6px;
  font-style: italic;
}
/* Объяснение тепловой карты */
.heatmap-explainer {
  background: #161616;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.heatmap-explainer p {
  font-size: 13px;
  color: #ccc;
  line-height: 1.5;
}
.heatmap-explainer-grid {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 6px;
}
.hex-zone {
  text-align: center;
  font-size: 11px;
  font-weight: bold;
  padding: 8px 6px;
  border-radius: 6px;
  line-height: 1.4;
}
.hex-zone span { font-weight: normal; font-size: 10px; color: #888; }
.hex-suited  { background: rgba(82,183,136,.12); color: #52b788; border: 1px solid rgba(82,183,136,.3); }
.hex-pairs   { background: rgba(244,162,97,.08); color: var(--accent); border: 1px solid rgba(244,162,97,.2); }
.hex-offsuit { background: rgba(233,196,106,.1); color: #e9c46a; border: 1px solid rgba(233,196,106,.25); }
.heatmap-explainer-tip {
  font-size: 12px;
  color: #888;
}

.stats-heatmap-labels {
  display: flex;
  justify-content: space-between;
  padding: 0 0 4px 20px;
  font-size: 10px;
  color: #555;
  font-style: italic;
}
.hm-label-suited  { color: #52b788; }
.hm-label-offsuit { color: #e9c46a; }

/* Email пользователя в шапке */
.auth-user-label {
  font-size: 12px;
  color: #666;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
