:root {
  --bg: #17181c;
  --panel: #22242b;
  --panel-2: #2d3038;
  --line: #454954;
  --text: #f5f7fb;
  --muted: #aeb5c2;
  --soft: #d9dee8;
  --danger: #e23b4a;
  --warn: #f29f42;
  --green: #1fa187;
  --blue: #3e8cc7;
  --violet: #8a5ce6;
  --paper: #fff7e8;
  --ink: #16171a;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at top left, rgba(226, 59, 74, 0.22), transparent 28rem),
    radial-gradient(circle at 80% 0%, rgba(31, 161, 135, 0.2), transparent 30rem),
    var(--bg);
  color: var(--text);
  font-family: Inter, "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.52;
}

input {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #111216;
  color: var(--text);
}

.shell {
  width: min(1480px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

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

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: conic-gradient(from 30deg, var(--danger), var(--warn), var(--green), var(--blue), var(--violet), var(--danger));
  box-shadow: inset 0 0 0 7px rgba(255, 255, 255, 0.16);
}

.brand h1,
.brand h2 {
  margin: 0;
  font-size: 1.3rem;
  line-height: 1.1;
}

.brand p,
.subtle {
  margin: 3px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.pill-row,
.actions,
.pattern-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.pill {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  color: var(--soft);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.9rem;
  font-weight: 800;
}

.btn-primary {
  background: var(--green);
  color: white;
}

.btn-danger {
  background: var(--danger);
  color: white;
}

.btn-warn {
  background: var(--warn);
  color: #241a0a;
}

.btn-blue {
  background: var(--blue);
  color: white;
}

.btn-ghost {
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
}

.sound-button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 900;
}

.sound-button.active {
  background: var(--green);
  border-color: var(--green);
  color: white;
}

.layout {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr) 360px;
  gap: 14px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 36, 43, 0.92);
  box-shadow: var(--shadow);
}

.panel-pad {
  padding: 14px;
}

.panel + .panel {
  margin-top: 14px;
}

.section-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
}

.section-title h3 {
  margin: 0;
  font-size: 0.98rem;
}

.section-title span {
  color: var(--muted);
  font-size: 0.82rem;
}

.home {
  min-height: calc(100vh - 36px);
  display: grid;
  place-items: center;
}

.home-card {
  width: min(760px, 100%);
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(34, 36, 43, 0.9);
  box-shadow: var(--shadow);
}

.home-card h1 {
  margin: 0 0 8px;
  font-size: clamp(2rem, 7vw, 4rem);
}

.home-card p {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 1rem;
}

.resume-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px;
  margin: 16px 0;
  border: 1px solid rgba(62, 140, 199, 0.38);
  border-radius: 8px;
  background: rgba(62, 140, 199, 0.12);
}

.resume-card strong,
.resume-card span {
  display: block;
}

.resume-card span {
  color: var(--muted);
  margin-top: 4px;
  font-size: 0.92rem;
}

.quick-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 20px 0;
}

.quick-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
}

.quick-item b {
  display: block;
  margin-bottom: 4px;
}

.quick-item span {
  color: var(--muted);
  font-size: 0.9rem;
}

.join-box {
  display: grid;
  grid-template-columns: 132px 1fr;
  gap: 12px;
  align-items: center;
}

.qr {
  width: 132px;
  height: 132px;
  border-radius: 8px;
  background: white;
  padding: 8px;
}

.qr img {
  width: 100%;
  height: 100%;
  display: block;
}

.link-line {
  overflow-wrap: anywhere;
  color: var(--soft);
  font-size: 0.92rem;
}

.mini-list {
  display: grid;
  gap: 8px;
}

.mini-item {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.16);
}

.mini-item small {
  color: var(--muted);
}

.caller-board,
.display-board {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.caller-col,
.display-col {
  display: grid;
  gap: 4px;
}

.col-head {
  display: grid;
  place-items: center;
  min-height: 36px;
  border-radius: 8px;
  color: white;
  font-size: 1.25rem;
  font-weight: 950;
}

.num-btn,
.display-num {
  display: grid;
  place-items: center;
  min-height: 32px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: #15161b;
  color: #777d89;
  font-weight: 900;
}

.num-btn.called,
.display-num.called {
  color: white;
  border-color: rgba(255, 255, 255, 0.28);
}

.stage-strip {
  display: grid;
  grid-template-columns: 120px 1fr;
  gap: 14px;
  align-items: center;
}

.ball {
  width: 98px;
  height: 98px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  margin: auto;
  color: white;
  box-shadow: inset -12px -12px 22px rgba(0, 0, 0, 0.24), inset 8px 8px 14px rgba(255, 255, 255, 0.16);
}

.ball b {
  display: block;
  text-align: center;
  font-size: 2.1rem;
  line-height: 1;
}

.ball span {
  display: block;
  text-align: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  font-weight: 950;
}

.last-meta h2 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4.5rem);
  line-height: 1;
}

