*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --green-dark: #0b3d2e;
  --green: #1a6b4a;
  --green-light: #2d9a6a;
  --gold: #f5c518;
  --gold-dark: #c9a012;
  --bg: #0f1419;
  --bg-card: #1a2332;
  --bg-card-hover: #222d3f;
  --text: #e8edf4;
  --text-muted: #8b9cb3;
  --border: #2a3548;
  --accent: #3b82f6;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.4);
}

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  background-image:
    radial-gradient(ellipse at 20% 0%, rgba(26, 107, 74, 0.25) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 100%, rgba(245, 197, 24, 0.08) 0%, transparent 50%);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.5;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

.visit-counter {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  background: rgba(0, 0, 0, 0.18);
  border: 1px solid rgba(245, 197, 24, 0.45);
  border-radius: 999px;
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.9);
  flex-shrink: 0;
}

.visit-counter-value {
  font-weight: 700;
  color: var(--gold);
  font-size: 0.9rem;
  line-height: 1;
}

.visit-counter-label {
  color: rgba(255, 255, 255, 0.72);
}

.header {
  background: linear-gradient(135deg, var(--green-dark) 0%, var(--green) 100%);
  border-bottom: 3px solid var(--gold);
  padding: 1.5rem 2rem;
  box-shadow: var(--shadow);
}

.header-shell {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.85rem;
}

.header-content {
  width: 100%;
  max-width: none;
  margin: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.header-title h1 {
  font-size: 1.75rem;
  font-weight: 700;
  color: #fff;
}

.subtitle {
  color: rgba(255, 255, 255, 0.75);
  font-size: 0.95rem;
}

.stats-bar {
  display: flex;
  gap: 2rem;
}

.stat {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--gold);
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.65);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.card h2 {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1rem;
  color: var(--gold);
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.5rem;
}

.controls-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}

.control-group label {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.control-group select {
  width: 100%;
  padding: 0.6rem 0.75rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.95rem;
  cursor: pointer;
}

.control-group select:focus {
  outline: 2px solid var(--green-light);
  outline-offset: 2px;
}

.control-actions {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.btn {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s, transform 0.1s;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

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

.btn-secondary {
  background: var(--border);
  color: var(--text);
}

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

.participants-toggle-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 0.25rem;
}

.participants-summary {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.participants-panel {
  margin-top: 0.85rem;
  padding-top: 0.85rem;
  border-top: 1px solid var(--border);
}

.participants-panel[hidden] {
  display: none;
}

.participants-actions {
  margin-bottom: 0.75rem;
}

.participants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.5rem;
}

.participant-chip {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  background: var(--bg);
  border: 2px solid var(--border);
  border-left: 4px solid var(--chip-color, var(--border));
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  user-select: none;
}

.participant-chip:hover {
  background: var(--bg-card-hover);
}

.participant-chip.active {
  border-color: var(--chip-color, var(--green-light));
  border-left-color: var(--chip-color, var(--green-light));
  background: color-mix(in srgb, var(--chip-color, var(--green-light)) 22%, var(--bg));
  box-shadow: 0 0 0 1px color-mix(in srgb, var(--chip-color) 40%, transparent);
}

.participant-chip input {
  accent-color: var(--chip-color, var(--green-light));
  cursor: pointer;
}

.participant-chip span {
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chart-wrapper {
  position: relative;
  height: 480px;
}

.chart-section-head {
  margin-bottom: 1rem;
}

.chart-section-head h2 {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--gold);
  margin-bottom: 0.2rem;
  border: none;
  padding: 0;
}

.chart-section-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* --- Match card (dia / jogo) --- */
.match-card {
  display: flex;
  align-items: stretch;
  gap: 0;
  margin-bottom: 1.25rem;
  padding: 1.35rem 1.5rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  transition: border-color 0.25s ease, box-shadow 0.25s ease;
  opacity: 1;
}

.match-card.pulse {
  animation: matchFade 0.35s ease;
}

@keyframes matchFade {
  0% { transform: translateY(4px); }
  100% { transform: translateY(0); }
}

.match-card--brazil {
  border-color: rgba(255, 223, 0, 0.45);
  box-shadow: inset 3px 0 0 #009c3b;
}

.match-card--bonus {
  border-color: rgba(245, 197, 24, 0.35);
  box-shadow: inset 3px 0 0 var(--gold);
}

.match-card-date {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
  min-width: 130px;
  padding-right: 1rem;
}

.match-card-date-icon {
  font-size: 2rem;
  line-height: 1;
  opacity: 0.85;
}

.match-card-date-label {
  display: block;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 0.2rem;
}

.match-card-date-value {
  display: block;
  font-size: 1.45rem;
  font-weight: 700;
  color: #fff;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.match-card-divider {
  width: 1px;
  background: var(--border);
  margin: 0.15rem 0;
  flex-shrink: 0;
}

.match-card-main {
  flex: 1;
  min-width: 0;
  padding-left: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.65rem;
}

.match-card-game {
  font-size: 1.55rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.3;
  margin: 0;
  opacity: 1;
}

.match-card-game--muted {
  font-size: 1.1rem;
  font-weight: 500;
  color: var(--text-muted);
}

.match-multi-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gold);
  margin-bottom: 0.4rem;
}

