:root {
  color-scheme: dark;
  --bg: #2a1248;
  --ink: #2a1740;
  --paper: #fff7ee;
  --muted: #f3d7ff;
  --line: #ffffff2e;
  --coral: #ff4d6d;
  --gold: #ffc857;
  --mint: #2ee6a6;
  --blue: #7aa2ff;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Noto Sans JP", system-ui, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--paper);
  background:
    radial-gradient(circle at 12% -10%, #ff4d6d55, transparent 36%),
    radial-gradient(circle at 100% 0%, #ffc85744, transparent 32%),
    linear-gradient(180deg, #42175f, var(--bg) 42%, #1b0c31);
}
#fx { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 20; }
main {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 16px 16px calc(28px + env(safe-area-inset-bottom));
}
.top, .roombar, .roomactions, .choice, .dock, .join { display: flex; gap: 8px; flex-wrap: wrap; }
.top, .roombar { justify-content: space-between; align-items: center; }
.top { min-width: 0; }
a { color: var(--gold); text-decoration: none; }
h1, h2, h3, p, li, button, label, .nm, .hint { overflow-wrap: anywhere; }
h1 {
  margin: 0;
  max-width: 100%;
  font-size: clamp(2rem, 5.2vw, 4.4rem);
  line-height: 1.08;
  letter-spacing: -0.03em;
}
h1 span { color: var(--gold); }
h2, h3, p { margin-top: 0; }
.eyebrow { margin: 18px 0 8px; letter-spacing: 0.18em; font-weight: 800; color: var(--gold); }
.lead { font-size: 1.15rem; line-height: 1.6; max-width: 40rem; }
.fieldlabel, .setup h3, .iconbox h3 { margin: 16px 0 8px; font-size: 1rem; }
.iconbox h3, .setup h3:first-child, .fieldlabel { margin-top: 0; }
.panel, .promptcard, .group, .acard, .who, .person, .step {
  background: #ffffff14;
  border: 1px solid var(--line);
  border-radius: 22px;
}
.panel { padding: 18px; margin: 14px 0 18px; min-width: 0; }
.iconbox { margin-bottom: 14px; }
label { display: block; font-weight: 800; min-width: 0; }
input, select, button { max-width: 100%; }
input, select {
  width: 100%;
  margin-top: 8px;
  min-height: 52px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid #ffffff55;
  background: #1b0c31;
  color: white;
  font: inherit;
  font-size: 16px;
}
button, .choice button {
  min-height: 48px;
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid #ffffff44;
  background: #ffffff18;
  color: white;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}
button.primary, .choice button[aria-pressed="true"] { background: var(--gold); color: #3a2500; border-color: var(--gold); }
button:disabled { opacity: 0.45; cursor: not-allowed; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible { outline: 3px solid var(--mint); outline-offset: 2px; }
#create { width: 100%; }
#status { min-height: 1.4em; margin: 8px 0; }
.join { align-items: end; margin-top: 16px; }
.join label { flex: 1 1 160px; min-width: 0; }
.choice button { flex: 1 1 96px; }
.roombar {
  margin: 8px 0 14px;
  padding: 12px 14px;
  border-radius: 22px;
  background: #00000033;
  min-width: 0;
}
.roombar > div:first-child { min-width: 0; }
.roombar strong {
  display: block;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  letter-spacing: 0.08em;
}
.roomactions { justify-content: flex-end; }
.promptcard { padding: 18px 18px 14px; background: var(--paper); color: var(--ink); text-align: center; min-width: 0; }
.kicker { margin: 0; color: #a14b68; font-weight: 800; letter-spacing: 0.06em; }
#promptText, .banner h2 {
  margin: 6px 0;
  font-size: clamp(1.45rem, 3.2vw, 2.6rem);
  line-height: 1.3;
}
.timer { margin: 0; font-variant-numeric: tabular-nums; font-size: clamp(1.4rem, 3vw, 1.8rem); font-weight: 900; }
.banner { text-align: center; padding: 4px 0; }
.banner .note { margin: 0; font-weight: 800; color: var(--gold); }
.banner.match h2 { color: var(--gold); font-size: clamp(2rem, 5vw, 3.4rem); }
.lobby-grid, .result-grid { display: grid; gap: 16px; min-width: 0; }
.side, .setup, .groups, .board, .chips { min-width: 0; }
.chips {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
  gap: 8px;
  margin: 12px 0;
}
.chip {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 16px;
  background: #ffffff18;
}
.chip .nm { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.people, .roster, .board { list-style: none; padding: 0; margin: 12px 0; display: grid; gap: 8px; }
.person, .who {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 8px 10px;
  border-radius: 16px;
  background: #ffffff18;
  border: 1px solid var(--line);
}
.person em, .who small { font-style: normal; color: var(--muted); font-weight: 700; }
.person.in { outline: 2px solid var(--mint); }
.person.typing em { color: var(--gold); }
.who.off { opacity: 0.62; }
.avatar {
  width: 36px; height: 36px; display: grid; place-items: center; flex: 0 0 auto;
  border-radius: 50%; font-size: 1.15rem; background: var(--gold);
}
.groups { display: grid; grid-template-columns: minmax(0, 1fr); gap: 12px; }
.group { padding: 12px; min-width: 0; }
.group h3 { margin: 0 0 8px; }
.group.sel { outline: 3px solid var(--gold); }
.cards { display: grid; gap: 8px; min-width: 0; }
.acard {
  min-width: 0;
  margin: 0;
  padding: 12px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}
.acard header {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}
.acard header strong { min-width: 0; }
.acard p { margin: 8px 0 0; font-size: clamp(1.2rem, 2vw, 1.6rem); font-weight: 900; line-height: 1.35; }
.acard button { width: auto; min-height: 40px; padding: 8px 10px; background: #2a1740; color: #fff7ee; border-color: #2a1740; }
.acard.sel { outline: 3px solid var(--coral); }
.hint { color: var(--muted); line-height: 1.5; }
.scoreline {
  display: grid;
  grid-template-columns: 3.4rem 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 16px;
  background: #ffffff18;
}
.scoreline .place { font-weight: 900; color: var(--gold); }
.scoreline .nm { min-width: 0; }
.scoreline strong { font-size: 1.15rem; text-align: right; }
.scoreline.lead { outline: 2px solid var(--gold); }
.delta { color: var(--mint); font-style: normal; font-weight: 900; margin-left: 6px; white-space: nowrap; }
.podium { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 8px; margin: 8px 0 4px; }
.podium:empty { display: none; }
.step { min-width: 0; padding: 12px; }
.step.r1 { background: #ffc85724; outline: 2px solid var(--gold); }
.step b { display: block; margin-bottom: 6px; }
.step span { display: flex; align-items: center; gap: 8px; min-width: 0; margin: 6px 0; }
.step em { font-style: normal; font-weight: 800; min-width: 0; }
.step small { margin-left: auto; font-weight: 900; white-space: nowrap; }
.icons {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(46px, 1fr));
  gap: 6px;
}
.iconbtn {
  aspect-ratio: 1;
  min-height: 44px;
  padding: 0;
  font-size: 1.3rem;
  line-height: 1;
}
.iconbtn[aria-pressed="true"] { outline: 3px solid #fff7ee; outline-offset: 2px; }
.composer, .dock {
  z-index: 5;
  align-items: center;
  margin-top: 8px;
  padding: 12px;
  background: #1b0c31f2;
  border: 1px solid var(--line);
  border-radius: 16px;
}
.dock { position: static; }
.composer {
  position: sticky;
  bottom: 52px;
}
.dock button, #hostOpen button { flex: 1 1 160px; }
#hostOpen button { margin: 8px 0; }
.composer { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px; }
.how { min-width: 0; }
.how li { margin: 10px 0; line-height: 1.55; }
.setup.locked { opacity: 0.72; }
[hidden] { display: none !important; }
@media (min-width: 720px) {
  .people { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .groups { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .group:only-child { grid-column: 1 / -1; }
  .group:only-child .cards { grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
  .composer { grid-template-columns: minmax(0, 1fr) auto; align-items: end; }
  .composer button { width: auto; min-width: 180px; }
}
@media (min-width: 960px) {
  #entry {
    display: grid;
    grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
    column-gap: 24px;
    align-items: start;
  }
  #entry > .eyebrow, #entry > h1, #entry > .lead { grid-column: 1 / -1; }
  #entry > .panel { margin-top: 0; }
  .lobby-grid, .result-grid { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .result-grid .groups { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 1200px) {
  .groups { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .people { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .result-grid .groups { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 719px) {
  .dock button.primary, #hostOpen button { flex-basis: 100%; }
}
.acard { animation: pop 0.35s ease both; }
@media (prefers-reduced-motion: reduce) {
  .acard { animation: none; }
}
@keyframes pop { from { transform: scale(.92); opacity: 0; } to { transform: none; opacity: 1; } }