.last-meta p {
  color: var(--muted);
  margin: 8px 0 0;
}

.pattern-grid,
.card-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}

.pattern-cell {
  aspect-ratio: 1;
  border-radius: 5px;
  background: #121318;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.pattern-cell.on {
  background: var(--warn);
  border-color: rgba(255, 255, 255, 0.35);
}

.pattern-button {
  min-height: 38px;
  padding: 0 12px;
}

.pattern-button.active {
  background: var(--warn);
  color: #211709;
}

.pattern-button:not(.active) {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border: 1px solid var(--line);
}

.verify-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
}

.result-box {
  border-radius: 8px;
  padding: 10px;
  margin-top: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--line);
}

.result-box.good {
  border-color: rgba(31, 161, 135, 0.7);
  background: rgba(31, 161, 135, 0.12);
}

.result-box.bad {
  border-color: rgba(226, 59, 74, 0.7);
  background: rgba(226, 59, 74, 0.1);
}

.host-display-note {
  border: 1px solid rgba(31, 161, 135, 0.45);
  border-radius: 8px;
  padding: 12px;
  background: rgba(31, 161, 135, 0.1);
  color: var(--soft);
  line-height: 1.45;
}

.timer-control {
  margin-top: 12px;
  display: grid;
  gap: 8px;
}

.timer-control label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
}

.timer-row {
  display: grid;
  grid-template-columns: minmax(90px, 1fr) auto;
  gap: 8px;
}

.audio-control-grid {
  display: grid;
  gap: 10px;
}

.audio-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--soft);
  font-weight: 850;
}

.audio-toggle input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--green);
}

.audio-slider {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.audio-slider span {
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 850;
}

.audio-slider input {
  min-height: auto;
  padding: 0;
  accent-color: var(--warn);
}

.audio-upload-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.audio-upload-group {
  display: grid;
  gap: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 8px;
  background: rgba(0, 0, 0, 0.12);
}

.audio-upload-heading {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: baseline;
}

.audio-upload-heading b,
.audio-upload-heading small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-upload-heading small {
  color: var(--muted);
  font-size: 0.82rem;
}

.audio-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.04);
}

.audio-upload-row b,
.audio-upload-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.audio-upload-row small,
.audio-note {
  color: var(--muted);
  font-size: 0.82rem;
}

.audio-file-button {
  min-height: 38px;
  display: grid;
  place-items: center;
  padding: 0 12px;
  cursor: pointer;
  font-weight: 850;
}

.audio-file-button input {
  display: none;
}

.audio-note {
  margin-top: 10px;
  line-height: 1.45;
}

.audit-list {
  display: grid;
  gap: 8px;
  max-height: 360px;
  overflow: auto;
}

.audit-item {
  border-left: 4px solid var(--line);
  padding: 8px 10px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.04);
}

.audit-item.blocked {
  border-color: var(--danger);
}

.audit-item.winner {
  border-color: var(--green);
}

.audit-item.call {
  border-color: var(--blue);
}

.audit-item small {
  color: var(--muted);
}

.display-page {
  width: min(1600px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.display-frame {
  min-height: calc(100vh - 36px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 12px;
}

.display-frame-results {
  height: calc(100vh - 36px);
  min-height: 0;
  overflow: hidden;
}

.display-main {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 12px;
  min-height: 0;
}

.display-main-calls {
  grid-template-columns: 1fr;
}

.display-main-results {
  overflow: hidden;
}

.display-call-stage {
  min-height: min(720px, calc(100vh - 150px));
  display: grid;
  align-items: center;
  overflow: hidden;
  position: relative;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 255, 255, 0.13), transparent 18rem),
    radial-gradient(ellipse at 50% 78%, rgba(0, 0, 0, 0.34), transparent 28rem),
    linear-gradient(160deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02));
}

.display-join-stage,
.display-countdown-stage {
  justify-items: center;
}

