:root {
  --bg: #121722;
  --panel: rgba(18, 23, 34, 0.9);
  --panel-strong: rgba(9, 13, 20, 0.96);
  --line: rgba(255, 255, 255, 0.12);
  --text: #f8fbff;
  --muted: #98a8ba;
  --accent: #ff6faf;
  --accent-2: #ffb6d9;
  --good: #53d67a;
  --bad: #ff6b88;
  --shadow: 0 24px 50px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(255, 111, 175, 0.24), transparent 34%),
    radial-gradient(circle at top right, rgba(255, 182, 217, 0.18), transparent 30%),
    linear-gradient(180deg, #192131 0%, #0d121c 100%);
  color: var(--text);
  min-height: 100vh;
}

.eyebrow,
.section-kicker {
  margin: 0;
  color: var(--accent-2);
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 11px;
  font-weight: 700;
}

.page {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 40px;
}

.hidden {
  display: none !important;
}

.hero {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
  margin-bottom: 24px;
}

.hero h1,
.overlay-title {
  margin: 0;
  font-size: clamp(28px, 4vw, 46px);
  font-weight: 800;
  letter-spacing: 0.03em;
}

.hero p,
.room-text {
  margin: 8px 0 0;
  color: var(--muted);
}

.subtle {
  margin: 0;
  color: var(--muted);
}

.hero-copy {
  max-width: 720px;
}

.compact-hero {
  margin-bottom: 16px;
}

.room-summary {
  display: grid;
  gap: 12px;
}

.summary-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.create-panel {
  max-width: 980px;
}

.join-panel {
  max-width: 820px;
}

.create-copy {
  color: var(--muted);
  line-height: 1.7;
}

.home-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.home-button {
  min-height: 88px;
  font-size: 20px;
}

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

.join-form label {
  max-width: 520px;
}

.join-actions {
  display: grid;
  gap: 10px;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  align-content: start;
}

.join-actions button {
  min-height: 56px;
}

.hero-actions {
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  align-items: center;
}

.hero-actions button,
.hero-actions .ghost-link {
  min-height: 42px;
  padding: 10px 14px;
  font-size: 14px;
  white-space: nowrap;
}

.editor-help {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.7;
  margin-bottom: 12px;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 0.42fr);
  gap: 16px;
}

.room-hero {
  margin-top: 8px;
}

.stack {
  display: grid;
  gap: 20px;
  align-content: start;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 20px;
  backdrop-filter: blur(8px);
}

.panel.dark {
  background: var(--panel-strong);
}

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 4px 0 0;
  font-size: 20px;
}

.form-grid,
.cards-grid,
.editor-list,
.stats-grid {
  display: grid;
  gap: 12px;
}

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

.form-grid.three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.form-grid.four {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

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

label {
  display: grid;
  gap: 8px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  padding: 12px 14px;
  font-size: 16px;
}

select {
  color: var(--text);
}

select option {
  color: #111;
}

button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  font-size: 15px;
  font-weight: 700;
  color: #10141d;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  cursor: pointer;
}

button.secondary {
  color: var(--text);
  background: rgba(255, 255, 255, 0.08);
}

button.danger {
  color: #fff;
  background: rgba(255, 107, 136, 0.18);
}

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

.top-gap {
  margin-top: 18px;
}

.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 14px;
  border-radius: 14px;
  color: var(--text);
  text-decoration: none;
  background: rgba(255, 255, 255, 0.07);
}

.room-chip-row {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 10px;
}

.room-chip {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.notice-panel {
  margin-bottom: 20px;
}

.notice-row {
  display: flex;
  align-items: end;
  gap: 12px;
  flex-wrap: wrap;
}

.chip-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
}

.danger-panel {
  border-color: rgba(255, 107, 136, 0.28);
}

.stat-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.stat-card.strong {
  background: linear-gradient(180deg, rgba(255, 122, 69, 0.12), rgba(255, 255, 255, 0.05));
}

.stat-label {
  color: var(--muted);
  font-size: 13px;
}

.stat-number {
  font-size: clamp(34px, 6vw, 68px);
  line-height: 1;
  font-weight: 900;
}

.stat-number.small {
  font-size: clamp(28px, 4vw, 42px);
}

.stat-note,
.sync-text {
  color: var(--muted);
  font-size: 13px;
}

