:root {
  --bg: #090f22;
  --panel: #121b2e;
  --panel-2: #1b273b;
  --line: #2f3b52;
  --text: #f4fff9;
  --muted: #9aa8ba;
  --green: #22ff88;
  --green-2: #099f69;
  --danger: #f43f46;
  --warning: #ffd15c;
  --red: #e82428;
  --navy: #10182b;
  --slate: #334155;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.42);
  color-scheme: dark;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background:
    radial-gradient(circle at top right, rgba(34, 255, 136, 0.08), transparent 32rem),
    linear-gradient(180deg, #121a30 0%, var(--bg) 42%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app {
  width: min(100%, 820px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 14px 102px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: -18px -14px 18px;
  padding: 16px 14px;
  background: rgba(9, 15, 34, 0.92);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  backdrop-filter: blur(18px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
  padding: 8px;
  border-radius: 22px;
  background: rgba(27, 39, 59, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04);
}

.logo {
  display: inline-flex;
  width: clamp(112px, 28vw, 150px);
  height: 48px;
  align-items: center;
  justify-content: center;
  gap: 9px;
  flex: 0 0 auto;
  border: 0;
  border-radius: 14px;
  background: var(--red);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 12px 26px rgba(232, 36, 40, 0.24);
}

.logo span {
  font-size: 1.25rem;
}

.logo strong {
  font-size: 1.2rem;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  overflow: hidden;
  font-size: 1.35rem;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.subtitle {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.82rem;
}

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 0 0 auto;
}

.screen {
  display: grid;
  gap: 14px;
}

.section {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid rgba(95, 111, 135, 0.32);
  border-radius: 18px;
  background: rgba(18, 27, 46, 0.9);
  box-shadow: var(--shadow);
}

.section.flat {
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.grid {
  display: grid;
  gap: 10px;
}

.grid.two {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.btn {
  display: inline-flex;
  min-height: 48px;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
  font-weight: 800;
  text-align: center;
  transition:
    transform 0.15s ease,
    border-color 0.15s ease,
    background 0.15s ease;
}

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

.btn.primary {
  border-color: rgba(34, 255, 136, 0.7);
  background: linear-gradient(180deg, var(--green), var(--green-2));
  color: #02110a;
  box-shadow: 0 0 30px rgba(34, 255, 136, 0.25);
}

.btn.ghost {
  border-color: var(--line);
  background: transparent;
}

.btn.danger {
  border-color: rgba(255, 77, 94, 0.55);
  color: #ffd7dc;
}

.btn.small {
  min-height: 38px;
  padding: 8px 10px;
  font-size: 0.86rem;
}

.btn.icon {
  width: 44px;
  min-height: 44px;
  padding: 0;
  flex: 0 0 auto;
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.field {
  display: grid;
  gap: 7px;
}

.field label {
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.input,
.select {
  width: 100%;
  min-height: 48px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0d1426;
  color: var(--text);
  outline: none;
}

.input:focus,
.select:focus {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(34, 255, 136, 0.12);
}

.switch-line,
.player-row,
.history-row,
.ranking-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(95, 111, 135, 0.38);
  border-radius: 16px;
  background: rgba(30, 42, 62, 0.92);
}

.player-row {
  position: relative;
  min-height: 108px;
  align-items: center;
  justify-content: center;
  padding: 16px 12px 12px;
}

.player-main {
  display: grid;
  min-width: 0;
  flex: 1;
  gap: 12px;
  justify-items: center;
  text-align: center;
}

.player-title {
  display: grid;
  align-items: center;
  gap: 8px;
  min-width: 0;
  justify-items: center;
}

.player-name {
  overflow: hidden;
  font-size: clamp(1.05rem, 4vw, 1.35rem);
  font-weight: 950;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hearts {
  color: var(--danger);
  font-size: 1rem;
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1;
  overflow-wrap: anywhere;
  text-shadow: 0 0 14px rgba(255, 77, 94, 0.35);
}

.empty-hearts {
  color: var(--muted);
  text-shadow: none;
}

.player-row.active {
  border-color: rgba(34, 255, 136, 0.92);
  background: linear-gradient(180deg, rgba(9, 159, 105, 0.24), rgba(10, 59, 52, 0.72));
  box-shadow:
    0 0 0 2px rgba(34, 255, 136, 0.14),
    0 0 32px rgba(34, 255, 136, 0.13);
}

.player-row.out {
  opacity: 0.62;
}

.player-row.just-eliminated {
  animation: eliminatedPulse 1.45s ease both;
  border-color: rgba(255, 77, 94, 0.85);
}

.pill {
  display: inline-flex;
  min-height: 26px;
  align-items: center;
  justify-content: center;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 900;
  white-space: nowrap;
}

.pill.green {
  background: rgba(34, 255, 136, 0.18);
  color: var(--green);
}

.pill.red {
  background: rgba(255, 77, 94, 0.14);
  color: #ff9ba5;
}

.stats {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.stats.compact .stat {
  min-width: 58px;
  padding: 7px;
}

.stat {
  min-width: 74px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 9px;
  background: rgba(5, 9, 18, 0.78);
}

.stat b {
  display: block;
  color: var(--green);
  font-size: 1.1rem;
}

.stat span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.player-actions {
  position: absolute;
  top: 10px;
  right: 10px;
  display: grid;
  gap: 6px;
}

.mini-action {
  display: grid;
  width: 30px;
  height: 30px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  cursor: pointer;
  font-size: 0.95rem;
  font-weight: 900;
}

.mini-action.danger {
  border-color: rgba(255, 77, 94, 0.35);
  color: #ff9ba5;
}

.mini-action:disabled {
  cursor: not-allowed;
  opacity: 0.35;
}

.current-card {
  display: grid;
  position: relative;
  gap: 30px;
  padding: 36px 16px 16px;
  overflow: hidden;
  border: 1px solid rgba(95, 111, 135, 0.48);
  border-radius: 20px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.03), transparent 35%),
    #10182b;
  box-shadow: var(--shadow);
}

.current-card::before {
  position: absolute;
  inset: 0 0 auto;
  height: 7px;
  background: linear-gradient(90deg, var(--red), var(--warning), var(--green-2));
  content: "";
}

.current-title {
  display: grid;
  align-items: center;
  gap: 18px;
  justify-items: center;
  text-align: center;
}

.current-name {
  color: #fff;
  font-size: clamp(3.1rem, 15vw, 5.5rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.current-title .hearts {
  padding-bottom: 0;
  font-size: clamp(2.5rem, 12vw, 4.25rem);
  line-height: 0.95;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-btn {
  display: grid;
  min-height: 116px;
  align-content: center;
  gap: 10px;
  padding: 14px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 16px;
  background: var(--panel-2);
  color: var(--text);
  cursor: pointer;
}

.action-btn[data-turn-action="miss"] {
  background: var(--red);
  color: #fff;
}

.action-btn[data-turn-action="one"],
.action-btn[data-turn-action="many"] {
  background: var(--green-2);
  color: #fff;
}

.action-btn[data-turn-action="black"] {
  background: var(--slate);
  color: #fff;
}

.action-btn[data-turn-action="absent"] {
  min-height: 76px;
  grid-column: 1 / -1;
  border-color: rgba(255, 209, 92, 0.42);
  background: rgba(255, 209, 92, 0.08);
}

.action-btn[data-turn-action="absent"] .action-title {
  color: var(--warning);
}

.action-title {
  font-size: 1.08rem;
  font-weight: 950;
  text-transform: uppercase;
}

.action-meta {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

.action-icon {
  display: grid;
  width: 46px;
  height: 46px;
  place-items: center;
  justify-self: center;
  border-radius: 50%;
  color: #fff;
  font-size: 2.45rem;
  font-weight: 950;
  line-height: 1;
}

.x-icon {
  border: 4px solid #fff;
}

.absent-icon {
  width: 38px;
  height: 38px;
  color: var(--warning);
  font-size: 1.85rem;
}

.ball-icon {
  display: block;
  width: 46px;
  height: 46px;
  border: 4px solid #fff;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 50%, transparent 0 22%, #fff 24% 31%, transparent 33%),
    radial-gradient(circle at 50% 50%, transparent 0 45%, #fff 47% 55%, transparent 57%),
    rgba(255, 255, 255, 0.08);
}

.single-ball {
  justify-self: center;
}

.double-balls {
  position: relative;
  display: block;
  width: 68px;
  height: 52px;
  justify-self: center;
}

.double-balls .ball-icon {
  position: absolute;
  top: 3px;
}

.double-balls .ball-icon:first-child {
  left: 0;
}

.double-balls .ball-icon:last-child {
  right: 0;
}

.black-ball-icon {
  justify-self: center;
  border-color: #fff;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.32), transparent 0.55rem),
    #05070d;
}

.performance-section {
  margin-bottom: 18px;
}

.chart-icon {
  color: var(--muted);
  font-size: 1.2rem;
}

.performance-list {
  display: grid;
  gap: 14px;
}

.performance-row {
  display: grid;
  grid-template-columns: minmax(70px, 0.36fr) minmax(90px, 1fr) minmax(34px, auto);
  align-items: center;
  gap: 10px;
}

.performance-name {
  overflow: hidden;
  color: #d5dfeb;
  font-size: 1rem;
  text-align: right;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.performance-track {
  display: block;
  height: 17px;
  overflow: hidden;
  border-radius: 999px;
  background: #070d20;
}

.performance-track span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(180deg, #22dd9a, #10b981);
  box-shadow: 0 0 18px rgba(16, 185, 129, 0.24);
}

.performance-score {
  color: #4adeaa;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 1.12rem;
  font-weight: 900;
  text-align: right;
}

.bottom-actions {
  position: fixed;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 15;
  display: grid;
  width: min(100%, 760px);
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 0 auto;
  padding: 10px 14px 14px;
  background: linear-gradient(180deg, transparent, rgba(9, 15, 34, 0.96) 26%);
}

.bottom-actions.solo {
  grid-template-columns: 1fr;
}

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

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

.check-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(18, 25, 24, 0.82);
}

.check-label {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
  cursor: pointer;
}

.check-label strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.check-card input {
  width: 22px;
  height: 22px;
  accent-color: var(--green);
}

.order-list {
  display: grid;
  gap: 8px;
  counter-reset: player-order;
}

.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  border-radius: 8px;
  background: #07100d;
  counter-increment: player-order;
}

.order-item::before {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border-radius: 50%;
  background: rgba(34, 255, 136, 0.15);
  color: var(--green);
  content: counter(player-order);
  font-size: 0.8rem;
  font-weight: 950;
}

.history-row,
.ranking-row {
  align-items: flex-start;
}

.history-section {
  gap: 0;
  margin-bottom: 24px;
}

.history-toggle {
  display: grid;
  width: 100%;
  min-height: 48px;
  grid-template-columns: 1fr auto auto;
  align-items: center;
  gap: 10px;
  border: 0;
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-size: 1.05rem;
  font-weight: 950;
  text-align: left;
}

.history-toggle .chevron {
  color: var(--muted);
  font-size: 1.2rem;
}

.history-content {
  margin-top: 12px;
}

.history-row small,
.ranking-row small {
  color: var(--muted);
}

.delta {
  color: var(--green);
  font-weight: 900;
  white-space: nowrap;
}

.delta.negative {
  color: #ff9ba5;
}

.modal-backdrop,
.countdown {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  padding: 18px;
  place-items: center;
  background: rgba(0, 0, 0, 0.78);
  backdrop-filter: blur(10px);
}

.modal {
  display: grid;
  width: min(100%, 560px);
  max-height: 88vh;
  gap: 14px;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #08100d;
  box-shadow: var(--shadow);
}

.rules {
  display: grid;
  gap: 10px;
  color: #d8ece4;
  line-height: 1.45;
}

.rules ul {
  margin: 0;
  padding-left: 20px;
}

.countdown-box {
  display: grid;
  width: min(100%, 340px);
  gap: 10px;
  padding: 24px;
  border: 1px solid rgba(34, 255, 136, 0.5);
  border-radius: 8px;
  background: #07100d;
  text-align: center;
}

.countdown-number {
  color: var(--green);
  font-size: 5rem;
  font-weight: 1000;
  line-height: 1;
}

.elimination-flash {
  position: fixed;
  inset: 0;
  z-index: 70;
  display: grid;
  padding: 18px;
  place-items: center;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(8px);
  animation: flashFade 1.5s ease both;
}

.elimination-box {
  display: grid;
  width: min(100%, 340px);
  gap: 10px;
  padding: 24px;
  border: 1px solid rgba(255, 77, 94, 0.65);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 77, 94, 0.17), transparent 55%),
    #12080a;
  text-align: center;
  box-shadow: 0 0 48px rgba(255, 77, 94, 0.22);
  animation: eliminationPop 1.5s cubic-bezier(0.18, 0.89, 0.32, 1.2) both;
}

.elimination-box h2 {
  color: #ff7b88;
  font-size: clamp(2rem, 12vw, 4rem);
  line-height: 0.95;
  overflow-wrap: anywhere;
}

.elimination-hearts {
  color: #ff7b88;
  font-size: 2rem;
  letter-spacing: 0;
  opacity: 0.9;
}

@keyframes eliminatedPulse {
  0%,
  100% {
    transform: translateX(0);
    box-shadow: none;
  }

  12%,
  36%,
  60% {
    transform: translateX(-4px);
  }

  24%,
  48%,
  72% {
    transform: translateX(4px);
  }

  50% {
    background: rgba(255, 77, 94, 0.14);
    box-shadow: 0 0 34px rgba(255, 77, 94, 0.18);
  }
}

@keyframes eliminationPop {
  0% {
    opacity: 0;
    transform: scale(0.82) translateY(12px);
  }

  18%,
  78% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }

  100% {
    opacity: 0;
    transform: scale(0.96) translateY(-10px);
  }
}

@keyframes flashFade {
  0% {
    opacity: 0;
  }

  15%,
  82% {
    opacity: 1;
  }

  100% {
    opacity: 0;
  }
}

.notice {
  padding: 10px 12px;
  border-left: 3px solid var(--green);
  border-radius: 8px;
  background: rgba(34, 255, 136, 0.1);
  color: #d9ffec;
}

@media (min-width: 640px) {
  .app {
    padding-inline: 20px;
  }

  .topbar {
    margin-inline: -20px;
    padding-inline: 20px;
  }

  .screen {
    gap: 18px;
  }

  .grid.desktop-two {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 420px) {
  .brand {
    padding: 6px;
  }

  .logo {
    width: 96px;
    gap: 6px;
  }

  .logo strong {
    font-size: 1rem;
  }

  h1 {
    font-size: 1.12rem;
  }

  .current-card {
    padding-inline: 12px;
  }

  .action-grid {
    gap: 8px;
  }

  .action-btn {
    min-height: 98px;
    padding-inline: 6px;
  }

  .action-title {
    font-size: 0.9rem;
  }

  .action-meta {
    font-size: 0.7rem;
  }

  .player-row {
    min-height: 118px;
    padding-inline: 8px;
  }

  .stats.compact .stat {
    min-width: 50px;
  }
}