.display-lobby {
  width: min(1180px, 100%);
  display: grid;
  grid-template-columns: minmax(280px, 430px) minmax(360px, 1fr);
  gap: clamp(26px, 5vw, 78px);
  align-items: center;
}

.display-qr-area {
  display: grid;
  justify-items: center;
  gap: 18px;
}

.display-qr {
  width: clamp(240px, 28vw, 400px);
  aspect-ratio: 1;
  border-radius: 8px;
  display: grid;
  place-items: center;
  padding: clamp(14px, 2vw, 22px);
  background: #fff;
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.34),
    0 0 0 10px rgba(255, 255, 255, 0.08);
}

.display-qr img {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.display-qr span {
  color: #1b1c20;
  font-size: clamp(3rem, 8vw, 7rem);
  font-weight: 950;
}

.display-room-code {
  display: grid;
  justify-items: center;
  gap: 2px;
}

.display-room-code span,
.display-lobby-copy span,
.countdown-wrap span {
  color: var(--muted);
  font-size: clamp(0.85rem, 1.5vw, 1.1rem);
  font-weight: 950;
  text-transform: uppercase;
}

.display-room-code b {
  font-size: clamp(3rem, 7vw, 6.6rem);
  line-height: 0.95;
}

.display-lobby-copy {
  display: grid;
  gap: 16px;
  align-content: center;
}

.display-lobby-copy h2 {
  margin: 0;
  font-size: clamp(3.2rem, 8vw, 8rem);
  line-height: 0.92;
}

.display-lobby-copy p {
  margin: 0;
  color: var(--soft);
  font-size: clamp(1rem, 1.8vw, 1.35rem);
  overflow-wrap: anywhere;
}

.display-control-panel {
  width: min(560px, 100%);
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(15, 16, 20, 0.62);
  backdrop-filter: blur(10px);
}

.display-control-panel label {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 900;
}

.display-control-row {
  display: grid;
  grid-template-columns: minmax(100px, 1fr) auto;
  gap: 8px;
}

.display-control-compact {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 9;
  width: min(520px, calc(100% - 28px));
}

.display-control-countdown {
  margin-top: 10px;
}

.display-control-status {
  width: min(540px, 100%);
  border: 1px dashed rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  padding: 12px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-weight: 800;
}

.display-results-stage {
  grid-template-columns: minmax(360px, 0.95fr) minmax(420px, 1.05fr);
  gap: clamp(18px, 3vw, 42px);
  padding: clamp(18px, 3vw, 34px);
  align-items: stretch;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.champion-panel,
.ranking-panel {
  position: relative;
  min-width: 0;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(15, 16, 20, 0.7);
  overflow: hidden;
}

.champion-panel {
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  min-height: min(620px, calc(100vh - 220px));
  padding: clamp(24px, 4vw, 56px);
  text-align: center;
  background:
    radial-gradient(circle at 50% 20%, rgba(242, 159, 66, 0.34), transparent 16rem),
    radial-gradient(circle at 50% 90%, rgba(31, 161, 135, 0.22), transparent 18rem),
    rgba(15, 16, 20, 0.72);
}

.display-frame-results .champion-panel {
  gap: clamp(8px, 1.4vh, 16px);
  min-height: 0;
  padding: clamp(16px, 3vh, 34px);
}

.champion-panel::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: conic-gradient(from 0deg, transparent, rgba(242, 159, 66, 0.18), transparent 24%, rgba(255, 255, 255, 0.16), transparent 42%);
  animation: champion-rays 8s linear infinite;
}

.champion-badge {
  position: relative;
  width: clamp(150px, 18vw, 250px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #241a0a;
  background:
    radial-gradient(circle at 34% 24%, rgba(255, 255, 255, 0.92), rgba(255, 255, 255, 0.16) 28%, transparent 42%),
    linear-gradient(145deg, #ffe27a, #f29f42 54%, #9b5d12);
  box-shadow:
    inset -22px -28px 38px rgba(82, 44, 6, 0.28),
    inset 18px 20px 30px rgba(255, 255, 255, 0.32),
    0 24px 80px rgba(242, 159, 66, 0.36);
  animation: champion-float 2.6s ease-in-out infinite;
  z-index: 1;
}

.display-frame-results .champion-badge {
  width: clamp(110px, 22vh, 220px);
}

.champion-badge::before,
.champion-badge::after {
  content: "";
  position: absolute;
  top: 16%;
  width: 30%;
  height: 24%;
  border-radius: 8px 8px 0 0;
  background: rgba(255, 255, 255, 0.28);
  transform: rotate(-18deg);
}

.champion-badge::before {
  left: 18%;
}

.champion-badge::after {
  right: 18%;
  transform: rotate(18deg);
}

.champion-badge span {
  position: relative;
  z-index: 2;
  font-size: clamp(5rem, 11vw, 10rem);
  line-height: 0.8;
  font-weight: 950;
}

.display-frame-results .champion-badge span {
  font-size: clamp(4rem, 13vh, 8.5rem);
}

.result-label {
  position: relative;
  z-index: 1;
  color: var(--warn);
  font-size: clamp(1rem, 2vw, 1.4rem);
  font-weight: 950;
  text-transform: uppercase;
}

.display-frame-results .result-label {
  font-size: clamp(0.95rem, 2.6vh, 1.35rem);
}

.champion-panel h2 {
  position: relative;
  z-index: 1;
  margin: 0;
  font-size: clamp(3rem, 8vw, 7.5rem);
  line-height: 0.88;
}

.display-frame-results .champion-panel h2 {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(2.3rem, 7.6vh, 5.2rem);
  line-height: 0.92;
}

.champion-panel p {
  position: relative;
  z-index: 1;
  margin: 0;
  color: var(--soft);
  font-size: clamp(1.1rem, 2.2vw, 1.6rem);
  font-weight: 900;
}

.display-frame-results .champion-panel p {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: clamp(0.9rem, 2.2vh, 1.35rem);
}

.champion-sparkles {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.champion-sparkles span {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--warn);
  box-shadow: 0 0 18px rgba(242, 159, 66, 0.8);
  animation: sparkle-pop 1.8s ease-in-out infinite;
}

.champion-sparkles span:nth-child(1) {
  left: 18%;
  top: 18%;
}

.champion-sparkles span:nth-child(2) {
  right: 16%;
  top: 28%;
  animation-delay: 0.35s;
  background: var(--green);
}

.champion-sparkles span:nth-child(3) {
  left: 28%;
  bottom: 18%;
  animation-delay: 0.7s;
  background: var(--blue);
}

.champion-sparkles span:nth-child(4) {
  right: 24%;
  bottom: 22%;
  animation-delay: 1s;
  background: var(--danger);
}

.ranking-panel {
  padding: clamp(16px, 2.3vw, 28px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  min-height: 0;
}

.ranking-list {
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  padding-right: 6px;
  scrollbar-gutter: stable;
}

.ranking-row {
  min-height: 76px;
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 8px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.055);
}

.ranking-row b {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #1b1c20;
  background: var(--soft);
  font-size: 1.35rem;
}

.ranking-row strong,
.ranking-row small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-row strong {
  font-size: clamp(1.05rem, 1.8vw, 1.35rem);
}

.ranking-row small {
  margin-top: 2px;
  color: var(--muted);
  font-weight: 750;
}

.ranking-row span {
  color: var(--warn);
  font-size: clamp(1.2rem, 2.2vw, 1.7rem);
  font-weight: 950;
}

@keyframes champion-rays {
  to {
    transform: rotate(1turn);
  }
}

@keyframes champion-float {
  50% {
    transform: translateY(-10px) scale(1.03);
  }
}

@keyframes sparkle-pop {
  0%,
  100% {
    opacity: 0.25;
    transform: scale(0.65);
  }
  50% {
    opacity: 1;
    transform: scale(1.6);
  }
}

.countdown-wrap {
  display: grid;
  justify-items: center;
  gap: 14px;
  text-align: center;
}

.countdown-wrap b {
  width: clamp(220px, 30vw, 420px);
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: clamp(8rem, 24vw, 19rem);
  line-height: 0.86;
  color: white;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.9) 0 5%, rgba(255, 255, 255, 0.22) 13%, transparent 27%),
    radial-gradient(circle at 72% 80%, rgba(0, 0, 0, 0.5), transparent 46%),
    linear-gradient(145deg, rgba(255, 255, 255, 0.22), rgba(0, 0, 0, 0.32)),
    var(--warn);
  box-shadow:
    inset -36px -48px 64px rgba(0, 0, 0, 0.38),
    inset 24px 28px 34px rgba(255, 255, 255, 0.22),
    0 35px 110px rgba(242, 159, 66, 0.28);
}

.countdown-wrap p {
  margin: 0;
  color: var(--soft);
  font-size: clamp(1.25rem, 3vw, 2.5rem);
  font-weight: 900;
}

.call-track {
  --track-ball-size: 190px;
  --track-shadow-offset: 84px;
  --slot-gap: 24px;
  --track-padding: 34px;
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: var(--slot-gap);
  align-items: center;
  min-height: min(540px, calc(100vh - 190px));
  overflow: hidden;
  padding: var(--track-padding);
  perspective: 1200px;
  contain: layout paint style;
}

.call-slot {
  position: relative;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  isolation: isolate;
  transform: translateZ(0);
  backface-visibility: hidden;
  will-change: transform, opacity;
}

.call-slot::after {
  content: "";
  position: absolute;
  top: calc(50% + var(--track-shadow-offset));
  left: 50%;
  width: min(150px, 72%);
  height: 20px;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.48), transparent 72%);
  filter: blur(2px);
  transform: translateX(-50%);
  z-index: -1;
}