.match-multi-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.match-multi-list li {
  font-size: 1.05rem;
  color: var(--text);
  padding-left: 0.85rem;
  position: relative;
}

.match-multi-list li::before {
  content: '⚽';
  position: absolute;
  left: 0;
  font-size: 0.55rem;
  top: 0.35em;
  opacity: 0.7;
}

.match-card-tags {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.55rem;
}

.phase-badge {
  display: inline-block;
  padding: 0.4rem 0.85rem;
  background: rgba(26, 107, 74, 0.65);
  border: 1px solid #34d399;
  color: #ecfdf5;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.bonus-chip {
  display: inline-block;
  padding: 0.4rem 0.9rem;
  border-radius: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.35;
}

.bonus-chip--brazil {
  background: rgba(0, 156, 59, 0.25);
  border: 1px solid rgba(255, 223, 0, 0.5);
  color: #ffdf00;
}

.bonus-chip--multi {
  background: rgba(245, 197, 24, 0.12);
  border: 1px solid rgba(245, 197, 24, 0.35);
  color: var(--gold);
}

/* --- Candle chart --- */
.chart-area {
  display: flex;
  gap: 0.5rem;
  height: 480px;
  margin-bottom: 1rem;
}

.chart-area:not(.chart-area--horizontal) .candles-scroll {
  overflow-x: auto;
  overflow-y: hidden;
}

.y-axis {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  width: 48px;
  flex-shrink: 0;
  padding: 0.5rem 0;
}

.y-axis.axis--proportional,
.x-axis.axis--proportional {
  position: relative;
  display: block;
  min-height: 100%;
}

.y-axis.axis--proportional {
  padding: 0.5rem 0;
}

.x-axis.axis--proportional {
  height: 1.75rem;
  padding: 0.5rem 0 0 calc(120px + 0.5rem);
}

.axis-tick--pos {
  position: absolute;
  white-space: nowrap;
}

.y-axis.axis--proportional .axis-tick--pos {
  right: 0.35rem;
  text-align: right;
}

.x-axis.axis--proportional .axis-tick--pos {
  top: 0.35rem;
  text-align: center;
}

.y-tick,
.axis-tick {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-align: right;
  padding-right: 0.35rem;
}

.candles-scroll {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.candles-container {
  display: flex;
  align-items: stretch;
  gap: 4px;
  height: 100%;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0.5rem 0;
  border-left: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
  background:
    repeating-linear-gradient(
      to top,
      transparent,
      transparent calc(20% - 1px),
      rgba(42, 53, 72, 0.5) calc(20% - 1px),
      rgba(42, 53, 72, 0.5) 20%
    );
}

.candles-container--vertical-ranked {
  position: relative;
  display: block;
  gap: 0;
  width: 100%;
  overflow-x: visible;
  overflow-y: hidden;
}

.candles-container--vertical-ranked .candle-col {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  min-width: 0;
  max-width: none;
  flex: none;
  overflow: hidden;
  will-change: transform;
}

.candles-container--vertical-ranked .candle-bar,
.candles-container--vertical-ranked .candle-stack {
  width: min(34px, 90%);
}

.candles-container--vertical-ranked .candle-value {
  font-size: 0.88rem;
  font-weight: 800;
}

.candles-container--vertical-ranked .candle-name {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text);
  margin-top: 0.4rem;
}

.candles-container--vertical-ranked .candle-crown {
  font-size: 1rem;
}

.candles-container--vertical-ranked .candle-plot {
  overflow: visible;
  min-height: 320px;
}

.candles-container--vertical-ranked .candle-top-labels {
  max-width: 100%;
}

