body {
    font-family: sans-serif;
    margin: 16px;
    background: #111;
    color: #eee;
}

h2 {
    margin-top: 0;
}

#connectionStatus {
    display: flex;
    align-items: center
}

#player {
    width: 100%;
    max-width: 1280px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
}

#video {
    width: 100%;
    display: block;
    background: #000;
}

.controls {
    margin-top: 12px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

button {
    padding: 10px 16px;
    font-size: 14px;
    cursor: pointer;
}

#log {
    margin-top: 16px;
    width: 100%;
    max-width: 1280px;
    height: 220px;
    background: #1b1b1b;
    color: #9f9;
    border: 1px solid #444;
    padding: 8px;
    box-sizing: border-box;
    white-space: pre-wrap;
    overflow: auto;
}

#status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  font-weight: 700;
  transition: transform 160ms ease, opacity 160ms ease, background-color 200ms ease;
}

#status.connecting,
#status.waiting {
  background: #fff3cd;
  color: #7a5a00;
}

#status.connected {
  background: #d1fae5;
  color: #065f46;
}

#status.failed,
#status.disconnected {
  background: #fee2e2;
  color: #991b1b;
}

.controls button,
#audio label {
  transition: transform 120ms ease, box-shadow 160ms ease, background-color 160ms ease, color 160ms ease;
}

.controls button:hover,
#audio label:hover {
  transform: translateY(-1px);
}

.controls button:active,
#audio label:active {
  transform: scale(0.98);
}

/* Audio toggle */
.audioArea {
  display: inline-flex;
  align-items: center;
}

#audio {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  width: 132px;
  padding: 4px;
  border-radius: 999px;
  background: #2e3371;
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.28),
    0 6px 18px rgba(0, 0, 0, 0.16);
  overflow: hidden;
}

#audio input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

#audio label {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  height: 36px;
  border-radius: 999px;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #cbd5e1;
  transition:
    color 180ms ease,
    transform 140ms ease,
    opacity 180ms ease;
}

#audio label:hover {
  transform: translateY(-1px);
}

#audio label:active {
  transform: scale(0.97);
}

/* 動く白い背景 */
#audio::before {
  content: "";
  position: absolute;
  top: 4px;
  left: 7px;
  width: calc(50% - 4px);
  height: 36px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #eef2f7 100%);
  box-shadow:
    0 4px 10px rgba(0, 0, 0, 0.18),
    inset 0 1px 0 rgba(255, 255, 255, 0.85);
  transform: translateX(62px);
  transition:
    transform 220ms cubic-bezier(.2, .8, .2, 1),
    background 180ms ease,
    box-shadow 180ms ease;
}

/* ON が選ばれたら左へ */
#audio:has(#audioOn:checked)::before {
  transform: translateX(0);
}

/* OFF が選ばれたら右へ */
#audio:has(#audioOff:checked)::before {
  transform: translateX(62px);
}

/* 選択中の文字色 */
#audio:has(#audioOn:checked) label[for="audioOn"] {
  color: #111827;
}

#audio:has(#audioOn:checked) label[for="audioOff"] {
  color: #94a3b8;
}

#audio:has(#audioOff:checked) label[for="audioOff"] {
  color: #111827;
}

#audio:has(#audioOff:checked) label[for="audioOn"] {
  color: #94a3b8;
}

/* 状態別アクセント */
.audioArea[data-audio-state="on"] #audio {
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.24),
    0 0 0 3px rgba(34, 197, 94, 0.18),
    0 8px 20px rgba(34, 197, 94, 0.14);
}

.audioArea[data-audio-state="off"] #audio {
  box-shadow:
    inset 0 1px 2px rgba(0, 0, 0, 0.24),
    0 0 0 3px rgba(148, 163, 184, 0.10),
    0 6px 18px rgba(0, 0, 0, 0.14);
}

.audioArea[data-audio-state="pending"] #audio {
  opacity: 1;
}

.audioArea[data-audio-state="pending"] #audio::before {
  animation: audioPulse 900ms ease-in-out infinite;
}

@keyframes audioPulse {
  0%, 100% {
    transform: translateX(0) scale(1);
    box-shadow:
      0 4px 10px rgba(0, 0, 0, 0.18),
      inset 0 1px 0 rgba(255, 255, 255, 0.85);
  }
  50% {
    transform: translateX(0) scale(1.03);
    box-shadow:
      0 6px 14px rgba(34, 197, 94, 0.22),
      inset 0 1px 0 rgba(255, 255, 255, 0.9);
  }
}

/* OFF 側 pending 対応 */
.audioArea[data-audio-state="pending-off"] #audio::before {
  animation: audioPulseOff 900ms ease-in-out infinite;
}

@keyframes audioPulseOff {
  0%, 100% {
    transform: translateX(62px) scale(1);
  }
  50% {
    transform: translateX(62px) scale(1.03);
  }
}

