/* Szachowy Trener dla Młodego Mistrza – przyjazny styl dla tabletu 11" i desktopu */
:root {
  --bg: #eef4ee;
  --surface: #ffffff;
  --surface-soft: #f7faf6;
  --primary: #2f6f4e;
  --primary-dark: #215239;
  --primary-light: #e3f2e8;
  --accent: #f59e0b;
  --accent-soft: #fffbeb;
  --success: #16a34a;
  --success-soft: #ecfdf5;
  --text: #1c2822;
  --text-muted: #52645a;
  --border: #d5e2d8;
  --shadow: 0 8px 24px rgba(28, 40, 34, 0.08);
  --radius: 18px;
}

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

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, Roboto, sans-serif;
  background: linear-gradient(160deg, #eaf3ec 0%, #f5f2e9 100%);
  color: var(--text);
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

.app-shell {
  max-width: 1260px;
  margin: 0 auto;
  padding: 14px 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* GÓRNY PASEK */
.topbar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  box-shadow: var(--shadow);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-logo {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  flex-shrink: 0;
}

.brand-text h1 {
  margin: 0;
  font-size: 1.25rem;
  line-height: 1.15;
  color: var(--primary-dark);
}

.brand-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.progress-pill {
  display: flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #fef9c3 0%, #fef3c7 100%);
  border: 2px solid #f59e0b;
  border-radius: 999px;
  padding: 6px 16px;
}

.rank-icon {
  font-size: 1.5rem;
  line-height: 1;
}

.rank-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.rank-title {
  font-size: 0.82rem;
  font-weight: 800;
  color: #92400e;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.stars-count {
  font-size: 0.95rem;
  color: #78350f;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 8px 13px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  color: var(--text-muted);
  font-size: 0.92rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.16s ease;
}

.icon-toggle[aria-pressed="true"] {
  background: var(--primary-light);
  border-color: var(--primary);
  color: var(--primary-dark);
}

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

/* NAWIGACJA MODUŁÓW */
.module-nav {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.module-tab {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  min-height: 62px;
  background: var(--surface);
  border: 2px solid var(--border);
  border-radius: 16px;
  text-align: left;
  cursor: pointer;
  transition: all 0.18s ease;
  box-shadow: 0 3px 10px rgba(28, 40, 34, 0.04);
}

.module-tab:hover {
  border-color: #84b096;
  transform: translateY(-1px);
}

.module-tab.active {
  background: linear-gradient(135deg, #2f6f4e 0%, #245a3e 100%);
  border-color: #1c4731;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(47, 111, 78, 0.25);
}

.module-tab-icon {
  font-size: 1.65rem;
  flex-shrink: 0;
}

.module-tab-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.module-tab-title {
  font-weight: 800;
  font-size: 0.98rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.module-tab-meta {
  font-size: 0.8rem;
  opacity: 0.82;
  margin-top: 2px;
}

/* GŁÓWNY UKŁAD DWUKOLUMNOWY (TABLET LANDSCAPE / DESKTOP) */
.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 580px) minmax(300px, 1fr);
  gap: 18px;
  align-items: start;
}

/* KOLUMNA SZACHOWNICY */
.board-column {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.material-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
  box-shadow: var(--shadow);
}

.material-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-size: 0.92rem;
  margin-bottom: 8px;
}

.material-side {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.side-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 2px solid #262c29;
  display: inline-block;
}

.side-white {
  background: #ffffff;
}

.side-black {
  background: #262c29;
}

.material-diff {
  font-weight: 800;
  font-size: 0.86rem;
  padding: 3px 10px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
}

.material-bar-track {
  height: 10px;
  border-radius: 999px;
  background: #374151;
  overflow: hidden;
  border: 1px solid #cbd5e1;
}

.material-bar-white {
  height: 100%;
  background: linear-gradient(90deg, #fef3c7 0%, #34d399 100%);
  transition: width 0.35s ease;
}

.piece-values-legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 6px 10px;
  margin-top: 8px;
  padding-top: 7px;
  border-top: 1px dashed var(--border);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.board-frame {
  background: #3c5442;
  padding: 10px;
  border-radius: 20px;
  box-shadow: 0 14px 30px rgba(24, 42, 30, 0.22);
}

.board-container {
  width: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  overflow: hidden;
  user-select: none;
  touch-action: manipulation;
}

.chess-svg {
  width: 100%;
  height: 100%;
  display: block;
  cursor: pointer;
}

@keyframes pulseHint {
  0%, 100% { fill-opacity: 0.24; stroke-opacity: 1; }
  50% { fill-opacity: 0.45; stroke-opacity: 0.65; }
}

.pulse-hint {
  animation: pulseHint 1.2s ease-in-out infinite;
}

.board-footer-tip {
  text-align: center;
  font-size: 0.88rem;
  color: var(--text-muted);
  font-weight: 600;
  padding: 4px 8px;
}

/* PANEL PRAWY */
.side-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.panel-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.lesson-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.topic-badge {
  display: inline-block;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--primary-light);
  color: var(--primary-dark);
  font-weight: 800;
  font-size: 0.84rem;
}

.topic-sparring {
  background: #fef3c7;
  color: #92400e;
}

.engine-badge {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-muted);
  background: var(--surface-soft);
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 999px;
}

.lesson-stars-earned {
  font-size: 1.35rem;
  letter-spacing: 2px;
  color: #f59e0b;
}

.lesson-title {
  margin: 0;
  font-size: 1.38rem;
  line-height: 1.25;
  color: var(--text);
}

.lesson-desc {
  margin: 0;
  font-size: 1.02rem;
  line-height: 1.5;
  color: var(--text-muted);
}

/* KOMUNIKATY TRENERA – CIEPŁE, BEZ KAR I CZERWONYCH EKRANÓW */
.coach-box {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  transition: background-color 0.25s ease, border-color 0.25s ease;
}

.coach-box.coach-success {
  background: var(--success-soft);
  border-color: #34d399;
}

.coach-box.coach-warn {
  background: var(--accent-soft);
  border-color: #fbbf24;
}

.coach-box.coach-hint {
  background: #eff6ff;
  border-color: #60a5fa;
}

.voice-coach-btn {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 54px;
  padding: 8px 12px;
  border-radius: 13px;
  border: 2px solid rgba(47, 111, 78, 0.22);
  background: rgba(255, 255, 255, 0.82);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.16s ease, box-shadow 0.16s ease;
}

.voice-coach-btn:hover {
  border-color: var(--primary);
  box-shadow: 0 4px 12px rgba(47, 111, 78, 0.14);
}

.voice-coach-btn:active {
  transform: scale(0.98);
}

.voice-coach-cta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: 1;
  font-size: 0.98rem;
}

