:root {
  --bg: #070a12;
  --ink: #eef1ff;
  --muted: #98a1bf;
  --muted-2: #6f7894;
  --line: rgba(255, 255, 255, 0.08);
  --line-strong: rgba(255, 255, 255, 0.16);
  --card: rgba(19, 23, 38, 0.72);
  --card-solid: #121728;
  --accent: #8b7bff;
  --accent-2: #35d6b0;
  --accent-3: #ffc46b;
  --danger: #ff7d97;
  --radius-lg: 26px;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  width: 100%;
  max-width: 100%;
  overflow-x: hidden;
  overscroll-behavior-x: none;
}

html {
  overflow-y: auto;
}

body {
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-x: clip;
  overflow-y: auto;
}

button,
input {
  font-family: inherit;
  font-size: inherit;
  color: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

/* ------------------------------------------------------------------ */
/* Backdrop                                                            */
/* ------------------------------------------------------------------ */
.backdrop {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 0;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite alternate;
}

.orb-a {
  width: 46vw;
  height: 46vw;
  left: -12vw;
  top: -14vw;
  background: radial-gradient(circle, #5b47ff 0%, rgba(91, 71, 255, 0) 70%);
}

.orb-b {
  width: 40vw;
  height: 40vw;
  right: -10vw;
  top: 10vh;
  background: radial-gradient(circle, #12b894 0%, rgba(18, 184, 148, 0) 70%);
  animation-delay: -6s;
}

.orb-c {
  width: 34vw;
  height: 34vw;
  left: 30vw;
  bottom: -20vw;
  background: radial-gradient(circle, #ff8a5c 0%, rgba(255, 138, 92, 0) 70%);
  opacity: 0.25;
  animation-delay: -11s;
}

.grain {
  position: absolute;
  inset: 0;
  background-image: radial-gradient(rgba(255, 255, 255, 0.06) 1px, transparent 1px);
  background-size: 3px 3px;
  opacity: 0.18;
}

@keyframes drift {
  from {
    transform: translate3d(0, 0, 0) scale(1);
  }
  to {
    transform: translate3d(3vw, 4vh, 0) scale(1.12);
  }
}

/* ------------------------------------------------------------------ */
/* Shell & screens                                                     */
/* ------------------------------------------------------------------ */
.app-shell {
  position: relative;
  z-index: 1;
  width: min(1080px, 100%);
  max-width: 100%;
  min-width: 0;
  margin: 0 auto;
  padding: 28px 24px calc(64px + env(safe-area-inset-bottom));
  min-height: 100vh;
}

.screen {
  display: none;
  min-width: 0;
  max-width: 100%;
}

.card,
.panel,
.game-layout,
.game-layout > *,
.home-grid > *,
.topbar > *,
.room-top > * {
  min-width: 0;
  max-width: 100%;
}

.screen.active {
  display: block;
  animation: fadeUp 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Login screen is vertically centered */
.screen-login.active {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: calc(100vh - 92px);
}

.login-wrap {
  width: min(420px, 100%);
  text-align: center;
}

.brand-block {
  margin-bottom: 26px;
}

.brand-badge {
  width: 74px;
  height: 74px;
  margin: 0 auto 18px;
  border-radius: 24px;
  display: grid;
  place-items: center;
  font-size: 34px;
  font-weight: 800;
  color: #0b0e18;
  background: linear-gradient(140deg, #c9c2ff 0%, #8b7bff 45%, #35d6b0 100%);
  box-shadow: 0 18px 45px rgba(139, 123, 255, 0.42);
  animation: badgeFloat 5s ease-in-out infinite;
}

@keyframes badgeFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-7px);
  }
}

.brand-title {
  margin: 0;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 6px;
  text-indent: 6px;
  background: linear-gradient(120deg, #ffffff 20%, #b9b0ff 55%, #9df0da 90%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-sub {
  margin: 8px 0 0;
  color: var(--muted);
  letter-spacing: 3px;
  font-size: 13px;
}

.login-foot {
  margin-top: 26px;
  font-size: 10px;
  letter-spacing: 3px;
  color: var(--muted-2);
}

/* ------------------------------------------------------------------ */
/* Cards & common                                                      */
/* ------------------------------------------------------------------ */
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.login-card {
  padding: 26px;
  text-align: left;
}

.field {
  margin-bottom: 16px;
}

.field label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  letter-spacing: 1px;
  margin-bottom: 7px;
}

input[type="text"],
input[type="password"] {
  width: 100%;
  padding: 13px 15px;
  border-radius: 14px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 11, 20, 0.6);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

input::placeholder {
  color: #5d6684;
}

input:focus {
  border-color: rgba(139, 123, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(139, 123, 255, 0.13);
  background: rgba(12, 16, 28, 0.85);
}

.form-error {
  min-height: 20px;
  margin: 0 0 8px;
  font-size: 12.5px;
  color: var(--danger);
}

.tiny-muted {
  margin: 14px 0 0;
  font-size: 11.5px;
  color: var(--muted-2);
  text-align: center;
}

.muted {
  color: var(--muted);
}

.center {
  text-align: center;
}

.hint {
  margin: 16px 0 0;
  font-size: 12.5px;
  color: var(--muted-2);
}

.hint.center {
  text-align: center;
}

.eyebrow {
  display: inline-block;
  font-size: 10px;
  letter-spacing: 3.5px;
  color: var(--accent-2);
  font-weight: 700;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 13px 22px;
  border-radius: 14px;
  border: 1px solid transparent;
  font-weight: 650;
  letter-spacing: 0.4px;
  transition: transform 0.16s, box-shadow 0.2s, background 0.2s, border-color 0.2s, opacity 0.2s;
  user-select: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.975);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.42;
  transform: none;
  box-shadow: none;
}

.btn.primary {
  color: #0a0d17;
  background: linear-gradient(135deg, #c4bcff 0%, #9484ff 45%, #6ff0cf 120%);
  box-shadow: 0 14px 34px rgba(139, 123, 255, 0.32);
}

.btn.primary:not(:disabled):hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 40px rgba(139, 123, 255, 0.45);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.03);
  border-color: var(--line-strong);
  color: var(--ink);
}

.btn.ghost:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.08);
}

