/* ==========================================================================
   Polski Sędzia Symulator — style
   „Ekstranet w pionie": ciemny, urzędowo-biurowy klimat × komunikator.
   Mobile-first, kciuk, pion. Tap-targety >= 48px. Nic nie miga.
   ========================================================================== */

:root {
  --bg: #12161c;
  --bg-raised: #1a2029;
  --card: #1d242e;
  --card-border: #2b333f;
  --text: #d8dde4;
  --text-dim: #8d97a5;
  --accent: #d9a441;          /* bursztyn urzędowy */
  --accent-dim: #8a6a2e;
  --danger: #c04b3a;
  --ok: #4f9d69;
  --paper: #efe8d6;           /* arkusz obserwatora — jasne „biurowe" tło */
  --paper-ink: #26221a;
  --pressure-0: #3f8f5f;      /* Cisza — zieleń */
  --pressure-1: #7fa24a;
  --pressure-2: #c99a3a;      /* Chór — bursztyn */
  --pressure-3: #c96a30;
  --pressure-4: #c03a2e;      /* Wrzenie — czerwień */
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.55;
  min-height: 100vh;
  min-height: 100dvh;
}

#app {
  max-width: 560px;
  margin: 0 auto;
  padding: 0 14px calc(16px + env(safe-area-inset-bottom));
  min-height: calc(100vh - 28px);
  min-height: calc(100dvh - 28px);
  display: flex;
  flex-direction: column;
}

#app-footer {
  text-align: center;
  color: var(--text-dim);
  font-size: 11px;
  padding: 6px 0 calc(6px + env(safe-area-inset-bottom));
  letter-spacing: 0.05em;
}

button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

/* --- Przyciski bazowe ----------------------------------------------------- */
.btn {
  display: block;
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 12px 18px;
  background: var(--bg-raised);
  color: var(--text);
  font-weight: 600;
}
.btn:active { transform: translateY(1px); }
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #191408;
}
.btn-secondary { color: var(--text-dim); }
.btn-danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}
.btn-small { width: auto; min-height: 44px; padding: 8px 16px; }
.btn-big { min-height: 56px; font-size: 17px; margin-top: 18px; }

/* ==========================================================================
   Ekran startowy
   ========================================================================== */
.start {
  padding-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}
.start-kicker {
  color: var(--accent);
  font-size: 12px;
  letter-spacing: 0.18em;
  margin: 0;
}
.start-title {
  margin: 0;
  font-size: 34px;
  line-height: 1.15;
  letter-spacing: -0.01em;
}
.start-sub {
  color: var(--text-dim);
  margin: 0;
}
.start-warning {
  border: 1px solid var(--danger);
  border-radius: 10px;
  padding: 14px;
  background: rgba(192, 75, 58, 0.08);
}
.start-warning-title {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #e08a7c;
}
.start-warning p { margin: 0 0 12px; font-size: 14px; }

.start-tribune-label {
  margin: 0 0 8px;
  color: var(--text-dim);
  font-size: 14px;
}
.segmented {
  display: flex;
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
}
.segmented-btn {
  flex: 1;
  min-height: 48px;
  background: var(--bg-raised);
  border: 0;
  color: var(--text-dim);
  font-weight: 600;
}
.segmented-btn + .segmented-btn { border-left: 1px solid var(--card-border); }
.segmented-btn.is-active {
  background: var(--accent-dim);
  color: #fff;
}
.start-tribune-note {
  margin: 8px 0 0;
  font-size: 13px;
  color: var(--text-dim);
  font-style: italic;
}

/* ==========================================================================
   Główny ekran gry
   ========================================================================== */
.game {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 14px 0 10px;
  border-bottom: 1px solid var(--card-border);
}
.game-header-title {
  margin: 0;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.14em;
  color: var(--accent);
}
.game-header-new {
  background: none;
  border: 0;
  color: var(--text-dim);
  font-size: 12px;
  min-height: 44px;
  padding: 0 4px;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.notice {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--bg-raised);
  border-radius: 0 8px 8px 0;
  font-size: 14px;
  color: var(--text);
}

/* --- Treść jako karty ------------------------------------------------------ */
.content {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 0 18px;
}
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  padding: 16px;
}
.core-text { margin: 0; white-space: pre-line; }

