/* ===== Reset & Base ===== */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --color-bg:            #F0F4F8;
  --color-surface:       #FFFFFF;
  --color-border:        #E2E8F0;

  --color-text:          #1A202C;
  --color-text-muted:    #718096;
  --color-text-light:    #A0AEC0;

  --color-action:        #1F2937;
  --color-action-hover:  #111827;
  --color-action-disabled: #D1D5DB;

  /* on/active state (toggle, etc.) */
  --color-on:            #0ACF83;
  --color-on-dark:       #00A86B;

  /* start button: pink */
  --color-start:         #EC4899;
  --color-start-dark:    #DB2777;

  /* active phase: green accent */
  --color-active:        #10B981;
  --color-active-dark:   #059669;

  --user-1:  #3F51B5;
  --user-2:  #81C784;
  --user-3:  #E57373;
  --user-4:  #FFB74D;
  --user-5:  #BA68C8;
  --user-6:  #4DD0E1;
  --user-7:  #F06292;
  --user-8:  #A1887F;
  --user-9:  #90A4AE;
  --user-10: #AED581;
  --user-11: #FFD54F;
  --user-12: #9575CD;

  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI',
          'Noto Sans JP', sans-serif;

  --shadow:    0 4px 24px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 2px 8px  rgba(0, 0, 0, 0.08);

  --radius:      12px;
  --radius-sm:   8px;
  --radius-full: 9999px;

  --header-h: 56px;
  --strip-h:  84px;
}

html, body {
  height: 100%;
}

body {
  font-family: var(--font);
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

button {
  font-family: var(--font);
}

.hidden {
  display: none !important;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ===== Waiting phase: interval-like layout ===== */

body[data-phase="waiting"] .main-content {
  background: #4A5568;
  transition: background 0.3s ease;
}

/* "つぎは" — section title */
body[data-phase="waiting"] .phase-label {
  font-size: 1.3rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.75);
  letter-spacing: 0.04em;
}

/* Person row: horizontal, compact */
body[data-phase="waiting"] .current-person {
  flex-direction: row;
  gap: 16px;
}

/* Avatar: ~70% */
body[data-phase="waiting"] .avatar-lg {
  width: 80px;
  height: 80px;
  font-size: 2rem;
  position: relative;
}

body[data-phase="waiting"] .avatar-lg::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 0 0 1px #fff;
  pointer-events: none;
  z-index: 2;
}

/* Name: white */
body[data-phase="waiting"] .current-name {
  font-size: 1.3rem;
  font-weight: 700;
  color: rgba(255, 255, 255, 0.9);
  letter-spacing: 0;
}

/* ===== Active phase ===== */

body[data-phase="active"] .main-content {
  background: #F0F2F5;
  transition: background 0.3s ease;
}

body[data-phase="active"] .avatar-lg {
  width: min(clamp(160px, 52vw, 280px), 42vh);
  height: min(clamp(160px, 52vw, 280px), 42vh);
  font-size: min(clamp(3.5rem, 14vw, 7rem), 12vh);
  position: relative;
  z-index: 1;
}

/* ===== Pulse ring (live-style) ===== */

.avatar-ring-wrapper {
  position: relative;
  display: inline-flex;
  border-radius: 50%;
  flex-shrink: 0;
}

body[data-phase="active"] .avatar-ring-wrapper {
  /* 隙間を白で埋める */
  background: #fff;
  /* ユーザーカラー 4px + 白 1px（外側・画像領域を狭めない） */
  box-shadow: 0 0 0 1px #fff,
              0 0 0 5px var(--avatar-border-color, transparent);
}

body[data-phase="active"] .avatar-ring-wrapper .avatar-lg {
  position: relative;
  z-index: 1;
}

body[data-phase="active"] .avatar-ring-wrapper::before,
body[data-phase="active"] .avatar-ring-wrapper::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  animation: ring-emit 1.8s ease-out infinite;
  pointer-events: none;
  z-index: 0;
}

body[data-phase="active"] .avatar-ring-wrapper::after {
  animation-delay: 0.5s;
}

@keyframes ring-emit {
  0%   { box-shadow: 0 0  2px  2px rgba(var(--ring-color-rgb, 31, 41, 55), 0.5); }
  75%  { box-shadow: 0 0 16px 28px rgba(var(--ring-color-rgb, 31, 41, 55), 0.0); }
  100% { box-shadow: 0 0 16px 28px rgba(var(--ring-color-rgb, 31, 41, 55), 0.0); }
}

