/* ============================================================
   TTC Team Exercises - design system
   ============================================================ */

:root {
  --bg: #080b16;
  --bg-2: #0d1226;
  --surface: rgba(23, 30, 54, 0.72);
  --surface-solid: #161d33;
  --surface-2: rgba(35, 45, 78, 0.6);
  --border: rgba(126, 148, 197, 0.18);
  --border-strong: rgba(126, 148, 197, 0.34);
  --text: #eef2fb;
  --muted: #93a1c0;
  --dim: #6b7897;

  --violet: #7c5cff;
  --indigo: #4d7cff;
  --cyan: #35d6f5;
  --mint: #2fe0a8;
  --lime: #b8f24a;
  --amber: #ffb347;
  --pink: #ff5fa2;
  --red: #ff5f6d;

  --grad-hot: linear-gradient(135deg, #7c5cff 0%, #ff5fa2 100%);
  --grad-cool: linear-gradient(135deg, #4d7cff 0%, #35d6f5 100%);
  --grad-win: linear-gradient(135deg, #2fe0a8 0%, #b8f24a 100%);

  --r-sm: 10px;
  --r-md: 16px;
  --r-lg: 22px;
  --r-xl: 30px;

  --shadow-sm: 0 4px 16px rgba(3, 6, 18, 0.4);
  --shadow-md: 0 14px 44px rgba(3, 6, 18, 0.5);
  --shadow-glow: 0 0 0 1px rgba(124, 92, 255, 0.35), 0 12px 40px rgba(124, 92, 255, 0.28);

  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

button {
  font: inherit;
  color: inherit;
}

body {
  margin: 0;
  font-family: 'Outfit', 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

::selection { background: rgba(124, 92, 255, 0.4); }

/* ---------- scrollbars ---------- */
*::-webkit-scrollbar { width: 9px; height: 9px; }
*::-webkit-scrollbar-track { background: transparent; }
*::-webkit-scrollbar-thumb {
  background: rgba(126, 148, 197, 0.24);
  border-radius: 99px;
}
*::-webkit-scrollbar-thumb:hover { background: rgba(126, 148, 197, 0.4); }

/* ============================================================
   Animated background
   ============================================================ */

.aurora {
  position: fixed;
  inset: 0;
  z-index: -2;
  overflow: hidden;
  background:
    radial-gradient(120% 90% at 12% -10%, #1b2350 0%, transparent 55%),
    radial-gradient(100% 80% at 100% 0%, #2a1a4d 0%, transparent 50%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 60%);
}

.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.5;
  will-change: transform;
}

.blob-a {
  width: 46vw; height: 46vw;
  left: -8vw; top: -10vw;
  background: radial-gradient(circle, #6d4bff 0%, transparent 68%);
  animation: drift-a 26s ease-in-out infinite;
}

.blob-b {
  width: 40vw; height: 40vw;
  right: -6vw; top: 8vh;
  background: radial-gradient(circle, #ff4d94 0%, transparent 68%);
  animation: drift-b 32s ease-in-out infinite;
}

.blob-c {
  width: 44vw; height: 44vw;
  left: 28vw; bottom: -18vw;
  background: radial-gradient(circle, #1fc4e8 0%, transparent 68%);
  animation: drift-c 29s ease-in-out infinite;
}

.grain {
  position: absolute;
  inset: 0;
  opacity: 0.16;
  background-image: radial-gradient(rgba(255, 255, 255, 0.5) 0.5px, transparent 0.5px);
  background-size: 3px 3px;
  mix-blend-mode: overlay;
}

@keyframes drift-a {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1); }
  50% { transform: translate3d(6vw, 8vh, 0) scale(1.14); }
}
@keyframes drift-b {
  0%, 100% { transform: translate3d(0, 0, 0) scale(1.05); }
  50% { transform: translate3d(-7vw, 12vh, 0) scale(0.9); }
}
@keyframes drift-c {
  0%, 100% { transform: translate3d(0, 0, 0) scale(0.95); }
  50% { transform: translate3d(5vw, -10vh, 0) scale(1.16); }
}

#fx-canvas {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
}

/* ============================================================
   Shared bits
   ============================================================ */

.brand-mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  flex-shrink: 0;
  border-radius: 50%;
  background:
    radial-gradient(circle at 35% 30%, rgba(255, 255, 255, 0.18), transparent 45%),
    linear-gradient(145deg, #1a3a5c 0%, #0b1f33 55%, #163d2a 100%);
  border: 2px solid rgba(212, 175, 55, 0.55);
  box-shadow:
    0 0 0 3px rgba(11, 16, 32, 0.65),
    0 8px 22px rgba(0, 0, 0, 0.35);
  overflow: hidden;
}
.brand-mark-sm {
  width: 36px;
  height: 36px;
  border-width: 1.5px;
  box-shadow:
    0 0 0 2px rgba(11, 16, 32, 0.65),
    0 4px 12px rgba(0, 0, 0, 0.3);
}
.brand-monogram {
  font-size: 0.95rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #f4e4a6;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.45);
  z-index: 0;
}
.brand-mark-sm .brand-monogram { font-size: 0.55rem; letter-spacing: 0.02em; }
.brand-seal {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  z-index: 1;
  background: #fff;
}

.avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  color: #fff;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.35);
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.16);
  flex-shrink: 0;
}
.avatar-sm { width: 26px; height: 26px; font-size: 0.62rem; }
.avatar-lg { width: 52px; height: 52px; font-size: 1rem; }

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  padding: 2px 7px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 99px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-size: 0.8rem;
  font-weight: 600;
  white-space: nowrap;
}
.pill-live { color: var(--mint); }

.pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--mint);
  box-shadow: 0 0 0 0 rgba(47, 224, 168, 0.7);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(47, 224, 168, 0.6); }
  70% { box-shadow: 0 0 0 9px rgba(47, 224, 168, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 224, 168, 0); }
}

