/* Puzzroom — fermag house style: cream paper, warm ink, terracotta accent, hairlines. */

:root {
  --cream: #faf9f5;
  --paper: #ffffff;
  --ink: #262624;
  --ink-2: #3c3a34;
  --muted: #6e6a62;
  --muted-2: #918c81;
  --line: #e6e2d8;
  --line-2: #d7d1c3;
  --accent: #c96442;
  --accent-deep: #a94e2f;
  --accent-soft: #f8ece6;
  --green: #3f7d5e;
  --radius: 22px;
  --radius-sm: 12px;
  --shadow: 0 1px 2px rgba(38, 38, 36, 0.04), 0 18px 44px -22px rgba(38, 38, 36, 0.22);
  --font-display: 'Bricolage Grotesque', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
  --font: ui-sans-serif, system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, monospace;
  --bar: 74px;
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; overflow-x: clip; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body[data-view='room'] {
  background: #1c1b18;
  color: var(--cream);
  overflow: hidden;
  overscroll-behavior: none;
}

[hidden], .is-hidden { display: none !important; }

.sprite { position: absolute; width: 0; height: 0; overflow: hidden; }

.ico {
  width: 18px;
  height: 18px;
  flex: 0 0 auto;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

a { color: inherit; text-decoration: none; }

button { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

h1, h2, h3, .brand-word { font-family: var(--font-display); font-weight: 600; letter-spacing: -0.025em; }

/* ------------------------------------------------------------------ nav */
.topnav {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--bar);
  display: flex;
  align-items: center;
  gap: 32px;
  padding: 0 max(28px, calc((100vw - 1240px) / 2));
  background: rgba(250, 249, 245, 0.86);
  backdrop-filter: blur(14px) saturate(1.2);
  border-bottom: 1px solid var(--line);
}

body[data-view='room'] .topnav { display: none; }

.brand { display: inline-flex; align-items: center; gap: 10px; }

.brand-mark {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  color: var(--accent);
}
.brand-mark svg { width: 26px; height: 26px; fill: currentColor; }

.brand-word {
  font-size: 21px;
  letter-spacing: -0.04em;
  font-weight: 700;
  line-height: 1;
}

.topnav-links { display: flex; gap: 26px; margin-left: 12px; }

.topnav-links a {
  font-size: 14px;
  color: var(--muted);
  padding: 6px 0;
  border-bottom: 1px solid transparent;
  transition: color 0.18s ease, border-color 0.18s ease;
}
.topnav-links a:hover { color: var(--ink); border-bottom-color: var(--ink); }

.topnav-right { margin-left: auto; display: flex; align-items: center; gap: 12px; }

/* --------------------------------------------------------------- buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  height: 46px;
  padding: 0 22px;
  border-radius: 999px;
  border: 1px solid transparent;
  font-size: 14.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease, transform 0.18s ease;
  white-space: nowrap;
}
.btn:active { transform: translateY(1px); }
.btn .ico { width: 17px; height: 17px; }

.btn-primary { background: var(--ink); color: var(--cream); }
.btn-primary:hover { background: var(--accent); }

.btn-outline { border-color: var(--line-2); color: var(--ink); background: transparent; }
.btn-outline:hover { border-color: var(--ink); background: #fff; }

.btn-quiet { color: var(--ink); background: transparent; border-color: transparent; }
.btn-quiet:hover { background: rgba(38, 38, 36, 0.06); }

.btn-light { background: rgba(250, 249, 245, 0.1); color: var(--cream); border-color: rgba(250, 249, 245, 0.18); }
.btn-light:hover { background: rgba(250, 249, 245, 0.18); }

.btn-sm { height: 38px; padding: 0 15px; font-size: 13.5px; }
.btn-block { width: 100%; height: 50px; }

.icon-btn {
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, border-color 0.18s ease;
}
.icon-btn:hover { background: rgba(38, 38, 36, 0.07); }
.icon-btn-sm { width: 30px; height: 30px; }
.icon-btn-sm .ico { width: 15px; height: 15px; }
.icon-btn.is-on { background: var(--accent-soft); color: var(--accent-deep); }

/* ----------------------------------------------------------------- hero */
#view-home { padding-bottom: 40px; }

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1.02fr) minmax(0, 0.98fr);
  gap: clamp(24px, 5vw, 72px);
  align-items: center;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(40px, 7vw, 92px) 28px clamp(36px, 5vw, 64px);
}

.eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  margin: 0 0 18px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}
.eyebrow .pip {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 4px rgba(201, 100, 66, 0.14);
}

.hero h1 {
  margin: 0 0 22px;
  font-size: clamp(46px, 6.4vw, 84px);
  line-height: 0.94;
  letter-spacing: -0.04em;
}
.hero h1 .accent { color: var(--accent); }

.lede {
  margin: 0 0 30px;
  max-width: 46ch;
  font-size: clamp(16px, 1.3vw, 18px);
  color: var(--muted);
  line-height: 1.6;
}

.hero-actions { display: flex; flex-wrap: wrap; gap: 12px; }

.hero-facts {
  display: flex;
  gap: clamp(20px, 3vw, 44px);
  margin: 40px 0 0;
  padding: 22px 0 0;
  border-top: 1px solid var(--line);
}
.hero-facts div { display: flex; flex-direction: column; gap: 3px; }
.hero-facts dt { font-family: var(--font-display); font-size: 24px; font-weight: 600; letter-spacing: -0.03em; }
.hero-facts dd { margin: 0; font-size: 12.5px; color: var(--muted); }

.hero-art { position: relative; }

.hero-puzzle {
  width: 100%;
  height: auto;
  overflow: visible;
}
.hero-puzzle .hp {
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 16px 26px rgba(38, 38, 36, 0.22));
  animation: hp-in 0.9s cubic-bezier(0.22, 1, 0.36, 1) backwards;
}
.hero-puzzle .hp1 { animation-delay: 0.05s; }
.hero-puzzle .hp2 { animation-delay: 0.11s; }
.hero-puzzle .hp4 { animation-delay: 0.17s; }
.hero-puzzle .hp3 {
  transform: translate(-18px, 14px) rotate(-4deg);
  filter: drop-shadow(0 26px 34px rgba(38, 38, 36, 0.34));
  animation-delay: 0.23s;
}

@keyframes hp-in {
  from { opacity: 0; translate: 0 28px; scale: 0.96; }
  to { opacity: 1; translate: 0 0; scale: 1; }
}

.hero-puzzle .seam { fill: none; stroke: rgba(255, 255, 255, 0.34); stroke-width: 1.1; stroke-linejoin: round; }

.hero-badge {
  position: absolute;
  right: 2%;
  bottom: 3%;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 16px 10px 12px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-size: 13px;
  color: var(--muted);
}
.hero-badge b { color: var(--ink); font-weight: 600; }

.avatars { display: inline-flex; }
.avatars i {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-style: normal;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid var(--paper);
  margin-left: -8px;
}
.avatars i:first-child { margin-left: 0; }

/* ---------------------------------------------------------------- panel */
.panel {
  max-width: 1240px;
  margin: 0 auto clamp(28px, 4vw, 56px);
  padding: clamp(24px, 3vw, 40px);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 1px 2px rgba(38, 38, 36, 0.03);
}

.panel-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 32px;
  padding-bottom: 26px;
  margin-bottom: 28px;
  border-bottom: 1px solid var(--line);
}
.panel-head .eyebrow { margin-bottom: 9px; }
.panel-head h2 { margin: 0; font-size: clamp(26px, 2.6vw, 34px); }
.panel-note { margin: 0; max-width: 38ch; font-size: 14px; color: var(--muted); text-align: right; }

.create-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(300px, 0.65fr);
  gap: clamp(24px, 3vw, 44px);
}

