* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0f1226;
  --panel: #1a1f3a;
  --accent: #6c5ce7;
  --accent-2: #00cec9;
  --text: #f5f6fa;
  --muted: #a0a3bd;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: radial-gradient(circle at 50% 0%, #232a52 0%, var(--bg) 60%);
  color: var(--text);
  min-height: 100vh;
  padding: 2rem 1rem 4rem;
}

.sound-prompt {
  position: fixed;
  bottom: 1.2rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  padding: 0.7rem 1.4rem;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.45);
  animation: pulse 1.6s ease-in-out infinite;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Pause the pulse while the wheel spins — the spin's per-frame style reads
   would otherwise make this animation stutter. */
body.spinning .sound-prompt {
  animation: none;
}

.sound-prompt.hidden {
  display: none;
}

@keyframes pulse {
  0%, 100% { transform: translateX(-50%) scale(1); }
  50% { transform: translateX(-50%) scale(1.06); }
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: clamp(1.8rem, 4vw, 2.8rem);
  letter-spacing: -0.5px;
}

.subtitle {
  color: var(--muted);
  margin-top: 0.4rem;
}

.connect-btn {
  margin-top: 1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.peer-badge {
  background: var(--accent-2);
  color: #06303a;
  font-weight: 700;
  border-radius: 999px;
  min-width: 1.4rem;
  padding: 0.05rem 0.45rem;
  font-size: 0.8rem;
}

main {
  display: flex;
  flex-wrap: wrap;
  gap: 2.5rem;
  justify-content: center;
  align-items: flex-start;
  max-width: 1000px;
  margin: 0 auto;
}

/* Wheel */
.wheel-area {
  display: flex;
  justify-content: center;
}

.wheel-wrap {
  position: relative;
  width: 500px;
  max-width: 90vw;
  aspect-ratio: 1 / 1;
}

#wheel {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 0 10px #0c0e1f, 0 20px 50px rgba(0, 0, 0, 0.5);
  /* Dramatic ease-out (easeOutQuint): hard launch, then a decel that stays
     visibly creeping right up to the stop — no dead "looks frozen" tail.
     Duration is overridden per-spin by JS; this 5s is just a fallback. */
  transition: transform 5s cubic-bezier(0.22, 1, 0.36, 1);
}

.pointer {
  position: absolute;
  top: -6px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 18px solid transparent;
  border-right: 18px solid transparent;
  border-top: 30px solid #ff7675;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.4));
  z-index: 5;
}

.spin-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 22%;
  height: 22%;
  border-radius: 50%;
  border: none;
  background: #fff;
  color: var(--accent);
  font-weight: 800;
  font-size: clamp(0.8rem, 2.2vw, 1.1rem);
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.45);
  transition: transform 0.1s, background 0.2s;
}

.spin-btn:hover:not(:disabled) {
  background: #f1f0ff;
}

.spin-btn:active:not(:disabled) {
  transform: translate(-50%, -50%) scale(0.93);
}

.spin-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Panel */
.panel {
  background: var(--panel);
  border-radius: 16px;
  padding: 1.5rem;
  width: 340px;
  max-width: 90vw;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

textarea {
  width: 100%;
  min-height: 260px;
  resize: vertical;
  background: #0e1124;
  border: 1px solid #2c3358;
  border-radius: 10px;
  color: var(--text);
  padding: 0.8rem;
  font-size: 1rem;
  line-height: 1.6;
  font-family: inherit;
}

textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.self-label {
  display: block;
  color: var(--text);
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  margin: 1.6rem 0 0.9rem;
  padding-left: 0.7rem;
  border-left: 5px solid var(--accent);
  line-height: 1.2;
}

.self-label:first-of-type {
  margin-top: 0.4rem;
}

.self-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.chip {
  --chip: var(--accent);
  border: 2px solid var(--chip);
  background: transparent;
  color: var(--text);
  padding: 0.5rem 1rem;
  border-radius: 999px;
  font-size: 0.95rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, color 0.15s, box-shadow 0.15s;
}

.chip:hover {
  background: color-mix(in srgb, var(--chip) 18%, transparent);
}

.chip:active {
  transform: scale(0.94);
}

.chip.active {
  background: var(--chip);
  color: #0c0e1f;
  box-shadow: 0 4px 14px color-mix(in srgb, var(--chip) 45%, transparent);
}

/* Attendance: absent people are greyed out and struck through. */
.chip.attend.absent {
  border-color: #3a4170;
  color: var(--muted);
  text-decoration: line-through;
  opacity: 0.55;
  background: transparent;
  box-shadow: none;
}

.self-hint {
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 0.8rem;
  line-height: 1.5;
}

/* Buttons */
.ghost-btn {
  background: transparent;
  border: 1px solid #3a4170;
  color: var(--text);
  padding: 0.45rem 0.8rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.2s;
}

.ghost-btn:hover {
  background: #2a3058;
}

.primary-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  padding: 0.55rem 1.4rem;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  transition: background 0.2s;
}

