:root {
  --bg: #0d0f14;
  --panel: #161a22;
  --panel2: #1e2430;
  --text: #e8ecf4;
  --muted: #8b94a7;
  --accent: #ff5d3a;
  --ok: #3ad17a;
  --border: #2a3140;
}

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

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: "BIZ UDPGothic", "Hiragino Sans", "Yu Gothic UI", system-ui, sans-serif;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
}

.logo {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 1px;
}
.logo .accent { color: var(--accent); }
.logo-sub {
  font-size: 9px;
  letter-spacing: 3px;
  color: var(--muted);
  text-transform: uppercase;
}

/* ---------- index ---------- */
.setup-wrap {
  max-width: 720px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}
.setup-wrap h1 { margin-bottom: 8px; }
.setup-wrap .lead { color: var(--muted); margin-bottom: 32px; font-size: 14px; }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
}
.card h2 {
  font-size: 15px;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.step-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  flex: none;
}
.card .hint { color: var(--muted); font-size: 12.5px; line-height: 1.7; margin-bottom: 14px; }

.btn {
  background: var(--accent);
  color: #fff;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 700;
}
.btn:disabled { opacity: 0.4; cursor: default; }
.btn.secondary { background: var(--panel2); color: var(--text); border: 1px solid var(--border); }

.drop {
  border: 2px dashed var(--border);
  border-radius: 10px;
  padding: 32px;
  text-align: center;
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.drop.over { border-color: var(--accent); background: rgba(255, 93, 58, 0.06); }
.drop input { display: none; }

.file-list { margin-top: 12px; font-size: 13px; color: var(--muted); }

.link-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
  margin-bottom: 10px;
}
.link-row .label { font-size: 12px; color: var(--muted); width: 90px; flex: none; }
.link-row a { color: var(--text); font-size: 13px; word-break: break-all; }
.link-row button {
  flex: none;
  background: var(--border);
  color: var(--text);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 12px;
}
.warn { color: #ffb45d; font-size: 12.5px; margin-top: 10px; line-height: 1.7; }

.room-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.room-table th, .room-table td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  text-align: left;
  white-space: nowrap;
}
.room-table th { color: var(--muted); font-size: 11px; font-weight: 400; letter-spacing: 1px; }
.room-table td.num { text-align: right; font-variant-numeric: tabular-nums; }
.room-table .del {
  background: #3a1d1d;
  color: #ff8a7a;
  border: 1px solid #5a2c2c;
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
}
.room-table .del:disabled { opacity: 0.4; cursor: default; }
.room-table .view {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 12px;
  margin-right: 6px;
}
.comment-log { margin-top: 16px; font-size: 13px; }
.comment-log h3 { font-size: 13px; margin-bottom: 8px; }
.comment-log table { width: 100%; border-collapse: collapse; }
.comment-log td { padding: 5px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.comment-log td.meta { color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; width: 1%; }
.comment-log td.body { word-break: break-all; }
.room-table code { font-family: Consolas, monospace; color: var(--text); }

/* ---------- present (stage) ---------- */
.stage {
  display: grid;
  grid-template-columns: 1fr 280px;
  height: 100vh;
}
.slide-area {
  position: relative;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.slide-area img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}
.slide-empty {
  color: var(--muted);
  text-align: center;
  font-size: 15px;
  line-height: 2;
}

.nav-btn {
  position: absolute;
  bottom: 16px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 20px;
  opacity: 0.35;
  transition: opacity 0.15s;
  z-index: 20;
}
.nav-btn:hover { opacity: 1; background: rgba(255, 255, 255, 0.2); }
.nav-btn.prev { right: 76px; }
.nav-btn.next { right: 20px; }

/* 浮遊スタンプ */
.float-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 10;
}
.float-emoji {
  position: absolute;
  bottom: -60px;
  font-size: 44px;
  animation: floatUp var(--dur, 3.2s) ease-out forwards;
  will-change: transform, opacity;
}
@keyframes floatUp {
  0%   { transform: translateY(0) translateX(0) scale(0.6) rotate(0deg); opacity: 0; }
  8%   { opacity: 1; transform: translateY(-6vh) translateX(calc(var(--sway) * 0.2)) scale(1.05); }
  60%  { opacity: 1; }
  100% { transform: translateY(-92vh) translateX(var(--sway)) scale(1) rotate(var(--rot)); opacity: 0; }
}

