:root {
  --accent: #f2ba2a;
  --accent-2: #ffd449;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: #06080f;
  overflow: hidden;
}

.rail-console {
  width: 100vw;
  height: 100vh;
  position: relative;
  overflow: hidden;
  font-family: "Barlow", "Inter", sans-serif;
  font-weight: 500;
  color: #ffffff;
  background-color: #06080f;
  background-image:
    linear-gradient(to right, #000000 0, rgba(0,0,0,0) 90px),
    linear-gradient(to left, #000000 0, rgba(0,0,0,0) 90px),
    radial-gradient(circle at 30% 20%, #191f31, #06080f);
  background-repeat: no-repeat;
  background-attachment: fixed, fixed, scroll;
  background-size: 100% 100%, 100% 100%, auto;
  display: flex;
  flex-direction: column;
}
.panel {
  background: linear-gradient(120deg, rgba(15,19,30,0.97), rgba(24,29,44,0.95));
  border-radius: 22px;
  border: 1px solid rgba(255,255,255,0.14);
  box-shadow: 0 20px 50px rgba(0,0,0,0.35);
}

/* ---- topbar ---- */
.topbar {
  display: grid;
  grid-template-columns: minmax(0,1fr) minmax(0,540px) minmax(0,1fr);
  align-items: center;
  padding: 16px 32px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  flex-shrink: 0;
  position: relative;
  z-index: 20;
}
.topbar-left { display: flex; align-items: center; }
.topbar-logo { height: 38px; width: auto; filter: drop-shadow(0 0 10px rgba(242,186,42,0.25)); }
.topbar-center { display: flex; justify-content: center; min-width: 0; }
.tournament-name {
  font-family: "Anton", sans-serif; font-size: 24px; letter-spacing: 0.06em; color: #fff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; text-align: center;
}
.topbar-right { display: flex; justify-content: flex-end; align-items: center; gap: 10px; }

.lang-toggle { display: flex; background: rgba(255,255,255,0.05); border-radius: 999px; padding: 3px; gap: 2px; }
.lang-opt {
  border: none; background: transparent; cursor: pointer; padding: 5px 11px; border-radius: 999px;
  font-family: "Barlow", sans-serif; font-weight: 700; font-size: 11px; letter-spacing: 0.06em;
  color: rgba(255,255,255,0.45); transition: background .2s ease, color .2s ease;
}
.lang-opt.active { background: rgba(242,186,42,0.16); color: #ffd449; }

.live-pill {
  display: flex; align-items: center; gap: 7px; cursor: pointer; border: 1px solid transparent;
  border-radius: 999px; padding: 6px 13px 6px 10px; font-size: 11px; letter-spacing: 0.09em;
  text-transform: uppercase; transition: background .2s ease, border-color .2s ease, color .2s ease;
  background: rgba(242,186,42,0.1); border-color: rgba(242,186,42,0.35); color: #ffd449;
}
.live-pill.error { background: rgba(255,90,90,0.1); border-color: rgba(255,110,110,0.4); color: #ff9c9c; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #ffd449; animation: pulse-dot 1.6s ease-in-out infinite; flex-shrink: 0; }
@keyframes pulse-dot { 0%,100% { opacity: 1; box-shadow: 0 0 0 0 rgba(255,212,73,0.5); } 50% { opacity: 0.55; box-shadow: 0 0 0 6px rgba(255,212,73,0); } }
.warn-icon { width: 13px; height: 13px; flex-shrink: 0; display: none; }
.live-pill.error .live-dot { display: none; }
.live-pill.error .warn-icon { display: inline-flex; }
.live-sub { font-size: 9px; letter-spacing: 0.04em; text-transform: none; color: rgba(255,255,255,0.35); margin-left: 2px; display: none; }
.live-pill.error .live-sub { display: inline; }

/* ---- stage (crossfading layers) ---- */
.stage { flex: 1; position: relative; overflow: hidden; }
.stage-layer {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  opacity: 0; transform: scale(0.97); pointer-events: none;
  transition: opacity .5s cubic-bezier(.22,1,.36,1), transform .5s cubic-bezier(.22,1,.36,1);
}
.stage-layer.active { opacity: 1; transform: scale(1); pointer-events: auto; }

/* ---- idle screen ---- */
.idle-screen { align-items: center; justify-content: center; gap: 6px; }
.idle-venue { font-size: 24px; font-weight: 500; color: rgba(255,255,255,0.7); letter-spacing: 0.02em; margin-bottom: 4px; }
.idle-label { font-size: 40px; letter-spacing: 0.28em; color: rgba(255,255,255,0.55); text-transform: uppercase; font-weight: 700; }
.idle-number {
  font-family: "Anton", sans-serif; font-size: 480px; line-height: 0.82; letter-spacing: 0.02em;
  background: linear-gradient(180deg, #ffd449, #f2ba2a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 10px 40px rgba(242,186,42,0.22));
}
.idle-waiting { font-size: 16px; color: rgba(255,255,255,0.45); letter-spacing: 0.08em; margin-top: -2px; }

/* ---- playing screen ---- */
.playing-screen { padding: 22px 32px 0; min-height: 0; }
.main-grid { flex: 1; display: grid; grid-template-columns: 1fr 264px 1fr; gap: 22px; min-height: 0; height: 100%; }

.player-card { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 26px 22px 18px; position: relative; overflow: hidden; }

.photo-wrap { position: relative; width: 108px; height: 108px; flex-shrink: 0; }
.avatar {
  width: 108px; height: 108px; border-radius: 50%;
  background-color: #1a2131; background-position: center; background-size: cover; background-repeat: no-repeat;
  border: 3px solid rgba(242,186,42,0.45);
  display: flex; align-items: center; justify-content: center;
  font-family: "Anton", sans-serif; font-size: 34px; color: #ffd449;
  box-shadow: 0 10px 26px rgba(0,0,0,0.4);
}
.flag-badge {
  position: absolute; right: -2px; bottom: -2px; width: 30px; height: 22px; border-radius: 5px;
  overflow: hidden; border: 2px solid #101420; box-shadow: 0 2px 8px rgba(0,0,0,0.5);
  object-fit: cover; background: #1a2131;
}

.break-badge {
  display: none; align-items: center; gap: 6px; margin-top: 10px; padding: 5px 12px 5px 8px;
  background: rgba(242,186,42,0.12); border: 1px solid rgba(242,186,42,0.35); border-radius: 999px;
}
.break-badge.active { display: flex; }
.break-badge svg { width: 18px; height: 18px; }
.break-badge span { font-size: 11px; letter-spacing: 0.1em; color: #ffd449; text-transform: uppercase; font-weight: 700; }

.name-block { text-align: center; margin-top: 12px; }
.name-first { font-family: "Barlow", sans-serif; font-weight: 500; font-size: 18px; color: rgba(255,255,255,0.6); line-height: 1.2; }
.name-last { font-family: "Barlow", sans-serif; font-weight: 800; font-size: 31px; letter-spacing: 0.02em; text-transform: uppercase; line-height: 1.08; }

.score-num { font-family: "Anton", sans-serif; font-size: 214px; line-height: 1; margin-top: 6px;
  background: linear-gradient(180deg, #ffd449, #f2ba2a); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px rgba(242,186,42,0.18));
}
@keyframes flash-pop { 0% { transform: scale(1); } 32% { transform: scale(1.14); filter: brightness(1.4); } 100% { transform: scale(1); } }
.score-num.flash { animation: flash-pop .6s ease; }

.score-controls { display: flex; align-items: center; gap: 16px; margin-top: 2px; }
.score-btn {
  width: 78px; height: 78px; border-radius: 20px; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: transform .12s ease, opacity .2s ease;
}
.score-btn:active { transform: scale(0.92); }
.score-btn:disabled { opacity: 0.3; cursor: default; }
.score-btn svg { width: 28px; height: 28px; }
.score-btn.plus { background: linear-gradient(160deg, #ffd449, #f2ba2a); box-shadow: 0 10px 24px rgba(242,186,42,0.28); }
.score-btn.plus svg { stroke: #16130a; }
.score-btn.minus { background: transparent; border: 2px solid rgba(242,186,42,0.55); }
.score-btn.minus svg { stroke: #ffd449; }

.runout-row { display: flex; align-items: center; gap: 10px; margin-top: 16px; }
.runout-label { font-size: 11px; letter-spacing: 0.1em; color: rgba(255,255,255,0.4); text-transform: uppercase; }
.stepper-btn {
  width: 30px; height: 30px; border-radius: 8px; border: 1px solid rgba(255,255,255,0.15);
  background: rgba(255,255,255,0.04); color: #fff; font-size: 15px; cursor: pointer; font-family: "Barlow", sans-serif;
}
.runout-val { font-family: "Anton", sans-serif; font-size: 19px; color: #ffd449; min-width: 22px; text-align: center; }

.breaking-bar { position: absolute; left: 0; bottom: 0; height: 4px; width: 100%; background: transparent; }
.breaking-bar.active { background: var(--accent); }

/* ---- center column ---- */
.center-col { display: flex; flex-direction: column; align-items: center; gap: 10px; padding-top: 10px; }
.center-table-label { font-size: 12px; letter-spacing: 0.24em; color: rgba(255,255,255,0.4); text-transform: uppercase; }
.center-table-num { font-family: "Anton", sans-serif; font-size: 62px; line-height: 0.95; color: #fff; }
.discipline-chip {
  font-size: 14px; font-weight: 700; letter-spacing: 0.1em; color: #ffd449;
  border: 1px solid rgba(242,186,42,0.35); background: rgba(242,186,42,0.08);
  border-radius: 999px; padding: 6px 16px; text-transform: uppercase; margin-top: 4px;
}
.match-clock { font-family: "Anton", sans-serif; font-size: 26px; color: rgba(255,255,255,0.55); letter-spacing: 0.04em; margin-top: 6px; font-variant-numeric: tabular-nums; }

.icon-row { display: flex; gap: 14px; margin-top: 8px; }
.icon-btn {
  width: 50px; height: 50px; border-radius: 50%; border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.04); display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.icon-btn svg { width: 20px; height: 20px; stroke: #fff; }
.icon-btn-label { font-size: 9px; letter-spacing: 0.08em; color: rgba(255,255,255,0.4); text-align: center; margin-top: 4px; text-transform: uppercase; }
.icon-col { display: flex; flex-direction: column; align-items: center; }

.race-badge { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 16px 14px; margin-top: 10px; width: 100%; }
.race-label { font-size: 11px; letter-spacing: 0.16em; color: rgba(255,255,255,0.45); text-transform: uppercase; }
.race-value { font-family: "Anton", sans-serif; font-size: 60px; color: #ffd449; line-height: 1; }

/* ---- finished screen ---- */
.finished-screen { align-items: center; justify-content: center; gap: 14px; }
.finished-title { font-size: 15px; letter-spacing: 0.3em; color: rgba(255,255,255,0.4); text-transform: uppercase; }
.finished-trophy { width: 56px; height: 56px; stroke: #ffd449; margin-top: 4px; }
.finished-winner-label { font-size: 12px; letter-spacing: 0.2em; color: rgba(255,255,255,0.4); text-transform: uppercase; margin-top: 6px; }
.finished-winner-name { font-family: "Anton", sans-serif; font-size: 54px; color: #ffd449; letter-spacing: 0.03em; }
.finished-score { font-family: "Anton", sans-serif; font-size: 96px; color: #fff; line-height: 1; margin-top: 6px; }
.finished-countdown { font-size: 13px; color: rgba(255,255,255,0.35); margin-top: 18px; letter-spacing: 0.05em; }
.finished-newmatch {
  margin-top: 10px; border: 1px solid rgba(242,186,42,0.4); background: rgba(242,186,42,0.1);
  color: #ffd449; font-family: "Barlow", sans-serif; font-weight: 700; font-size: 12px;
  letter-spacing: 0.08em; text-transform: uppercase; padding: 11px 22px; border-radius: 10px; cursor: pointer;
}

/* ---- overlays / modals ---- */
.overlay {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: rgba(4,5,10,0.72); backdrop-filter: blur(10px);
  opacity: 0; pointer-events: none;
  transition: opacity .35s ease;
}
.overlay.open { opacity: 1; pointer-events: auto; }
.modal-card {
  transform: scale(0.92); transition: transform .35s cubic-bezier(.22,1,.36,1);
  padding: 34px 38px; display: flex; flex-direction: column; align-items: center; gap: 18px;
}
.overlay.open .modal-card { transform: scale(1); }

.who-title { font-family: "Anton", sans-serif; font-size: 30px; letter-spacing: 0.04em; }
.who-sub { font-size: 12px; letter-spacing: 0.08em; color: rgba(255,255,255,0.45); text-transform: uppercase; margin-top: -10px; }
.who-tiles { display: flex; gap: 22px; }
.who-tile {
  display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 20px 26px;
  border-radius: 18px; border: 2px solid rgba(255,255,255,0.1); background: rgba(255,255,255,0.03);
  cursor: pointer; transition: border-color .2s ease, background .2s ease; width: 200px;
}
.who-tile.selected { border-color: #f2ba2a; background: rgba(242,186,42,0.08); }
.who-ball { width: 22px; height: 22px; visibility: hidden; }
.who-tile.selected .who-ball { visibility: visible; }
.start-btn {
  border: none; border-radius: 14px; padding: 14px 40px;
  font-family: "Anton", sans-serif; font-size: 20px; letter-spacing: 0.1em;
  background: linear-gradient(160deg, #ffd449, #f2ba2a); color: #16130a; cursor: pointer;
  transition: opacity .2s ease;
}
.start-btn:disabled { opacity: 0.35; cursor: default; }

.finish-icon { width: 34px; height: 34px; stroke: #ffd449; }
.finish-title { font-family: "Anton", sans-serif; font-size: 28px; }
.finish-sub { font-size: 13px; color: rgba(255,255,255,0.45); margin-top: -12px; }
.finish-buttons { display: flex; gap: 14px; margin-top: 6px; }
.btn-ghost {
  border: 1px solid rgba(255,255,255,0.2); background: rgba(255,255,255,0.03); color: #fff;
  font-family: "Barlow", sans-serif; font-weight: 700; font-size: 13px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 13px 22px; border-radius: 12px; cursor: pointer;
}
.btn-solid {
  border: none; background: linear-gradient(160deg, #ffd449, #f2ba2a); color: #16130a;
  font-family: "Barlow", sans-serif; font-weight: 800; font-size: 13px; letter-spacing: 0.06em;
  text-transform: uppercase; padding: 13px 22px; border-radius: 12px; cursor: pointer;
}