.call-tone-1 {
  --ball-light: 0.45;
  --ball-dark: 0.04;
}

.call-tone-2 {
  --ball-light: 0.34;
  --ball-dark: 0.1;
}

.call-tone-3 {
  --ball-light: 0.24;
  --ball-dark: 0.18;
}

.call-tone-4 {
  --ball-light: 0.16;
  --ball-dark: 0.28;
}

.call-tone-5 {
  --ball-light: 0.09;
  --ball-dark: 0.42;
}

.call-tone-1 .display-ball {
  filter: brightness(1.22) saturate(0.9);
}

.call-tone-2 .display-ball {
  filter: brightness(1.12) saturate(0.96);
}

.call-tone-3 .display-ball {
  filter: brightness(1.02) saturate(1);
}

.call-tone-4 .display-ball {
  filter: brightness(0.93) saturate(1.08);
}

.call-tone-5 .display-ball {
  filter: brightness(0.84) saturate(1.16);
}

.call-slot-fade {
  opacity: 0.34;
  filter: blur(0.4px);
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, black 38%, black 100%);
  mask-image: linear-gradient(90deg, transparent 0%, black 38%, black 100%);
}

.call-slot-previous {
  opacity: 0.9;
}

.call-slot-latest .display-ball {
  transform: translateY(-6px);
  box-shadow:
    inset -32px -40px 52px rgba(0, 0, 0, 0.36),
    inset 18px 22px 32px rgba(255, 255, 255, 0.26),
    0 0 0 8px rgba(255, 255, 255, 0.08),
    0 28px 86px rgba(242, 159, 66, 0.32);
}