/* ===== Header ===== */
.header {
  height: var(--header-h);
  background: var(--color-surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 6px 0 16px;
  box-shadow: var(--shadow-sm);
  flex-shrink: 0;
  z-index: 10;
}

.header-title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--color-text);
  letter-spacing: -0.01em;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}

.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: var(--radius-sm);
  color: var(--color-text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: background 0.15s, color 0.15s;
}

.icon-btn:hover {
  background: var(--color-bg);
  color: var(--color-text);
}

.icon-btn.sound-muted {
  color: var(--color-text-light);
  opacity: 0.55;
}

/* ===== Participant Strip ===== */
.strip-container {
  height: var(--strip-h);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  overflow-x: auto;
  overflow-y: hidden;
  flex-shrink: 0;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  scroll-behavior: smooth;
}

.strip-container::-webkit-scrollbar {
  display: none;
}

.strip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  height: 100%;
  width: max-content;
  min-width: 100%;
}

.strip-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
  transition: transform 0.2s;
}

.strip-item.strip-current {
  transform: scale(1.1);
}

.avatar-sm {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 800;
  color: white;
  border: 1px solid var(--color-border);
  transition: border-color 0.2s, box-shadow 0.2s;
  overflow: hidden;
}

.avatar-sm img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.strip-item.strip-current .avatar-sm {
  border-width: 2.5px;
  border-color: var(--strip-current-color, var(--color-action));
  box-shadow: 0 0 0 3px rgba(31, 41, 55, 0.15);
}

.strip-name {
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--color-text-muted);
  max-width: 52px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.strip-item.strip-current .strip-name {
  color: var(--color-text);
  font-weight: 800;
}

/* ===== Main Content ===== */
.main-content {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
  min-height: 0;
  transition: background 0.3s ease;
}

.screen {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 40px;
  padding: 24px 24px 62px;
}

/* ===== Phase Label ===== */
.phase-label {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  font-weight: 800;
  color: var(--color-text-muted);
  letter-spacing: -0.01em;
  text-align: center;
}

.name-highlight {
  color: var(--color-text);
  font-size: 1.3em;
  letter-spacing: -0.03em;
  padding-right: .3em;
}

/* ===== Avatar base ===== */
.avatar {
  border-radius: var(--radius-full);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  flex-shrink: 0;
  user-select: none;
}

.avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* ===== Current Person ===== */
.current-person {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.avatar-lg {
  width: clamp(120px, 30vw, 160px);
  height: clamp(120px, 30vw, 160px);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(2.5rem, 8vw, 4rem);
  font-weight: 900;
  color: white;
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: transform 0.2s;
}

.avatar-lg img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.current-name {
  font-size: clamp(1.3rem, 5vw, 2rem);
  font-weight: 800;
  color: var(--color-text);
  letter-spacing: -0.02em;
  text-align: center;
}

/* ===== Action Buttons ===== */
.action-btn {
  border: none;
  cursor: pointer;
  font-size: clamp(1.1rem, 4vw, 1.4rem);
  font-weight: 800;
  border-radius: var(--radius-full);
  padding: 0 36px;
  height: 64px;
  white-space: nowrap;
  transition: transform 0.1s, box-shadow 0.1s, background 0.15s;
  letter-spacing: -0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-icon {
  flex-shrink: 0;
  width: 18px;
  height: 20px;
  fill: currentColor;
}

.action-btn:active {
  transform: scale(0.95);
}

.btn-start {
  background: var(--color-start);
  color: #fff;
  box-shadow: 0 4px 16px rgba(236, 72, 153, 0.35);
  flex-shrink: 0;
}

.btn-start:hover {
  background: var(--color-start-dark);
}

.btn-end {
  background: var(--color-action);
  color: #fff;
  box-shadow: 0 4px 16px rgba(31, 41, 55, 0.3);
  margin: 0 0 20px;
  flex-shrink: 0;
}

.btn-end:hover {
  background: var(--color-action-hover);
}
.btn-end svg {
  fill: #fff;
  width: 20px;
}

/* ===== Transition overlay ===== */
.transition-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  pointer-events: none;
}

.transition-message {
  font-size: clamp(2.5rem, 12vw, 5rem);
  font-weight: 900;
  color: var(--color-action);
  background: rgba(255, 255, 255, 0.92);
  padding: 16px 48px;
  border-radius: var(--radius-full);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  letter-spacing: -0.02em;
  animation: msg-pop 1s ease forwards;
}

@keyframes msg-pop {
  0%   { opacity: 0; transform: scale(0.7); }
  18%  { opacity: 1; transform: scale(1.08); }
  40%  { opacity: 1; transform: scale(1);   }
  75%  { opacity: 1; transform: scale(1);   }
  100% { opacity: 0; transform: scale(0.92); }
}

/* ===== Modal ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  padding: 16px;
}

.modal {
  background: var(--color-surface);
  border-radius: var(--radius);
  width: 100%;
  max-width: 520px;
  max-height: 90dvh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 20px 16px;
  border-bottom: 1px solid var(--color-border);
  flex-shrink: 0;
}

.modal-header .icon-btn {
  font-size: 1.5rem;
}

.modal-header .icon-btn svg {
  width: 24px;
  height: 24px;
}

@media (max-width: 600px) {
  .modal-header .icon-btn {
    min-width: 52px;
    min-height: 52px;
    padding: 12px;
    transform: translateX(10px);
  }

  .modal-header .icon-btn svg {
    width: 28px;
    height: 28px;
  }
}

.modal-title {
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.modal-body {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px 8px;
  -webkit-overflow-scrolling: touch;
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 20px;
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.settings-section {
  width: 100%;
  margin-bottom: 28px;
}

.settings-section:last-child {
  margin-bottom: 0;
}

#draftList {
  width: 100%;
}

.section-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--color-text-muted);
  margin-bottom: 10px;
}

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

.setting-label {
  font-size: 0.95rem;
  /* font-weight: 600; */
  color: var(--color-text);
}

/* ===== Toggle switch ===== */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
  cursor: pointer;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  inset: 0;
  background: #D1D5DB;
  border-radius: 26px;
  transition: background 0.2s;
}

.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  left: 3px;
  top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
  box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.toggle-switch input:checked + .toggle-slider {
  background: var(--color-on);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(18px);
}

.btn {
  border: none;
  cursor: pointer;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 700;
  transition: background 0.15s;
}

.btn-primary {
  background: var(--color-action);
  color: #fff;
}

.btn-primary:hover {
  background: var(--color-action-hover);
}

.btn-secondary {
  background: #E5E7EB;
  color: var(--color-text);
}

.btn-secondary:hover {
  background: #D1D5DB;
}

/* ===== Participant items in modal ===== */
.participant-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.participant-drag-handle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 40px;
  flex-shrink: 0;
  cursor: grab;
  color: var(--color-text-light);
  touch-action: none;
}

.participant-drag-handle:active {
  cursor: grabbing;
}

.participant-item.participant-dragging {
  opacity: 0.6;
}

.participant-drop-line {
  height: 4px;
  background: #94a3b8;
  flex-shrink: 0;
  width: 100%;
}

.participant-avatar-btn {
  position: relative;
  background: none;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-full);
  width: 52px;
  height: 52px;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  overflow: hidden;
  transition: border-color 0.15s;
}

.participant-avatar-btn:hover {
  border-color: var(--color-action);
}

.participant-avatar-btn .avatar {
  width: 100%;
  height: 100%;
  border-radius: 0;
  font-size: 1.2rem;
}

.participant-name-input {
  flex: 1;
  min-width: 0;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: var(--font);
  color: var(--color-text);
  background: var(--color-bg);
  outline: none;
  transition: border-color 0.15s;
  user-select: text;
  -webkit-user-select: text;
}

.participant-name-input:focus {
  border-color: var(--color-action);
}

.participant-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-light);
  font-size: 1rem;
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  min-width: 32px;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.participant-delete-btn:hover {
  color: #E53E3E;
  background: #FFF5F5;
}

.participant-delete-btn svg {
  width: 20px;
  height: 20px;
}

.add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: none;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  width: 100%;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 700;
  color: var(--color-text-muted);
  font-family: var(--font);
  margin-top: 10px;
  transition: border-color 0.15s, color 0.15s;
}

.add-btn:hover {
  border-color: var(--color-action);
  color: var(--color-action);
}