/* ---------- buttons ---------- */

.btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  overflow: hidden;
  transition: transform 0.16s var(--ease-bounce), border-color 0.2s, background 0.2s, box-shadow 0.2s;
}
.btn:hover { transform: translateY(-2px); border-color: rgba(124, 92, 255, 0.6); }
.btn:active { transform: translateY(0) scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; transform: none; }

.btn::after {
  content: '';
  position: absolute;
  top: 0; left: -60%;
  width: 40%; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.22), transparent);
  transform: skewX(-20deg);
  transition: left 0.5s var(--ease-out);
}
.btn:hover::after { left: 120%; }

.btn-primary {
  background: var(--grad-hot);
  border-color: transparent;
  color: #fff;
  box-shadow: var(--shadow-glow);
}
.btn-success { background: var(--grad-win); border-color: transparent; color: #06210f; }
.btn-cool { background: var(--grad-cool); border-color: transparent; color: #04182b; }
.btn-danger { background: linear-gradient(135deg, #ff5f6d, #ff2d55); border-color: transparent; color: #fff; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }
.btn-lg { padding: 14px 20px; font-size: 1rem; }
.btn-sm { padding: 7px 12px; font-size: 0.82rem; }

.btn-send {
  padding: 10px 13px;
  background: var(--grad-cool);
  border-color: transparent;
  color: #04182b;
}

/* ---------- form fields ---------- */

.field { margin-bottom: 16px; }
.field-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.field-row .field { margin-bottom: 16px; }
.field label, .field-label {
  display: block;
  margin-bottom: 7px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--muted);
  letter-spacing: 0.02em;
}

input[type='text'], input[type='password'], textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: rgba(10, 14, 30, 0.6);
  color: var(--text);
  font: inherit;
  font-size: 0.95rem;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}
input::placeholder, textarea::placeholder { color: var(--dim); }
input:focus, textarea:focus, select:focus {
  outline: none;
  border-color: rgba(124, 92, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(124, 92, 255, 0.16);
  background: rgba(10, 14, 30, 0.85);
}
textarea { resize: vertical; min-height: 88px; }

.form-error {
  margin: 12px 0 0;
  padding: 10px 12px;
  border-radius: var(--r-sm);
  background: rgba(255, 95, 109, 0.12);
  border: 1px solid rgba(255, 95, 109, 0.35);
  color: #ffb3b8;
  font-size: 0.88rem;
  animation: shake 0.4s;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(3px); }
}

/* ============================================================
   Join screen
   ============================================================ */

.join-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  color: #fff;
}

.join-card {
  width: min(500px, 100%);
  padding: 30px;
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow-md);
  animation: card-in 0.7s var(--ease-out) both;
}

@keyframes card-in {
  from { opacity: 0; transform: translateY(26px) scale(0.97); }
  to { opacity: 1; transform: none; }
}

.join-brand {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 26px;
}
.brand-kicker {
  margin: 0 0 4px;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #d4af37;
  line-height: 1.25;
}
.join-brand h1 {
  margin: 0;
  font-size: 1.45rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #fff;
}
.subtitle { margin: 3px 0 0; color: var(--muted); font-size: 0.88rem; }

.color-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
  gap: 8px;
}
.color-swatch {
  height: 34px;
  border-radius: 10px;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.18s var(--ease-bounce), box-shadow 0.2s;
}
.color-swatch:hover { transform: translateY(-3px) scale(1.06); }
.color-swatch.is-active {
  border-color: #fff;
  transform: translateY(-2px) scale(1.08);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}