.meter {
  width: 100%;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #53d67a 0%, #ffcc4d 60%, #ff7a45 100%);
  transition: width 250ms ease;
}

.action-card,
.editor-row,
.info-card,
.log-item {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.self-action-card {
  border-color: rgba(255, 204, 77, 0.28);
  background: linear-gradient(180deg, rgba(255, 204, 77, 0.08), rgba(255, 255, 255, 0.05));
}

.my-input-simple {
  display: grid;
  gap: 0;
}

.editor-row.my-input-row {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.my-input-quick-steps {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.quick-step-button {
  min-height: 42px;
  padding: 8px 6px;
  font-size: 14px;
}

.editor-row {
  display: grid;
  grid-template-columns: 1fr 1.4fr 0.8fr auto;
  gap: 10px;
  align-items: center;
}

.gift-editor-row {
  grid-template-columns: 1.4fr 0.9fr auto;
}

.editor-static {
  min-height: 48px;
  display: flex;
  align-items: center;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--muted);
  font-size: 14px;
}

.participant-input-row {
  grid-template-columns: 1.2fr 0.85fr auto;
}

.participant-input-row.delete-mode {
  grid-template-columns: 1fr auto;
}

.participant-input-name {
  display: block;
  min-width: 0;
}

.participant-name-line {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  min-width: 0;
}

.participant-name-line strong {
  flex: 0 1 auto;
  line-height: 1;
  min-width: 0;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border-radius: 999px;
  font-size: 12px;
  line-height: 1;
}

.participant-edit-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.07);
  flex: 0 0 auto;
  order: -1;
}

.participant-head-actions {
  display: flex;
  align-items: center;
  flex: 0 0 auto;
  gap: 8px;
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.participant-head-actions button {
  padding: 10px 14px;
  font-size: 14px;
}

#toggleParticipantDeleteButton {
  margin-left: auto;
}

.participant-inline-total {
  font-size: 13px;
  white-space: nowrap;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  line-height: 1;
  margin: 0;
}

#participantActions {
  display: grid;
  gap: 12px;
}

#participantActions .participant-input-row {
  align-items: center;
}

.participant-input-row button:not(.icon-button) {
  min-height: 48px;
  white-space: nowrap;
}

.participant-layout {
  grid-template-columns: minmax(0, 1fr);
}

.participant-mode .layout > .stack,
.participant-mode .layout > aside.stack {
  display: contents;
}

.participant-mode #livePanel {
  order: 1;
}

.participant-mode #myInputPanel {
  order: 2;
}

.participant-mode #participantPanel {
  order: 3;
}

.participant-mode #eventsPanel {
  order: 4;
}

.participant-mode .hero.compact-hero.room-hero {
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
}

.participant-mode .summary-chips {
  gap: 8px;
}

.participant-mode .room-chip {
  padding: 10px 12px;
  border-radius: 14px;
}

.participant-mode .chip-label {
  margin-bottom: 4px;
  font-size: 11px;
}

.participant-mode .room-chip strong {
  font-size: 14px;
}

.action-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}

.action-grid.single {
  grid-template-columns: 1fr;
}

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

.info-card {
  display: grid;
  gap: 8px;
}

.block-code {
  display: block;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.07);
  color: #f5f7ff;
  overflow-wrap: anywhere;
}

.empty-text {
  padding: 20px 8px;
  color: var(--muted);
}

.log-list,
.overlay-log,
.overlay-players {
  display: grid;
  gap: 10px;
}

.log-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
}

.log-actions {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
  flex-wrap: nowrap;
}

.delta {
  font-weight: 800;
}

.delta.plus {
  color: var(--bad);
}

.delta.minus {
  color: var(--good);
}

.small-button {
  padding: 8px 12px;
  font-size: 12px;
}

.overlay-shell {
  width: 100vw;
  min-height: 100vh;
  padding: 28px;
  background: transparent;
}

.compact-live {
  display: grid;
  gap: 12px;
}

.compact-meter {
  height: 10px;
}

.compact-live-summary {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 12px;
}

.compact-live-number-row {
  display: flex;
  align-items: end;
  gap: 10px;
  flex-wrap: wrap;
  min-width: 0;
}

.compact-live-number {
  font-size: clamp(18px, 2vw, 24px);
  line-height: 1;
  font-weight: 900;
}

.compact-live-unit {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 4px;
}

.compact-live-progress {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
  flex: 0 0 auto;
}

