:root {
  --kup-card: rgba(255, 255, 255, 0.92);
  --kup-line: rgba(255, 255, 255, 0.18);
  --kup-ink: rgba(31, 26, 36, 0.95);
  --kup-muted: rgba(31, 26, 36, 0.72);
  --kup-accent: #7c5cff;
  --kup-accent2: #2dd4bf;
  --kup-gold: #d4a853;
  --kup-ok: #1f7a4a;
  --kup-warn: #b86b00;
  --kup-bad: #a83232;
}

.page--kup {
  width: 100%;
  min-height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.section--kup {
  width: 100%;
  padding-top: 1.25rem;
  padding-bottom: 2.5rem;
  display: flex;
  justify-content: center;
}

.kup-shell {
  width: 100%;
  max-width: min(980px, 100%);
  margin: 0 auto;
  padding-left: var(--layout-pad);
  padding-right: var(--layout-pad);
}

.kup-head {
  text-align: center;
  margin-bottom: 1rem;
}

.kup-head .section__title {
  margin: 0 auto 0.35rem;
  font-size: clamp(1.15rem, 2.6vw, 1.75rem);
  line-height: 1.25;
}

.kup-subtitle {
  margin: 0 auto;
  color: rgba(255, 255, 255, 0.86);
  font-size: clamp(0.9rem, 1.6vw, 1.05rem);
  line-height: 1.4;
  max-width: none;
  white-space: nowrap;
}

@media (max-width: 560px) {
  .kup-subtitle {
    white-space: normal;
    font-size: 0.9rem;
    max-width: 100%;
  }
}

.kup-empty {
  text-align: center;
  color: rgba(255, 255, 255, 0.78);
  margin: 1.5rem 0;
}

.kup-meta {
  text-align: center;
  margin-bottom: 0.85rem;
  color: rgba(255, 255, 255, 0.88);
  font-size: clamp(0.88rem, 1.5vw, 1rem);
  line-height: 1.45;
}

.kup-meta strong {
  color: var(--kup-gold);
  font-weight: 800;
}

.kup-stats {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.65rem;
  max-width: 420px;
  margin: 0 auto 1rem;
}

.kup-stat {
  background: var(--kup-card);
  border: 1px solid var(--kup-line);
  border-radius: 14px;
  padding: 0.55rem 0.5rem;
  text-align: center;
  min-height: 3.25rem;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.kup-stat__k {
  display: block;
  font-size: 0.72rem;
  color: var(--kup-muted);
  margin-bottom: 0.1rem;
}

.kup-stat__v {
  display: block;
  font-weight: 900;
  font-size: 1.1rem;
  color: var(--kup-ink);
}

.kup-board {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin-bottom: 1rem;
}

.kup-zone {
  background: rgba(21, 27, 36, 0.55);
  border: 1px solid rgba(124, 92, 255, 0.22);
  border-radius: 18px;
  padding: 0.95rem;
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
}

.kup-zone__head {
  margin-bottom: 0.75rem;
}

.kup-zone__title {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  color: rgba(255, 255, 255, 0.94);
}

.kup-zone__hint {
  margin: 0;
  font-size: 0.84rem;
  color: rgba(255, 255, 255, 0.68);
  line-height: 1.4;
}

.kup-slots {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
}

.kup-slot {
  min-height: 3.6rem;
  border-radius: 14px;
  border: 2px dashed rgba(255, 255, 255, 0.22);
  background: rgba(255, 255, 255, 0.04);
  padding: 0.45rem 0.55rem;
  display: flex;
  align-items: stretch;
  gap: 0.5rem;
  transition: border-color 0.15s, background-color 0.15s, box-shadow 0.15s;
}

.kup-slot--over {
  border-color: var(--kup-accent2);
  background: rgba(45, 212, 191, 0.08);
  box-shadow: 0 0 0 3px rgba(45, 212, 191, 0.15);
}

.kup-slot--filled {
  border-style: solid;
  border-color: rgba(255, 255, 255, 0.16);
  background: rgba(255, 255, 255, 0.06);
}

.kup-slot__num {
  flex: 0 0 1.65rem;
  width: 1.65rem;
  height: 1.65rem;
  border-radius: 50%;
  background: rgba(124, 92, 255, 0.22);
  color: rgba(255, 255, 255, 0.92);
  font-weight: 900;
  font-size: 0.82rem;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-top: 0.15rem;
}

.kup-slot__body {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
}

.kup-slot__placeholder {
  color: rgba(255, 255, 255, 0.42);
  font-size: 0.88rem;
  font-style: italic;
}

.kup-pool {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 4rem;
}

.kup-line {
  appearance: none;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: var(--kup-card);
  color: var(--kup-ink);
  border-radius: 14px;
  padding: 0.65rem 0.75rem;
  text-align: left;
  cursor: grab;
  touch-action: none;
  user-select: none;
  width: 100%;
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  transition: transform 0.12s ease, box-shadow 0.12s ease, border-color 0.12s;
}

.kup-line:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.16);
}

.kup-line:active {
  cursor: grabbing;
}

.kup-line--selected {
  border-color: var(--kup-accent);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.22);
}

.kup-line--dragging {
  opacity: 0.55;
}