.audioArea[data-audio-state="pending"] {
  opacity: 1;
  filter: saturate(0.8);
}

.audioArea[data-audio-state="on"] #audioOn + label {
  box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.25);
}

.audioArea[data-audio-state="off"] #audioOff + label {
  box-shadow: 0 0 0 2px rgba(239, 68, 68, 0.18);
}

#toast {
  position: fixed;
  right: 20px;
  bottom: 20px;
  padding: 12px 16px;
  border-radius: 12px;
  background: rgba(17, 24, 39, 0.92);
  color: white;
  opacity: 0;
  transform: translateY(8px);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}

#toast.show {
  opacity: 1;
  transform: translateY(0);
}

#toast[data-type="error"] {
  background: rgba(153, 27, 27, 0.95);
}

#copySessionIdBtn {
  min-width: 96px;
  height: 38px;
  padding: 0 14px;
  border: none;
  border-radius: 12px;
  background: linear-gradient(180deg, #2563eb 0%, #1d4ed8 100%);
  color: white;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 140ms ease,
    box-shadow 180ms ease,
    background 180ms ease,
    opacity 180ms ease;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.28);
}

#copySessionIdBtn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 20px rgba(37, 99, 235, 0.30);
}

#copySessionIdBtn:active {
  transform: scale(0.97);
}

#copySessionIdBtn.copy-success {
  background: linear-gradient(180deg, #22c55e 0%, #16a34a 100%);
  box-shadow: 0 8px 18px rgba(34, 197, 94, 0.30);
  animation: copyPop 260ms ease;
}

#copySessionIdBtn.copy-error {
  background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
  box-shadow: 0 8px 18px rgba(239, 68, 68, 0.26);
  animation: copyShake 280ms ease;
}

@keyframes copyPop {
  0% {
    transform: scale(0.94);
  }
  45% {
    transform: scale(1.06);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes copyShake {
  0% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  50% { transform: translateX(3px); }
  75% { transform: translateX(-2px); }
  100% { transform: translateX(0); }
}

.fullscreenBtn {
        display: flex;
    justify-content: center;
    align-items: center;
    position: relative;
    width: 250px;
    padding: .9em 2em;
    border: 1px solid #6d73bf;
    border-radius: 10px;
    background-color: #2e3371;;
    color: #fff;
    font-size: 1em;
}

.fullscreenBtn:hover {
    animation: anima-button-30 1s;
}

@keyframes anima-button-30 {
    0% {
        box-shadow: 0 0 0 0 rgb(37 137 208 / 50%);
    }
    100% {
        box-shadow: 0 0 0 1.2em rgb(0 0 0 / 0%);
    }
}

.sns-box {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

.btn-sns {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 3rem;
    height: 3rem;
    box-sizing: border-box;
    border-radius: 50%;
    color: white;
    font-size: 1.5rem;
    text-align: center;
    text-decoration: none;
    transition: 0.3s;
}

.btn-sns svg {
    fill: #fff;
}

.btn-x {
    background-color: #42589b;
}

.btn-github {
    background-color: #42589b;
}

.btn-github > svg {
    width: 100%;
    height: 100%;
}

.btn-sns:hover .btn-github:hover {
    opacity: 0.8;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  align-content: center;
  place-items: center;
  background:
    radial-gradient(circle at 50% 35%, rgba(255,255,255,0.10), transparent 28%),
    linear-gradient(180deg, rgba(12,18,28,0.94), rgba(8,12,20,0.98));
  backdrop-filter: blur(8px);
  opacity: 0;
  visibility: hidden;
  transition:
    opacity 420ms ease,
    visibility 420ms ease;
}

.splash.show {
  opacity: 1;
  visibility: visible;
}

.splash.hide {
  opacity: 0;
  visibility: hidden;
}

.splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 32px;
  border-radius: 24px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow:
    0 18px 50px rgba(0,0,0,0.35),
    inset 0 1px 0 rgba(255,255,255,0.08);
  transform: translateY(10px) scale(0.98);
  animation: splashCardIn 700ms cubic-bezier(.2,.8,.2,1) forwards;
}

.splash-logo {
  width: 72px;
  height: 72px;
  border-radius: 18px;
  object-fit: cover;
  box-shadow:
    0 10px 24px rgba(0,0,0,0.28),
    0 0 0 1px rgba(255,255,255,0.10);
  animation: splashLogoFloat 2200ms ease-in-out infinite;
}

.splash-title {
  font-size: 1.7rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #ffffff;
}

.splash-subtitle {
  font-size: 0.98rem;
  color: rgba(255,255,255,0.78);
  letter-spacing: 0.01em;
}

@keyframes splashCardIn {
  0% {
    opacity: 0;
    transform: translateY(18px) scale(0.95);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes splashLogoFloat {
  0%, 100% {
    transform: translateY(0px);
  }
  50% {
    transform: translateY(-4px);
  }
}