:root {
  --accent: #FF8C1A;          /* ぐりこ先生のブランド色。アプリ全体の基調 */
  --g: var(--accent);         /* いま入っているグループの色（J-7：色＝現在地） */
  --g-soft: #FFF1E2;
  --ink: #1d1d1f;
  --sub: #6b6b70;
  --line: #e6e6ea;
  --bg: #fafafa;
  --card: #ffffff;
  --busy: #8a8a90;
  --scale: 1;
  font-size: calc(16px * var(--scale));
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--ink);
  font-family: "Noto Sans JP", "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  overscroll-behavior: none;
}
button { font: inherit; color: inherit; cursor: pointer; }
input { font: inherit; }
[hidden] { display: none !important; }

.screen { min-height: 100dvh; padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; }

/* ① 名前 */
#s-name { justify-content: center; gap: 32px; max-width: 460px; margin: 0 auto; }
.hero { text-align: center; }
.logo { font-size: 4.5rem; line-height: 1; }
h1 { font-size: 2rem; margin: 12px 0 8px; letter-spacing: .04em; }
.lead { color: var(--sub); margin: 0; line-height: 1.7; }
.namebox { display: flex; flex-direction: column; gap: 10px; }
.namebox label, .label { font-size: .85rem; color: var(--sub); font-weight: 700; }
input:not([type=range]) {
  width: 100%; padding: 14px 16px; border: 2px solid var(--line); border-radius: 14px;
  background: #fff; font-size: 1.15rem; outline: none; -webkit-user-select: text; user-select: text;
}
input:focus { border-color: var(--accent); }

.big-btn {
  border: 0; border-radius: 16px; background: var(--accent); color: #fff;
  font-size: 1.2rem; font-weight: 800; padding: 16px; box-shadow: 0 4px 0 #c96a0c;
  transition: transform .05s, box-shadow .05s;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c96a0c; }
