:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1b1f2a;
  --panel-2: #222837;
  --line: rgba(255, 255, 255, 0.12);
  --text: #f6f7fb;
  --muted: #a8b0c1;
  --men: #3fb7ff;
  --women: #ff5d8f;
  --gold: #ffd166;
  --shadow: 0 18px 60px rgba(0, 0, 0, 0.36);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(63, 183, 255, 0.18), transparent 26rem),
    radial-gradient(circle at 82% 14%, rgba(255, 93, 143, 0.18), transparent 25rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, "Hiragino Kaku Gothic ProN", "Yu Gothic", Meiryo, system-ui, sans-serif;
}

button,
select,
input {
  font: inherit;
}

.app-shell {
  width: min(1280px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.stage {
  position: relative;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(260px, 0.8fr) minmax(220px, 1fr);
  gap: 24px;
  min-height: 560px;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.018));
  box-shadow: var(--shadow);
  overflow: hidden;
}

.line-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 4;
}

.heart-burst {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 5;
}

.heart-burst[hidden] {
  display: none;
}

.heart-core {
  display: grid;
  place-items: center;
  width: clamp(110px, 14vw, 190px);
  aspect-ratio: 1;
  color: #ff3d7f;
  font-size: clamp(76px, 10vw, 142px);
  line-height: 1;
  text-shadow:
    0 0 18px rgba(255, 61, 127, 0.72),
    0 0 44px rgba(255, 209, 102, 0.48);
  animation:
    heartEnter 360ms cubic-bezier(0.18, 1.4, 0.24, 1) both,
    heartBeat 660ms ease-in-out 360ms 4,
    heartFade 420ms ease-out 3000ms forwards;
}

.heart-chip {
  position: absolute;
  left: 50%;
  top: 50%;
  color: #ff6aa0;
  font-size: var(--heart-size);
  line-height: 1;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.35);
  text-shadow: 0 0 12px rgba(255, 106, 160, 0.64);
  animation: heartChip 1100ms cubic-bezier(0.16, 0.86, 0.28, 1) var(--heart-delay) forwards;
}

.broken-heart-core {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: clamp(116px, 15vw, 200px);
  aspect-ratio: 1;
  color: #8ea0b8;
  font-size: clamp(78px, 10vw, 146px);
  line-height: 1;
  text-shadow: 0 0 22px rgba(142, 160, 184, 0.48);
}

.broken-heart-half {
  display: block;
  overflow: hidden;
  animation-duration: 2200ms;
  animation-timing-function: cubic-bezier(0.18, 0.78, 0.28, 1);
  animation-fill-mode: forwards;
}

.broken-heart-half.left {
  text-align: left;
  animation-name: brokenLeft;
}

.broken-heart-half.right {
  text-align: right;
  animation-name: brokenRight;
}

.broken-heart-half.left span {
  display: inline-block;
  width: 200%;
}

.broken-heart-half.right span {
  display: inline-block;
  width: 200%;
  transform: translateX(-50%);
}

.team,
.host-panel {
  position: relative;
  z-index: 2;
}

.team {
  display: grid;
  align-content: center;
  gap: 14px;
}

.player-card {
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.11);
  border-radius: 8px;
  background: rgba(18, 22, 31, 0.78);
  backdrop-filter: blur(10px);
  transition:
    transform 220ms ease,
    border-color 220ms ease,
    box-shadow 220ms ease,
    background 220ms ease;
}

.team-women .player-card {
  grid-template-columns: 1fr 56px;
}

.avatar {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: #071018;
  font-weight: 800;
  background: var(--men);
}

.team-women .avatar {
  order: 2;
  background: var(--women);
}

.team-women .player-info {
  text-align: right;
}

.player-name {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}

.player-vote {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.player-card.active-from {
  transform: scale(1.035);
  border-color: var(--gold);
  box-shadow: 0 0 0 1px rgba(255, 209, 102, 0.36), 0 0 28px rgba(255, 209, 102, 0.26);
}

.player-card.active-to {
  transform: scale(1.045);
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 34px rgba(255, 255, 255, 0.22);
}

.host-panel {
  align-self: center;
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 28px 22px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  background: rgba(17, 19, 24, 0.64);
  text-align: center;
}

.host-label {
  color: var(--gold);
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.08em;
}

.host-title {
  font-size: clamp(24px, 3vw, 42px);
  font-weight: 900;
  line-height: 1.12;
}

.host-status {
  min-height: 48px;
  color: var(--muted);
  line-height: 1.55;
}

.match-badge {
  min-width: 148px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 209, 102, 0.8);
  border-radius: 999px;
  color: #16120b;
  background: var(--gold);
  font-weight: 900;
  box-shadow: 0 0 30px rgba(255, 209, 102, 0.42);
  animation: badgePop 520ms cubic-bezier(0.2, 1.4, 0.28, 1);
}