.participant-choice {
  min-height: 64px;
  font-size: 18px;
}

.overlay-body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: center;
  background: transparent;
  overflow: hidden;
}

.overlay-minimal {
  position: relative;
  display: inline-grid;
  width: fit-content;
  max-width: calc(100vw - 32px);
  gap: 0;
  padding: 18px 22px 112px;
  background: transparent;
  overflow: visible;
  justify-items: center;
  margin: auto;
}

.overlay-minimal-number {
  font-size: clamp(72px, 18vw, 160px);
  line-height: 0.9;
  font-weight: 900;
  text-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  transition: color 180ms ease, transform 180ms ease;
}

.overlay-finished {
  font-size: clamp(56px, 12vw, 120px);
  letter-spacing: 0.08em;
}

.overlay-finish-enter {
  animation: finish-pop 900ms cubic-bezier(0.2, 0.9, 0.2, 1);
}

.overlay-minimal-number-row {
  position: relative;
  display: flex;
  align-items: end;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
  width: fit-content;
  z-index: 1;
}

.overlay-minimal-unit {
  font-size: clamp(22px, 4vw, 42px);
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 10px;
  text-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  transition: color 180ms ease, transform 180ms ease;
}

.text-white {
  color: #fff;
}

.text-black {
  color: #111;
}

.feedback-good {
  color: #56e17e !important;
  transform: scale(1.03);
}

.feedback-bad {
  color: #ff5f6d !important;
  transform: scale(1.03);
}

.overlay-effect-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.overlay-gift-popup {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  max-width: min(92vw, 1100px);
  margin: 0;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  text-align: center;
  box-shadow:
    0 14px 28px rgba(0, 0, 0, 0.14),
    inset 0 1px 0 rgba(255, 255, 255, 0.42);
  overflow: hidden;
  backdrop-filter: blur(14px);
}

.gift-popup-headline {
  display: block;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: clamp(28px, 6vw, 44px);
  line-height: 1.05;
  letter-spacing: -0.01em;
}

.gift-popup-subline {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 6px;
  font-size: clamp(13px, 2.6vw, 19px);
  line-height: 1.1;
  white-space: nowrap;
}

.gift-popup-target,
.gift-popup-gift {
  font-weight: 900;
}

.gift-popup-target {
  opacity: 0.96;
}

.gift-popup-gift {
  position: relative;
  padding: 0 0.22em;
  border-radius: 999px;
}

.gift-popup-copy {
  font-size: 0.58em;
  font-weight: 800;
  opacity: 0.7;
}

.gift-popup-by {
  font-size: 0.86em;
  font-weight: 800;
  opacity: 0.56;
}

.gift-popup-sender {
  font-weight: 800;
  opacity: 0.82;
}

.gift-popup-gift::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 52%;
  bottom: auto;
  height: 0.88em;
  transform: translateY(-50%);
  border-radius: 999px;
  opacity: 0.22;
  z-index: -1;
}

.popup-theme-light {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(248, 248, 248, 0.9));
  color: #111;
}

.popup-theme-dark {
  background:
    linear-gradient(180deg, rgba(18, 22, 30, 0.94), rgba(8, 10, 16, 0.9));
  color: #fff;
}

.popup-theme-light .gift-popup-gift::after {
  background: linear-gradient(135deg, rgba(255, 186, 115, 0.62), rgba(255, 222, 143, 0.54));
}

.popup-theme-dark .gift-popup-gift::after {
  background: linear-gradient(135deg, rgba(255, 196, 112, 0.34), rgba(255, 226, 149, 0.24));
}

.overlay-gift-popup-enter {
  animation: gift-popup-in 320ms ease-out forwards;
}

.overlay-gift-popup-leave {
  animation: gift-popup-out 280ms ease-in forwards;
}

.overlay-particle {
  position: absolute;
  bottom: 88px;
  display: block;
  font-size: 58px;
  font-weight: 900;
  opacity: 0;
  line-height: 1;
  filter: drop-shadow(0 10px 18px rgba(0, 0, 0, 0.2));
  text-shadow: 0 0 18px rgba(255, 255, 255, 0.18);
}

.overlay-particle.up {
  animation: float-up 1.15s ease-out forwards;
}

.overlay-particle.down {
  animation: float-down 1.15s ease-out forwards;
}

.overlay-particle.good {
  color: #56e17e;
}

.overlay-particle.bad {
  color: #ff5f6d;
}