.kup-line__grip {
  flex: 0 0 auto;
  color: rgba(31, 26, 36, 0.35);
  font-size: 1rem;
  line-height: 1;
  margin-top: 0.1rem;
}

.kup-line__text {
  flex: 1;
  font-size: 0.98rem;
  line-height: 1.45;
  margin: 0;
}

.kup-pill {
  appearance: none;
  border: 1px solid var(--kup-line);
  background: var(--kup-card);
  color: var(--kup-ink);
  border-radius: 999px;
  padding: 0.55rem 0.95rem;
  font-weight: 800;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.12s ease, background-color 0.12s;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.kup-pill:hover {
  transform: translateY(-1px);
}

.kup-pill:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.kup-pill--secondary {
  background: rgba(255, 255, 255, 0.84);
}

.kup-pill--link {
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.92), rgba(45, 212, 191, 0.85));
  color: #0a0e14;
  border-color: transparent;
}

.kup-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
  margin-bottom: 1rem;
}

.kup-result {
  background: rgba(21, 27, 36, 0.62);
  border: 1px solid rgba(124, 92, 255, 0.28);
  border-radius: 18px;
  padding: 1rem;
  margin-top: 0.25rem;
}

.kup-result__head {
  text-align: center;
  margin-bottom: 1rem;
}

.kup-result__score {
  font-weight: 900;
  font-size: clamp(1.15rem, 2.6vw, 1.45rem);
  color: var(--kup-gold);
  margin-bottom: 0.5rem;
}

.kup-result__comment {
  margin: 0 0 0.75rem;
  color: rgba(255, 255, 255, 0.82);
  font-size: 0.95rem;
  line-height: 1.5;
}

.kup-duel {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.65rem;
  align-items: stretch;
  margin-bottom: 1rem;
}

.kup-duel__vs {
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255, 255, 255, 0.35);
  font-size: 1.35rem;
  font-weight: 800;
  padding: 0 0.15rem;
}

.kup-duel__panel {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 16px;
  padding: 0.85rem 0.9rem;
  min-height: 100%;
}

.kup-duel__panel--user {
  border-color: rgba(124, 92, 255, 0.35);
  box-shadow: inset 0 0 0 1px rgba(124, 92, 255, 0.08);
}

.kup-duel__panel--author {
  border-color: rgba(212, 168, 83, 0.4);
  box-shadow: inset 0 0 0 1px rgba(212, 168, 83, 0.08);
}

.kup-duel__title {
  margin: 0 0 0.65rem;
  font-size: 0.92rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.78);
}

.kup-duel__panel--user .kup-duel__title {
  color: #c4b5fd;
}

.kup-duel__panel--author .kup-duel__title {
  color: var(--kup-gold);
}

.kup-duel__lines {
  margin: 0;
  padding: 0.75rem 0.85rem 0.75rem 0.9rem;
  list-style: none;
  display: block;
  counter-reset: kup-line;
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  border-left: 4px solid var(--kup-gold);
}

.kup-duel__lines li {
  counter-increment: kup-line;
  display: block;
  width: 100%;
  padding: 0.28rem 0 0.28rem 1.6rem;
  font-size: 0.95rem;
  line-height: 1.5;
  position: relative;
  color: rgba(255, 255, 255, 0.94);
  background: none;
  border: none;
  border-radius: 0;
}

.kup-duel__panel--user .kup-duel__lines li {
  background: none;
  border-left: none;
}

.kup-duel__lines li::before {
  content: counter(kup-line) ".";
  position: absolute;
  left: 0;
  top: 0.28rem;
  width: auto;
  height: auto;
  border-radius: 0;
  background: none;
  color: rgba(255, 255, 255, 0.5);
  font-size: 0.8rem;
  font-weight: 800;
  display: block;
}

.kup-duel__lines--author li {
  background: none;
  border-left: none;
}

.kup-duel__lines--author li::before {
  background: none;
  color: rgba(212, 168, 83, 0.75);
}

.kup-result__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  justify-content: center;
}

.kup-play[hidden],
.kup-result[hidden] {
  display: none !important;
}

.kup-drag-ghost {
  position: fixed;
  z-index: 9999;
  pointer-events: none;
  max-width: min(92vw, 420px);
  border-radius: 14px;
  border: 1px solid rgba(124, 92, 255, 0.45);
  background: var(--kup-card);
  color: var(--kup-ink);
  padding: 0.65rem 0.75rem;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.35);
  font-size: 0.95rem;
  line-height: 1.45;
  opacity: 0.96;
  transform: translate(-50%, -50%);
}

@media (min-width: 860px) {
  .kup-board {
    grid-template-columns: 1.05fr 0.95fr;
    align-items: start;
  }
}

@media (max-width: 720px) {
  .kup-duel {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  .kup-duel__vs {
    transform: rotate(90deg);
    padding: 0.15rem 0;
  }

  .kup-result__actions .kup-pill {
    width: 100%;
  }

  .kup-actions .kup-pill {
    flex: 1 1 calc(50% - 0.3rem);
    min-width: 9rem;
  }
}

@media (max-width: 420px) {
  .kup-actions .kup-pill {
    flex: 1 1 100%;
  }
}