.role-toggle { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.role-btn {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 13px;
  border-radius: var(--r-md);
  border: 1px solid var(--border);
  background: rgba(10, 14, 30, 0.5);
  color: var(--text);
  cursor: pointer;
  font: inherit;
  text-align: left;
  transition: transform 0.18s var(--ease-bounce), border-color 0.2s, background 0.2s;
}
.role-btn small { color: var(--dim); font-size: 0.76rem; }
.role-btn:hover { transform: translateY(-2px); }
.role-btn.is-active {
  border-color: rgba(124, 92, 255, 0.75);
  background: rgba(124, 92, 255, 0.14);
  box-shadow: 0 0 0 3px rgba(124, 92, 255, 0.12);
}
.role-btn.is-active small { color: #c9bcff; }

/* ============================================================
   App shell
   ============================================================ */

.app {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  animation: fade-in 0.5s var(--ease-out) both;
}

@media (min-width: 1081px) {
  .app {
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }
}

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }

.topbar-stack {
  position: sticky;
  top: 0;
  z-index: 30;
}

.topbar {
  position: relative;
  z-index: 31;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 20px;
  background: rgba(11, 15, 32, 0.72);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-title { display: flex; flex-direction: column; min-width: 0; }
.topbar-title strong { font-size: 1rem; font-weight: 800; letter-spacing: -0.01em; }
.topbar-sub {
  font-size: 0.78rem;
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-right { display: flex; align-items: center; gap: 10px; }

.me-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 12px 5px 5px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  transition: border-color 0.2s, transform 0.16s var(--ease-bounce);
}
.me-chip:hover { transform: translateY(-1px); border-color: var(--border-strong); }
.me-meta { display: flex; flex-direction: column; align-items: flex-start; line-height: 1.15; }
.me-meta strong { font-size: 0.85rem; }
.me-meta small { font-size: 0.7rem; color: var(--mint); font-weight: 700; }

.logout-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: color 0.2s, border-color 0.2s, background 0.2s, transform 0.16s var(--ease-bounce);
}
.logout-btn:hover {
  color: var(--text);
  border-color: var(--border-strong);
  background: rgba(255, 255, 255, 0.04);
  transform: translateY(-1px);
}
.logout-btn span { display: none; }
@media (min-width: 720px) {
  .logout-btn span { display: inline; }
}

/* ---------- timer ring ---------- */

.timer-ring {
  position: relative;
  width: 46px; height: 46px;
  display: grid;
  place-items: center;
  animation: pop-in 0.35s var(--ease-bounce) both;
}
.timer-ring svg { position: absolute; inset: 0; width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-track { fill: none; stroke: rgba(126, 148, 197, 0.2); stroke-width: 4; }
.ring-progress {
  fill: none;
  stroke: url(#none);
  stroke: var(--cyan);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 0;
  transition: stroke 0.3s;
}
.timer-ring span {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--cyan);
}
.timer-ring.is-low .ring-progress { stroke: var(--red); }
.timer-ring.is-low span { color: var(--red); }
.timer-ring.is-low { animation: tick-shake 0.9s ease-in-out infinite; }

@keyframes tick-shake {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.1); }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.6); }
  to { opacity: 1; transform: scale(1); }
}

/* ---------- round timer bar ---------- */

.round-timer {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 12px;
  padding: 8px 20px 10px;
  background: rgba(11, 15, 32, 0.88);
  backdrop-filter: blur(18px);
  border-bottom: 1px solid var(--border);
  animation: fade-in 0.25s var(--ease-out) both;
}
.round-timer.hidden { display: none; }

.round-timer-track {
  position: relative;
  height: 10px;
  border-radius: 99px;
  background: rgba(126, 148, 197, 0.16);
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(126, 148, 197, 0.12);
}
.round-timer-fill {
  position: absolute;
  inset: 0 auto 0 0;
  width: 100%;
  transform: scaleX(1);
  transform-origin: left center;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--indigo), var(--cyan) 55%, var(--mint));
  box-shadow: 0 0 18px rgba(53, 214, 245, 0.35);
  will-change: transform;
}
.round-timer-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 7.5rem;
  justify-content: flex-end;
}
.round-timer-meta #round-timer-label {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.round-timer-meta #round-timer-clock {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--cyan);
  min-width: 3.2rem;
  text-align: right;
}

.round-timer.is-warn .round-timer-fill {
  background: linear-gradient(90deg, var(--amber), #ff8a3d);
  box-shadow: 0 0 18px rgba(255, 179, 71, 0.4);
}
.round-timer.is-warn #round-timer-clock { color: var(--amber); }

.round-timer.is-low .round-timer-fill {
  background: linear-gradient(90deg, var(--red), var(--pink));
  box-shadow: 0 0 18px rgba(255, 95, 109, 0.45);
  animation: bar-pulse 0.9s ease-in-out infinite;
}
.round-timer.is-low #round-timer-clock,
.round-timer.is-low #round-timer-label { color: var(--red); }

@keyframes bar-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}

/* ---------- layout ---------- */

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  width: 100%;
  max-width: 1560px;
  margin: 0 auto;
  padding: 16px 20px 132px;
  min-height: 0;
}

.stage-col { min-width: 0; min-height: 0; }
.side-col {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 0;
}

@media (min-width: 1081px) {
  .layout { overflow: hidden; }
  .stage-col { overflow-y: auto; }
  .side-col {
    overflow: hidden;
    max-height: 100%;
  }
  .panel-roster { flex-shrink: 0; }
}

@media (max-width: 1080px) {
  .layout { grid-template-columns: 1fr; padding-bottom: 150px; }
  .side-col { order: 2; }
}

/* ============================================================
   Panels (roster / chat)
   ============================================================ */

.panel {
  border-radius: var(--r-lg);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  animation: card-in 0.6s var(--ease-out) both;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 13px 16px;
  border-bottom: 1px solid var(--border);
}
.panel-head h3 {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
}
.panel-hint { font-size: 0.72rem; color: var(--dim); }

/* ---------- roster ---------- */

.panel-roster { animation-delay: 0.05s; }

.roster-list {
  max-height: 290px;
  overflow-y: auto;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.roster-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: var(--r-sm);
  background: rgba(10, 14, 30, 0.4);
  border: 1px solid transparent;
  animation: slide-in-right 0.4s var(--ease-out) both;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}