.call-slot-latest::after {
  width: min(190px, 92%);
  height: 26px;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.58), transparent 72%);
}

.outgoing-call-ball {
  position: absolute;
  left: var(--track-padding);
  top: var(--track-padding);
  bottom: var(--track-padding);
  width: calc((100% - (var(--track-padding) * 2) - (var(--slot-gap) * 4)) / 5);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 1;
  will-change: transform, opacity;
  animation: call-slot-roll-out 0.98s cubic-bezier(0.18, 0.86, 0.18, 1) both;
}

.outgoing-call-ball .display-ball {
  width: min(calc(var(--track-ball-size) * 0.84), 100%);
  height: auto;
  aspect-ratio: 1;
}

.empty-slot {
  opacity: 0.18;
}

.call-showcase {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(180px, 320px);
  gap: clamp(18px, 4vw, 54px);
  align-items: center;
}

.current-call,
.previous-call-ball {
  display: grid;
  justify-items: center;
  gap: 14px;
}

.call-label {
  color: var(--muted);
  font-size: clamp(0.9rem, 1.6vw, 1.15rem);
  font-weight: 950;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.display-ball {
  position: relative;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: white;
  overflow: hidden;
  transform-style: preserve-3d;
  backface-visibility: hidden;
  will-change: transform, opacity;
  background:
    radial-gradient(circle at 24% 18%, rgba(255, 255, 255, 0.95) 0 6%, rgba(255, 255, 255, 0.24) 12%, transparent 24%),
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.38), transparent 34%),
    radial-gradient(circle at 72% 78%, rgba(0, 0, 0, 0.48), transparent 44%),
    linear-gradient(145deg, rgba(255, 255, 255, var(--ball-light, 0.18)), rgba(0, 0, 0, var(--ball-dark, 0.24))),
    var(--ball-color);
  background-blend-mode: screen, soft-light, multiply, overlay, normal;
  box-shadow:
    inset -30px -38px 46px rgba(0, 0, 0, 0.38),
    inset 18px 20px 30px rgba(255, 255, 255, 0.24),
    inset 0 0 0 2px rgba(255, 255, 255, 0.16),
    0 26px 70px rgba(0, 0, 0, 0.36);
}