.seg {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  background: #f3f0e9;
  border-radius: 999px;
  margin-bottom: 20px;
}
.seg-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: 38px;
  padding: 0 16px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--muted);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}
.seg-btn .ico { width: 16px; height: 16px; }
.seg-btn.is-active { background: var(--paper); color: var(--ink); box-shadow: 0 1px 3px rgba(38, 38, 36, 0.1); }

.gallery {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}
.g-item {
  position: relative;
  padding: 0;
  border: 0;
  background: #eee;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  aspect-ratio: 3 / 2;
  transition: transform 0.2s ease;
}
.g-item img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform 0.5s cubic-bezier(0.22, 1, 0.36, 1); }
.g-item:hover img { transform: scale(1.05); }
.g-item::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 12px;
  border: 2px solid transparent;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.g-item.is-active::after { border-color: var(--accent); box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.75); }
.g-item span {
  position: absolute;
  left: 8px;
  bottom: 8px;
  padding: 3px 8px;
  border-radius: 6px;
  background: rgba(24, 23, 20, 0.62);
  backdrop-filter: blur(6px);
  color: #fff;
  font-size: 11px;
  font-weight: 500;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.g-item:hover span, .g-item.is-active span { opacity: 1; transform: none; }

.drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 240px;
  padding: 28px;
  border: 1.5px dashed var(--line-2);
  border-radius: 16px;
  background: #fcfbf8;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.drop:hover, .drop.is-over { border-color: var(--accent); background: var(--accent-soft); }
.drop b { font-size: 16px; font-weight: 600; }
.drop > span:last-child { font-size: 12.5px; color: var(--muted); }
.drop-icon {
  width: 48px; height: 48px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--paper); border: 1px solid var(--line);
  color: var(--accent);
  margin-bottom: 4px;
}
.drop-icon .ico { width: 21px; height: 21px; }

.upload-state {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fcfbf8;
}
.upload-state img { width: 84px; height: 56px; object-fit: cover; border-radius: 8px; background: #eee; }
.upload-meta { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.upload-meta b { font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-meta span { font-size: 12px; color: var(--muted); }
.upload-state .btn { margin-left: auto; }

.create-side { display: flex; flex-direction: column; gap: 20px; }

.field { display: flex; flex-direction: column; gap: 8px; }
.field-top { display: flex; align-items: baseline; justify-content: space-between; }
.field label { font-size: 12.5px; font-weight: 600; letter-spacing: 0.01em; color: var(--ink-2); }
.field output {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.03em;
  color: var(--accent);
}
.field input[type='text'] {
  height: 46px;
  padding: 0 14px;
  border: 1px solid var(--line-2);
  border-radius: 12px;
  background: #fcfbf8;
  color: var(--ink);
  font: inherit;
  font-size: 14.5px;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.field input[type='text']:focus { outline: none; border-color: var(--ink); background: #fff; }
.field-hint { margin: 0; font-size: 12.5px; color: var(--muted); }
.field-hint b { color: var(--ink); font-weight: 600; }

input[type='range'] {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 26px;
  background: transparent;
  cursor: pointer;
}
input[type='range']::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent) 0%, var(--accent) var(--fill, 13%), var(--line-2) var(--fill, 13%), var(--line-2) 100%);
}
input[type='range']::-moz-range-track { height: 4px; border-radius: 2px; background: var(--line-2); }
input[type='range']::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
input[type='range']::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  margin-top: -7px;
  border-radius: 50%;
  background: var(--paper);
  border: 2px solid var(--ink);
  box-shadow: 0 1px 4px rgba(38, 38, 36, 0.22);
}
input[type='range']::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--paper); border: 2px solid var(--ink);
}

.range-ticks { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted-2); font-family: var(--mono); }

.create-foot { margin: 0; font-size: 12px; color: var(--muted); line-height: 1.5; }