/* --- Warstwy rozwijane ----------------------------------------------------- */
.layer {
  background: var(--bg-raised);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  overflow: hidden;
}
.layer-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 48px;
  padding: 10px 14px;
  background: none;
  border: 0;
  color: var(--text-dim);
  font-weight: 600;
  font-size: 14px;
  text-align: left;
}
.layer-arrow { color: var(--accent); }
.layer-body {
  padding: 0 14px 14px;
  border-top: 1px dashed var(--card-border);
}
.layer-body p { margin: 12px 0 0; font-size: 14px; color: var(--text); white-space: pre-line; }
.layer-official .layer-body {
  background: var(--paper);
  color: var(--paper-ink);
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
}
.layer-official .layer-body p { color: var(--paper-ink); }

/* ==========================================================================
   Pasek meczu i Ciśnienie
   ========================================================================== */
.match-bar {
  margin-top: 12px;
  background: var(--bg-raised);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 10px 14px;
}
.match-teams {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin: 0;
  font-weight: 700;
  font-size: 15px;
}
.match-home, .match-away {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.match-away { text-align: right; }
.match-score {
  color: var(--accent);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.match-meta {
  margin: 4px 0 0;
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
}

.pressure { margin-top: 10px; }
.pressure-label {
  display: flex;
  justify-content: space-between;
  margin: 0 0 6px;
  font-size: 13px;
  color: var(--text-dim);
}
.pressure-label strong { color: var(--text); letter-spacing: 0.04em; }
.pressure-track {
  height: 10px;
  background: var(--bg-raised);
  border: 1px solid var(--card-border);
  border-radius: 6px;
  overflow: hidden;
}
.pressure-fill {
  height: 100%;
  border-radius: 5px;
  transition: width 0.4s ease;
}
.pressure-step-0 .pressure-fill { background: var(--pressure-0); }
.pressure-step-1 .pressure-fill { background: var(--pressure-1); }
.pressure-step-2 .pressure-fill { background: var(--pressure-2); }
.pressure-step-3 .pressure-fill { background: var(--pressure-3); }
.pressure-step-4 .pressure-fill { background: var(--pressure-4); }

/* ==========================================================================
   Dok dolny: ticker trybuny + decyzje (zasięg kciuka)
   ========================================================================== */
.dock {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding-top: 8px;
  background: linear-gradient(to bottom, rgba(18,22,28,0), var(--bg) 22%);
}

/* Ticker trybuny — dymki od dołu, NIE blokują interakcji */
.tribune {
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  min-height: 0;
  margin-bottom: 4px;
}
.tribune-bubble {
  margin: 0;
  max-width: 88%;
  padding: 8px 12px;
  background: #26201a;
  border: 1px solid #4a3a24;
  border-radius: 12px 12px 12px 3px;
  font-size: 14px;
  font-weight: 600;
  color: #e8cf9e;
  opacity: 0;
  transform: translateY(16px);
  animation: tribune-in 0.45s ease-out forwards;
}
.tribune-fury .tribune-bubble {
  font-size: 17px;
  background: #2c1a16;
  border-color: #6e2f24;
  color: #f0b0a0;
  animation: tribune-in 0.45s ease-out forwards, tribune-shake 0.28s linear 0.5s infinite;
}
@keyframes tribune-in {
  to { opacity: 1; transform: translateY(0); }
}
@keyframes tribune-shake {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(1px, -1px) rotate(0.4deg); }
  50% { transform: translate(-1px, 1px) rotate(-0.4deg); }
  75% { transform: translate(1px, 1px) rotate(0.2deg); }
}

/* Decyzje — duże przyciski w dolnej trzeciej ekranu */
.choices {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 4px;
}
.choice {
  position: relative;
  width: 100%;
  min-height: 56px;
  padding: 12px 16px;
  background: var(--card);
  border: 1px solid var(--accent-dim);
  border-radius: 12px;
  color: var(--text);
  text-align: left;
}
.choice:active:not(:disabled) { background: var(--bg-raised); }
.choice:disabled { opacity: 0.55; cursor: wait; }
.choice-label {
  display: block;
  font-weight: 700;
  font-size: 16px;
}
.choice-sub {
  display: block;
  margin-top: 3px;
  font-size: 13px;
  color: var(--text-dim);
}
.choices-empty { color: var(--text-dim); text-align: center; }

/* Spinner */
.spinner {
  position: absolute;
  top: 50%;
  right: 14px;
  width: 18px;
  height: 18px;
  margin-top: -9px;
  border: 2px solid var(--card-border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
.spinner-big {
  position: static;
  width: 34px;
  height: 34px;
  margin: 0 auto 14px;
  border-width: 3px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Arkusz obserwatora — celowo brzydki urzędowy dokument
   ========================================================================== */
.official {
  background: var(--paper);
  color: var(--paper-ink);
  border: 2px solid #4a4436;
  border-radius: 2px;
  padding: 18px 16px 14px;
  font-family: "Courier New", Courier, monospace;
  box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.35);
  position: relative;
}
.official-head {
  border-bottom: 2px solid var(--paper-ink);
  padding-bottom: 8px;
  margin-bottom: 12px;
  text-align: center;
}
.official-org {
  margin: 0;
  font-size: 11px;
  letter-spacing: 0.12em;
}
.official-title {
  margin: 4px 0 0;
  font-size: 15px;
  font-weight: 700;
  text-transform: uppercase;
}
.official-grades {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin: 14px 0;
}
.official-grade { text-align: center; }
.official-grade-num {
  display: block;
  font-size: 44px;
  font-weight: 700;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.official-grade-predicted .official-grade-num {
  font-size: 28px;
  color: #6b6350;
  padding-top: 10px;
}
.official-grade-cap {
  display: block;
  margin-top: 4px;
  font-size: 10px;
  letter-spacing: 0.16em;
}
.official-body {
  border: 1px dashed #8a8270;
  padding: 12px;
  font-size: 14px;
}
.official-body p { margin: 0; white-space: pre-line; }
.official-stamp {
  margin: 14px 0 0;
  text-align: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: #7a2e22;
  border: 2px solid #7a2e22;
  border-radius: 4px;
  padding: 6px;
  transform: rotate(-2deg);
  opacity: 0.8;
}

/* ==========================================================================
   Epilog
   ========================================================================== */
.epilog {
  padding-top: 48px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1;
}
.epilog-kicker {
  margin: 0;
  color: var(--text-dim);
  font-size: 12px;
  letter-spacing: 0.18em;
}
.epilog-title { margin: 0; font-size: 28px; }
.epilog-core { margin: 0; white-space: pre-line; }
.epilog-stats h2 {
  margin: 0 0 10px;
  font-size: 14px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.stats-list {
  margin: 0;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 10px;
  padding: 6px 16px;
}
.stats-list dt {
  margin-top: 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-dim);
}
.stats-list dd {
  margin: 2px 0 10px;
  font-size: 17px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Stany: ładowanie, błędy, potwierdzenie
   ========================================================================== */
.loading {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 12px;
  padding: 40px 0;
  text-align: center;
}
.loading p { color: var(--text-dim); margin: 0; }
.loading .btn { max-width: 320px; }
.error-text { color: #e08a7c !important; }

.error-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  padding: 10px 12px;
  background: rgba(192, 75, 58, 0.12);
  border: 1px solid var(--danger);
  border-radius: 10px;
}
.error-bar p { margin: 0; font-size: 13px; color: #e08a7c; }
.error-bar .btn { flex-shrink: 0; }

.confirm-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding: 16px;
  z-index: 100;
}
.confirm-box {
  width: 100%;
  max-width: 480px;
  background: var(--bg-raised);
  border: 1px solid var(--card-border);
  border-radius: 14px;
  padding: 20px 16px 16px;
}
.confirm-title { margin: 0 0 6px; font-size: 18px; font-weight: 700; }
.confirm-text { margin: 0 0 16px; color: var(--text-dim); font-size: 14px; }
.confirm-actions {
  display: flex;
  gap: 10px;
}
.confirm-actions .btn { flex: 1; }

/* Szanuj ograniczenie ruchu — gra ma działać spokojnie */
@media (prefers-reduced-motion: reduce) {
  .tribune-bubble { animation: none; opacity: 1; transform: none; }
  .tribune-fury .tribune-bubble { animation: none; }
  .spinner, .spinner-big { animation-duration: 2s; }
  .pressure-fill { transition: none; }
}