.voice-waves {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 18px;
  opacity: 0.32;
  transition: opacity 0.2s ease;
}

.voice-waves span {
  width: 4px;
  height: 8px;
  border-radius: 99px;
  background: var(--primary);
}

.voice-coach-btn.is-speaking {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(47, 111, 78, 0.16);
}

.voice-coach-btn.is-speaking .voice-waves {
  opacity: 1;
}

.voice-coach-btn.is-speaking .voice-waves span:nth-child(1) {
  animation: waveBar 0.7s ease-in-out infinite;
}

.voice-coach-btn.is-speaking .voice-waves span:nth-child(2) {
  animation: waveBar 0.7s ease-in-out 0.16s infinite;
}

.voice-coach-btn.is-speaking .voice-waves span:nth-child(3) {
  animation: waveBar 0.7s ease-in-out 0.32s infinite;
}

@keyframes waveBar {
  0%, 100% { height: 6px; }
  50% { height: 18px; }
}

/* Tryb ukrytych komentarzy tekstowych (domyślny dla młodszych dzieci) */
body.text-hints-hidden .text-comment-only {
  display: none !important;
}

.coach-avatar {
  font-size: 2rem;
  line-height: 1;
  flex-shrink: 0;
}

.coach-content {
  flex: 1;
  min-width: 0;
  padding: 2px 4px 0;
}

.coach-heading {
  font-weight: 800;
  font-size: 0.94rem;
  margin-bottom: 4px;
  color: var(--text);
}

.coach-message {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.48;
  color: var(--text);
}