.control-panel,
.vote-editor {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(27, 31, 42, 0.84);
}

.control-panel {
  display: grid;
  grid-template-columns: 200px 1fr minmax(160px, 0.45fr) minmax(150px, 0.45fr) auto;
  gap: 18px;
  align-items: end;
}

.control-group {
  display: grid;
  gap: 8px;
}

.control-group > label,
.control-group > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mode-group {
  grid-template-columns: repeat(2, minmax(190px, max-content));
  align-items: center;
}

.mode-group > span {
  grid-column: 1 / -1;
}

.mode-group label {
  display: flex;
  gap: 8px;
  align-items: center;
  color: var(--text);
  font-size: 14px;
}

.speed-group label {
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

.speed-group output {
  color: var(--gold);
  font-weight: 900;
}

input[type="range"] {
  accent-color: var(--gold);
  width: 100%;
}

select {
  width: 100%;
  height: 42px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 6px;
  color: var(--text);
  background: var(--panel-2);
  padding: 0 12px;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 42px;
  border: 0;
  border-radius: 6px;
  padding: 0 16px;
  color: #10131a;
  background: var(--gold);
  font-weight: 800;
  cursor: pointer;
}

button.secondary {
  color: var(--text);
  background: #303746;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: baseline;
  margin-bottom: 14px;
}

.section-heading h2 {
  margin: 0;
  font-size: 18px;
}

.section-heading p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.vote-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 12px;
}

.vote-row {
  display: grid;
  gap: 7px;
  padding: 12px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.045);
}

.vote-row label {
  font-size: 13px;
  font-weight: 800;
}

.vote-guide {
  fill: none;
  stroke: transparent;
}

.vote-pulse-dot {
  opacity: 0;
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 0 8px currentColor);
}

.vote-head-dot {
  opacity: 0;
  filter: drop-shadow(0 0 12px currentColor);
}

@keyframes badgePop {
  from {
    opacity: 0;
    transform: scale(0.78);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes heartEnter {
  from {
    opacity: 0;
    transform: scale(0.34) rotate(-8deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes heartBeat {
  0%,
  100% {
    transform: scale(1);
  }
  22% {
    transform: scale(1.18);
  }
  38% {
    transform: scale(0.96);
  }
  58% {
    transform: scale(1.1);
  }
}

@keyframes heartFade {
  to {
    opacity: 0;
    transform: scale(1.22);
  }
}

@keyframes heartChip {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.35) rotate(0deg);
  }
  18% {
    opacity: 1;
  }
  78% {
    opacity: 0.92;
  }
  100% {
    opacity: 0;
    transform: translate(calc(-50% + var(--heart-x)), calc(-50% + var(--heart-y))) scale(1) rotate(var(--heart-rotate));
  }
}

@keyframes brokenLeft {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.6) rotate(0deg);
  }
  18% {
    opacity: 1;
    transform: translate(0, 0) scale(1.08) rotate(0deg);
  }
  38% {
    transform: translate(-10px, 4px) scale(1) rotate(-8deg);
  }
  100% {
    opacity: 0;
    transform: translate(-64px, 180px) scale(0.8) rotate(-28deg);
  }
}

@keyframes brokenRight {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.6) rotate(0deg);
  }
  18% {
    opacity: 1;
    transform: translate(0, 0) scale(1.08) rotate(0deg);
  }
  38% {
    transform: translate(10px, 4px) scale(1) rotate(8deg);
  }
  100% {
    opacity: 0;
    transform: translate(64px, 180px) scale(0.8) rotate(28deg);
  }
}

@media (max-width: 860px) {
  .stage {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .team {
    align-content: start;
  }

  .host-panel {
    order: -1;
  }

  .control-panel {
    grid-template-columns: 1fr;
  }

  .mode-group {
    grid-template-columns: 1fr;
  }

  .team-women .player-card {
    grid-template-columns: 56px 1fr;
  }

  .team-women .avatar {
    order: initial;
  }

  .team-women .player-info {
    text-align: left;
  }
}
