:root {
  --bg: #fff2f7;
  --card: #ffffff;
  --accent: #e86aa2;
  --text: #5c2b45;
  --muted: #8c5c74;
  --border: #f6c8dc;
  --shadow: 0 14px 32px rgba(196, 119, 156, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", Arial, sans-serif;
  background: radial-gradient(circle at 0% 0%, #fff 0%, transparent 40%), var(--bg);
  color: var(--text);
}

.container {
  width: min(980px, 92vw);
  margin: 0 auto;
  padding: 1rem 0 2rem;
}

.hero-card,
.result-card,
.panel {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.hero-title {
  margin: 0 0 0.4rem;
  font-size: clamp(1.6rem, 7vw, 2.4rem);
  color: #b34578;
}

.top-home-link {
  display: inline-block;
  margin-bottom: 0.5rem;
  color: #8d4568;
  text-decoration: none;
  font-weight: 600;
}

.top-home-link:hover {
  text-decoration: underline;
}

.mode-switch {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.7rem;
}

.hero-subtitle {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.5;
}

.controls {
  display: grid;
  gap: 0.7rem;
}

.friend-box {
  margin-bottom: 0.8rem;
  padding: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fffafd;
}

.field-label {
  display: block;
  margin-bottom: 0.45rem;
  color: #a24b74;
  font-weight: 600;
}

.field-hint {
  margin-top: 0.45rem;
  color: var(--muted);
  font-size: 0.9rem;
}

input,
textarea,
button {
  font: inherit;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 0.75rem 0.8rem;
  background: #fff;
}

button {
  border: none;
  border-radius: 999px;
  padding: 0.75rem 1.1rem;
  background: linear-gradient(135deg, #ee74aa, #e45b99);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
}

button.secondary {
  background: #f3d8e6;
  color: #8d4568;
}

.grid-3 {
  display: grid;
  gap: 0.8rem;
  margin-top: 1rem;
}

.slot {
  border: 1px dashed var(--border);
  border-radius: 14px;
  padding: 0.8rem;
  background: #fffafd;
  min-height: 120px;
}

.slot h3 {
  margin: 0 0 0.4rem;
  font-size: 1rem;
  color: #a24b74;
}

.slot .emoji {
  font-size: 1.8rem;
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", "Noto Emoji", sans-serif;
}

.slot .text {
  margin-top: 0.35rem;
  color: #6a3a53;
  line-height: 1.45;
}

.rare-banner {
  display: none;
  margin-top: 0.9rem;
  padding: 0.65rem 0.9rem;
  border-radius: 12px;
  background: #ffe2f2;
  color: #ad3773;
  animation: glow 1.2s ease-in-out infinite alternate;
}

.rare-banner.visible {
  display: block;
}

@keyframes glow {
  from {
    box-shadow: 0 0 0 rgba(234, 94, 156, 0.1);
  }
  to {
    box-shadow: 0 0 18px rgba(234, 94, 156, 0.45);
  }
}

.share-line {
  margin-top: 0.8rem;
  word-break: break-all;
}

.share-actions {
  margin-top: 0.65rem;
  display: grid;
  gap: 0.55rem;
}

.share-line[hidden],
.share-actions[hidden] {
  display: none !important;
}

.mode-section[hidden] {
  display: none !important;
}

.stats {
  margin-top: 1rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.office-winner {
  margin-top: 1rem;
  font-size: clamp(1.2rem, 4.5vw, 2.4rem);
  line-height: 1.2;
  text-align: center;
  color: #c0407d;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.office-final {
  text-align: center;
  color: var(--muted);
  margin-top: 0.7rem;
}

.office-toolbar {
  display: grid;
  gap: 0.6rem;
}

.office-toolbar a {
  text-decoration: none;
}

.broadcast-exit {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 50;
  background: #b94b7e;
  color: #fff;
  box-shadow: 0 8px 18px rgba(185, 75, 126, 0.28);
}

.office-legend {
  margin-top: 0.7rem;
  padding: 0.7rem 0.85rem;
  border-radius: 12px;
  background: #fff3fa;
  border: 1px solid var(--border);
  color: #94516e;
  font-size: 0.92rem;
}

.office-names-wrap {
  margin-top: 0.7rem;
}

.office-names-wrap.is-collapsed {
  display: none;
}

body.office-fullscreen .container {
  width: min(1200px, 96vw);
}

body.office-fullscreen .office-legend {
  font-size: 0.95rem;
}

body.office-broadcast .office-non-broadcast {
  display: none !important;
}

body.office-broadcast .container > .hero-card {
  display: none !important;
}

body.office-broadcast #office-mode {
  display: flex !important;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 2rem);
}

body.office-broadcast .panel {
  margin-top: 0 !important;
  width: min(1120px, 96vw);
  min-height: min(78vh, 780px);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 0.65rem;
  padding-top: 1rem;
}

body.office-broadcast .panel .grid-3 {
  width: 100%;
}

body.office-broadcast .office-winner {
  margin-top: 0.3rem;
  font-size: clamp(1.4rem, 6vw, 3rem);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  padding: 0 0.4rem;
}

body.office-broadcast .office-final {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  margin-bottom: 0.4rem;
}

@media (min-width: 768px) {
  .container {
    padding-top: 2rem;
  }

  .hero-card,
  .result-card,
  .panel {
    padding: 1.5rem;
  }

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

  .office-toolbar {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

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

  .mode-switch {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-width: 520px;
  }
}