.display-ball::before {
  content: "";
  position: absolute;
  inset: 8%;
  border-radius: 50%;
  background:
    radial-gradient(circle at 28% 20%, rgba(255, 255, 255, 0.46), transparent 19%),
    radial-gradient(circle at 66% 72%, rgba(0, 0, 0, 0.2), transparent 50%);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
  pointer-events: none;
  z-index: 1;
}

.display-ball::after {
  content: "";
  position: absolute;
  left: 18%;
  right: 18%;
  bottom: 7%;
  height: 18%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0, 0, 0, 0.34), transparent 70%);
  filter: blur(3px);
  pointer-events: none;
  z-index: 1;
}

.display-ball-main {
  width: clamp(260px, 42vw, 560px);
  height: clamp(260px, 42vw, 560px);
}

.display-ball-previous,
.display-ball-fade,
.display-ball-empty {
  width: min(calc(var(--track-ball-size) * 0.84), 100%);
  height: auto;
  aspect-ratio: 1;
}

.display-ball-latest {
  width: min(calc(var(--track-ball-size) * 1.08), calc(100% + 34px));
  height: auto;
  aspect-ratio: 1;
}

.display-ball-latest {
  transform: translateZ(0);
}

.display-ball-previous {
  opacity: 0.94;
}

.display-ball-empty {
  border: 1px dashed rgba(255, 255, 255, 0.28);
  box-shadow:
    inset -18px -22px 34px rgba(0, 0, 0, 0.24),
    inset 12px 14px 24px rgba(255, 255, 255, 0.08);
}

.call-track-rolling .call-slot {
  animation: call-slot-roll-in 0.98s cubic-bezier(0.18, 0.86, 0.18, 1) both;
}

.call-track-rolling .call-slot:nth-child(2) {
  animation-delay: 0ms;
}

.call-track-rolling .call-slot:nth-child(3) {
  animation-delay: 18ms;
}

.call-track-rolling .call-slot:nth-child(4) {
  animation-delay: 32ms;
}

.call-track-rolling .call-slot:nth-child(5) {
  animation-delay: 44ms;
}

.call-track-rolling .call-slot:nth-child(6) {
  animation-delay: 56ms;
}

.call-track-rolling .call-slot-latest .display-ball {
  animation: latest-ball-settle 0.98s cubic-bezier(0.16, 0.92, 0.18, 1) both;
}

@keyframes call-slot-roll-in {
  0% {
    opacity: 0.68;
    transform: translate3d(calc(100% + var(--slot-gap)), 0, 0);
  }
  60% {
    opacity: 1;
  }
  100% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

@keyframes call-slot-roll-out {
  0% {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
  100% {
    opacity: 0;
    transform: translate3d(calc(-100% - var(--slot-gap)), 0, 0) scale(0.92);
  }
}

@keyframes latest-ball-settle {
  0% {
    transform: translateY(-6px) scale(0.92);
  }
  58% {
    transform: translateY(-6px) scale(1.045);
  }
  100% {
    transform: translateY(-6px) scale(1);
  }
}

.ball-shine {
  position: absolute;
  width: 32%;
  height: 20%;
  top: 14%;
  left: 18%;
  border-radius: 50%;
  background:
    radial-gradient(ellipse, rgba(255, 255, 255, 0.82), rgba(255, 255, 255, 0.18) 58%, transparent 72%);
  filter: blur(0.5px);
  transform: rotate(-24deg);
  z-index: 2;
}

.ball-face {
  width: 58%;
  height: 58%;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 32% 22%, rgba(255, 255, 255, 0.42), transparent 30%),
    linear-gradient(155deg, rgba(255, 255, 255, 0.28), rgba(0, 0, 0, 0.1));
  border: 3px solid rgba(255, 255, 255, 0.34);
  text-align: center;
  box-shadow:
    inset -10px -14px 22px rgba(0, 0, 0, 0.18),
    inset 8px 8px 16px rgba(255, 255, 255, 0.18);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.34);
  z-index: 3;
}

.ball-face span {
  display: block;
  font-size: clamp(1rem, 3vw, 2.2rem);
  font-weight: 950;
  letter-spacing: 0.08em;
  line-height: 1;
}

