/* Colours, fonts, header and base styles come from ../resources/styles.css */
.main *, .main *::before, .main *::after { margin: 0; padding: 0; }

:root {
  --text-main: var(--ink);
  --text-muted: var(--muted);
  --violet: #7c3aed;
  --green: #059669;
  --amber: #d97706;
  --danger: #dc2626;
}

body {
  min-height: 100vh;
}

.main {
  padding: 28px 24px;
}
.main {
  display: flex;
  gap: 24px;
  max-width: 1180px;
  margin: 0 auto;
  align-items: flex-start;
}

.left-panel {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.grid-wrapper {
  background: var(--panel);
  border-radius: 18px;
  padding: 18px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid var(--panel-border);
}

.counter-grid {
  display: grid;
  gap: 7px;
}

.counter {
  width: var(--counter-size, 38px);
  height: var(--counter-size, 38px);
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 2px 10px rgba(239, 68, 68, 0.45);
  transition: background-color 0.35s ease, box-shadow 0.35s ease, transform 0.15s ease;
  cursor: default;
}

.counter.blue {
  background: var(--blue);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.45);
}

.counter.flip {
  transform: scale(1.25);
}

.step-badge {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.step-badge span {
  font-weight: 700;
  color: #f59e0b;
  font-size: 1rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
}

.btn {
  width: auto;
  padding: 11px 18px;
  border: none;
  border-radius: 10px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.18s, transform 0.15s, background 0.2s;
  letter-spacing: 0.01em;
}

.btn:hover { filter: brightness(1.15); transform: translateY(-2px); }
.btn:active { transform: translateY(0); filter: brightness(0.95); }

.btn-step { background: var(--violet); color: #fff; }
.btn-play { background: var(--green); color: #fff; min-width: 100px; }
.btn-play.pausing { background: var(--amber); }
.btn-reset { background: var(--danger); color: #fff; }
.btn-size { background: #0ea5e9; color: #fff; min-width: 140px; }

.right-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 18px;
  min-width: 0;
}

.card {
  background: var(--panel);
  border-radius: 18px;
  padding: 20px 22px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--panel-border);
}

.card-title {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 16px;
}

.sliders { display: flex; flex-direction: column; gap: 14px; }
.slider-row { display: flex; flex-direction: column; gap: 6px; }

.slider-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.88rem;
  color: var(--ink);
}

.prob-pill {
  font-weight: 700;
  font-size: 0.85rem;
  padding: 2px 10px;
  border-radius: 20px;
  min-width: 48px;
  text-align: center;
}

.pill-red { color: var(--red); background: rgba(239, 68, 68, 0.12); }
.pill-blue { color: var(--blue); background: rgba(59, 130, 246, 0.12); }

input[type=range] {
  -webkit-appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

input[type=range].red-range { background: linear-gradient(to right, #ef4444 0%, #ef4444 var(--pct, 20%), #334155 var(--pct, 20%), #334155 100%); }
input[type=range].blue-range { background: linear-gradient(to right, #3b82f6 0%, #3b82f6 var(--pct, 8%), #334155 var(--pct, 8%), #334155 100%); }

input[type=range]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s;
}

input[type=range]::-webkit-slider-thumb:hover { transform: scale(1.2); }

.eq-info {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.eq-chip {
  flex: 1;
  text-align: center;
  padding: 8px 4px;
  border-radius: 10px;
  font-size: 0.82rem;
}

.eq-chip.red { background: rgba(239, 68, 68, 0.08); border: 1px solid rgba(239, 68, 68, 0.2); color: var(--red); }
.eq-chip.blue { background: rgba(59, 130, 246, 0.08); border: 1px solid rgba(59, 130, 246, 0.2); color: var(--blue); }
.eq-chip .val { font-size: 1.2rem; font-weight: 700; display: block; }

.table-scroll {
  max-height: 200px;
  overflow-y: auto;
  border-radius: 8px;
}

.table-scroll::-webkit-scrollbar { width: 4px; }
.table-scroll::-webkit-scrollbar-track { background: transparent; }
.table-scroll::-webkit-scrollbar-thumb { background: #334155; border-radius: 2px; }

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.stats-table thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 8px 10px;
  text-align: center;
  border-bottom: 1px solid var(--panel-border);
}

.stats-table td {
  padding: 7px 8px;
  text-align: center;
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
}

.stats-table tbody tr:last-child td { border-bottom: none; }
.stats-table tbody tr.latest td { background: rgba(245, 158, 11, 0.12); }

.red-cell { color: #f87171; font-weight: 600; }
.blue-cell { color: #60a5fa; font-weight: 600; }
.step-cell { color: var(--muted); }

.chart-wrap {
  position: relative;
  height: 240px;
}

.chart-wrap canvas {
  width: 100%;
  max-width: none;
  aspect-ratio: auto;
  background: none;
  border: 0;
  border-radius: 0;
}

@media (max-width: 980px) {
  .main {
    flex-direction: column;
    align-items: stretch;
  }

  .left-panel {
    align-items: stretch;
  }

  .grid-wrapper {
    display: flex;
    justify-content: center;
  }

  .controls {
    justify-content: center;
  }
}
