/* 視聴ページのスタイルです。 */
body {
  font-family: "Noto Sans JP", sans-serif;
  margin: 0;
  background-color: #111;
  color: #f5f5f5;
}

body.lock-scroll {
  overflow: hidden;
}

.site-header {
  background-color: #202020;
  padding: 6px 16px;
}

.site-header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.site-header h1 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
}

.stream-meta {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  color: #cfcfcf;
}

.viewer-count {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  border-radius: 999px;
  background-color: #2a2a2a;
}

main {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 16px;
  padding-bottom: 220px;
}

.player-wrapper {
  position: relative;
  width: 100%;
  background-color: #000;
  border-radius: 8px;
  overflow: hidden;
}

.player-section video {
  width: 100%;
  display: block;
  background-color: #000;
}

.player-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000;
  pointer-events: none;
  transition: opacity 0.25s ease;
  z-index: 1;
}

.player-placeholder[hidden] {
  opacity: 0;
}

.player-placeholder img {
  max-width: 60%;
  height: auto;
}

.player-controls {
  position: absolute;
  right: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: flex-end;
  z-index: 2;
}

.player-control-button {
  padding: 8px 12px;
  border: none;
  border-radius: 999px;
  background-color: rgba(90, 90, 90, 0.85);
  color: #f5f5f5;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease, transform 0.2s ease, opacity 0.2s ease;
}

.player-control-button:hover {
  background-color: rgba(120, 120, 120, 0.85);
}

.player-control-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.player-control-button:focus-visible {
  outline: 2px solid rgba(138, 180, 248, 0.9);
  outline-offset: 2px;
}

.player-control-button.is-active {
  box-shadow: 0 0 0 2px rgba(138, 180, 248, 0.45);
}

.live-edge-button {
  background-color: rgba(138, 180, 248, 0.85);
  color: #111;
}

.live-edge-button:hover {
  background-color: rgba(174, 203, 250, 0.95);
}

.live-edge-button:disabled {
  background-color: rgba(90, 90, 90, 0.85);
  color: #bbb;
}

.live-edge-button.is-behind {
  background-color: rgba(255, 89, 94, 0.92);
  color: #fff;
  transform: translateY(-2px);
}

.chat-section {
  background-color: #1d1d1d;
  padding: 16px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}

.chat-list {
  flex: 1;
  overflow-y: auto;
  border: 1px solid #333;
  padding: 12px;
  border-radius: 6px;
  max-height: 420px;
  background-color: #141414;
  scroll-behavior: smooth;
}

.chat-item {
  margin-bottom: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid #333;
}

.chat-item:last-child {
  border-bottom: none;
}

.chat-item .name {
  font-weight: bold;
  color: #8ab4f8;
}

.chat-form-container {
  background-color: #151515;
  border: 1px solid #333;
  border-radius: 8px;
  padding: 12px;
  position: sticky;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: 0 -8px 20px rgba(0, 0, 0, 0.4);
}

.chat-form-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

.chat-form-title {
  font-weight: 600;
  font-size: 1rem;
  color: #f5f5f5;
}

.chat-form-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.chat-autoscroll-toggle {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #444;
  background-color: transparent;
  color: #f5f5f5;
  cursor: pointer;
  font-weight: 600;
}

.chat-autoscroll-toggle:hover {
  background-color: #2a2a2a;
}

.chat-autoscroll-toggle:disabled {
  opacity: 0.6;
  cursor: default;
  background-color: transparent;
}

.chat-form-toggle {
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #444;
  background-color: transparent;
  color: #f5f5f5;
  cursor: pointer;
  font-weight: 600;
}

.chat-form-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.chat-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-field label {
  font-size: 0.9rem;
  color: #ccc;
}

.chat-field input,
.chat-field textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 6px;
  border: 1px solid #444;
  background-color: #111;
  color: #f5f5f5;
  font-size: 1rem;
  resize: none;
  box-sizing: border-box;
}

.chat-field textarea {
  line-height: 1.5;
  max-height: 220px;
  overflow-y: auto;
}

.chat-form-footer {
  display: flex;
  justify-content: flex-end;
}

.primary-button {
  padding: 10px 16px;
  background-color: #8ab4f8;
  border: none;
  border-radius: 4px;
  color: #111;
  font-weight: bold;
  cursor: pointer;
}

.primary-button:hover {
  background-color: #aecbfa;
}

.chat-form-container.is-collapsed .chat-form-body {
  display: none;
}

.chat-form-container.is-collapsed .chat-form-toggle {
  background-color: #8ab4f8;
  border-color: #8ab4f8;
  color: #111;
}

.error {
  color: #ff6b6b;
  min-height: 1.5em;
}

@media (min-width: 960px) {
  main {
    flex-direction: row;
    align-items: flex-start;
    padding-bottom: 32px;
  }
  .player-section,
  .chat-section {
    flex: 1;
  }
  .chat-section {
    max-width: 420px;
    position: sticky;
    top: 16px;
    height: calc(100vh - 64px);
  }
  .chat-list {
    max-height: none;
  }
  .chat-form-container {
    position: static;
    box-shadow: none;
  }
}

@media (max-width: 768px) {
  main {
    padding: 12px;
    padding-bottom: 80px;
  }
  .chat-section {
    padding: 12px;
    background-color: transparent;
    border: none;
  }
  .chat-list {
    border: none;
    background-color: transparent;
    padding: 0 4px 120px;
  }
  .chat-form-container {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 16px 16px 0 0;
    border: 1px solid #2a2a2a;
    margin: 0 auto;
    max-width: 100%;
    background-color: #1a1a1a;
    transition: transform 0.2s ease-in-out;
    transform: translateY(0);
    padding-bottom: calc(16px + env(safe-area-inset-bottom));
  }
  .chat-form-container.is-collapsed {
    transform: translateY(calc(100% - 60px));
  }
  .chat-form-header {
    cursor: pointer;
  }
  .chat-form-toggle {
    background-color: transparent;
    border-color: transparent;
    color: #8ab4f8;
  }
  .chat-form-container.is-collapsed .chat-form-toggle {
    background-color: transparent;
    color: #8ab4f8;
  }
}

@media (max-width: 768px) {
  .site-header {
    padding: 2px 12px;
  }
  .site-header h1 {
    font-size: 1rem;
  }
  .stream-meta {
    font-size: 0.8rem;
  }
  .chat-autoscroll-toggle {
    display: none;
  }
}