.roster-row:hover { background: rgba(10, 14, 30, 0.7); transform: translateX(2px); }
.roster-row.is-offline { opacity: 0.42; }
.roster-row.is-me { border-color: rgba(124, 92, 255, 0.45); background: rgba(124, 92, 255, 0.1); }
.roster-row.is-leader { border-color: rgba(184, 242, 74, 0.4); }

.roster-rank {
  width: 20px;
  font-size: 0.74rem;
  font-weight: 800;
  color: var(--dim);
  text-align: right;
  font-family: 'JetBrains Mono', monospace;
}
.roster-row.is-leader .roster-rank { color: var(--lime); }

.roster-body { flex: 1; min-width: 0; }
.roster-name {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.roster-tag {
  padding: 1px 6px;
  border-radius: 99px;
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}
.tag-host { background: rgba(124, 92, 255, 0.22); color: #c3b2ff; }
.tag-you { background: rgba(53, 214, 245, 0.18); color: #9ae9fa; }
.tag-turn { background: rgba(255, 179, 71, 0.2); color: var(--amber); }

.roster-sub { font-size: 0.72rem; color: var(--dim); }

.roster-score {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--mint);
}
.roster-check { color: var(--mint); font-size: 0.95rem; }

@keyframes slide-in-right {
  from { opacity: 0; transform: translateX(14px); }
  to { opacity: 1; transform: none; }
}

/* ---------- chat ---------- */

.panel-chat {
  animation-delay: 0.1s;
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0;
}

@media (max-width: 1080px) {
  .panel-chat { min-height: 280px; }
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 0;
}

@media (max-width: 1080px) {
  .chat-messages { max-height: 46vh; }
}

.chat-msg {
  display: flex;
  gap: 9px;
  animation: msg-in 0.35s var(--ease-out) both;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: none; }
}

.chat-body { min-width: 0; flex: 1; }
.chat-meta {
  display: flex;
  align-items: baseline;
  gap: 7px;
  font-size: 0.72rem;
  margin-bottom: 1px;
}
.chat-author { font-weight: 700; font-size: 0.8rem; }
.chat-time { color: var(--dim); font-size: 0.66rem; }
.chat-text { font-size: 0.88rem; line-height: 1.45; word-wrap: break-word; }

.chat-msg.is-correct .chat-text {
  display: inline-block;
  padding: 5px 10px;
  border-radius: var(--r-sm);
  background: var(--grad-win);
  color: #06210f;
  font-weight: 700;
  animation: flash-win 0.7s var(--ease-out);
}
@keyframes flash-win {
  0% { transform: scale(0.85); }
  50% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

/* system messages, colored by tone */
.chat-sys {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 11px;
  border-radius: var(--r-sm);
  font-size: 0.82rem;
  font-weight: 600;
  border-left: 3px solid var(--dim);
  background: rgba(126, 148, 197, 0.08);
  color: var(--muted);
  animation: msg-in 0.35s var(--ease-out) both;
}
.chat-sys .sys-time { margin-left: auto; font-size: 0.64rem; color: var(--dim); font-weight: 500; }

.tone-info { border-color: var(--indigo); background: rgba(77, 124, 255, 0.12); color: #a9c2ff; }
.tone-success { border-color: var(--mint); background: rgba(47, 224, 168, 0.12); color: #8fecc9; }
.tone-join { border-color: var(--cyan); background: rgba(53, 214, 245, 0.1); color: #9ae9fa; }
.tone-warn { border-color: var(--amber); background: rgba(255, 179, 71, 0.13); color: #ffd39c; }
.tone-muted { border-color: rgba(126, 148, 197, 0.5); color: var(--dim); }
.tone-headline {
  border-color: transparent;
  background: var(--grad-hot);
  color: #fff;
  font-weight: 800;
  letter-spacing: 0.01em;
  box-shadow: 0 6px 22px rgba(124, 92, 255, 0.32);
}
.tone-win {
  border-color: transparent;
  background: var(--grad-win);
  color: #06210f;
  font-weight: 800;
  box-shadow: 0 6px 22px rgba(47, 224, 168, 0.28);
}
.tone-countdown {
  border-color: transparent;
  background: rgba(255, 95, 162, 0.16);
  color: #ffa8cd;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  font-size: 0.95rem;
  animation: msg-in 0.3s var(--ease-out) both, cd-glow 1s ease-in-out;
}
@keyframes cd-glow {
  0% { box-shadow: 0 0 0 0 rgba(255, 95, 162, 0.5); }
  100% { box-shadow: 0 0 0 14px rgba(255, 95, 162, 0); }
}

.chat-form {
  display: flex;
  gap: 8px;
  padding: 11px 12px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-form input { flex: 1; padding: 10px 13px; }

/* ============================================================
   Stage
   ============================================================ */

.stage {
  border-radius: var(--r-xl);
  background: var(--surface);
  border: 1px solid var(--border);
  backdrop-filter: blur(18px);
  box-shadow: var(--shadow-md);
  padding: 26px;
  min-height: 62vh;
  animation: card-in 0.6s var(--ease-out) both;
}

@media (max-width: 640px) { .stage { padding: 18px; border-radius: var(--r-lg); } }

.stage-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 20px;
}

.stage-eyebrow {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 5px;
}

.stage-title {
  margin: 0;
  font-size: clamp(1.5rem, 3.4vw, 2.15rem);
  font-weight: 800;
  letter-spacing: -0.025em;
  line-height: 1.1;
}

.stage-sub { margin: 6px 0 0; color: var(--muted); font-size: 0.92rem; }

/* ---------- phase stepper ---------- */

.stepper { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.step {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 99px;
  background: rgba(10, 14, 30, 0.5);
  border: 1px solid var(--border);
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--dim);
  transition: all 0.3s var(--ease-out);
}
.step.is-done { color: var(--mint); border-color: rgba(47, 224, 168, 0.35); }
.step.is-active {
  color: #fff;
  background: var(--grad-hot);
  border-color: transparent;
  box-shadow: 0 4px 18px rgba(124, 92, 255, 0.35);
  transform: scale(1.04);
}
.step-dot { width: 6px; height: 6px; border-radius: 50%; background: currentColor; }

/* ---------- lobby ---------- */

.lobby-hero { text-align: center; padding: 22px 0 30px; }
.lobby-hero .brand-mark { margin: 0 auto 18px; width: 76px; height: 76px; }
.lobby-hero .brand-monogram { font-size: 1.05rem; }
.lobby-hero h2 {
  margin: 0 0 8px;
  font-size: clamp(1.7rem, 4vw, 2.5rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  color: #fff;
}
.lobby-hero p { margin: 0 auto; max-width: 460px; color: var(--muted); }

.exercise-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
  gap: 14px;
  margin-top: 26px;
}

.ex-card {
  position: relative;
  padding: 20px;
  border-radius: var(--r-lg);
  background: rgba(10, 14, 30, 0.55);
  border: 1px solid var(--border);
  text-align: left;
  cursor: default;
  overflow: hidden;
  color: #fff;
  animation: card-in 0.5s var(--ease-out) both;
  transition: transform 0.25s var(--ease-out), border-color 0.25s, box-shadow 0.25s;
}
.ex-card.is-clickable { cursor: pointer; }
.ex-card.is-clickable:hover {
  transform: translateY(-6px);
  border-color: rgba(124, 92, 255, 0.6);
  box-shadow: 0 18px 44px rgba(124, 92, 255, 0.22);
}
.ex-card::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: var(--grad-hot);
  opacity: 0.85;
}
.ex-card:nth-child(2)::before { background: var(--grad-cool); }
.ex-card:nth-child(3)::before { background: linear-gradient(135deg, #ffb347, #ff5fa2); }
.ex-card:nth-child(4)::before { background: var(--grad-win); }

.ex-icon {
  display: grid;
  place-items: center;
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(124, 92, 255, 0.16);
  font-size: 1.2rem;
  margin-bottom: 13px;
}
.ex-card h4 { margin: 0 0 5px; font-size: 1.02rem; font-weight: 700; color: #fff; }
.ex-card p { margin: 0; font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.ex-card .ex-go {
  margin-top: 14px;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--violet);
  opacity: 0;
  transform: translateX(-6px);
  transition: all 0.25s var(--ease-out);
}
.ex-card.is-clickable:hover .ex-go { opacity: 1; transform: none; }

/* ---------- prompt hero ---------- */

.prompt-hero {
  position: relative;
  padding: 26px 28px;
  border-radius: var(--r-lg);
  background: linear-gradient(135deg, rgba(124, 92, 255, 0.2), rgba(255, 95, 162, 0.14));
  border: 1px solid rgba(124, 92, 255, 0.35);
  margin-bottom: 22px;
  overflow: hidden;
  animation: pop-in 0.45s var(--ease-bounce) both;
}
.prompt-hero::after {
  content: '';
  position: absolute;
  inset: -40% -10% auto auto;
  width: 60%; height: 200%;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.09), transparent 70%);
  animation: sheen 7s linear infinite;
}
@keyframes sheen {
  0% { transform: translateX(-60%) rotate(8deg); }
  100% { transform: translateX(160%) rotate(8deg); }
}
.prompt-label {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #d7c9ff;
  margin-bottom: 8px;
}
.prompt-text {
  margin: 0;
  font-size: clamp(1.25rem, 3vw, 1.85rem);
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.22;
}

/* ---------- notices ---------- */

.notice {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  border-radius: var(--r-md);
  background: rgba(77, 124, 255, 0.1);
  border: 1px solid rgba(77, 124, 255, 0.3);
  color: #b9cdff;
  font-size: 0.9rem;
  margin-bottom: 16px;
  animation: card-in 0.4s var(--ease-out) both;
}
.notice-success { background: rgba(47, 224, 168, 0.1); border-color: rgba(47, 224, 168, 0.32); color: #9aecce; }
.notice-warn { background: rgba(255, 179, 71, 0.1); border-color: rgba(255, 179, 71, 0.32); color: #ffd8a6; }
.notice-icon { font-size: 1.1rem; }

.waiting {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 46px 20px;
  text-align: center;
  color: var(--muted);
}
.waiting h3 { margin: 0; color: var(--text); font-size: 1.15rem; }
.waiting p { margin: 0; max-width: 380px; font-size: 0.9rem; }

.spinner-dots { display: flex; gap: 7px; }
.spinner-dots span {
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--violet);
  animation: bounce-dot 1.3s var(--ease-out) infinite;
}
.spinner-dots span:nth-child(2) { background: var(--pink); animation-delay: 0.15s; }
.spinner-dots span:nth-child(3) { background: var(--cyan); animation-delay: 0.3s; }
@keyframes bounce-dot {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-11px); opacity: 1; }
}

/* ---------- progress ---------- */

.progress-block { margin-bottom: 20px; }
.progress-top {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 7px;
  font-size: 0.8rem;
  color: var(--muted);
  font-weight: 600;
}
.progress-track {
  height: 8px;
  border-radius: 99px;
  background: rgba(10, 14, 30, 0.7);
  overflow: hidden;
}
.progress-fill {
  height: 100%;
  border-radius: 99px;
  background: var(--grad-win);
  transition: width 0.6s var(--ease-out);
  box-shadow: 0 0 14px rgba(47, 224, 168, 0.5);
}

.avatar-queue { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.queue-item {
  position: relative;
  animation: pop-in 0.35s var(--ease-bounce) both;
}
.queue-item.is-pending { opacity: 0.34; filter: grayscale(0.6); }
.queue-item .queue-tick {
  position: absolute;
  right: -2px; bottom: -2px;
  width: 15px; height: 15px;
  border-radius: 50%;
  background: var(--mint);
  color: #06210f;
  font-size: 0.6rem;
  font-weight: 900;
  display: grid;
  place-items: center;
  border: 2px solid var(--surface-solid);
}

/* ---------- drawing canvas ---------- */

.canvas-shell {
  border-radius: var(--r-lg);
  overflow: hidden;
  border: 1px solid var(--border-strong);
  background: #fff;
  box-shadow: var(--shadow-md);
  max-width: 640px;
}
canvas.draw-canvas {
  display: block;
  width: 100%;
  height: auto;
  touch-action: none;
  cursor: crosshair;
}

.canvas-tools {
  display: flex;
  align-items: center;
  gap: 9px;
  flex-wrap: wrap;
  margin-top: 14px;
}
.swatch-row { display: flex; gap: 6px; }
.ink-swatch {
  width: 26px; height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform 0.16s var(--ease-bounce);
}
.ink-swatch:hover { transform: scale(1.15); }
.ink-swatch.is-active { border-color: var(--violet); transform: scale(1.15); }

/* ---------- gallery / voting ---------- */

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px;
}

.vote-card {
  position: relative;
  padding: 12px;
  border-radius: var(--r-md);
  background: rgba(10, 14, 30, 0.5);
  border: 2px solid var(--border);
  cursor: pointer;
  overflow: hidden;
  animation: card-in 0.45s var(--ease-out) both;
  transition: transform 0.22s var(--ease-out), border-color 0.22s, box-shadow 0.22s;
}
.vote-card:hover { transform: translateY(-5px); border-color: rgba(124, 92, 255, 0.55); }
.vote-card.is-selected {
  border-color: var(--mint);
  box-shadow: 0 0 0 4px rgba(47, 224, 168, 0.16), 0 14px 34px rgba(47, 224, 168, 0.2);
  animation: select-pop 0.35s var(--ease-bounce);
}
.vote-card.is-locked { cursor: default; opacity: 0.55; }
.vote-card.is-locked:hover { transform: none; border-color: var(--border); }
.vote-card.is-winner {
  border-color: var(--lime);
  box-shadow: 0 0 0 4px rgba(184, 242, 74, 0.18), 0 16px 40px rgba(184, 242, 74, 0.22);
}

@keyframes select-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.06); }
  100% { transform: scale(1); }
}

.vote-card img {
  display: block;
  width: 100%;
  border-radius: var(--r-sm);
  background: #fff;
}
.vote-card .vote-text {
  font-size: 0.95rem;
  line-height: 1.5;
  font-weight: 600;
}
.vote-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.78rem;
  color: var(--muted);
}
.vote-check {
  position: absolute;
  top: 10px; right: 10px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: var(--grad-win);
  color: #06210f;
  display: grid;
  place-items: center;
  font-weight: 900;
  font-size: 0.85rem;
  animation: pop-in 0.3s var(--ease-bounce) both;
}
.vote-count-chip {
  padding: 2px 9px;
  border-radius: 99px;
  background: rgba(47, 224, 168, 0.16);
  color: var(--mint);
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
}

.vote-meter {
  display: flex;
  gap: 3px;
  align-items: center;
}

/* ---------- statements (two truths) ---------- */

.statement-list { display: flex; flex-direction: column; gap: 11px; }
.statement {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 17px 19px;
  border-radius: var(--r-md);
  background: rgba(10, 14, 30, 0.5);
  border: 2px solid var(--border);
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font: inherit;
  animation: card-in 0.45s var(--ease-out) both;
  transition: transform 0.2s var(--ease-out), border-color 0.2s, box-shadow 0.2s;
}
.statement:hover { transform: translateX(5px); border-color: rgba(124, 92, 255, 0.55); }
.statement.is-selected { border-color: var(--cyan); box-shadow: 0 0 0 4px rgba(53, 214, 245, 0.14); }
.statement.is-lie { border-color: var(--red); background: rgba(255, 95, 109, 0.1); }
.statement.is-truth { border-color: rgba(47, 224, 168, 0.4); }
.statement.is-locked { cursor: default; }
.statement.is-locked:hover { transform: none; }

.statement-num {
  display: grid;
  place-items: center;
  width: 34px; height: 34px;
  border-radius: 10px;
  background: rgba(124, 92, 255, 0.18);
  font-weight: 800;
  font-family: 'JetBrains Mono', monospace;
  flex-shrink: 0;
}
.statement-body { flex: 1; font-size: 1rem; font-weight: 600; line-height: 1.4; }
.statement-flag {
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 9px;
  border-radius: 99px;
}
.flag-lie { background: rgba(255, 95, 109, 0.2); color: #ffa8ae; }
.flag-truth { background: rgba(47, 224, 168, 0.16); color: #8fecc9; }

/* ---------- word guess ---------- */

.word-wrap {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  padding: 26px 10px;
}
.word-group { display: flex; gap: 8px; }

.letter-tile {
  display: grid;
  place-items: center;
  width: 46px; height: 60px;
  border-radius: 12px;
  background: rgba(10, 14, 30, 0.65);
  border: 1px solid var(--border);
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--dim);
  animation: card-in 0.4s var(--ease-out) both;
}
.letter-tile.is-revealed {
  background: var(--grad-cool);
  border-color: transparent;
  color: #04182b;
  animation: flip-reveal 0.6s var(--ease-bounce) both;
  box-shadow: 0 8px 24px rgba(53, 214, 245, 0.3);
}
.letter-tile.is-punct { background: none; border: none; color: var(--muted); width: 24px; }

@keyframes flip-reveal {
  0% { transform: rotateX(-90deg) scale(0.8); opacity: 0; }
  60% { transform: rotateX(12deg) scale(1.06); opacity: 1; }
  100% { transform: none; opacity: 1; }
}

@media (max-width: 560px) {
  .letter-tile { width: 34px; height: 46px; font-size: 1.15rem; }
  .word-wrap { gap: 12px; }
}

.category-chip {
  display: inline-flex;
  align-items: center;
  gap: 9px;
  padding: 9px 17px;
  border-radius: 99px;
  background: var(--grad-cool);
  color: #04182b;
  font-weight: 800;
  font-size: 0.92rem;
  box-shadow: 0 8px 26px rgba(53, 214, 245, 0.28);
  animation: pop-in 0.4s var(--ease-bounce) both;
}

.guess-hint {
  text-align: center;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.92rem;
}
.guess-hint strong { color: var(--cyan); }

/* ---------- results ---------- */

.results-head { text-align: center; margin-bottom: 24px; }
.results-head h2 {
  margin: 0 0 6px;
  font-size: clamp(1.7rem, 4vw, 2.4rem);
  font-weight: 800;
  letter-spacing: -0.03em;
  background: var(--grad-win);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.podium {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 12px;
  margin: 26px 0 30px;
  flex-wrap: wrap;
}
.podium-slot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  animation: rise 0.7s var(--ease-bounce) both;
}
.podium-slot .avatar { box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.22); }
.podium-block {
  width: 92px;
  border-radius: 14px 14px 0 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-bottom: none;
  display: grid;
  place-items: center;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  font-size: 1.1rem;
}
.podium-1 .podium-block { height: 108px; background: linear-gradient(180deg, rgba(184, 242, 74, 0.3), rgba(47, 224, 168, 0.12)); border-color: rgba(184, 242, 74, 0.45); }
.podium-2 .podium-block { height: 82px; background: linear-gradient(180deg, rgba(53, 214, 245, 0.24), transparent); }
.podium-3 .podium-block { height: 62px; background: linear-gradient(180deg, rgba(255, 179, 71, 0.24), transparent); }
.podium-name { font-size: 0.84rem; font-weight: 700; max-width: 96px; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.podium-medal { font-size: 1.3rem; }

@keyframes rise {
  from { opacity: 0; transform: translateY(34px); }
  to { opacity: 1; transform: none; }
}
.podium-1 { animation-delay: 0.2s; }
.podium-2 { animation-delay: 0.05s; }
.podium-3 { animation-delay: 0.35s; }

.score-table { width: 100%; border-collapse: collapse; }
.score-table th {
  text-align: left;
  padding: 9px 12px;
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  border-bottom: 1px solid var(--border);
}
.score-table td {
  padding: 11px 12px;
  border-bottom: 1px solid rgba(126, 148, 197, 0.09);
  font-size: 0.9rem;
}
.score-table tbody tr { animation: slide-in-right 0.4s var(--ease-out) both; }
.score-cell {
  font-family: 'JetBrains Mono', monospace;
  font-weight: 800;
  color: var(--mint);
}
.score-delta {
  font-size: 0.74rem;
  font-weight: 700;
  color: var(--lime);
  margin-left: 6px;
}
.name-cell { display: flex; align-items: center; gap: 10px; }

.section-title {
  margin: 28px 0 13px;
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---------- more time bar ---------- */

.time-bar {
  display: flex;
  align-items: center;
  gap: 11px;
  flex-wrap: wrap;
  margin-top: 20px;
  padding: 13px 16px;
  border-radius: var(--r-md);
  background: rgba(255, 179, 71, 0.1);
  border: 1px solid rgba(255, 179, 71, 0.32);
  color: #ffd8a6;
  font-size: 0.88rem;
  font-weight: 600;
  animation: card-in 0.4s var(--ease-out) both;
}
.time-bar-actions { display: flex; gap: 7px; margin-left: auto; }

/* ============================================================
   Host dock
   ============================================================ */

.host-dock {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 40;
  background: rgba(11, 15, 32, 0.9);
  backdrop-filter: blur(22px);
  border-top: 1px solid var(--border-strong);
  box-shadow: 0 -12px 40px rgba(3, 6, 18, 0.55);
  animation: dock-in 0.5s var(--ease-out) both;
}
@keyframes dock-in {
  from { transform: translateY(100%); }
  to { transform: none; }
}

.dock-toggle {
  display: flex;
  align-items: center;
  gap: 9px;
  width: 100%;
  padding: 9px 20px;
  background: none;
  border: none;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  cursor: pointer;
}
.dock-toggle:hover { color: var(--text); }
.dock-chevron {
  width: 0; height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 6px solid currentColor;
  transition: transform 0.25s var(--ease-out);
}
.host-dock.is-collapsed .dock-chevron { transform: rotate(180deg); }

.dock-body {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-wrap: wrap;
  padding: 4px 20px 16px;
  max-height: 46vh;
  overflow-y: auto;
  transition: max-height 0.3s var(--ease-out), padding 0.3s, opacity 0.2s;
}
.host-dock.is-collapsed .dock-body {
  max-height: 0;
  padding-top: 0;
  padding-bottom: 0;
  opacity: 0;
  overflow: hidden;
}

.dock-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding-right: 18px;
  border-right: 1px solid var(--border);
}
.dock-group:last-child { border-right: none; padding-right: 0; }
.dock-group:empty { display: none; }
.dock-setup { flex: 1; min-width: 260px; }

.dock-label {
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--dim);
}
.dock-row { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }
.dock-row input, .dock-row select { min-width: 180px; padding: 8px 12px; font-size: 0.88rem; }

.prompt-picks {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  max-width: 920px;
}
.prompt-chip {
  padding: 6px 11px;
  border-radius: 99px;
  border: 1px solid var(--border);
  background: rgba(10, 14, 30, 0.55);
  color: var(--text);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1.25;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, color 0.15s, transform 0.15s;
}
.prompt-chip:hover {
  border-color: var(--border-strong);
  background: rgba(124, 92, 255, 0.16);
  transform: translateY(-1px);
}
.prompt-chip.is-active {
  border-color: transparent;
  background: var(--grad-hot);
  color: #fff;
}
.prompt-chip-custom {
  border-style: dashed;
  color: var(--muted);
}

/* ============================================================
   Countdown overlay
   ============================================================ */

.countdown-overlay {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(6, 9, 20, 0.72);
  backdrop-filter: blur(8px);
  animation: fade-in 0.3s var(--ease-out) both;
  pointer-events: none;
}
.countdown-inner { text-align: center; }
.countdown-label {
  display: block;
  font-size: 0.86rem;
  font-weight: 800;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--violet);
  margin-bottom: 8px;
}
.countdown-number {
  display: block;
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(6rem, 22vw, 14rem);
  font-weight: 700;
  line-height: 1;
  background: var(--grad-hot);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 10px 40px rgba(124, 92, 255, 0.5));
}
.countdown-number.is-tick { animation: cd-tick 0.85s var(--ease-out); }
@keyframes cd-tick {
  0% { transform: scale(1.5); opacity: 0; }
  25% { transform: scale(1); opacity: 1; }
  100% { transform: scale(0.94); opacity: 0.85; }
}
.word-board-pending .letter-tile:not(.is-revealed):not(.is-punct) {
  animation: tile-pulse 0.85s ease-in-out infinite;
  border-color: rgba(255, 179, 71, 0.55);
}