.candles-container--vertical-ranked.candles-container--ranking .candle-col {
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.candles-container--vertical-ranked:not(.candles-container--ranking) .candle-col {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .candles-container--vertical-ranked .candle-col {
    transition: none !important;
  }
}

.scroll-hint {
  display: none;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: -0.5rem 0 0.75rem;
  opacity: 0.7;
}

.chart-area--horizontal + .scroll-hint {
  display: none !important;
}

.candle-col {
  flex: 1 1 0;
  width: 0;
  min-width: 48px;
  max-width: 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  height: 100%;
}

.candle-value {
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.1;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.8);
}

.candle-top-labels {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -100%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding-bottom: 3px;
  pointer-events: none;
  z-index: 2;
}

.candle-col--leader .candle-value {
  color: var(--gold);
}

.candle-plot {
  flex: 1;
  width: 100%;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  min-height: 280px;
  position: relative;
}

.candle-bar {
  width: 28px;
  flex-shrink: 0;
  border-radius: 4px 4px 0 0;
  border: 2px solid var(--candle-color, var(--border));
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  overflow: visible;
  position: relative;
  box-shadow: 0 0 10px color-mix(in srgb, var(--candle-color, #fff) 25%, transparent);
  transition: height 0.08s linear;
}

.candle-gain {
  width: 100%;
  flex-shrink: 0;
  border-radius: 2px 2px 0 0;
  position: relative;
  overflow: visible;
}

.candle-gain.up {
  opacity: 1;
}

.candle-gain.flat {
  opacity: 0.6;
}

.gain-badge-wrap {
  position: absolute;
  z-index: 4;
  pointer-events: none;
}

.gain-badge-wrap--vertical {
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.gain-badge-wrap--vertical.gain-badge-wrap--floating {
  top: 50%;
  left: calc(100% + 6px);
  transform: translateY(-50%);
}

.candle-gain .gain-badge {
  font-size: 0.65rem;
  padding: 0.14rem 0.38rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

.gain-badge-wrap--horizontal {
  top: 50%;
  left: 50%;
  right: auto;
  transform: translate(-50%, -50%);
}

.gain-badge-wrap--horizontal.gain-badge-wrap--floating {
  top: 0;
  transform: translateY(calc(-100% - 4px));
}

.gain-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.22rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  color: #fff;
  white-space: nowrap;
  background: linear-gradient(135deg, #22c55e 0%, #15803d 100%);
  border: 1px solid rgba(255, 255, 255, 0.45);
  box-shadow: 0 2px 10px rgba(34, 197, 94, 0.55);
  animation: gainPop 0.3s ease-out;
}

@keyframes gainPop {
  from {
    opacity: 0;
    transform: scale(0.85);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.candle-name {
  font-size: 0.6rem;
  color: var(--text-muted);
  text-align: center;
  margin-top: 0.35rem;
  line-height: 1.2;
  width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 2px;
}

.empty-chart {
  margin: auto;
  color: var(--text-muted);
  font-size: 1rem;
}

/* --- Horizontal bar chart --- */
.chart-area--horizontal {
  flex-direction: column;
  height: auto;
}

.chart-area--horizontal .candles-scroll {
  order: 1;
  overflow: visible;
}

.chart-area--horizontal .x-axis,
.chart-area--horizontal #yAxis.x-axis {
  order: 2;
}

.chart-area--horizontal .x-axis {
  order: 2;
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  height: auto;
  flex-shrink: 0;
  padding: 0.5rem 0 0 calc(120px + 0.5rem);
  margin-top: 0.25rem;
  border-top: 1px solid var(--border);
}

.chart-area--horizontal .x-axis .axis-tick {
  text-align: center;
  padding: 0;
  flex: 1;
}

.candles-container--horizontal {
  position: relative;
  display: block;
  gap: 0;
  height: auto;
  overflow: visible;
  border-left: none;
  border-bottom: none;
  padding: 0.35rem 0.25rem;
  background:
    repeating-linear-gradient(
      to right,
      transparent,
      transparent calc(20% - 1px),
      rgba(42, 53, 72, 0.5) calc(20% - 1px),
      rgba(42, 53, 72, 0.5) 20%
    );
}

.candles-container--horizontal .bar-row {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  width: 100%;
  will-change: transform;
}

.candles-container--horizontal.candles-container--ranking .bar-row {
  transition: transform 0.7s cubic-bezier(0.22, 1, 0.36, 1);
}

.candles-container--horizontal:not(.candles-container--ranking) .bar-row {
  transition: none;
}

@media (prefers-reduced-motion: reduce) {
  .candles-container--horizontal .bar-row {
    transition: none !important;
  }
}

.bar-row {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 0.5rem;
  align-items: center;
  min-height: 36px;
}

.bar-row--leader .bar-name {
  color: var(--gold);
  font-weight: 700;
}

.bar-name {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  text-align: right;
  padding-right: 0.35rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar-plot {
  min-width: 0;
  padding-right: 2.75rem;
}

.bar-track {
  position: relative;
  width: 100%;
  height: 32px;
  background: rgba(15, 20, 25, 0.5);
  border-radius: 6px;
  overflow: visible;
  border: 1px solid var(--border);
}

.bar-stack {
  height: 100%;
  min-width: 0;
  transition: width 0.08s linear;
}

.bar-fill {
  height: 100%;
  display: flex;
  flex-direction: row;
  border-radius: 4px;
  border: 2px solid var(--bar-color, var(--border));
  overflow: hidden;
  box-shadow: 0 0 10px color-mix(in srgb, var(--bar-color, #fff) 25%, transparent);
}

.bar-base {
  height: 100%;
  flex-shrink: 0;
}

.bar-gain {
  height: 100%;
  flex-shrink: 0;
  position: relative;
  overflow: visible;
}

.bar-gain.up {
  opacity: 1;
}

.bar-gain.flat {
  opacity: 0.6;
}

.bar-end-labels {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  gap: 0.25rem;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

.bar-value {
  font-size: 1.15rem;
  font-weight: 800;
  color: #fff;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.85);
}

.bar-row--leader .bar-value {
  color: var(--gold);
}

.bar-crown {
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(245, 197, 24, 0.5));
  animation: crownBounce 1.5s ease-in-out infinite;
}

.bar-gain .gain-badge {
  font-size: 0.65rem;
  padding: 0.14rem 0.38rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.45);
}

/* --- Animation controls --- */
.anim-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
}

.anim-bar input[type="range"] {
  flex: 1;
  min-width: 120px;
  accent-color: var(--gold);
  cursor: pointer;
}

.anim-bar select {
  padding: 0.5rem 0.65rem;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.85rem;
}

.frame-counter {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 48px;
}

.frame-mode-label {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.btn-primary {
  background: linear-gradient(135deg, var(--green) 0%, var(--green-light) 100%);
  color: #fff;
  padding: 0.6rem 1.25rem;
}

.btn-primary:hover {
  filter: brightness(1.1);
}

.candle-legend {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  margin-top: 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.legend-box {
  display: inline-block;
  width: 14px;
  height: 14px;
  border-radius: 2px;
  vertical-align: middle;
  margin-right: 0.35rem;
}

.legend-box.up { background: #22c55e; }
.legend-box.flat { background: #4a5568; }
.legend-box.wick { background: var(--gold); width: 2px; height: 14px; border-radius: 1px; }

.table-wrapper {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

thead th {
  text-align: left;
  padding: 0.75rem 1rem;
  background: var(--bg);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--border);
}

tbody td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--border);
}

tbody tr:hover {
  background: var(--bg-card-hover);
}

tbody tr.top-1 td:first-child {
  color: var(--gold);
  font-weight: 700;
}

tbody tr.top-2 td:first-child {
  color: #c0c0c0;
  font-weight: 700;
}

tbody tr.top-3 td:first-child {
  color: #cd7f32;
  font-weight: 700;
}

.rank-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-weight: 700;
  font-size: 0.8rem;
}

.candle-stack {
  position: relative;
  width: 28px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.candle-stack .candle-bar {
  flex: 1;
  height: 100%;
  min-height: 0;
}

.candle-crown {
  font-size: 0.95rem;
  line-height: 1;
  filter: drop-shadow(0 1px 3px rgba(245, 197, 24, 0.5));
  animation: crownBounce 1.5s ease-in-out infinite;
}

@keyframes crownBounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.rank-badge.rank-1 {
  font-size: 1.1rem;
  background: rgba(245, 197, 24, 0.25);
  color: var(--gold);
}
.rank-2 { background: rgba(192, 192, 192, 0.15); color: #c0c0c0; }
.rank-3 { background: rgba(205, 127, 50, 0.15); color: #cd7f32; }

.participant-name {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.color-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.footer {
  text-align: center;
  padding: 1.5rem;
  color: var(--text-muted);
  font-size: 0.85rem;
  border-top: 1px solid var(--border);
  margin-top: 1rem;
}

.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 50vh;
  font-size: 1.1rem;
  color: var(--text-muted);
}

.loading-screen {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  background: var(--bg);
  color: var(--text-muted);
}

.loading-spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.error {
  color: #ef4444;
  text-align: center;
  padding: 2rem;
}

@media (max-width: 768px) {
  .header {
    padding: calc(1rem + env(safe-area-inset-top, 0)) 1rem 1rem;
  }

  .header-content {
    flex-direction: column;
    align-items: stretch;
    gap: 1rem;
  }

  .header-title h1 {
    font-size: 1.35rem;
  }

  .subtitle {
    font-size: 0.85rem;
  }

  .stats-bar {
    width: 100%;
    justify-content: space-between;
    gap: 0.5rem;
  }

  .stat-value {
    font-size: 1.2rem;
  }

  .stat-label {
    font-size: 0.65rem;
  }

  .main {
    padding: 0.75rem;
    padding-bottom: calc(0.75rem + env(safe-area-inset-bottom, 0));
    gap: 1rem;
  }

  .card {
    padding: 1rem;
    border-radius: 10px;
  }

  .controls-grid {
    grid-template-columns: 1fr;
  }

  .control-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .control-actions .btn {
    width: 100%;
    min-height: 44px;
  }

  .participants-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 0.4rem;
  }

  .participant-chip {
    min-height: 44px;
    padding: 0.5rem 0.6rem;
  }

  .match-card {
    flex-direction: column;
    padding: 0.85rem 1rem;
    gap: 0.75rem;
  }

  .match-card-date {
    min-width: 0;
    padding-right: 0;
  }

  .match-card-divider {
    width: 100%;
    height: 1px;
    margin: 0;
  }

  .match-card-main {
    padding-left: 0;
  }

  .match-card-date-value {
    font-size: 1.25rem;
  }

  .match-card-game {
    font-size: 1.3rem;
  }

  .phase-badge,
  .bonus-chip {
    font-size: 0.8rem;
    padding: 0.35rem 0.75rem;
  }

  .chart-area {
    height: 360px;
  }

  .candles-container--vertical-ranked .candle-bar,
  .candles-container--vertical-ranked .candle-stack {
    width: min(28px, 88%);
  }

  .candles-container--vertical-ranked .candle-value {
    font-size: 0.78rem;
  }

  .candles-container--vertical-ranked .candle-name {
    font-size: 0.68rem;
  }

  .candles-container--vertical-ranked .candle-plot {
    min-height: 220px;
  }

  .chart-area--horizontal {
    height: auto;
  }

  .candles-container--horizontal {
    max-height: none;
  }

  .bar-row {
    grid-template-columns: 88px 1fr;
    min-height: 32px;
  }

  .bar-name {
    font-size: 0.92rem;
  }

  .bar-track {
    height: 28px;
  }

  .bar-value {
    font-size: 1rem;
  }

  .chart-area--horizontal .x-axis {
    padding-left: calc(88px + 0.5rem);
  }

  .y-axis {
    width: 36px;
  }

  .y-tick,
  .axis-tick {
    font-size: 0.6rem;
  }

  .candle-bar {
    width: 22px;
  }

  .candle-stack {
    width: 22px;
  }

  .candle-plot {
    min-height: 160px;
  }

  .scroll-hint {
    display: block;
  }

  .chart-area--horizontal + .scroll-hint {
    display: none;
  }

  .anim-bar {
    display: grid;
    grid-template-columns: 1fr auto auto;
    grid-template-rows: auto auto;
    gap: 0.5rem;
  }

  .anim-bar .btn-primary {
    grid-column: 1 / -1;
    min-height: 48px;
    font-size: 1rem;
  }

  .anim-bar #restart {
    min-height: 44px;
    min-width: 44px;
  }

  .anim-bar input[type="range"] {
    grid-column: 1 / -1;
    min-height: 32px;
  }

  .anim-bar select {
    min-height: 44px;
    flex: 1;
  }

  .frame-counter {
    text-align: right;
    align-self: center;
  }

  .candle-legend {
    flex-direction: column;
    gap: 0.5rem;
    font-size: 0.75rem;
  }

  thead th,
  tbody td {
    padding: 0.55rem 0.65rem;
    font-size: 0.85rem;
  }

  thead th {
    font-size: 0.7rem;
  }

  .footer {
    padding: 1rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 380px) {
  .stats-bar {
    flex-wrap: wrap;
  }

  .stat {
    flex: 1;
    min-width: 80px;
  }

  .participants-grid {
    grid-template-columns: 1fr;
  }

  .match-card-game {
    font-size: 1.15rem;
  }

  .candle-col {
    flex: 0 0 44px;
    width: 44px;
    min-width: 44px;
    max-width: 44px;
  }

  .candle-bar {
    width: 18px;
  }

  .candle-stack {
    width: 18px;
  }

  .candle-value {
    font-size: 0.65rem;
  }

  .candle-name {
    font-size: 0.55rem;
  }
}