.btn.danger {
  color: var(--danger);
  border-color: rgba(255, 125, 151, 0.35);
}

.btn.danger:hover {
  background: rgba(255, 125, 151, 0.1);
}

.btn.block {
  width: 100%;
}

.btn.small {
  padding: 8px 14px;
  font-size: 12.5px;
  border-radius: 11px;
}

.link-btn {
  background: none;
  border: 0;
  color: var(--muted-2);
  font-size: 12px;
  padding: 4px 2px;
  transition: color 0.2s;
}

.link-btn:hover {
  color: var(--danger);
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid var(--line);
  font-size: 11.5px;
  color: var(--muted);
  white-space: nowrap;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  letter-spacing: 0.3px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
  color: var(--muted);
  white-space: nowrap;
}

.tag.ready {
  color: #7ff0d2;
  border-color: rgba(53, 214, 176, 0.35);
  background: rgba(53, 214, 176, 0.1);
}

.tag.host {
  color: var(--accent-3);
  border-color: rgba(255, 196, 107, 0.35);
  background: rgba(255, 196, 107, 0.1);
}

.tag.submitted {
  color: #9fa8ff;
  border-color: rgba(139, 123, 255, 0.4);
  background: rgba(139, 123, 255, 0.12);
}

.tag.offline {
  color: var(--muted-2);
  border-color: transparent;
  background: rgba(255, 255, 255, 0.04);
}

.tag.win {
  color: var(--accent-3);
  border-color: rgba(255, 196, 107, 0.4);
  background: rgba(255, 196, 107, 0.12);
}

/* ------------------------------------------------------------------ */
/* Topbar                                                              */
/* ------------------------------------------------------------------ */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 34px;
  flex-wrap: wrap;
}

.logo-line {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  letter-spacing: 1px;
}

.logo-mark {
  width: 32px;
  height: 32px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 16px;
  color: #0b0e18;
  background: linear-gradient(140deg, #c9c2ff, #8b7bff 55%, #35d6b0);
}

.user-chip {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 14px 6px 7px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.045);
  border: 1px solid var(--line);
  font-size: 13px;
}

.avatar {
  width: 44px;
  height: 44px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-weight: 800;
  font-size: 17px;
  color: #0c0f1a;
  flex-shrink: 0;
  letter-spacing: 0;
}