.mentor-decision-bar {
  margin-top: 4px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* PRZYCISKI (DUŻE CELE DOTYKOWE DLA TABLETU) */
.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: 14px;
  border: none;
  font-size: 0.98rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.16s ease, background-color 0.16s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-sm {
  min-height: 42px;
  padding: 8px 14px;
  font-size: 0.9rem;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(47, 111, 78, 0.24);
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-success {
  background: #16a34a;
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(22, 163, 74, 0.3);
  flex: 1;
}

.btn-success:hover {
  background: #15803d;
}

.btn-hint {
  background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
  color: #451a03;
  box-shadow: 0 4px 12px rgba(245, 158, 11, 0.25);
}

.btn-hint:hover {
  filter: brightness(1.03);
}

.btn-secondary {
  background: var(--surface-soft);
  color: var(--text);
  border: 2px solid var(--border);
}

.btn-secondary:hover {
  background: #ebf3ec;
}

.hint-step-pill {
  background: rgba(255, 255, 255, 0.65);
  padding: 2px 8px;
  border-radius: 999px;
  font-size: 0.8rem;
}

/* LISTA ZADAŃ W MODULE */
.task-list-section {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.task-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.task-grid {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 290px;
  overflow-y: auto;
  padding-right: 4px;
}

.task-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 11px 13px;
  min-height: 50px;
  border-radius: 13px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  text-align: left;
  transition: all 0.15s ease;
}

.task-item:hover {
  border-color: #7ea88e;
}

.task-item.active {
  background: var(--primary-light);
  border-color: var(--primary);
}

.task-item.done {
  border-color: #86efac;
}

.task-item-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.task-num {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #ffffff;
  border: 2px solid var(--border);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 0.85rem;
  flex-shrink: 0;
}

.task-item.done .task-num {
  background: #16a34a;
  border-color: #16a34a;
  color: #ffffff;
}

.task-item-title {
  font-weight: 700;
  font-size: 0.93rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.task-item-stars {
  font-size: 0.95rem;
  color: #f59e0b;
  flex-shrink: 0;
}

/* SPARING Z TRENEREM */
.sparring-settings {
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--surface-soft);
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.setting-group label {
  font-size: 0.86rem;
  font-weight: 800;
  color: var(--text-muted);
}

.select-input {
  min-height: 44px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 2px solid var(--border);
  background: #ffffff;
  font-size: 0.96rem;
  font-weight: 700;
  color: var(--text);
}

.mentor-switch {
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.mentor-switch input {
  display: none;
}

.switch-track {
  width: 52px;
  height: 30px;
  border-radius: 999px;
  background: #cbd5e1;
  position: relative;
  flex-shrink: 0;
  transition: background-color 0.2s ease;
}

.switch-track::after {
  content: '';
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s ease;
}

.mentor-switch input:checked + .switch-track {
  background: var(--primary);
}

.mentor-switch input:checked + .switch-track::after {
  transform: translateX(22px);
}

.switch-text {
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}

.switch-text small {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.moves-history-box {
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.moves-list {
  min-height: 68px;
  max-height: 150px;
  overflow-y: auto;
  background: var(--surface-soft);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text);
}

/* MODAL PROMOCJI PIONKA */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 32, 24, 0.56);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
}

.modal-card {
  background: var(--surface);
  border-radius: 22px;
  padding: 22px;
  max-width: 440px;
  width: 100%;
  text-align: center;
  box-shadow: 0 20px 44px rgba(0, 0, 0, 0.25);
}

.modal-card h3 {
  margin: 0 0 6px;
  color: var(--primary-dark);
}

.modal-card p {
  margin: 0 0 16px;
  color: var(--text-muted);
}

.promo-choices {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.promo-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border-radius: 16px;
  border: 2px solid var(--border);
  background: var(--surface-soft);
  cursor: pointer;
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--text);
}

.promo-btn:hover {
  border-color: var(--primary);
  background: var(--primary-light);
}

.promo-svg svg {
  width: 56px;
  height: 56px;
  display: block;
}

/* RESPONSYWNOŚĆ – TABLET PIONOWY I MNIEJSZE EKRANY */
@media (max-width: 960px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .board-column {
    max-width: 600px;
    width: 100%;
    margin: 0 auto;
  }

  .module-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 10px 10px 20px;
  }

  .toggle-label {
    display: none;
  }

  .piece-values-legend {
    font-size: 0.75rem;
  }
}