/* 流れるコメント */
.comment-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 11;
}
.flow-comment {
  position: absolute;
  left: 0;
  top: 0;
  white-space: nowrap;
  line-height: 1.45;
  font-weight: 800;
  color: #fff;
  text-shadow: 0 0 3px #000, 1px 1px 0 #000, -1px -1px 0 #000, 1px -1px 0 #000, -1px 1px 0 #000;
  will-change: transform;
}
.side-btn.on { background: #3a1d1d; color: #ff8a7a; border-color: #5a2c2c; }

.sidebar {
  background: var(--panel);
  border-left: 1px solid var(--border);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
}
.sidebar .live {
  display: inline-block;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  letter-spacing: 1px;
}
.stat-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.stat {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
.stat .k { font-size: 10px; color: var(--muted); letter-spacing: 1px; text-transform: uppercase; }
.stat .v { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; }

.totals { display: flex; flex-wrap: wrap; gap: 8px; }
.totals .tot {
  background: var(--panel2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.qr-box {
  background: #fff;
  border-radius: 10px;
  padding: 14px;
  text-align: center;
}
.qr-box svg, .qr-box img { width: 100%; height: auto; display: block; }
.join-code {
  text-align: center;
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 3px;
  text-transform: uppercase;
}
.join-hint { text-align: center; color: var(--muted); font-size: 11px; }

.side-note { color: var(--muted); font-size: 11.5px; line-height: 1.7; }
.side-btn {
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-size: 13px;
  width: 100%;
}
.conn-dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--ok); margin-right: 6px; }
.conn-dot.off { background: #e0503a; }

/* ---------- react (audience) ---------- */
.react-wrap {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  max-width: 480px;
  margin: 0 auto;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
}
.react-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.react-status { font-size: 12px; color: var(--muted); }
.react-msg { text-align: center; color: var(--muted); font-size: 13px; margin: 12px 0; min-height: 20px; }

.react-slide {
  position: relative;
  margin-top: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #000;
}
.react-slide img { display: block; width: 100%; height: auto; }
.react-slide-page {
  position: absolute;
  right: 8px;
  bottom: 8px;
  background: rgba(0, 0, 0, 0.55);
  color: #fff;
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-variant-numeric: tabular-nums;
}

.comment-form { display: flex; gap: 8px; margin-top: 12px; }
.comment-form input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  font-size: 16px; /* 16px 未満だと iOS が入力時に拡大する */
  font-family: inherit;
}
.comment-form input:disabled { opacity: 0.5; }
.comment-form button {
  flex: none;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 0 18px;
  font-size: 15px;
  font-weight: 700;
}
.comment-form button:disabled { opacity: 0.4; cursor: default; }
.comment-note { font-size: 12px; color: var(--muted); margin-top: 6px; min-height: 18px; display: flex; justify-content: space-between; gap: 8px; }
.comment-note .over { color: #ff8a7a; }

.emoji-grid {
  flex: 1;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  align-content: center;
}
.emoji-btn {
  position: relative;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  font-size: 56px;
  padding: 26px 0;
  transition: transform 0.08s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  overflow: visible;
}
.emoji-btn:active { transform: scale(0.92); background: var(--panel2); }
.emoji-btn .cnt {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.pop {
  position: fixed;
  font-size: 34px;
  pointer-events: none;
  animation: popUp 0.9s ease-out forwards;
  z-index: 100;
}
@keyframes popUp {
  0% { transform: translateY(0) scale(0.7); opacity: 1; }
  100% { transform: translateY(-120px) scale(1.3); opacity: 0; }
}

@media (max-width: 860px) {
  .stage { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sidebar { border-left: none; border-top: 1px solid var(--border); flex-direction: row; flex-wrap: wrap; }
}