.avatar-sm {
  width: 30px;
  height: 30px;
  border-radius: 10px;
  font-size: 13px;
}

/* ------------------------------------------------------------------ */
/* Home                                                                */
/* ------------------------------------------------------------------ */
.home-hero {
  text-align: center;
  margin: 18px 0 40px;
}

.home-hero h2 {
  margin: 14px 0 12px;
  font-size: clamp(28px, 4.4vw, 46px);
  line-height: 1.25;
  letter-spacing: 1px;
}

.highlight {
  background: linear-gradient(110deg, #b7adff 10%, #35d6b0 60%, #ffc46b 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.lede {
  margin: 0 auto;
  max-width: 560px;
  color: var(--muted);
  font-size: 14.5px;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 18px;
  margin-bottom: 22px;
}

.action-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  padding: 26px;
  min-height: 180px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: linear-gradient(160deg, rgba(139, 123, 255, 0.12), rgba(19, 23, 38, 0.7) 55%);
  text-align: left;
  color: var(--ink);
  overflow: hidden;
  transition: transform 0.22s, border-color 0.22s, box-shadow 0.22s;
}

.action-card::after {
  content: "";
  position: absolute;
  inset: -60% -30% auto auto;
  width: 220px;
  height: 220px;
  background: radial-gradient(circle, rgba(139, 123, 255, 0.3), transparent 65%);
  opacity: 0.7;
  pointer-events: none;
}

.action-card:hover {
  transform: translateY(-4px);
  border-color: rgba(139, 123, 255, 0.5);
  box-shadow: 0 26px 50px rgba(0, 0, 0, 0.4);
}

.action-card:nth-child(2) {
  background: linear-gradient(160deg, rgba(53, 214, 176, 0.1), rgba(19, 23, 38, 0.7) 55%);
}

.action-card:nth-child(2)::after {
  background: radial-gradient(circle, rgba(53, 214, 176, 0.28), transparent 65%);
}

.action-icon {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  font-size: 22px;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid var(--line);
  margin-bottom: 10px;
}

.action-title {
  font-size: 20px;
  font-weight: 750;
  letter-spacing: 0.5px;
}

.action-desc {
  color: var(--muted);
  font-size: 12.5px;
}

.action-arrow {
  position: absolute;
  right: 24px;
  bottom: 22px;
  font-size: 20px;
  color: var(--muted-2);
  transition: transform 0.2s, color 0.2s;
}

.action-card:hover .action-arrow {
  transform: translateX(5px);
  color: var(--ink);
}

.rules-card {
  padding: 24px 26px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.panel-head h3 {
  margin: 0;
  font-size: 16.5px;
  letter-spacing: 0.5px;
}

.rules {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

.rules li {
  display: flex;
  gap: 12px;
  padding: 16px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.028);
  border: 1px solid var(--line);
}

.rule-num {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  letter-spacing: 1px;
  padding-top: 2px;
}

.rules strong {
  font-size: 13.5px;
}

.rules p {
  margin: 4px 0 0;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}

/* ------------------------------------------------------------------ */
/* Create / Join                                                       */
/* ------------------------------------------------------------------ */
.page-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 26px;
}

.back-btn {
  background: none;
  border: 0;
  color: var(--muted);
  font-size: 13px;
  padding: 8px 0;
  transition: color 0.2s;
}

.back-btn:hover {
  color: var(--ink);
}

.panel {
  padding: 26px;
}

.panel.narrow {
  max-width: 520px;
  margin: 0 auto;
}

.panel h3 {
  margin: 0 0 6px;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.panel.narrow > .muted {
  margin: 0 0 22px;
  font-size: 13px;
}

.count-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.count-btn {
  padding: 16px 8px;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 0.18s, background 0.18s, transform 0.18s;
}

.count-btn:hover {
  border-color: rgba(139, 123, 255, 0.5);
}

.count-btn.active {
  border-color: rgba(139, 123, 255, 0.8);
  background: rgba(139, 123, 255, 0.16);
  box-shadow: 0 0 0 4px rgba(139, 123, 255, 0.1);
}

.count-btn b {
  display: block;
  font-size: 22px;
  line-height: 1.2;
}

.count-btn span {
  font-size: 10.5px;
  color: var(--muted-2);
  letter-spacing: 1px;
}

.join-code-display {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
  width: min(340px, 100%);
  margin: 22px auto 20px;
}

.code-digit {
  display: grid;
  place-items: center;
  height: 64px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 11, 20, 0.65);
  color: var(--muted-2);
  font-size: 32px;
  font-weight: 800;
  transition: border-color 0.18s, background 0.18s, box-shadow 0.18s;
}