/* ----------------------------------------------------------------- strip */
.strip {
  max-width: 1240px;
  margin: 0 auto clamp(28px, 4vw, 56px);
  padding: clamp(28px, 3.4vw, 46px) clamp(24px, 3vw, 44px);
  border-radius: 26px;
  background: var(--ink);
  color: var(--cream);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: center;
}
.strip .eyebrow { color: rgba(250, 249, 245, 0.55); margin-bottom: 10px; }
.strip h2 { margin: 0 0 8px; font-size: clamp(26px, 2.8vw, 36px); }
.strip-copy p:last-child { margin: 0; font-size: 14px; color: rgba(250, 249, 245, 0.66); max-width: 40ch; }

.join-form { display: flex; gap: 10px; justify-self: end; width: 100%; min-width: 0; max-width: 420px; }
.join-form input {
  flex: 1 1 0;
  width: 100%;
  min-width: 0;
  height: 54px;
  padding: 0 18px;
  border-radius: 14px;
  border: 1px solid rgba(250, 249, 245, 0.2);
  background: rgba(250, 249, 245, 0.07);
  color: var(--cream);
  font-family: var(--mono);
  font-size: 19px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
}
.join-form input::placeholder { color: rgba(250, 249, 245, 0.32); letter-spacing: 0.22em; }
.join-form input:focus { outline: none; border-color: var(--cream); background: rgba(250, 249, 245, 0.11); }
.join-form .btn { height: 54px; padding: 0 26px; background: var(--cream); color: var(--ink); border-radius: 14px; }
.join-form .btn:hover { background: var(--accent); color: #fff; }
.join-error { grid-column: 2; margin: -14px 0 0; font-size: 12.5px; color: #f0a68c; }

/* ----------------------------------------------------------------- rooms */
.rooms { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 14px; }

.room-card {
  position: relative;
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fcfbf8;
  transition: border-color 0.18s ease, transform 0.18s ease, box-shadow 0.18s ease;
}
.room-card:hover { border-color: var(--line-2); box-shadow: var(--shadow); transform: translateY(-2px); }
.room-card img { width: 96px; height: 84px; object-fit: cover; border-radius: 10px; background: #eee; }
.room-card-body { display: flex; flex-direction: column; gap: 3px; min-width: 0; padding-right: 26px; }
.room-card-body b { font-size: 14.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-card-body .code { font-family: var(--mono); font-size: 11.5px; letter-spacing: 0.12em; color: var(--muted); }
.room-card-progress { display: flex; align-items: center; gap: 8px; margin-top: auto; font-size: 11.5px; color: var(--muted); }
.room-card-progress .bar { flex: 1; height: 4px; border-radius: 2px; background: var(--line); overflow: hidden; }
.room-card-progress .bar i { display: block; height: 100%; background: var(--accent); border-radius: 2px; }
.room-card-del {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 0;
  background: transparent;
  color: var(--muted-2);
  cursor: pointer;
  display: grid;
  place-items: center;
  opacity: 0;
  transition: opacity 0.18s ease, background 0.18s ease, color 0.18s ease;
}
.room-card-del .ico { width: 14px; height: 14px; }
.room-card:hover .room-card-del { opacity: 1; }
.room-card-del:hover { background: #fbe9e4; color: var(--accent-deep); }

.rooms-empty {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 26px;
  border: 1px dashed var(--line-2);
  border-radius: 16px;
  color: var(--muted);
  font-size: 14px;
}
.rooms-empty .ico { width: 20px; height: 20px; color: var(--muted-2); }
.rooms-empty p { margin: 0; }

/* ------------------------------------------------------------------- how */
.how { max-width: 1240px; margin: 0 auto; padding: clamp(20px, 4vw, 52px) 28px clamp(30px, 5vw, 70px); }
.how-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: clamp(18px, 3vw, 40px); }
.how article { padding-top: 20px; border-top: 1px solid var(--line-2); }
.how-num { font-family: var(--mono); font-size: 11.5px; color: var(--accent); letter-spacing: 0.14em; }
.how h3 { margin: 10px 0 8px; font-size: 19px; }
.how p { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.6; max-width: 34ch; }

/* ------------------------------------------------------------------ foot */
.foot {
  max-width: 1240px;
  margin: 0 auto;
  padding: 26px 28px 44px;
  border-top: 1px solid var(--line);
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 24px;
  font-size: 12.5px;
  color: var(--muted);
}
.foot-brand { display: flex; flex-direction: column; gap: 4px; }
.foot-brand .brand-word { font-size: 17px; color: var(--ink); }
.foot-note { max-width: 46ch; text-align: right; }

/* ================================================================ ROOM */
.room { position: fixed; inset: 0; display: flex; flex-direction: column; }

.room-bar {
  position: relative;
  z-index: 20;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 18px;
  height: 70px;
  padding: 0 16px;
  background: rgba(24, 23, 20, 0.9);
  backdrop-filter: blur(16px) saturate(1.1);
  border-bottom: 1px solid rgba(250, 249, 245, 0.09);
}

.room-left { display: flex; align-items: center; gap: 10px; min-width: 0; }
.room-left .icon-btn { color: rgba(250, 249, 245, 0.72); }
.room-left .icon-btn:hover { background: rgba(250, 249, 245, 0.1); color: var(--cream); }

.room-title { min-width: 0; }
.room-title h1 {
  margin: 0;
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--cream);
  max-width: 34ch;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.room-sub { display: flex; align-items: center; gap: 8px; margin-top: 2px; font-size: 11.5px; color: rgba(250, 249, 245, 0.5); }
.room-sub .sep { opacity: 0.5; }

.code-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 7px;
  border: 1px solid rgba(250, 249, 245, 0.16);
  border-radius: 7px;
  background: rgba(250, 249, 245, 0.07);
  color: rgba(250, 249, 245, 0.86);
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}
.code-chip .ico { width: 12px; height: 12px; opacity: 0.6; }
.code-chip:hover { border-color: var(--accent); color: var(--cream); background: rgba(201, 100, 66, 0.16); }

.room-progress { flex: 1 1 auto; max-width: 360px; margin: 0 auto; display: flex; flex-direction: column; gap: 5px; }
.room-progress .bar { height: 5px; border-radius: 3px; background: rgba(250, 249, 245, 0.12); overflow: hidden; }
.room-progress .bar span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  background: linear-gradient(90deg, #d0734f, var(--accent));
  transition: width 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}
.progress-text { text-align: center; font-size: 11px; color: rgba(250, 249, 245, 0.52); font-family: var(--mono); }
.progress-text b { color: var(--cream); font-weight: 500; }

.room-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.room-actions .icon-btn { color: rgba(250, 249, 245, 0.7); }
.room-actions .icon-btn:hover { background: rgba(250, 249, 245, 0.1); color: var(--cream); }

.players { display: flex; margin-right: 4px; }
.players i {
  width: 26px;
  height: 26px;
  margin-left: -7px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-style: normal;
  font-size: 10.5px;
  font-weight: 700;
  color: #fff;
  border: 2px solid #1a1917;
}
.players i:first-child { margin-left: 0; }

.stage { position: relative; flex: 1 1 auto; min-height: 0; background: radial-gradient(120% 90% at 50% 0%, #26241f 0%, #1a1916 60%, #151412 100%); }
#board { display: block; width: 100%; height: 100%; cursor: grab; }
#board.is-dragging { cursor: grabbing; }
#board.is-panning { cursor: move; }

.zoombox {
  position: absolute;
  left: 16px;
  bottom: 16px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(24, 23, 20, 0.82);
  border: 1px solid rgba(250, 249, 245, 0.12);
  backdrop-filter: blur(10px);
}
.zoombox button {
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: rgba(250, 249, 245, 0.74);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.16s ease, color 0.16s ease;
}
.zoombox button:hover { background: rgba(250, 249, 245, 0.12); color: var(--cream); }
.zoombox .ico { width: 16px; height: 16px; }

.room-hint {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(92vw, 560px);
  padding: 9px 10px 9px 16px;
  border-radius: 999px;
  background: rgba(24, 23, 20, 0.8);
  border: 1px solid rgba(250, 249, 245, 0.1);
  backdrop-filter: blur(10px);
  color: rgba(250, 249, 245, 0.66);
  font-size: 12px;
  line-height: 1.4;
  transition: opacity 0.4s ease;
}
.room-hint.is-gone { opacity: 0; pointer-events: none; }
.hint-close { width: 24px; height: 24px; border: 0; border-radius: 50%; background: transparent; color: inherit; display: grid; place-items: center; cursor: pointer; flex: 0 0 auto; }
.hint-close .ico { width: 13px; height: 13px; }
.hint-close:hover { background: rgba(250, 249, 245, 0.12); }

.chat-fab {
  position: absolute;
  right: 16px;
  bottom: 16px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 1px solid rgba(250, 249, 245, 0.14);
  background: rgba(24, 23, 20, 0.86);
  backdrop-filter: blur(10px);
  color: var(--cream);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.18s ease;
}
.chat-fab:hover { background: var(--accent); transform: translateY(-1px); }
.chat-dot { position: absolute; top: 9px; right: 9px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); border: 2px solid #1a1917; }

.chat {
  position: absolute;
  right: 16px;
  bottom: 76px;
  width: 320px;
  max-height: min(480px, 62vh);
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: rgba(26, 25, 22, 0.94);
  border: 1px solid rgba(250, 249, 245, 0.12);
  box-shadow: 0 24px 60px -24px rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(16px);
  overflow: hidden;
}
.chat-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 10px 12px 16px; border-bottom: 1px solid rgba(250, 249, 245, 0.08); }
.chat-head b { font-size: 13px; font-weight: 600; }
.chat-head .icon-btn { color: rgba(250, 249, 245, 0.6); }
.chat-log { flex: 1; overflow-y: auto; padding: 12px 16px; display: flex; flex-direction: column; gap: 9px; min-height: 80px; }
.chat-msg { font-size: 13px; line-height: 1.45; color: rgba(250, 249, 245, 0.86); overflow-wrap: anywhere; }
.chat-msg b { display: block; font-size: 11px; font-weight: 600; margin-bottom: 1px; }
.chat-empty { margin: auto 0; text-align: center; font-size: 12px; color: rgba(250, 249, 245, 0.4); }
.chat-form { display: flex; gap: 6px; padding: 10px; border-top: 1px solid rgba(250, 249, 245, 0.08); }
.chat-form input {
  flex: 1;
  min-width: 0;
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid rgba(250, 249, 245, 0.14);
  background: rgba(250, 249, 245, 0.06);
  color: var(--cream);
  font: inherit;
  font-size: 13px;
}
.chat-form input:focus { outline: none; border-color: var(--accent); }
.chat-form input::placeholder { color: rgba(250, 249, 245, 0.34); }
.chat-form .icon-btn { color: var(--cream); background: rgba(250, 249, 245, 0.1); }
.chat-form .icon-btn:hover { background: var(--accent); }

.toast {
  position: absolute;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 8px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(250, 249, 245, 0.95);
  color: var(--ink);
  font-size: 13px;
  font-weight: 500;
  box-shadow: 0 12px 30px -12px rgba(0, 0, 0, 0.6);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  pointer-events: none;
}
.toast.is-on { opacity: 1; transform: translate(-50%, 0); }

/* --------------------------------------------------------------- responsive */
@media (max-width: 1080px) {
  .hero { grid-template-columns: 1fr; }
  .hero-art { order: -1; max-width: 560px; }
  .create-grid { grid-template-columns: 1fr; }
  .studio { grid-template-columns: 1fr; }
  .rooms { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .panel-note { display: none; }
}

@media (max-width: 860px) {
  :root { --bar: 64px; }
  .topnav { padding: 0 18px; gap: 16px; }
  .topnav-links { display: none; }
  .hero { padding: 26px 18px 34px; }
  .hero h1 { font-size: clamp(40px, 11vw, 60px); }
  .hero-facts { gap: 18px; margin-top: 30px; }
  .hero-facts dt { font-size: 19px; }
  .panel { margin-left: 14px; margin-right: 14px; border-radius: 20px; padding: 20px 16px; }
  .gallery { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .strip { margin-left: 14px; margin-right: 14px; grid-template-columns: minmax(0, 1fr); padding: 24px 18px; border-radius: 20px; }
  .join-form { justify-self: stretch; max-width: none; }
  .join-error { grid-column: 1; }
  .rooms { grid-template-columns: 1fr; }
  .how { padding: 10px 18px 40px; }
  .how-grid { grid-template-columns: 1fr; gap: 22px; }
  .foot { flex-direction: column; align-items: flex-start; padding: 22px 18px 34px; }
  .foot-note { text-align: left; }
  .room-hint { font-size: 11px; top: 10px; }
}

@media (max-width: 720px) {
  .room-bar { height: auto; padding: 10px 12px; flex-wrap: wrap; gap: 10px; }
  .room-left { flex: 1 1 auto; order: 1; }
  .room-actions { order: 2; gap: 2px; }
  .room-actions .btn { height: 34px; padding: 0 12px; font-size: 12.5px; }
  .hide-sm { display: none; }
  .room-progress { order: 3; flex: 1 1 100%; max-width: none; margin: 0; }
  .room-title h1 { max-width: 46vw; font-size: 13.5px; }
  .players { display: none; }
  .chat { right: 8px; left: 8px; width: auto; bottom: 68px; max-height: 56vh; }
  .zoombox { left: 10px; bottom: 10px; }
  .chat-fab { right: 10px; bottom: 10px; }
  .room-hint { display: none; }
  .toast { bottom: 72px; font-size: 12px; max-width: 88vw; text-align: center; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* ---------------------------------------------------------------- modal */
.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(18, 17, 15, 0.62);
  backdrop-filter: blur(4px);
  animation: fade-in 0.18s ease;
}
.modal-card {
  width: min(420px, 100%);
  padding: 26px 24px 20px;
  border-radius: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.6);
  color: var(--ink);
}
.modal-card h3 { margin: 0 0 8px; font-size: 20px; }
.modal-card p { margin: 0 0 22px; font-size: 14px; line-height: 1.55; color: var(--muted); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; }
@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.room-error {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 24px;
  text-align: center;
  color: var(--cream);
}
.room-error h2 { margin: 0; font-size: 26px; }
.room-error p { margin: 0 0 12px; color: rgba(250, 249, 245, 0.6); font-size: 14px; }


/* --------------------------------------------------------------- finish */
.finish {
  position: absolute;
  inset: 0;
  z-index: 150;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(14, 13, 11, 0.72);
  backdrop-filter: blur(6px);
  animation: fade-in 0.3s ease;
}
.finish-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  width: min(780px, 100%);
  overflow: hidden;
  border-radius: 22px;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: 0 40px 100px -40px rgba(0, 0, 0, 0.8);
  color: var(--ink);
}
.finish-media { background: #1a1916; }
.finish-media img { display: block; width: 100%; height: 100%; max-height: 62vh; object-fit: contain; }
.finish-body { padding: 26px 24px; display: flex; flex-direction: column; }
.finish-body h2 { margin: 0 0 6px; font-size: 28px; }
.finish-meta { margin: 0 0 22px; font-size: 13.5px; color: var(--muted); }
.finish-actions { margin-top: auto; display: flex; flex-direction: column; gap: 8px; }
.finish-actions .btn { width: 100%; }
@media (max-width: 720px) {
  .finish-card { grid-template-columns: 1fr; max-height: 88vh; overflow: auto; }
  .finish-media img { max-height: 38vh; }
}