.overlay-particle.finish {
  width: 34px;
  height: 34px;
  color: #ffe27a;
  background: rgba(255, 226, 122, 0.16);
  border: 2px solid rgba(255, 226, 122, 0.34);
  animation: finish-burst 1.15s ease-out forwards;
}

@keyframes finish-pop {
  0% {
    transform: scale(0.72) rotate(-6deg);
    filter: brightness(1);
  }
  38% {
    transform: scale(1.16) rotate(2deg);
    filter: brightness(1.18);
  }
  65% {
    transform: scale(0.96) rotate(-1deg);
  }
  100% {
    transform: scale(1) rotate(0deg);
    filter: brightness(1);
  }
}

@keyframes gift-popup-in {
  0% {
    transform: translateX(-50%) translateY(8px) scale(0.94);
    opacity: 0;
  }
  100% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
}

@keyframes gift-popup-out {
  0% {
    transform: translateX(-50%) translateY(0) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateX(-50%) translateY(6px) scale(0.96);
    opacity: 0;
  }
}

@keyframes float-up {
  0% {
    transform: translate3d(0, 20px, 0) scale(0.72);
    opacity: 0;
  }
  15% {
    opacity: 0.95;
  }
  100% {
    transform: translate3d(var(--drift), -96px, 0) scale(1.04);
    opacity: 0;
  }
}

@keyframes float-down {
  0% {
    transform: translate3d(0, -42px, 0) scale(0.72);
    opacity: 0;
  }
  15% {
    opacity: 0.95;
  }
  100% {
    transform: translate3d(var(--drift), 14px, 0) scale(1.02);
    opacity: 0;
  }
}

@keyframes finish-burst {
  0% {
    transform: translate3d(0, 0, 0) scale(0.4);
    opacity: 0;
  }
  12% {
    opacity: 1;
  }
  100% {
    transform: translate3d(var(--finish-x), var(--finish-y), 0) scale(1.2) rotate(18deg);
    opacity: 0;
  }
}

.overlay-frame {
  width: min(980px, 100%);
  display: grid;
  gap: 18px;
}

.overlay-header {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 16px;
}

.overlay-main {
  display: grid;
  grid-template-columns: 1.2fr 0.8fr;
  gap: 18px;
}

.overlay-number {
  font-size: clamp(72px, 16vw, 150px);
  line-height: 0.9;
  font-weight: 900;
}

.overlay-player {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.06);
}

@media (max-width: 920px) {
  .layout,
  .overlay-main,
  .form-grid.three,
  .form-grid.four,
  .cards-grid,
  .stats-grid,
  .action-grid,
  .room-chip-row,
  .home-actions,
  .form-grid.two,
  .summary-chips {
    grid-template-columns: 1fr;
  }

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

  .page {
    width: min(100% - 20px, 1240px);
    padding: 16px 0 28px;
  }

  .hero.compact-hero.room-hero {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }

  .summary-chips {
    gap: 8px;
  }

  .room-chip {
    padding: 10px 12px;
    border-radius: 14px;
  }

  .chip-label {
    margin-bottom: 4px;
  }

  .hero-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }

  .hero-actions button,
  .hero-actions .ghost-link {
    min-height: 42px;
    padding: 10px 8px;
    font-size: 13px;
    white-space: nowrap;
    text-align: center;
  }

  .panel {
    padding: 16px;
    border-radius: 20px;
  }

  .participant-head-actions {
    width: auto;
    justify-content: flex-end;
    margin-left: 0;
  }

  #participantPanel .panel-head {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: start;
  }

  #participantPanel .panel-head h2 {
    font-size: 18px;
    line-height: 1.25;
    word-break: keep-all;
  }

  .participant-input-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .participant-input-row.delete-mode {
    grid-template-columns: 1fr;
  }

  .participant-input-row button:not(.icon-button) {
    width: 100%;
  }

  .my-input-quick-steps {
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 6px;
  }

  .compact-live-number {
    font-size: clamp(18px, 6vw, 24px);
  }

  .participant-mode .participant-input-row {
    grid-template-columns: 1fr;
  }

  .participant-mode .my-input-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .participant-mode .my-input-row button {
    width: auto;
    min-width: 96px;
  }

  .participant-mode .quick-step-button {
    font-size: 12px;
    padding: 8px 2px;
    min-height: 40px;
  }
}