.code-digit.active {
  border-color: rgba(53, 214, 176, 0.7);
  box-shadow: 0 0 0 3px rgba(53, 214, 176, 0.1);
}

.code-digit.filled {
  color: var(--ink);
  border-color: rgba(139, 123, 255, 0.65);
  background: rgba(139, 123, 255, 0.12);
}

.number-keypad {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  width: min(340px, 100%);
  margin: 0 auto 20px;
}

.keypad-key {
  min-height: 58px;
  border-radius: 15px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  font-size: 24px;
  font-weight: 700;
  user-select: none;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.keypad-key:hover {
  background: rgba(139, 123, 255, 0.13);
  border-color: rgba(139, 123, 255, 0.5);
}

.keypad-key:active {
  transform: scale(0.96);
  background: rgba(139, 123, 255, 0.2);
}

.keypad-key.utility {
  color: var(--muted);
  font-size: 14px;
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Room                                                                */
/* ------------------------------------------------------------------ */
.room-top {
  display: flex;
  align-items: stretch;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.code-card {
  flex: 1;
  min-width: 280px;
  padding: 22px 26px;
  border-radius: var(--radius-lg);
  background: linear-gradient(140deg, rgba(139, 123, 255, 0.16), rgba(19, 23, 38, 0.66) 60%);
  border: 1px solid rgba(139, 123, 255, 0.28);
  box-shadow: var(--shadow);
}

.code-card .label {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--muted);
}

.code-row {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 4px 0 2px;
}

.code-row > span {
  font-size: 44px;
  font-weight: 800;
  letter-spacing: 10px;
  line-height: 1.2;
  background: linear-gradient(120deg, #ffffff 10%, #b9b0ff 60%, #8ef2d7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.copy-btn {
  padding: 5px 12px;
  font-size: 11.5px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  transition: color 0.2s, background 0.2s;
}

.copy-btn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.1);
}

.room-top > .btn {
  align-self: center;
}

.players-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.player-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 13px 15px;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.032);
  border: 1px solid var(--line);
  animation: fadeUp 0.35s ease;
}

.player-card.is-me {
  border-color: rgba(139, 123, 255, 0.45);
  background: rgba(139, 123, 255, 0.09);
}

.player-card.offline {
  opacity: 0.5;
}

.player-info {
  min-width: 0;
  flex: 1;
}

.player-name {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 650;
  font-size: 14px;
}

.player-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-tags {
  display: flex;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.room-actions {
  display: flex;
  gap: 12px;
  margin-top: 22px;
  flex-wrap: wrap;
}

.room-actions .btn {
  flex: 1;
  min-width: 160px;
}

.pulse-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-2);
  box-shadow: 0 0 0 0 rgba(53, 214, 176, 0.5);
  animation: pulseDot 1.8s infinite;
  display: inline-block;
}

@keyframes pulseDot {
  0% {
    box-shadow: 0 0 0 0 rgba(53, 214, 176, 0.45);
  }
  70% {
    box-shadow: 0 0 0 7px rgba(53, 214, 176, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(53, 214, 176, 0);
  }
}

/* ------------------------------------------------------------------ */
/* Game                                                                */
/* ------------------------------------------------------------------ */
.round-pill {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  padding: 9px 20px;
  border-radius: 999px;
  border: 1px solid rgba(139, 123, 255, 0.35);
  background: rgba(139, 123, 255, 0.1);
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 1px;
}

.round-pill .sep {
  width: 1px;
  height: 14px;
  background: var(--line-strong);
}

.round-pill #game-phase {
  color: var(--accent-2);
  font-weight: 600;
  font-size: 12.5px;
  letter-spacing: 1px;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.game-layout {
  display: grid;
  grid-template-columns: 1.55fr 1fr;
  gap: 18px;
  align-items: start;
}

.side-panel {
  position: sticky;
  top: 24px;
}

#game-panel {
  min-height: 330px;
  display: flex;
  flex-direction: column;
}