@keyframes tile-pulse {
  0%, 100% { transform: scale(1); box-shadow: none; }
  50% { transform: scale(1.06); box-shadow: 0 0 18px rgba(255, 179, 71, 0.35); }
}

.countdown-reveal .countdown-number {
  background: linear-gradient(135deg, #ffb347 0%, #ff5fa2 100%);
  -webkit-background-clip: text;
  background-clip: text;
}

.countdown-hint {
  display: block;
  margin-top: 8px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 600;
}

/* ============================================================
   Toasts
   ============================================================ */

.toast-host {
  position: fixed;
  top: 74px;
  right: 20px;
  z-index: 95;
  display: flex;
  flex-direction: column;
  gap: 9px;
  pointer-events: none;
}

.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--r-md);
  background: rgba(22, 29, 51, 0.96);
  border: 1px solid var(--border-strong);
  box-shadow: var(--shadow-md);
  font-size: 0.88rem;
  font-weight: 600;
  max-width: 330px;
  animation: toast-in 0.4s var(--ease-bounce) both;
}
.toast.is-out { animation: toast-out 0.3s var(--ease-out) both; }
.toast-info { border-left: 3px solid var(--indigo); }
.toast-success { border-left: 3px solid var(--mint); }
.toast-warn { border-left: 3px solid var(--amber); }
.toast-error { border-left: 3px solid var(--red); }

@keyframes toast-in {
  from { opacity: 0; transform: translateX(40px) scale(0.94); }
  to { opacity: 1; transform: none; }
}
@keyframes toast-out {
  to { opacity: 0; transform: translateX(40px) scale(0.94); }
}

@media (max-width: 640px) {
  .toast-host { left: 14px; right: 14px; top: 68px; }
  .toast { max-width: none; }
}

/* ============================================================
   Motion preferences
   ============================================================ */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
