* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: "Hiragino Sans", "Noto Sans JP", system-ui, sans-serif;
  background: linear-gradient(100deg, #166e74 0%, #274b9f 45%, #5b11b8 100%);
  color: #fff;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
.hidden { display: none !important; }

/* Lobby */
#lobby { max-width: 520px; margin: 0 auto; padding: 8vh 20px 40px; text-align: center; }
#lobby h1 { font-size: 34px; line-height: 1.35; font-weight: 800; }
#lobby .sub { opacity: .85; margin: 12px 0 28px; }
.lobby-card {
  background: rgba(10, 10, 40, .35); border-radius: 18px; padding: 24px;
  display: flex; flex-direction: column; gap: 10px; text-align: left;
  backdrop-filter: blur(4px);
}
.lobby-card label { font-size: 13px; opacity: .85; }
.lobby-card input {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25);
  border-radius: 10px; color: #fff; font-size: 17px; padding: 12px 14px; width: 100%;
}
.lobby-card input::placeholder { color: rgba(255,255,255,.45); }
button {
  cursor: pointer; border: none; border-radius: 999px; font-size: 15px; font-weight: 700;
  padding: 12px 18px; background: rgba(255,255,255,.9); color: #4a0fa5;
}
button.primary { background: #fff; font-size: 17px; padding: 14px; }
button:active { transform: scale(.97); }
.or { text-align: center; opacity: .6; font-size: 13px; margin: 4px 0; }
.join-row { display: flex; gap: 8px; }
.join-row input { flex: 1; text-transform: lowercase; }
.note { font-size: 12px; opacity: .65; text-align: center; margin-top: 6px; }

/* Room */
#room { max-width: 1400px; margin: 0 auto; padding: 18px 16px 90px; }
.topic-wrap { max-width: 900px; margin: 0 auto 6px; }
#topic {
  width: 100%; background: rgba(10,10,40,.35); border: none; border-radius: 14px;
  color: #fff; font-size: clamp(20px, 3.4vw, 30px); font-weight: 800;
  text-align: center; padding: 16px 12px;
}
#topic::placeholder { color: rgba(255,255,255,.45); }
#topic-view {
  font-size: clamp(20px, 3.4vw, 30px); font-weight: 800; text-align: center; padding: 16px 12px;
  min-height: 34px;
}
.room-bar {
  display: flex; gap: 10px; align-items: center; justify-content: center;
  flex-wrap: wrap; margin: 8px 0 14px; font-size: 14px;
}
.room-bar button { padding: 7px 14px; font-size: 13px; background: rgba(255,255,255,.18); color: #fff; border: 1px solid rgba(255,255,255,.3); }
.bar-info { display: inline-flex; gap: 8px; align-items: center; }
.bar-group { display: inline-flex; gap: 6px; align-items: center; border: 1px solid rgba(255,255,255,.28); background: rgba(0,0,0,.22); border-radius: 999px; padding: 4px 6px 4px 10px; }
.bar-group-label { font-size: 10px; font-weight: 700; letter-spacing: .1em; opacity: .75; }
.bar-group button { padding: 5px 11px; }
#btn-leave { color: #ffb3b8; border-color: rgba(255,120,130,.55); }
#btn-sound { min-width: 84px; }
#room-code-label { opacity: .85; }
#member-count { opacity: .85; font-weight: 700; }
#spectator-note { text-align: center; background: rgba(0,0,0,.3); border-radius: 10px; padding: 8px; margin-bottom: 12px; font-size: 14px; }
#conn-dot { color: #7dff8a; font-size: 12px; }
#conn-dot.off { color: #ffd94a; }
#conn-banner { text-align: center; background: rgba(180,40,40,.55); border-radius: 10px; padding: 8px; margin-bottom: 12px; font-size: 14px; }
#host-tools { display: flex; gap: 8px; align-items: center; justify-content: center; flex-wrap: wrap; margin-bottom: 10px; font-size: 13px; }
#host-tools input {
  background: rgba(255,255,255,.12); border: 1px solid rgba(255,255,255,.25); border-radius: 8px;
  color: #fff; font-size: 14px; padding: 7px 10px; width: 180px;
}
#host-tools input::placeholder { color: rgba(255,255,255,.4); }
.head-row { display: flex; gap: 14px; align-items: flex-start; max-width: 1200px; margin: 0 auto; }
.head-row .topic-wrap { flex: 1; }
#subtitle-view {
  background: #6d28b8; border-radius: 6px; padding: 12px 16px; font-weight: 800;
  font-size: clamp(15px, 2.2vw, 22px); margin-top: 6px; max-width: 42%;
}
.meter-section { display: flex; align-items: center; gap: 6px; max-width: 1200px; margin: 0 auto; }
.meter-section .label-circle { flex: 0 0 auto; }
#meter-wrap { position: relative; flex: 1; aspect-ratio: 1000 / 440; min-width: 0; container-type: inline-size; }
#meter-svg svg { width: 100%; height: 100%; display: block; }
#markers { position: absolute; inset: 0; }
/* アイコンはメーター幅に比例させる（PC=約82px / スマホ=約30px） */
.marker {
  position: absolute; width: 8.2cqw; margin-left: -4.1cqw; margin-top: -4.1cqw;
  text-align: center; pointer-events: none; transition: none; z-index: 3;
}
.marker .avatar {
  width: 8.2cqw; height: 8.2cqw; border-radius: 50%; border: 3px solid #fff;
  overflow: hidden; display: flex; align-items: center; justify-content: center;
  font-size: 3.4cqw; font-weight: 900; color: #fff; background: #444; margin: 0 auto;
  box-shadow: 0 3px 10px rgba(0,0,0,.45);
}
.marker .avatar img { width: 100%; height: 100%; object-fit: cover; }
.marker .badge {
  display: inline-block; background: #0b0b0f; color: #fff; font-weight: 900; font-size: 1.8cqw;
  border-radius: 0 0 999px 999px; padding: 1px 1.3cqw 4px; margin-top: -1.1cqw; position: relative; z-index: -1;
  min-width: 5cqw;
}
/* 切断中でもグレー表示はしない（本人の希望で通常表示のまま） */
.avatar-sm {
  width: 46px; height: 46px; border-radius: 50%; border: 2px solid rgba(255,255,255,.8);
  overflow: hidden; display: inline-flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 900; color: #fff; background: #444; vertical-align: middle;
}
.avatar-sm img { width: 100%; height: 100%; object-fit: cover; }
.icon-tools { margin: 4px auto 10px; font-size: 12px; }
.icon-tools label {
  cursor: pointer; background: rgba(255,255,255,.16); border: 1px solid rgba(255,255,255,.3);
  border-radius: 999px; padding: 5px 12px; display: inline-block;
}
.icon-tools input[type="file"] { display: none; }
.label-circle {
  width: 92px; height: 92px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  text-align: center; font-weight: 800; font-size: 17px; line-height: 1.3; padding: 8px;
  background: rgba(10,10,40,.35); word-break: break-all;
}
.label-circle.left { border: 3px solid #38b6d9; color: #aee9fa; }
.label-circle.right { border: 3px solid #b26bff; color: #e3c8ff; }
.card.mine { background: rgba(255,255,255,.07); }
.card .lever-wrap:focus { outline: 2px solid rgba(255,255,255,.7); outline-offset: 2px; border-radius: 12px; }

#grid {
  display: grid; gap: 10px;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
}
@media (min-width: 1100px) { #grid { grid-template-columns: repeat(4, 1fr); } }

.card { text-align: center; padding: 8px 4px 0; border-radius: 16px; }

.card .pct { font-size: clamp(34px, 4.5vw, 52px); font-weight: 900; line-height: 1.05; }
.card svg { width: 100%; max-width: 340px; display: block; margin: 0 auto; }
.card.mine svg { cursor: grab; touch-action: none; }
.card.mine svg:active { cursor: grabbing; }
.card .name {
  width: 78%; max-width: 260px; margin: 2px auto 10px; display: block;
  background: rgba(10,10,40,.35); border: none; border-radius: 10px;
  color: #fff; font-size: 16px; text-align: center; padding: 9px 8px;
}
.card .name::placeholder { color: rgba(255,255,255,.45); }
.card .name-view { font-size: 16px; padding: 9px 8px; min-height: 38px; }
.card .host-badge { font-size: 11px; background: #ffd94a; color: #333; border-radius: 999px; padding: 2px 8px; margin-left: 6px; vertical-align: middle; font-weight: 700; }

/* 退出通知トーストとフェードアウト */
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; }
.toast { background: rgba(20,20,28,.92); color: #fff; border: 1px solid rgba(255,255,255,.25); padding: 9px 18px; border-radius: 999px; font-size: 14px; box-shadow: 0 6px 24px rgba(0,0,0,.35); opacity: 1; transition: opacity .45s ease, transform .45s ease; }
.toast.out { opacity: 0; transform: translateY(8px); }
.card.leaving, .marker.leaving { opacity: 0 !important; transform: scale(.9); transition: opacity .5s ease, transform .5s ease !important; pointer-events: none; }

/* 簡易マニュアル（ロビー） */
.manual { margin-top: 14px; text-align: left; border-top: 1px solid rgba(255,255,255,.14); padding-top: 12px; }
.manual summary { cursor: pointer; font-weight: 700; font-size: 15px; padding: 4px 0; }
.manual-body { font-size: 13.5px; line-height: 1.65; color: #d8d8e2; }
.manual-body h3 { font-size: 14px; margin: 12px 0 4px; color: #fff; }
.manual-body ul { margin: 0; padding-left: 18px; }
.manual-body li { margin: 2px 0; }

/* ロビーの再入室カード */
#resume-card { margin-top: 14px; border: 1px solid rgba(255,255,255,.25); border-radius: 12px; padding: 12px; }
#resume-card p { margin: 0 0 10px; font-size: 14px; }
#resume-card .join-row { display: flex; gap: 8px; }
.my-room-row { display: flex; gap: 8px; align-items: center; padding: 7px 0; border-top: 1px solid rgba(255,255,255,.14); }
.my-room-row:first-child { border-top: none; padding-top: 0; }
.my-room-label { flex: 1; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-room-mode { font-size: 11px; opacity: .75; border: 1px solid rgba(255,255,255,.35); border-radius: 999px; padding: 2px 8px; }
.my-room-row button { padding: 6px 12px; font-size: 13px; }