.players-grid.compact {
  grid-template-columns: 1fr;
  gap: 8px;
}

.players-grid.compact .player-card {
  padding: 10px 12px;
}

.word-form {
  display: flex;
  flex-direction: column;
  flex: 1;
}

.word-label {
  font-size: 12px;
  letter-spacing: 2px;
  color: var(--muted);
  margin-bottom: 10px;
}

.word-input-row {
  display: flex;
  gap: 10px;
}

.word-input {
  flex: 1;
  font-size: 22px;
  font-weight: 650;
  padding: 16px 18px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(8, 11, 20, 0.6);
  outline: none;
  letter-spacing: 2px;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.word-input:focus {
  border-color: rgba(139, 123, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(139, 123, 255, 0.13);
}

.word-input-row .btn {
  padding: 0 26px;
  font-size: 15px;
}

.round-tip {
  margin: 14px 0 0;
  font-size: 12.5px;
  color: var(--muted-2);
}

.waiting-block {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px 10px;
  gap: 6px;
}

.waiting-word {
  font-size: clamp(30px, 5vw, 46px);
  font-weight: 800;
  letter-spacing: 4px;
  margin: 10px 0 4px;
  background: linear-gradient(120deg, #ffffff, #b9b0ff 60%, #8ef2d7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  word-break: break-all;
}

.waiting-title {
  font-size: 14px;
  color: var(--muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.waiting-sub {
  font-size: 12px;
  color: var(--muted-2);
}

/* Reveal */
.reveal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.reveal-title {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 1px;
}

.reveal-title.sad {
  color: var(--muted);
}

.reveal-title.happy {
  background: linear-gradient(110deg, #ffe9b0, #ffc46b 40%, #8ef2d7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.reveal-sub {
  font-size: 12.5px;
  color: var(--muted-2);
  margin-top: 2px;
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 10px;
}

.result-card {
  padding: 16px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  text-align: center;
  animation: fadeUp 0.4s ease;
}

.result-card.match {
  border-color: rgba(255, 196, 107, 0.4);
  background: rgba(255, 196, 107, 0.08);
}

.result-name {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 6px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-word {
  font-size: 21px;
  font-weight: 750;
  letter-spacing: 2px;
  word-break: break-all;
}

.result-word.empty {
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0;
}

.reveal-foot {
  margin-top: 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.previous-round-card {
  margin-bottom: 18px;
  padding: 20px 24px;
  border-color: rgba(53, 214, 176, 0.28);
  background: linear-gradient(140deg, rgba(53, 214, 176, 0.1), rgba(19, 23, 38, 0.82) 58%);
}

.previous-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 15px;
}

.previous-head h3 {
  margin: 3px 0 0;
  font-size: 19px;
}

.previous-words {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 10px;
}

.previous-word {
  min-width: 0;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(7, 10, 18, 0.42);
}

.previous-word span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted);
  font-size: 12px;
}

.previous-word strong {
  display: block;
  color: #f4f2ff;
  font-size: 20px;
  letter-spacing: 1px;
  overflow-wrap: anywhere;
}

.auto-next {
  flex: 1;
  min-width: 210px;
  color: var(--accent-3);
  font-size: 13px;
  font-weight: 650;
}

.auto-next-track {
  height: 4px;
  margin-top: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
}

.auto-next-progress {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent-3), var(--accent-2));
  transform-origin: left;
  animation: autoNext 2s linear forwards;
}

@keyframes autoNext {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

#game-history {
  margin-top: 18px;
  padding: 24px 26px;
  border-color: rgba(139, 123, 255, 0.32);
  background: rgba(20, 24, 42, 0.9);
}

.history-head {
  margin-bottom: 4px;
}

.history-head h3 {
  color: #f2efff;
  font-size: 20px;
}

.history-caption {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 13px;
}

.history-list {
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.history-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 12px;
  align-items: start;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  font-size: 14px;
}

.history-row.latest {
  border-color: rgba(139, 123, 255, 0.45);
  background: rgba(139, 123, 255, 0.08);
}

.history-round {
  color: #b9afff;
  font-weight: 750;
  white-space: nowrap;
  min-width: 62px;
  padding-top: 7px;
}

.history-words {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  color: var(--muted);
}

.history-words > span {
  display: inline-flex;
  gap: 3px;
  max-width: 100%;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: rgba(7, 10, 18, 0.45);
  overflow-wrap: anywhere;
}

.history-words em {
  font-style: normal;
  color: #ffffff;
  font-size: 15px;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.history-win,
.history-miss {
  justify-self: end;
  margin-top: 5px;
}

.history-miss {
  color: #c6cadd;
}

/* ------------------------------------------------------------------ */
/* Summary                                                             */
/* ------------------------------------------------------------------ */
#summary-hero {
  text-align: center;
  padding: 12px 0 30px;
}

.summary-medal {
  width: 92px;
  height: 92px;
  margin: 0 auto 18px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 38px;
  font-weight: 800;
  color: #12131f;
  background: radial-gradient(circle at 32% 28%, #fff6d8, #ffc46b 55%, #ff9f5c);
  box-shadow: 0 0 0 10px rgba(255, 196, 107, 0.1), 0 22px 54px rgba(255, 159, 92, 0.4);
  animation: medalPop 0.8s cubic-bezier(0.22, 1.4, 0.36, 1);
}

.summary-medal.calm {
  background: radial-gradient(circle at 32% 28%, #dfe5ff, #8b7bff 60%, #5b47ff);
  box-shadow: 0 0 0 10px rgba(139, 123, 255, 0.1), 0 22px 54px rgba(91, 71, 255, 0.35);
}

@keyframes medalPop {
  from {
    transform: scale(0.5) rotate(-14deg);
    opacity: 0;
  }
  to {
    transform: scale(1) rotate(0);
    opacity: 1;
  }
}

.summary-title {
  margin: 0;
  font-size: clamp(30px, 5vw, 44px);
  font-weight: 800;
  letter-spacing: 4px;
  background: linear-gradient(110deg, #fff1c9, #ffc46b 45%, #8ef2d7 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.summary-title.calm {
  background: linear-gradient(110deg, #e9e6ff, #b0a5ff 55%, #8ef2d7);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.summary-sub {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 13.5px;
}

.summary-round-list {
  display: grid;
  gap: 13px;
}

.summary-round {
  min-width: 0;
  padding: 17px;
  border-radius: var(--radius);
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.035);
}

.summary-round.win {
  border-color: rgba(255, 196, 107, 0.38);
  background: rgba(255, 196, 107, 0.07);
}

.summary-round-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 13px;
}

.summary-round-head > strong {
  color: #c5bcff;
  font-size: 16px;
}

.summary-word-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 9px;
}

.summary-word {
  min-width: 0;
  padding: 11px 13px;
  border-radius: 12px;
  background: rgba(7, 10, 18, 0.4);
  border: 1px solid var(--line);
}

.summary-word span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.summary-word strong {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 18px;
  overflow-wrap: anywhere;
}

.summary-word strong.empty {
  color: var(--muted-2);
  font-size: 13px;
  font-weight: 500;
}

.summary-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 22px;
  flex-wrap: wrap;
}

.summary-actions .btn {
  min-width: 170px;
}

/* ------------------------------------------------------------------ */
/* Toasts                                                              */
/* ------------------------------------------------------------------ */
.toasts {
  position: fixed;
  top: 22px;
  right: 22px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 9px;
  max-width: min(340px, calc(100vw - 40px));
  pointer-events: none;
}

.toast {
  padding: 11px 16px;
  border-radius: 13px;
  background: rgba(20, 24, 40, 0.96);
  border: 1px solid var(--line-strong);
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45);
  font-size: 12.5px;
  color: var(--ink);
  animation: toastIn 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(14px);
}

.toast.error {
  border-color: rgba(255, 125, 151, 0.45);
  color: #ffc4ce;
}

.toast.out {
  animation: toastOut 0.3s ease forwards;
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translateX(22px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateX(0) scale(1);
  }
}

@keyframes toastOut {
  to {
    opacity: 0;
    transform: translateX(22px) scale(0.96);
  }
}

/* ------------------------------------------------------------------ */
/* Responsive                                                          */
/* ------------------------------------------------------------------ */
@media (max-width: 860px) {
  .game-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .side-panel {
    position: static;
  }

  .rules {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    padding: 16px 12px calc(42px + env(safe-area-inset-bottom));
  }

  .topbar {
    gap: 12px;
    margin-bottom: 20px;
  }

  .btn {
    min-height: 48px;
  }

  .btn.small,
  .link-btn,
  .back-btn,
  .copy-btn {
    min-height: 44px;
  }

  input[type="text"],
  input[type="password"] {
    font-size: 16px;
  }

  .toasts {
    top: calc(12px + env(safe-area-inset-top));
    right: 12px;
    left: 12px;
    max-width: none;
  }

  .home-hero {
    margin: 10px 0 26px;
  }

  .home-hero h2 {
    font-size: 30px;
  }

  .home-grid {
    grid-template-columns: minmax(0, 1fr);
    gap: 12px;
  }

  .action-card {
    min-height: 142px;
    padding: 20px;
  }

  .rules-card {
    padding: 18px;
  }

  .rules li {
    padding: 14px;
  }

  .count-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .count-btn {
    min-height: 56px;
    padding: 10px 4px;
  }

  .count-btn b {
    font-size: 19px;
  }

  .panel {
    padding: 18px;
  }

  .login-card {
    padding: 20px;
  }

  .screen-login.active {
    min-height: calc(100dvh - 58px);
  }

  .brand-block {
    margin-bottom: 18px;
  }

  .brand-title {
    font-size: 28px;
  }

  .brand-badge {
    width: 64px;
    height: 64px;
  }

  .code-card {
    width: 100%;
    min-width: 0;
    padding: 18px;
  }

  .code-row {
    gap: 10px;
  }

  .code-row > span {
    font-size: clamp(30px, 10vw, 36px);
    letter-spacing: 6px;
  }

  .room-top > .btn {
    width: 100%;
  }

  .players-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .room-actions .btn {
    min-width: 0;
  }

  .word-input {
    width: 100%;
    min-width: 0;
    font-size: 18px;
    padding: 14px;
  }

  .word-input-row {
    flex-direction: column;
  }

  .word-input-row .btn {
    padding: 13px;
  }

  .round-pill {
    max-width: 100%;
    padding: 8px 14px;
    font-size: 12.5px;
  }

  .topbar-right {
    gap: 8px;
    max-width: 100%;
  }

  .topbar-right .pill {
    display: none;
  }

  #game-panel {
    min-height: 280px;
  }

  .result-grid,
  .previous-words {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .previous-round-card {
    padding: 17px;
  }

  .previous-head {
    align-items: flex-start;
    flex-direction: column;
    gap: 8px;
  }

  .previous-head .pill {
    white-space: normal;
  }

  .reveal-foot {
    align-items: stretch;
    flex-direction: column;
  }

  .reveal-foot > .hint {
    margin-top: 0;
  }

  .auto-next {
    width: 100%;
    min-width: 0;
  }

  #game-history {
    padding: 18px;
  }

  .history-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
    padding: 13px;
  }

  .history-round {
    min-width: 0;
    padding-top: 0;
  }

  .history-words {
    grid-column: 1 / -1;
    grid-row: 2;
  }

  .history-win,
  .history-miss {
    grid-column: 2;
    grid-row: 1;
    margin-top: 0;
  }

  .summary-word-grid {
    grid-template-columns: minmax(0, 1fr);
  }

  .summary-title {
    letter-spacing: 2px;
  }

  .summary-actions .btn {
    width: 100%;
    min-width: 0;
  }
}

@media (max-width: 380px) {
  .app-shell {
    padding-right: 10px;
    padding-left: 10px;
  }

  .panel,
  #game-history,
  .previous-round-card {
    padding: 15px;
  }

  .login-card {
    padding: 18px;
  }

  .join-code-display,
  .number-keypad {
    gap: 8px;
  }

  .code-digit {
    height: 56px;
  }

  .keypad-key {
    min-height: 54px;
  }

  .result-card,
  .previous-word {
    padding: 11px 9px;
  }

  .result-word,
  .previous-word strong {
    font-size: 18px;
  }

  .round-pill,
  .round-pill #game-phase {
    letter-spacing: 0.4px;
  }
}