.primary-btn:hover {
  background: #5a4bd4;
}

/* Modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 10, 24, 0.75);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  backdrop-filter: blur(4px);
}

.modal.hidden {
  display: none;
}

.modal-card {
  background: var(--panel);
  border-radius: 18px;
  padding: 2.5rem 3rem;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
  animation: pop 0.3s ease;
  max-width: 90vw;
}

@keyframes pop {
  from { transform: scale(0.8); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-label {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.8rem;
}

.modal-card h2 {
  font-size: clamp(1.8rem, 5vw, 3rem);
  margin: 0.5rem 0 1.5rem;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.modal-actions {
  display: flex;
  gap: 0.8rem;
  justify-content: center;
}

/* Connect modal */
.connect-card {
  position: relative;
  text-align: left;
  padding: 2rem;
  width: 760px;
  max-width: 92vw;
  max-height: 90vh;
  overflow-y: auto;
}

.modal-close {
  position: absolute;
  top: 0.8rem;
  right: 1rem;
  background: none;
  border: none;
  color: var(--muted);
  font-size: 1.8rem;
  line-height: 1;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
}

.connect-title {
  font-size: 1.5rem !important;
  -webkit-text-fill-color: initial !important;
  background: none !important;
  margin: 0 0 0.5rem !important;
}

.connect-status {
  color: var(--muted);
  margin-bottom: 0.5rem;
}

.connect-status strong {
  color: var(--accent-2);
}

.connect-help {
  color: var(--muted);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

.connect-cols {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.connect-col {
  flex: 1 1 300px;
  background: #0e1124;
  border: 1px solid #2c3358;
  border-radius: 12px;
  padding: 1.2rem;
}

.connect-col h3 {
  margin-bottom: 0.8rem;
  font-size: 1.1rem;
}

.step {
  color: var(--muted);
  font-size: 0.85rem;
  margin: 0.9rem 0 0.4rem;
}

.code-box {
  width: 100%;
  min-height: 70px;
  resize: vertical;
  background: #060814;
  border: 1px solid #2c3358;
  border-radius: 8px;
  color: var(--accent-2);
  padding: 0.6rem;
  font-family: ui-monospace, "SF Mono", Menlo, monospace;
  font-size: 0.72rem;
  word-break: break-all;
  margin-bottom: 0.5rem;
}

.code-box:focus {
  outline: none;
  border-color: var(--accent);
}

.full {
  width: 100%;
}

.status-grid {
  background: #0e1124;
  border: 1px solid #2c3358;
  border-radius: 12px;
  padding: 0.5rem 1rem;
  margin-bottom: 1.2rem;
}

.status-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.6rem 0;
  border-bottom: 1px solid #1d2342;
}

.status-row:last-child {
  border-bottom: none;
}

.status-label {
  color: var(--muted);
}

.status-value {
  font-weight: 600;
  color: var(--accent-2);
}

.room-input {
  background: #060814;
  border: 1px solid #2c3358;
  border-radius: 8px;
  color: var(--text);
  padding: 0.4rem 0.6rem;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 0.9rem;
  text-align: right;
  min-width: 0;
  flex: 1;
}

.room-input:focus {
  outline: none;
  border-color: var(--accent);
}

.connect-help code,
.step code {
  background: #060814;
  border: 1px solid #2c3358;
  border-radius: 4px;
  padding: 0.05rem 0.35rem;
  font-size: 0.85em;
  color: var(--accent-2);
}
