* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  margin: 0;
  min-height: 100vh;
  background: #1a1a2e;
  color: #fff;
}

.hidden {
  display: none !important;
}

/* ===== 接続画面 ===== */
.connect-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  text-align: center;
}

.connect-screen h2 {
  margin-bottom: 30px;
  font-size: 1.5rem;
}

.connect-screen input {
  font-size: 1.5rem;
  padding: 15px 20px;
  border: none;
  border-radius: 8px;
  text-align: center;
  width: 100%;
  max-width: 300px;
  margin-bottom: 15px;
  color: #1a1a2e;
}

.connect-screen button {
  font-size: 1.2rem;
  padding: 15px 40px;
  border: none;
  border-radius: 8px;
  background: #4a4aff;
  color: #fff;
  cursor: pointer;
}

.connect-screen button:hover {
  background: #6a6aff;
}

.status {
  margin-top: 20px;
  color: #888;
}

/* ===== 演台タイマー画面 ===== */
.timer-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  transition: background-color 0.3s;
}

.display-layout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  gap: 2vh;
}

.time-display {
  font-size: 30vw;
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  letter-spacing: 2vw;
  line-height: 1;
}

/* ===== メッセージ表示エリア（演台側） ===== */
.message-area {
  width: 90%;
  max-width: 90vw;
  text-align: center;
  animation: message-slide-in 0.4s ease-out;
}

.message-text {
  font-size: 5vw;
  font-weight: bold;
  padding: 2vh 3vw;
  background: #ffd700;
  color: #1a1a1a;
  border-radius: 1vw;
  border-left: 0.8vw solid #b8960b;
  backdrop-filter: blur(4px);
  line-height: 1.4;
}

@keyframes message-slide-in {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.message-area.message-dismiss {
  animation: message-slide-out 0.3s ease-in forwards;
}

@keyframes message-slide-out {
  from {
    opacity: 1;
    transform: translateY(0);
  }
  to {
    opacity: 0;
    transform: translateY(20px);
  }
}

/* ===== 背景色の状態 ===== */
.display-mode.normal {
  background: #1a1a2e;
}

.display-mode.warning {
  background: #b8860b;
}

.display-mode.danger {
  background: #c0392b;
}

.display-mode.finished {
  background: #c0392b;
  animation: blink 0.5s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.7;
  }
}

/* ===== 操作画面 ===== */
.controller-screen {
  padding: 20px;
  max-width: 500px;
  margin: 0 auto;
}

/* ルーム情報 */
.room-info {
  text-align: center;
  margin-bottom: 20px;
  padding: 15px;
  background: #2a2a4a;
  border-radius: 8px;
}

.room-info p {
  margin: 0 0 5px;
  color: #888;
  font-size: 0.9rem;
}

.room-id-box {
  font-size: 1.8rem;
  font-weight: bold;
  letter-spacing: 3px;
  color: #4a4aff;
}

.viewer-count {
  margin-top: 10px !important;
  font-size: 0.85rem !important;
}

/* タブバー */
.tab-bar {
  display: flex;
  gap: 0;
  margin-bottom: 20px;
  background: #2a2a4a;
  border-radius: 8px;
  overflow: hidden;
}

.tab-btn {
  flex: 1;
  padding: 14px 10px;
  font-size: 0.95rem;
  font-weight: bold;
  border: none;
  background: transparent;
  color: #888;
  cursor: pointer;
  transition: all 0.2s;
}

.tab-btn.active {
  background: #4a4aff;
  color: #fff;
}

.tab-btn:not(.active):hover {
  background: #3a3a5a;
  color: #ccc;
}

/* タブコンテンツ */
.tab-content {
  /* visible by default unless .hidden */
}

/* タイマープレビュー */
.time-preview {
  font-size: 4rem;
  font-weight: bold;
  text-align: center;
  padding: 30px;
  background: #2a2a4a;
  border-radius: 12px;
  margin-bottom: 20px;
  font-variant-numeric: tabular-nums;
}

/* セクション */
.section {
  margin-bottom: 20px;
}

.section > p {
  margin: 0 0 10px;
  color: #888;
  font-size: 0.9rem;
}

/* タイマーボタン群 */
.preset-buttons,
.adjust-buttons,
.control-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.preset-buttons button,
.adjust-buttons button {
  flex: 1;
  min-width: 60px;
  padding: 15px 10px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background: #3a3a5a;
  color: #fff;
  cursor: pointer;
}

.preset-buttons button:hover,
.adjust-buttons button:hover {
  background: #4a4a7a;
}

.control-buttons button {
  flex: 1;
  padding: 20px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.control-buttons .primary {
  background: #27ae60;
  color: #fff;
}

.control-buttons .warning {
  background: #f39c12;
  color: #fff;
}

.control-buttons .danger {
  background: #c0392b;
  color: #fff;
}

.control-buttons button:hover {
  opacity: 0.9;
}

/* ===== SIGNAL: メッセージ送信パネル ===== */
.signal-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.signal-presets button {
  padding: 14px 16px;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  background: #3a3a5a;
  color: #fff;
  cursor: pointer;
  transition: all 0.15s;
}

.signal-presets button:hover {
  background: #4a4a7a;
}

.signal-presets button.sent {
  background: #27ae60;
  transform: scale(0.96);
}

/* 自由入力 */
.free-message-area {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.free-message-area textarea {
  width: 100%;
  padding: 12px;
  font-size: 1rem;
  border: none;
  border-radius: 8px;
  background: #2a2a4a;
  color: #fff;
  resize: vertical;
  font-family: inherit;
}

.free-message-area textarea::placeholder {
  color: #666;
}

.send-btn {
  padding: 14px;
  font-size: 1.1rem;
  font-weight: bold;
  border: none;
  border-radius: 8px;
  background: #4a4aff;
  color: #fff;
  cursor: pointer;
  transition: background 0.2s;
}

.send-btn:hover {
  background: #6a6aff;
}

/* 表示設定 */
.signal-settings {
  display: flex;
  align-items: center;
  gap: 15px;
  flex-wrap: wrap;
}

.signal-settings label {
  font-size: 0.95rem;
  color: #ccc;
}

.signal-settings select {
  padding: 8px 12px;
  font-size: 0.95rem;
  border: none;
  border-radius: 6px;
  background: #2a2a4a;
  color: #fff;
  cursor: pointer;
}

.dismiss-btn {
  padding: 10px 20px;
  font-size: 0.95rem;
  border: none;
  border-radius: 8px;
  background: #c0392b;
  color: #fff;
  cursor: pointer;
}

.dismiss-btn:hover {
  background: #e74c3c;
}

/* 送信履歴 */
.message-log {
  max-height: 200px;
  overflow-y: auto;
  background: #2a2a4a;
  border-radius: 8px;
  padding: 12px;
}

.log-empty {
  color: #666;
  text-align: center;
  font-size: 0.9rem;
  margin: 0;
}

.log-entry {
  padding: 8px 0;
  border-bottom: 1px solid #3a3a5a;
  font-size: 0.9rem;
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
}

.log-entry:last-child {
  border-bottom: none;
}

.log-entry .log-msg {
  flex: 1;
}

.log-entry .log-time {
  color: #666;
  font-size: 0.8rem;
  white-space: nowrap;
}