.big-btn.small { font-size: 1rem; padding: 12px 20px; }
.ghost-btn { border: 2px dashed #cfcfd4; background: transparent; border-radius: 14px; padding: 12px 16px; font-weight: 700; color: var(--sub); }
.ghost-btn:active { background: #f0f0f2; }

/* ヘッダー */
.bar { display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: 48px; }
.brand { font-weight: 800; font-size: 1.1rem; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 8px 14px; font-weight: 700; font-size: .9rem; }
.help { color: var(--sub); font-size: .9rem; line-height: 1.6; margin: 8px 0 14px; }
.help.center { text-align: center; }
.help.small { font-size: .8rem; }

/* ② グループ一覧（J-14：マークと色で、文字を読まなくても選べる） */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.gcard {
  position: relative; text-align: left; border: 0; border-radius: 20px; padding: 16px 14px 14px;
  background: var(--c-soft); border-bottom: 5px solid var(--c); min-height: 132px;
  display: flex; flex-direction: column; gap: 6px; transition: transform .06s;
}
.gcard:active { transform: scale(.96); }
.gcard .gi { font-size: 2.3rem; line-height: 1; }
.gcard .gn { font-weight: 800; font-size: 1.15rem; word-break: break-all; }
.gcard .gm { font-size: .8rem; color: var(--sub); margin-top: auto; }
.gcard .live {
  position: absolute; top: 10px; right: 10px; background: var(--c); color: #fff; font-size: .72rem;
  font-weight: 800; padding: 3px 8px; border-radius: 999px; animation: blink 1s infinite;
}
@keyframes blink { 50% { opacity: .45; } }
.list-foot { display: flex; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.list-foot .ghost-btn { flex: 1; min-width: 140px; }

/* ③ 話す画面 */
.room { background: var(--g-soft); transition: background .15s; }
.back { border: 0; background: transparent; font-weight: 800; font-size: 1.05rem; padding: 8px 4px; color: var(--ink); }
.room-title { font-weight: 800; font-size: 1.2rem; display: flex; gap: 6px; align-items: center; min-width: 0; }
.room-title #r-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room .chip { background: rgba(255,255,255,.7); border-color: transparent; }
.members { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 4px; min-height: 30px; }
.mem { background: rgba(255,255,255,.75); border-radius: 999px; padding: 4px 10px; font-size: .8rem; font-weight: 700; }
.mem.me { outline: 2px solid var(--g); }
.mem.talking { background: var(--g); color: #fff; }

.stage { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; }
.status { text-align: center; min-height: 4.6rem; }
.st-main { font-size: 1.55rem; font-weight: 900; }
.st-sub { font-size: .95rem; color: var(--sub); margin-top: 4px; }

/* いちばん大事なものを、いちばん大きく（J-8） */
.ptt-wrap { position: relative; width: min(74vw, 340px); aspect-ratio: 1; display: grid; place-items: center; }
.ring { position: absolute; inset: 0; border-radius: 50%; background: var(--g); opacity: 0; transform: scale(var(--lv, 1)); transition: transform .07s linear, opacity .15s; }
.ptt {
  position: relative; width: 86%; aspect-ratio: 1; border-radius: 50%; border: 0;
  background: var(--g); color: #fff; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 10px 0 color-mix(in srgb, var(--g) 65%, #000), 0 18px 30px rgba(0,0,0,.18);
  transition: transform .04s, box-shadow .04s, background .12s, filter .12s;
  touch-action: none; -webkit-touch-callout: none;
}
.ptt-icon { font-size: 4.2rem; line-height: 1; }
.ptt-label { font-size: 1.35rem; font-weight: 900; letter-spacing: .05em; }

/* 押した瞬間に沈む（D-2：ボタンの重さは画面側で作る） */
.ptt.down { transform: translateY(8px) scale(.97); box-shadow: 0 2px 0 color-mix(in srgb, var(--g) 65%, #000), 0 6px 12px rgba(0,0,0,.15); }
.ptt.talking { filter: saturate(1.25) brightness(1.05); }
.room.talking .ring { opacity: .25; }
/* 他の人が話しているとき：押せない色に（J-7：状態も色で） */
.ptt.listening { background: var(--busy); box-shadow: 0 10px 0 #5e5e63, 0 18px 30px rgba(0,0,0,.15); }
.room.listening .ring { opacity: .18; background: var(--busy); }
.ptt.shake { animation: shake .32s; }
@keyframes shake { 20%,60% { transform: translateX(-10px); } 40%,80% { transform: translateX(10px); } }

/* 下から出るシート */
dialog.sheet { border: 0; border-radius: 22px; padding: 20px; width: min(94vw, 460px); max-height: 90dvh; overflow: auto; background: #fff; color: var(--ink); }
dialog::backdrop { background: rgba(0,0,0,.4); }
.sheet h2 { margin: 0 0 12px; font-size: 1.3rem; }
.sheet form { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; gap: 10px; justify-content: flex-end; margin-top: 8px; }
.pick { display: flex; flex-wrap: wrap; gap: 8px; }
.pick button { border: 2px solid var(--line); background: #fff; border-radius: 14px; width: 52px; height: 52px; font-size: 1.6rem; }
.pick button.on { border-color: var(--ink); border-width: 3px; }
.colors button { background: var(--c); }
.seg { display: flex; flex-direction: column; gap: 6px; }
.seg button { border: 2px solid var(--line); background: #fff; border-radius: 12px; padding: 10px; font-weight: 700; text-align: left; }
.seg button.on { border-color: var(--accent); background: #FFF1E2; }
input[type=range] { width: 100%; accent-color: var(--accent); }
.qr { width: 100%; max-width: 280px; margin: 4px auto; display: block; image-rendering: pixelated; }
.url { text-align: center; font-weight: 800; word-break: break-all; margin: 0; -webkit-user-select: text; user-select: text; }

.netbar { position: fixed; top: 0; left: 0; right: 0; z-index: 10; background: #d92d20; color: #fff; text-align: center; font-weight: 700; font-size: .9rem; padding: max(8px, env(safe-area-inset-top)) 12px 8px; }
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); transform: translateX(-50%); background: rgba(20,20,22,.92); color: #fff; padding: 12px 18px; border-radius: 14px; font-weight: 700; font-size: .95rem; z-index: 20; max-width: 92vw; text-align: center; }
.h-sub { font-size: 1.1rem; margin: 14px 0 0; padding-top: 12px; border-top: 1px solid var(--line); }
.meter { height: 18px; border-radius: 999px; background: #eee; overflow: hidden; }
#m-bar { height: 100%; width: 0; background: var(--accent); transition: width .05s linear; }
.sel { width: 100%; padding: 12px; border: 2px solid var(--line); border-radius: 12px; background: #fff; font: inherit; }