.ball-face b {
  display: block;
  margin-top: -18%;
  font-size: clamp(3rem, 11vw, 8.5rem);
  line-height: 0.86;
}

.call-track .ball-face span {
  font-size: 1.15rem;
}

.call-track .ball-face b {
  margin-top: -14%;
  font-size: 4.5rem;
}

.call-track .display-ball-empty .ball-face b {
  font-size: 2.7rem;
}

.previous-call {
  min-height: 78px;
  margin-top: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.05);
  display: grid;
  place-items: center;
  text-align: center;
  padding: 12px;
}

.previous-call span {
  color: var(--muted);
  display: block;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.previous-call strong {
  display: block;
  margin-top: 4px;
  font-size: clamp(1.35rem, 3vw, 2rem);
  line-height: 1;
}

.winner-inline {
  min-height: 112px;
  margin-top: 12px;
  border-radius: 8px;
  padding: 14px;
  text-align: center;
  color: white;
  background: linear-gradient(135deg, var(--danger), var(--warn), var(--green), var(--blue), var(--violet));
  display: grid;
  place-items: center;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.24);
}

.winner-inline b {
  display: block;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 0.92;
}

.winner-inline span {
  display: block;
  font-size: 0.95rem;
  font-weight: 900;
}

.winner-stage-overlay {
  position: fixed;
  inset: 0;
  z-index: 24;
  display: none;
  place-items: center;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.12), rgba(0, 0, 0, 0.68));
  pointer-events: none;
}

.winner-stage-overlay.show {
  display: grid;
}

.winner-stage-card {
  width: min(720px, calc(100% - 40px));
  min-height: 300px;
  border-radius: 8px;
  padding: clamp(22px, 4vw, 44px);
  text-align: center;
  display: grid;
  place-items: center;
  color: white;
  border: 3px solid rgba(255, 255, 255, 0.55);
  background:
    radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.3), transparent 9rem),
    linear-gradient(135deg, var(--danger), var(--warn), var(--green), var(--blue), var(--violet));
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.48);
  animation: winner-pop 0.42s ease-out;
}

.winner-stage-card span {
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 950;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.winner-stage-card b {
  display: block;
  font-size: clamp(4rem, 13vw, 9rem);
  line-height: 0.88;
}

.winner-stage-card p {
  margin: 0;
  font-size: clamp(1rem, 2.4vw, 1.6rem);
  font-weight: 950;
}

@keyframes winner-pop {
  from {
    transform: translateY(24px) scale(0.86);
    opacity: 0;
  }
}

.display-board .display-num {
  min-height: clamp(34px, 5.5vh, 64px);
  font-size: clamp(1rem, 2vw, 1.8rem);
}

.display-board .col-head {
  min-height: 48px;
  font-size: 1.8rem;
}

.player-shell {
  width: min(560px, 100%);
  margin: 0 auto;
  padding: 14px;
}

.phone-card {
  background: var(--paper);
  color: var(--ink);
  border-radius: 8px;
  padding: 14px;
  box-shadow: var(--shadow);
}

.phone-card .subtle {
  color: #62666f;
}

.card-grid {
  gap: 7px;
  margin-top: 12px;
}

.card-head,
.card-cell {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border-radius: 8px;
  font-weight: 950;
}

.card-head {
  color: white;
  min-height: 42px;
  aspect-ratio: auto;
}

.card-cell {
  border: 2px solid #dfd4be;
  background: #fffdf8;
  color: #1b1c20;
  font-size: clamp(1rem, 8vw, 1.65rem);
  position: relative;
}

.card-cell.called {
  border-color: rgba(31, 161, 135, 0.82);
  background: #dcfff6;
}

.card-cell.marked::after {
  content: "";
  position: absolute;
  width: 72%;
  height: 72%;
  border-radius: 50%;
  border: 5px solid rgba(226, 59, 74, 0.86);
}

.card-cell.free {
  background: #1b1c20;
  color: white;
  font-size: 0.95rem;
}

.card-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.join-form {
  display: grid;
  gap: 10px;
}

.player-game-over {
  position: fixed;
  inset: 0;
  z-index: 26;
  display: grid;
  place-items: center;
  background: rgba(0, 0, 0, 0.58);
  padding: 18px;
}

.player-game-over-card {
  width: min(420px, 100%);
  border-radius: 8px;
  padding: 22px;
  text-align: center;
  color: white;
  background: linear-gradient(135deg, var(--danger), var(--blue));
  border: 2px solid rgba(255, 255, 255, 0.4);
  box-shadow: var(--shadow);
}

.player-game-over-card b {
  display: block;
  font-size: clamp(2.4rem, 10vw, 4rem);
  line-height: 1;
}

.player-game-over-card span {
  display: block;
  margin-top: 10px;
  font-weight: 900;
}

.player-game-over-card p {
  margin: 14px 0 0;
  padding: 10px 12px;
  border-radius: 8px;
  color: #1b1c20;
  background: rgba(255, 255, 255, 0.88);
  font-size: 1.05rem;
  font-weight: 950;
}

.winner-overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(0, 0, 0, 0.64);
  z-index: 20;
}

.winner-overlay.show {
  display: grid;
}

.winner-card {
  width: min(740px, calc(100% - 36px));
  border-radius: 8px;
  padding: 28px;
  border: 2px solid rgba(255, 255, 255, 0.5);
  background: linear-gradient(135deg, var(--danger), var(--warn), var(--green), var(--blue), var(--violet));
  color: white;
  text-align: center;
  animation: pop 0.32s ease-out;
}

.winner-card h2 {
  font-size: clamp(3rem, 12vw, 8rem);
  margin: 0;
  line-height: 0.95;
}

.winner-card p {
  margin: 12px 0 0;
  font-size: 1.2rem;
  font-weight: 900;
}

@keyframes pop {
  from {
    transform: scale(0.86);
    opacity: 0;
  }
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%) translateY(14px);
  min-width: min(440px, calc(100% - 32px));
  max-width: 640px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101115;
  color: var(--text);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s, transform 0.18s;
  z-index: 30;
  box-shadow: var(--shadow);
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.empty {
  color: var(--muted);
  padding: 12px;
  border: 1px dashed var(--line);
  border-radius: 8px;
}

.hidden {
  display: none !important;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr;
  }
  .display-main {
    grid-template-columns: 1fr;
  }
  .display-results-stage {
    grid-template-columns: 1fr;
  }
  .champion-panel {
    min-height: 340px;
  }
  .ranking-panel {
    min-height: 300px;
  }
  .display-lobby {
    grid-template-columns: 1fr;
    gap: 28px;
  }
  .display-control-compact {
    position: relative;
    top: auto;
    right: auto;
    justify-self: end;
  }
  .call-showcase {
    grid-template-columns: 1fr;
  }
  .call-track {
    --track-ball-size: 138px;
    --track-shadow-offset: 60px;
    --slot-gap: 14px;
    --track-padding: 22px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 280px;
  }
  .call-track .ball-face span {
    font-size: 0.9rem;
  }
  .call-track .ball-face b {
    font-size: 3.25rem;
  }
}

@media (max-width: 720px) {
  .topbar,
  .stage-strip,
  .join-box {
    grid-template-columns: 1fr;
    display: grid;
  }
  .quick-grid {
    grid-template-columns: 1fr;
  }
  .actions button,
  .pattern-button {
    flex: 1 1 auto;
  }
  .caller-board,
  .display-board {
    gap: 4px;
  }
  .num-btn,
  .display-num {
    min-height: 30px;
    font-size: 0.85rem;
  }
  .card-actions {
    grid-template-columns: 1fr;
  }
  .resume-card {
    grid-template-columns: 1fr;
  }
  .display-call-stage {
    min-height: 220px;
  }
  .display-lobby-copy h2 {
    font-size: 3rem;
  }
  .display-room-code b {
    font-size: 3.4rem;
  }
  .display-control-row {
    grid-template-columns: 1fr;
  }
  .ranking-row {
    grid-template-columns: 42px minmax(0, 1fr) auto;
    min-height: 64px;
  }
  .ranking-row b {
    width: 34px;
    height: 34px;
    font-size: 1rem;
  }
  .ranking-row span {
    font-size: 1rem;
  }
  .countdown-wrap b {
    width: min(72vw, 260px);
    font-size: 8rem;
  }
  .call-track {
    --track-ball-size: 64px;
    --track-shadow-offset: 28px;
    --slot-gap: 6px;
    --track-padding: 8px;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    min-height: 150px;
  }
  .ball-face {
    border-width: 2px;
  }
  .call-track .ball-face span {
    font-size: 0.68rem;
  }
  .call-track .ball-face b {
    margin-top: -8%;
    font-size: 1.55rem;
  }
  .call-track .display-ball-empty .ball-face b {
    font-size: 1.25rem;
  }
}
