:root {
  --paper: #f6f1e8;
  --paper-deep: #ece4d7;
  --surface: #fffdf8;
  --ink: #1f2a24;
  --ink-soft: #35443b;
  --muted: #727b74;
  --line: #ddd6c9;
  --line-strong: #c8c0b2;
  --coral: #fb7c61;
  --coral-deep: #e45e44;
  --mint: #c5e8d7;
  --mint-deep: #2c7c66;
  --mint-pale: #e7f4ed;
  --ocean: #b9d5e7;
  --lemon: #f5d575;
  --rose: #f4c6c0;
  --shadow: 0 18px 60px rgba(44, 51, 44, 0.09);
  --shadow-small: 0 8px 24px rgba(44, 51, 44, 0.08);
  --radius: 24px;
  --radius-small: 15px;
  --sans: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --display: "Arial Rounded MT Bold", "Avenir Next", "PingFang SC", "Microsoft YaHei", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  min-height: 100%;
  background: var(--paper);
  -webkit-text-size-adjust: 100%;
}

body {
  min-width: 320px;
  min-height: 100svh;
  margin: 0;
  color: var(--ink);
  font-family: var(--sans);
  background:
    radial-gradient(circle at 84% 10%, rgba(197, 232, 215, 0.48), transparent 26rem),
    radial-gradient(circle at 8% 88%, rgba(251, 124, 97, 0.12), transparent 25rem),
    var(--paper);
  -webkit-font-smoothing: antialiased;
}

body::before {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  content: "";
  opacity: 0.28;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 180 180' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.09'/%3E%3C/svg%3E");
}

button,
input,
textarea {
  color: inherit;
  font: inherit;
}

button {
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

button:disabled {
  cursor: not-allowed;
}

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

svg {
  display: block;
  width: 1.25em;
  height: 1.25em;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hidden {
  display: none !important;
}

.ambient {
  position: fixed;
  z-index: -1;
  width: 300px;
  height: 300px;
  pointer-events: none;
  border-radius: 50%;
  filter: blur(2px);
}

.ambient-one {
  top: -180px;
  right: 12%;
  border: 1px solid rgba(31, 42, 36, 0.08);
}

.ambient-two {
  bottom: -220px;
  left: -100px;
  border: 1px solid rgba(31, 42, 36, 0.07);
}

.view {
  min-height: 100svh;
  animation: view-in 0.45s ease both;
}

@keyframes view-in {
  from {
    opacity: 0;
    transform: translateY(7px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.home-view {
  width: min(1220px, calc(100% - 64px));
  margin: 0 auto;
  padding: 0 0 40px;
}

.home-nav {
  display: flex;
  min-height: 92px;
  align-items: center;
  justify-content: space-between;
}

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

.brand-mark {
  position: relative;
  width: 42px;
  height: 38px;
  flex: 0 0 auto;
}

.brand-card {
  position: absolute;
  display: grid;
  width: 27px;
  height: 32px;
  place-items: center;
  border: 1.6px solid var(--ink);
  border-radius: 7px;
  font-family: var(--display);
  font-size: 12px;
  font-weight: 800;
}

.brand-card-cn {
  top: 3px;
  left: 0;
  color: var(--ink);
  background: var(--coral);
  transform: rotate(-8deg);
}

.brand-card-en {
  right: 0;
  bottom: 0;
  background: var(--mint);
  transform: rotate(7deg);
}

.brand-name {
  display: flex;
  align-items: center;
  gap: 9px;
  font-family: var(--display);
  font-size: 21px;
  font-weight: 900;
  letter-spacing: -0.04em;
  white-space: nowrap;
}

.brand-name b {
  padding-left: 9px;
  border-left: 1px solid var(--line-strong);
  color: var(--muted);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.home-nav-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}

.home-nav-tag i,
.live-dot i,
.waiting-label i,
.connection-status i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #45a77d;
  box-shadow: 0 0 0 4px rgba(69, 167, 125, 0.11);
}

.home-layout {
  display: grid;
  min-height: calc(100svh - 132px);
  grid-template-columns: minmax(0, 1.1fr) minmax(390px, 0.9fr);
  gap: clamp(50px, 8vw, 110px);
  align-items: center;
}

.hero {
  position: relative;
  padding: 36px 0 50px;
}

.eyebrow {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 25px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
  letter-spacing: 0.03em;
  animation: rise-in 0.6s 0.08s ease both;
}

.eyebrow span {
  display: grid;
  width: 28px;
  height: 28px;
  place-items: center;
  border: 1px solid var(--line-strong);
  border-radius: 50%;
  color: var(--ink);
  font-size: 9px;
  font-weight: 850;
}

.hero h1 {
  max-width: 650px;
  margin: 0;
  font-family: var(--display);
  font-size: clamp(64px, 7.4vw, 108px);
  font-weight: 900;
  letter-spacing: -0.085em;
  line-height: 0.98;
  animation: rise-in 0.7s 0.12s ease both;
}

.hero h1 em {
  position: relative;
  color: var(--coral-deep);
  font-style: normal;
  white-space: nowrap;
}

.hero h1 em::after {
  position: absolute;
  right: 0.02em;
  bottom: -0.08em;
  left: 0.04em;
  height: 9px;
  content: "";
  border-radius: 50%;
  background: var(--coral);
  opacity: 0.22;
  transform: rotate(-1deg);
}

.hero-copy {
  margin: 29px 0 0;
  color: var(--muted);
  font-size: 16px;
  font-weight: 520;
  line-height: 1.75;
  animation: rise-in 0.7s 0.18s ease both;
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.floating-board {
  display: flex;
  width: min(100%, 520px);
  margin: 37px 0 32px;
  align-items: center;
  animation: rise-in 0.75s 0.24s ease both;
}

.float-card {
  position: relative;
  display: flex;
  width: 154px;
  min-height: 82px;
  padding: 15px 16px;
  flex-direction: column;
  justify-content: space-between;
  border: 1.5px solid var(--ink);
  border-radius: 15px;
  box-shadow: 4px 5px 0 var(--ink);
}

.float-card span {
  color: var(--muted);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 0.12em;
}

.float-card strong {
  overflow: hidden;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.float-card-en {
  background: var(--surface);
  transform: rotate(-3deg);
}

.float-card-zh {
  background: var(--mint);
  transform: rotate(3deg);
}

.float-line {
  position: relative;
  display: grid;
  width: 92px;
  height: 60px;
  flex: 0 0 auto;
  place-items: center;
}

.float-line svg {
  position: absolute;
  width: 66px;
  height: 30px;
  color: var(--ink);
  opacity: 0.35;
  stroke-dasharray: 4 4;
}

.float-line b {
  z-index: 1;
  padding: 4px 8px;
  border-radius: 999px;
  color: var(--surface);
  background: var(--ink);
  font-size: 9px;
  letter-spacing: 0.03em;
}

.hero-stats {
  display: flex;
  width: min(100%, 460px);
  align-items: center;
  justify-content: space-between;
  animation: rise-in 0.75s 0.3s ease both;
}

.hero-stats div {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.hero-stats strong {
  font-family: var(--display);
  font-size: 24px;
  font-weight: 900;
  letter-spacing: -0.05em;
}

.hero-stats span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 620;
}

.hero-stats > i {
  width: 1px;
  height: 25px;
  background: var(--line);
}

.entry-card {
  position: relative;
  width: min(100%, 450px);
  justify-self: end;
  padding: 34px;
  border: 1px solid rgba(31, 42, 36, 0.14);
  border-radius: 30px;
  background: rgba(255, 253, 248, 0.88);
  box-shadow: 0 24px 70px rgba(53, 57, 47, 0.1);
  backdrop-filter: blur(14px);
  animation: card-in 0.7s 0.18s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.entry-card::after {
  position: absolute;
  z-index: -1;
  inset: 11px -10px -10px 11px;
  content: "";
  border: 1px solid var(--line-strong);
  border-radius: 30px;
}

@keyframes card-in {
  from {
    opacity: 0;
    transform: translateY(24px) rotate(1.5deg);
  }
  to {
    opacity: 1;
    transform: translateY(0) rotate(0);
  }
}

.entry-topline {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.tiny-label,
.section-kicker,
.card-index {
  color: var(--muted);
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 0.13em;
}

.live-dot {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.live-dot i {
  width: 5px;
  height: 5px;
  box-shadow: none;
}

.entry-card h2 {
  margin: 19px 0 5px;
  font-family: var(--display);
  font-size: 31px;
  font-weight: 900;
  letter-spacing: -0.055em;
}

.entry-copy {
  margin: 0 0 27px;
  color: var(--muted);
  font-size: 12px;
}

.field-label {
  display: block;
  margin: 0 0 8px;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 720;
}

.input-wrap {
  position: relative;
  display: flex;
  height: 56px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.input-wrap:focus-within {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(31, 42, 36, 0.06);
}

.input-icon {
  display: grid;
  width: 50px;
  flex: 0 0 auto;
  place-items: center;
  color: var(--muted);
}

.input-icon svg {
  width: 18px;
  height: 18px;
}

.input-wrap input {
  width: 100%;
  min-width: 0;
  height: 100%;
  padding: 0 48px 0 0;
  border: 0;
  outline: 0;
  background: transparent;
  font-size: 15px;
  font-weight: 650;
}

input::placeholder,
textarea::placeholder {
  color: #a6aaa5;
  font-weight: 450;
}

.icon-button {
  position: absolute;
  right: 9px;
  display: grid;
  width: 37px;
  height: 37px;
  place-items: center;
  border-radius: 10px;
  color: var(--muted);
  background: var(--paper);
  transition: color 0.2s ease, transform 0.2s ease;
}

.icon-button:active {
  transform: rotate(-16deg) scale(0.94);
}

.icon-button svg {
  width: 16px;
  height: 16px;
}

.segmented {
  display: grid;
  margin: 20px 0 17px;
  padding: 4px;
  grid-template-columns: 1fr 1fr;
  border-radius: 13px;
  background: var(--paper-deep);
}

.segment {
  height: 40px;
  border-radius: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  transition: background 0.2s ease, color 0.2s ease, box-shadow 0.2s ease;
}

.segment.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 3px 10px rgba(44, 51, 44, 0.08);
}

.entry-panel > p {
  margin: 0 0 16px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.primary-button,
.secondary-button,
.quiet-button,
.start-button,
.share-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-weight: 750;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}

.primary-button {
  width: 100%;
  height: 54px;
  border-radius: 14px;
  color: var(--surface);
  background: var(--ink);
  box-shadow: 0 9px 22px rgba(31, 42, 36, 0.14);
  font-size: 13px;
}

.primary-button:hover {
  background: #111a15;
}

.primary-button:active,
.secondary-button:active,
.start-button:active,
.share-button:active {
  transform: translateY(2px);
}

.primary-button svg,
.secondary-button svg,
.start-button svg,
.share-button svg {
  width: 17px;
  height: 17px;
}

.primary-button.compact,
.secondary-button {
  width: auto;
  min-width: 128px;
  height: 46px;
  padding: 0 18px;
  border-radius: 12px;
  font-size: 12px;
}

.secondary-button {
  color: var(--ink);
  background: var(--paper);
}

.primary-button:disabled,
.start-button:disabled {
  transform: none;
  box-shadow: none;
  opacity: 0.46;
}

.code-input {
  width: 100%;
  height: 56px;
  margin-bottom: 10px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  outline: 0;
  background: var(--surface);
  font-family: var(--display);
  font-size: 19px;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.code-input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(31, 42, 36, 0.06);
}

.entry-foot {
  display: flex;
  margin-top: 21px;
  align-items: center;
  justify-content: space-between;
  color: var(--muted);
  font-size: 9px;
}

.entry-foot span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.check-icon {
  display: grid;
  width: 14px;
  height: 14px;
  place-items: center;
  border-radius: 50%;
  color: var(--mint-deep);
  background: var(--mint-pale);
  font-size: 8px;
  font-style: normal;
  font-weight: 900;
}

/* Room shell */

.room-view {
  width: min(1280px, calc(100% - 64px));
  margin: 0 auto;
  padding-bottom: 42px;
}

.room-nav {
  display: grid;
  height: 82px;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
}

.nav-icon-button {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 253, 248, 0.65);
  transition: transform 0.18s ease, background 0.18s ease;
}

.nav-icon-button:hover {
  background: var(--surface);
}

.nav-icon-button:active {
  transform: scale(0.93);
}

.nav-icon-button svg {
  width: 18px;
  height: 18px;
}

.room-nav > .nav-icon-button {
  justify-self: start;
}

.brand-compact {
  justify-self: center;
}

.brand-compact .brand-mark {
  width: 30px;
  height: 29px;
}

.brand-compact .brand-card {
  width: 21px;
  height: 25px;
  border-width: 1.3px;
  border-radius: 5px;
  font-size: 9px;
}

.brand-compact .brand-name {
  font-size: 16px;
}

.room-nav-right {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 15px;
}

.connection-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 650;
}

.connection-status i {
  width: 5px;
  height: 5px;
  box-shadow: 0 0 0 3px rgba(69, 167, 125, 0.12);
}

.connection-status.offline i {
  background: var(--coral);
  box-shadow: 0 0 0 3px rgba(251, 124, 97, 0.13);
}

.lobby-panel {
  padding-top: 26px;
}

.lobby-heading {
  display: flex;
  margin-bottom: 28px;
  align-items: flex-end;
  justify-content: space-between;
}

.lobby-heading h1 {
  margin: 8px 0 0;
  font-family: var(--display);
  font-size: clamp(34px, 4vw, 53px);
  font-weight: 900;
  letter-spacing: -0.07em;
  line-height: 1.1;
}

.role-badge {
  padding: 7px 11px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 750;
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 22px;
  align-items: start;
}

.lobby-main {
  display: grid;
  gap: 16px;
}

.invite-banner {
  display: flex;
  min-height: 112px;
  padding: 23px 25px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--ink);
  border-radius: 20px;
  background: var(--mint);
  box-shadow: 4px 5px 0 var(--ink);
}

.invite-label {
  display: block;
  margin-bottom: 3px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

.room-code {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--display);
  font-size: clamp(26px, 3.5vw, 40px);
  font-weight: 900;
  letter-spacing: 0.12em;
}

.room-code svg {
  width: 17px;
  height: 17px;
  color: var(--ink-soft);
  stroke-width: 1.6;
}

.invite-banner p {
  margin: 4px 0 0;
  color: var(--ink-soft);
  font-size: 10px;
}

.share-button {
  min-width: 122px;
  height: 44px;
  padding: 0 17px;
  border: 1px solid var(--ink);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 2px 3px 0 var(--ink);
  font-size: 11px;
}

.lobby-card {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 253, 248, 0.76);
}

.card-heading {
  display: flex;
  min-height: 41px;
  margin-bottom: 18px;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.card-heading h2 {
  margin: 5px 0 0;
  font-family: var(--display);
  font-size: 20px;
  font-weight: 900;
  letter-spacing: -0.04em;
}

.card-heading h2 small {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 10px;
  font-weight: 650;
  letter-spacing: 0;
}

.waiting-label,
.host-hint {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 650;
}

.waiting-label i {
  width: 5px;
  height: 5px;
  box-shadow: 0 0 0 3px rgba(69, 167, 125, 0.12);
  animation: blink 2s infinite;
}

@keyframes blink {
  50% {
    opacity: 0.35;
  }
}

.lobby-players {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 9px;
}

.player-card {
  position: relative;
  display: flex;
  min-width: 0;
  height: 67px;
  padding: 10px;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
  animation: player-in 0.35s ease both;
}

@keyframes player-in {
  from {
    opacity: 0;
    transform: scale(0.94);
  }
}

.player-card.is-you {
  border-color: var(--ink);
}

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

.player-avatar,
.ribbon-avatar {
  display: grid;
  width: 37px;
  height: 37px;
  flex: 0 0 auto;
  place-items: center;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  font-family: var(--display);
  font-size: 13px;
  font-weight: 900;
}

.avatar-coral {
  background: var(--coral);
}

.avatar-mint {
  background: var(--mint);
}

.avatar-ocean {
  background: var(--ocean);
}

.avatar-lemon {
  background: var(--lemon);
}

.avatar-rose {
  background: var(--rose);
}

.avatar-paper {
  background: var(--paper-deep);
}

.player-meta {
  min-width: 0;
}

.player-meta strong {
  display: block;
  overflow: hidden;
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta span {
  color: var(--muted);
  font-size: 8px;
}

.mini-crown {
  position: absolute;
  top: 7px;
  right: 7px;
  color: var(--coral-deep);
  font-size: 10px;
}

.empty-player {
  display: grid;
  min-height: 67px;
  place-items: center;
  border: 1px dashed var(--line-strong);
  border-radius: 13px;
  color: #a2a79f;
  font-size: 10px;
}

.setup-row {
  display: flex;
  min-height: 58px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid var(--line);
}

.setup-copy {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.setup-copy strong {
  font-size: 11px;
  font-weight: 750;
}

.setup-copy span {
  color: var(--muted);
  font-size: 9px;
}

.pill-options {
  display: flex;
  padding: 3px;
  gap: 3px;
  border-radius: 11px;
  background: var(--paper-deep);
}

.pill-options button {
  height: 31px;
  padding: 0 12px;
  border-radius: 8px;
  color: var(--muted);
  font-size: 9px;
  font-weight: 720;
  transition: background 0.18s ease, color 0.18s ease;
}

.pill-options button.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 7px rgba(31, 42, 36, 0.08);
}

.lobby-panel:not(.host-mode) .setup-card button,
.lobby-panel:not(.host-mode) .text-button,
.lobby-panel:not(.host-mode) .pack-card {
  pointer-events: none;
}

.text-button {
  display: inline-flex;
  height: 33px;
  padding: 0 11px;
  align-items: center;
  gap: 7px;
  border-radius: 9px;
  color: var(--ink);
  background: var(--paper);
  font-size: 9px;
  font-weight: 750;
}

.text-button svg {
  width: 13px;
  height: 13px;
}

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

.pack-card {
  position: relative;
  min-width: 0;
  min-height: 105px;
  padding: 13px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 13px;
  text-align: left;
  background: var(--surface);
  transition: border-color 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.pack-card::after {
  position: absolute;
  right: -10px;
  bottom: -13px;
  width: 50px;
  height: 50px;
  content: "";
  border: 1px solid var(--ink);
  border-radius: 50%;
  opacity: 0.12;
}

.pack-card:hover {
  transform: translateY(-2px);
}

.pack-card.active {
  border-color: var(--ink);
  box-shadow: 2px 3px 0 var(--ink);
}

.pack-color {
  display: block;
  width: 19px;
  height: 19px;
  margin-bottom: 12px;
  border: 1px solid var(--ink);
  border-radius: 6px;
}

.pack-color.coral {
  background: var(--coral);
}

.pack-color.ocean {
  background: var(--ocean);
}

.pack-color.lemon {
  background: var(--lemon);
}

.pack-color.ink {
  background: var(--ink);
}

.pack-card strong {
  display: block;
  overflow: hidden;
  font-size: 10px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-card span {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  color: var(--muted);
  font-size: 8px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pack-count {
  position: absolute;
  top: 9px;
  right: 9px;
  color: var(--muted);
  font-size: 7px;
  font-weight: 700;
}

.pack-warning {
  margin: 12px 0 0;
  padding: 9px 11px;
  border-radius: 9px;
  color: #945244;
  background: #fff0ec;
  font-size: 9px;
  line-height: 1.5;
}

.lobby-side {
  display: grid;
  gap: 14px;
}

.start-card {
  position: relative;
  min-height: 352px;
  padding: 27px;
  overflow: hidden;
  border-radius: 22px;
  color: var(--surface);
  background: var(--ink);
}

.start-card .section-kicker {
  color: rgba(255, 253, 248, 0.55);
}

.start-card h2 {
  position: relative;
  z-index: 1;
  margin: 37px 0 8px;
  font-family: var(--display);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: -0.06em;
  line-height: 1.08;
}

.start-card p {
  position: relative;
  z-index: 1;
  max-width: 205px;
  margin: 0;
  color: rgba(255, 253, 248, 0.58);
  font-size: 10px;
  line-height: 1.6;
}

.start-card-orbit {
  position: absolute;
  top: -97px;
  right: -78px;
  width: 275px;
  height: 275px;
  border: 1px solid rgba(255, 253, 248, 0.13);
  border-radius: 50%;
}

.start-card-orbit::before,
.start-card-orbit::after {
  position: absolute;
  content: "";
  border: 1px solid rgba(255, 253, 248, 0.1);
  border-radius: 50%;
}

.start-card-orbit::before {
  inset: 30px;
}

.start-card-orbit::after {
  inset: 61px;
}

.start-button {
  position: relative;
  z-index: 1;
  width: 100%;
  height: 55px;
  margin-top: 37px;
  border-radius: 14px;
  color: var(--ink);
  background: var(--coral);
  box-shadow: 0 8px 0 #b54531;
  font-size: 13px;
}

.start-button:active {
  transform: translateY(5px);
  box-shadow: 0 3px 0 #b54531;
}

.start-button svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
  stroke-width: 1;
}

.start-note {
  position: relative;
  z-index: 1;
  display: flex;
  margin-top: 23px;
  align-items: center;
  gap: 7px;
  color: rgba(255, 253, 248, 0.48);
  font-size: 8px;
}

.start-note svg {
  width: 13px;
  height: 13px;
}

.tip-card {
  padding: 20px;
  border: 1px dashed var(--line-strong);
  border-radius: 17px;
}

.tip-card span {
  color: var(--coral-deep);
  font-size: 9px;
  font-weight: 800;
}

.tip-card p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

/* Game */

.game-panel {
  padding-top: 15px;
  animation: view-in 0.35s ease both;
}

.game-top {
  display: flex;
  margin-bottom: 20px;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
}

.game-top h1 {
  margin: 5px 0 0;
  font-family: var(--display);
  font-size: clamp(30px, 3.8vw, 46px);
  font-weight: 900;
  letter-spacing: -0.065em;
}

.player-ribbon {
  display: flex;
  align-items: center;
}

.ribbon-player {
  position: relative;
  display: flex;
  height: 38px;
  margin-left: -6px;
  padding: 4px 10px 4px 5px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--surface);
}

.ribbon-player:first-child {
  margin-left: 0;
}

.ribbon-player.is-you {
  z-index: 2;
  border-color: var(--ink);
}

.ribbon-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  font-size: 9px;
}

.ribbon-player span {
  max-width: 58px;
  overflow: hidden;
  font-size: 9px;
  font-weight: 720;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ribbon-player b {
  color: var(--coral-deep);
  font-family: var(--display);
  font-size: 9px;
}

.game-dashboard {
  display: flex;
  min-height: 75px;
  margin-bottom: 13px;
  padding: 11px 17px;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 253, 248, 0.7);
}

.timer-block,
.score-block {
  display: flex;
  align-items: center;
  gap: 12px;
}

.timer-ring {
  position: relative;
  width: 52px;
  height: 52px;
  flex: 0 0 auto;
}

.timer-ring svg {
  position: absolute;
  inset: 0;
  width: 52px;
  height: 52px;
  transform: rotate(-90deg);
}

.timer-ring circle {
  fill: none;
  stroke-width: 3;
}

.ring-track {
  stroke: var(--paper-deep);
}

.ring-progress {
  stroke: var(--coral);
  stroke-dasharray: 138.23;
  stroke-dashoffset: 0;
  stroke-linecap: round;
  transition: stroke-dashoffset 0.4s linear, stroke 0.3s ease;
}

.timer-ring strong {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--display);
  font-size: 16px;
  font-weight: 900;
}

.timer-block > div:last-child,
.my-score {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-label {
  color: var(--muted);
  font-size: 8px;
  font-weight: 720;
  letter-spacing: 0.04em;
}

.timer-block b {
  font-size: 10px;
  font-weight: 750;
}

.score-block {
  gap: 20px;
}

.my-score {
  align-items: flex-end;
}

.my-score strong {
  font-family: var(--display);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.05em;
}

.streak-chip {
  display: flex;
  height: 37px;
  padding: 0 12px;
  align-items: center;
  gap: 6px;
  border-radius: 10px;
  color: var(--ink);
  background: var(--lemon);
}

.streak-chip svg {
  width: 15px;
  height: 15px;
}

.streak-chip span {
  font-size: 8px;
  font-weight: 730;
}

.streak-chip b {
  font-size: 12px;
}

.streak-chip.celebrate {
  animation: chip-pop 0.4s ease;
}

@keyframes chip-pop {
  50% {
    transform: scale(1.1) rotate(-2deg);
  }
}

.board-section {
  position: relative;
  padding: 17px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 253, 248, 0.72);
  box-shadow: var(--shadow-small);
}

.board-heading {
  display: flex;
  min-height: 34px;
  margin-bottom: 12px;
  align-items: center;
  justify-content: space-between;
}

.board-instruction {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 580;
}

.board-instruction i {
  width: 7px;
  height: 7px;
  border: 1px solid var(--mint-deep);
  border-radius: 50%;
  background: var(--mint);
}

.ranking-button {
  display: flex;
  height: 29px;
  padding: 0 10px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface);
  font-size: 8px;
  font-weight: 700;
}

.ranking-button svg {
  width: 12px;
  height: 12px;
}

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

.word-tile {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 70px;
  padding: 21px 7px 9px;
  overflow: hidden;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  box-shadow: 0 2px 0 rgba(31, 42, 36, 0.06);
  text-align: center;
  transition:
    transform 0.16s ease,
    border-color 0.16s ease,
    opacity 0.28s ease,
    background 0.16s ease,
    box-shadow 0.16s ease;
  animation: tile-in 0.32s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.word-tile::before {
  position: absolute;
  top: 7px;
  left: 7px;
  display: grid;
  width: 17px;
  height: 17px;
  content: attr(data-lang-mark);
  place-items: center;
  border-radius: 5px;
  font-size: 6px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.word-tile[data-language="en"]::before {
  color: #436b88;
  background: #e4eff5;
}

.word-tile[data-language="zh"] {
  border-color: #c5d9ce;
  background: var(--mint-pale);
}

.word-tile[data-language="zh"]::before {
  color: var(--mint-deep);
  background: #cce7d9;
}

.word-tile:hover {
  border-color: #b7b0a3;
  transform: translateY(-1px);
}

.word-tile:active {
  transform: scale(0.97);
}

.word-tile.selected {
  z-index: 2;
  border-color: var(--ink);
  background: #fff8e8;
  box-shadow: 0 0 0 2px var(--ink), 0 5px 13px rgba(31, 42, 36, 0.15);
  transform: translateY(-2px);
}

.word-tile.selected::after {
  position: absolute;
  top: 6px;
  right: 6px;
  display: grid;
  width: 15px;
  height: 15px;
  content: "✓";
  place-items: center;
  border-radius: 50%;
  color: var(--surface);
  background: var(--ink);
  font-size: 7px;
  font-weight: 900;
}

.word-tile.wrong {
  border-color: var(--coral-deep);
  background: #fff0ec;
  animation: tile-shake 0.35s ease;
}

@keyframes tile-shake {
  20%,
  60% {
    transform: translateX(-4px);
  }
  40%,
  80% {
    transform: translateX(4px);
  }
}

.word-tile.matched {
  pointer-events: none;
  border-color: transparent;
  background: transparent;
  box-shadow: none;
  animation: tile-away 0.45s cubic-bezier(0.5, 0, 0.75, 0) forwards;
}

.word-tile.matched::before,
.word-tile.matched::after {
  display: none;
}

@keyframes tile-away {
  30% {
    opacity: 1;
    border-color: var(--mint-deep);
    background: var(--mint);
    transform: scale(1.04) rotate(1deg);
  }
  100% {
    opacity: 0;
    transform: scale(0.68) rotate(-7deg);
  }
}

@keyframes tile-in {
  from {
    opacity: 0;
    transform: translateY(7px) scale(0.97);
  }
}

.tile-word {
  display: -webkit-box;
  overflow: hidden;
  font-family: var(--display);
  font-size: clamp(13px, 1.75vw, 19px);
  font-weight: 850;
  letter-spacing: -0.025em;
  line-height: 1.12;
  overflow-wrap: anywhere;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.word-tile[data-long="true"] .tile-word {
  font-size: clamp(10px, 1.35vw, 14px);
  line-height: 1.08;
}

.word-tile[data-language="zh"] .tile-word {
  letter-spacing: 0.02em;
}

.board-footer {
  display: flex;
  margin-top: 12px;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 8px;
}

.board-footer span {
  display: flex;
  align-items: center;
  gap: 5px;
}

.board-footer span:last-child {
  margin-left: auto;
}

.lang-dot {
  width: 6px;
  height: 6px;
  border-radius: 2px;
}

.lang-dot-en {
  background: var(--ocean);
}

.lang-dot-zh {
  background: var(--mint);
}

/* Drawer */

.drawer {
  position: fixed;
  z-index: 60;
  inset: 0;
}

.drawer-scrim {
  position: absolute;
  inset: 0;
  width: 100%;
  background: rgba(23, 31, 26, 0.26);
  backdrop-filter: blur(3px);
  animation: fade-in 0.2s ease;
}

.drawer-panel {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(390px, 88vw);
  padding: 31px 27px;
  border-left: 1px solid var(--line);
  background: var(--paper);
  box-shadow: -20px 0 60px rgba(31, 42, 36, 0.12);
  animation: drawer-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes drawer-in {
  from {
    transform: translateX(100%);
  }
}

@keyframes fade-in {
  from {
    opacity: 0;
  }
}

.drawer-handle {
  display: none;
}

.drawer-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
}

.drawer-heading h2 {
  margin: 6px 0 0;
  font-family: var(--display);
  font-size: 28px;
  font-weight: 900;
  letter-spacing: -0.05em;
}

.ranking-list {
  display: grid;
  margin-top: 26px;
  gap: 8px;
}

.ranking-row {
  display: grid;
  min-height: 62px;
  padding: 9px 12px;
  grid-template-columns: 23px 38px minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--surface);
}

.ranking-row.is-you {
  border-color: var(--ink);
}

.ranking-number {
  color: var(--muted);
  font-family: var(--display);
  font-size: 13px;
  font-weight: 900;
}

.ranking-row:nth-child(1) .ranking-number {
  color: var(--coral-deep);
}

.ranking-name {
  min-width: 0;
}

.ranking-name strong {
  display: block;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-name span {
  color: var(--muted);
  font-size: 8px;
}

.ranking-score {
  font-family: var(--display);
  font-size: 16px;
  font-weight: 900;
}

.drawer-note {
  margin: 21px 0 0;
  color: var(--muted);
  font-size: 9px;
  line-height: 1.6;
}

/* Modal */

.modal-backdrop {
  position: fixed;
  z-index: 80;
  inset: 0;
  display: grid;
  padding: 24px;
  overflow-y: auto;
  place-items: center;
  background: rgba(22, 30, 25, 0.48);
  backdrop-filter: blur(8px);
  animation: fade-in 0.2s ease;
}

.modal {
  position: relative;
  width: min(100%, 570px);
  max-height: calc(100svh - 48px);
  padding: 29px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--surface);
  box-shadow: 0 24px 80px rgba(20, 27, 23, 0.22);
  animation: modal-in 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.98);
  }
}

.modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
}

.modal-header h2 {
  margin: 7px 0 0;
  font-family: var(--display);
  font-size: 27px;
  font-weight: 900;
  letter-spacing: -0.055em;
}

.modal-copy {
  margin: 14px 0 18px;
  color: var(--muted);
  font-size: 10px;
  line-height: 1.65;
}

.format-tabs {
  display: inline-flex;
  margin-bottom: 8px;
  padding: 3px;
  border-radius: 9px;
  background: var(--paper-deep);
}

.format-tab {
  height: 28px;
  padding: 0 11px;
  border-radius: 7px;
  color: var(--muted);
  font-size: 8px;
  font-weight: 750;
}

.format-tab.active {
  color: var(--ink);
  background: var(--surface);
  box-shadow: 0 2px 6px rgba(31, 42, 36, 0.08);
}

#wordsTextarea {
  width: 100%;
  height: 190px;
  padding: 15px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 13px;
  outline: 0;
  background: #fbf9f4;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", monospace;
  font-size: 11px;
  line-height: 1.65;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

#wordsTextarea:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 4px rgba(31, 42, 36, 0.06);
}

.import-tools {
  display: flex;
  min-height: 50px;
  align-items: center;
  gap: 13px;
}

.file-button,
.quiet-button {
  display: inline-flex;
  height: 31px;
  padding: 0 10px;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink-soft);
  background: var(--surface);
  cursor: pointer;
  font-size: 8px;
  font-weight: 700;
}

.file-button input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
}

.file-button svg {
  width: 12px;
  height: 12px;
}

.quiet-button {
  border-color: transparent;
  background: var(--paper);
}

.import-count {
  margin-left: auto;
  color: var(--muted);
  font-size: 8px;
}

.word-preview {
  display: flex;
  min-height: 34px;
  max-height: 79px;
  margin-bottom: 11px;
  overflow: hidden;
  align-content: flex-start;
  flex-wrap: wrap;
  gap: 5px;
}

.word-chip {
  height: 24px;
  padding: 0 8px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--muted);
  background: var(--paper);
  font-size: 7px;
  line-height: 22px;
}

.form-error {
  margin: 4px 0 0;
  color: var(--coral-deep);
  font-size: 9px;
}

.modal-actions {
  display: flex;
  margin-top: 18px;
  align-items: center;
  justify-content: flex-end;
  gap: 9px;
}

/* Result */

.result-modal {
  overflow: hidden;
  text-align: center;
}

.result-modal h2 {
  margin: 13px 0 6px;
  font-family: var(--display);
  font-size: clamp(30px, 6vw, 43px);
  font-weight: 900;
  letter-spacing: -0.065em;
}

.result-subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 10px;
}

.result-celebration {
  position: absolute;
  inset: 0 0 auto;
  height: 90px;
  pointer-events: none;
}

.result-celebration i {
  position: absolute;
  width: 7px;
  height: 20px;
  border-radius: 2px;
  background: var(--coral);
  transform: rotate(24deg);
}

.result-celebration i:nth-child(1) {
  top: 28px;
  left: 13%;
}

.result-celebration i:nth-child(2) {
  top: 17px;
  left: 28%;
  background: var(--lemon);
  transform: rotate(-35deg);
}

.result-celebration i:nth-child(3) {
  top: 34px;
  right: 20%;
  height: 14px;
  background: var(--mint-deep);
  transform: rotate(62deg);
}

.result-celebration i:nth-child(4) {
  top: 19px;
  right: 8%;
  background: var(--ocean);
  transform: rotate(-20deg);
}

.result-celebration i:nth-child(5) {
  top: 58px;
  right: 31%;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--coral);
}

.podium {
  display: flex;
  margin: 28px 0 24px;
  align-items: flex-end;
  justify-content: center;
  gap: 8px;
}

.podium-place {
  display: flex;
  min-width: 108px;
  padding: 13px 8px;
  flex-direction: column;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
}

.podium-place.rank-1 {
  padding-top: 19px;
  border-color: var(--ink);
  background: var(--mint);
  box-shadow: 3px 4px 0 var(--ink);
}

.podium-place .player-avatar {
  margin-bottom: 8px;
}

.podium-rank {
  color: var(--muted);
  font-size: 7px;
  font-weight: 800;
  letter-spacing: 0.1em;
}

.podium-place strong {
  display: block;
  max-width: 95px;
  margin-top: 2px;
  overflow: hidden;
  font-size: 10px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.podium-place b {
  margin-top: 5px;
  font-family: var(--display);
  font-size: 17px;
  font-weight: 900;
}

.words-unlocked {
  margin: 0 auto 18px;
}

.answer-reveal {
  display: grid;
  max-height: 130px;
  margin-top: 11px;
  padding: 12px;
  overflow-y: auto;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  border-radius: 11px;
  background: var(--paper);
  text-align: left;
}

.answer-pair {
  display: flex;
  min-width: 0;
  padding: 6px 8px;
  justify-content: space-between;
  gap: 8px;
  border-radius: 7px;
  background: var(--surface);
  font-size: 8px;
}

.answer-pair span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.answer-pair span:last-child {
  color: var(--mint-deep);
}

.result-actions {
  display: flex;
  justify-content: center;
}

.result-actions .primary-button {
  margin: 0 auto;
}

.result-wait-text {
  padding: 11px 16px;
  border-radius: 10px;
  color: var(--muted);
  background: var(--paper);
  font-size: 9px;
}

/* Toasts and effects */

.toast-stack {
  position: fixed;
  z-index: 100;
  top: calc(18px + env(safe-area-inset-top));
  left: 50%;
  display: flex;
  width: min(420px, calc(100% - 32px));
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  transform: translateX(-50%);
}

.toast {
  display: flex;
  max-width: 100%;
  min-height: 42px;
  padding: 10px 15px;
  align-items: center;
  gap: 9px;
  border: 1px solid rgba(31, 42, 36, 0.18);
  border-radius: 12px;
  color: var(--surface);
  background: rgba(31, 42, 36, 0.94);
  box-shadow: 0 9px 30px rgba(20, 27, 23, 0.2);
  font-size: 10px;
  font-weight: 620;
  line-height: 1.35;
  text-align: center;
  animation: toast-in 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  backdrop-filter: blur(8px);
}

.toast.success {
  color: var(--ink);
  border-color: var(--mint-deep);
  background: rgba(197, 232, 215, 0.97);
}

.toast.error {
  color: var(--ink);
  border-color: var(--coral);
  background: rgba(255, 223, 215, 0.98);
}

.toast.leaving {
  animation: toast-out 0.22s ease forwards;
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px) scale(0.97);
  }
}

@keyframes toast-out {
  to {
    opacity: 0;
    transform: translateY(-5px);
  }
}

.confetti-layer {
  position: fixed;
  z-index: 110;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.confetti {
  position: absolute;
  top: -20px;
  width: 8px;
  height: 15px;
  border-radius: 2px;
  animation: confetti-fall var(--fall-time) cubic-bezier(0.2, 0.65, 0.42, 1) forwards;
}

@keyframes confetti-fall {
  to {
    opacity: 0.8;
    transform: translate3d(var(--drift), 110svh, 0) rotate(var(--spin));
  }
}

.match-burst {
  position: fixed;
  z-index: 70;
  top: 45%;
  left: 50%;
  display: grid;
  width: 90px;
  height: 90px;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%);
}

.match-burst.show {
  animation: burst-show 0.8s ease forwards;
}

.match-burst strong {
  z-index: 2;
  color: var(--ink);
  font-family: var(--display);
  font-size: 24px;
  font-weight: 900;
  text-shadow: 0 2px 0 var(--surface);
}

.match-burst span {
  position: absolute;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  background: var(--coral);
  opacity: 0;
}

.match-burst.show span {
  animation: spark 0.65s ease-out forwards;
}

.match-burst span:nth-child(2) {
  background: var(--mint);
  --x: 48px;
  --y: -37px;
}

.match-burst span:nth-child(3) {
  background: var(--lemon);
  --x: -50px;
  --y: -20px;
}

.match-burst span:nth-child(4) {
  background: var(--ocean);
  --x: -30px;
  --y: 42px;
}

.match-burst span:nth-child(5) {
  background: var(--coral);
  --x: 38px;
  --y: 36px;
}

@keyframes burst-show {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.6);
  }
  20% {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.08);
  }
  70% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -65%) scale(0.92);
  }
}

@keyframes spark {
  0% {
    opacity: 1;
    transform: translate(0, 0) rotate(0);
  }
  100% {
    opacity: 0;
    transform: translate(var(--x), var(--y)) rotate(170deg);
  }
}

/* Responsive */

@media (min-width: 901px) {
  .board-grid {
    grid-template-columns: repeat(6, minmax(0, 1fr));
  }

  .word-tile {
    min-height: 79px;
    padding-top: 23px;
  }
}

@media (min-width: 1200px) {
  .board-grid {
    gap: 10px;
  }

  .word-tile {
    min-height: 86px;
  }
}

@media (max-width: 1060px) {
  .home-view {
    width: min(100% - 44px, 960px);
  }

  .home-layout {
    grid-template-columns: 1fr minmax(360px, 0.82fr);
    gap: 45px;
  }

  .hero h1 {
    font-size: clamp(58px, 8vw, 82px);
  }

  .float-card {
    width: 134px;
  }

  .room-view {
    width: calc(100% - 40px);
  }

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

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

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

@media (max-width: 800px) {
  .home-view,
  .room-view {
    width: calc(100% - 30px);
  }

  .home-nav {
    min-height: 72px;
  }

  .home-nav-tag {
    font-size: 10px;
  }

  .home-layout {
    display: block;
    min-height: 0;
  }

  .hero {
    padding: 43px 3px 10px;
  }

  .hero h1 {
    font-size: clamp(53px, 15vw, 83px);
  }

  .hero-copy {
    margin-top: 22px;
    font-size: 14px;
  }

  .floating-board {
    margin: 32px 0 27px;
  }

  .entry-card {
    width: 100%;
    margin: 26px 0 20px;
    justify-self: auto;
  }

  .hero-stats {
    width: 100%;
  }

  .room-nav {
    height: 68px;
  }

  .connection-status {
    display: none;
  }

  .lobby-panel {
    padding-top: 18px;
  }

  .lobby-heading {
    margin-bottom: 20px;
  }

  .lobby-grid {
    display: flex;
    flex-direction: column;
  }

  .lobby-main {
    width: 100%;
  }

  .lobby-side {
    display: contents;
  }

  .start-card {
    width: 100%;
    min-height: 270px;
    order: 3;
  }

  .start-card h2 {
    margin-top: 29px;
  }

  .start-button {
    margin-top: 26px;
  }

  .tip-card {
    width: 100%;
    order: 4;
  }

  .players-card {
    order: 1;
  }

  .setup-card {
    order: 2;
  }

  .words-card {
    order: 2;
  }

  .invite-banner {
    order: 0;
  }

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

  .game-top {
    align-items: flex-start;
  }

  .player-ribbon {
    max-width: 45%;
    overflow: hidden;
  }

  .ribbon-player:nth-child(n + 4) {
    display: none;
  }

  .game-dashboard {
    padding: 9px 12px;
  }

  .board-section {
    padding: 13px;
  }

  .drawer-panel {
    top: auto;
    left: 0;
    width: 100%;
    max-height: 76svh;
    padding: 11px 20px calc(22px + env(safe-area-inset-bottom));
    overflow-y: auto;
    border-top: 1px solid var(--line);
    border-left: 0;
    border-radius: 24px 24px 0 0;
    animation: drawer-up 0.3s cubic-bezier(0.22, 1, 0.36, 1);
  }

  @keyframes drawer-up {
    from {
      transform: translateY(100%);
    }
  }

  .drawer-handle {
    display: block;
    width: 37px;
    height: 4px;
    margin: 0 auto 17px;
    border-radius: 99px;
    background: var(--line-strong);
  }
}

@media (max-width: 560px) {
  .home-view,
  .room-view {
    width: calc(100% - 24px);
  }

  .brand-name b {
    display: none;
  }

  .brand-mark {
    width: 37px;
    height: 34px;
  }

  .brand-card {
    width: 24px;
    height: 28px;
    font-size: 10px;
  }

  .brand-name {
    font-size: 17px;
  }

  .home-nav-tag {
    gap: 6px;
    font-size: 9px;
  }

  .hero {
    padding-top: 37px;
  }

  .eyebrow {
    margin-bottom: 20px;
    font-size: 10px;
  }

  .hero h1 {
    font-size: clamp(50px, 16vw, 69px);
    line-height: 1.02;
  }

  .hero-copy {
    font-size: 13px;
    line-height: 1.7;
  }

  .floating-board {
    margin: 27px 0 26px;
  }

  .float-card {
    width: 118px;
    min-height: 71px;
    padding: 12px 13px;
    border-radius: 12px;
    box-shadow: 3px 4px 0 var(--ink);
  }

  .float-card strong {
    font-size: 16px;
  }

  .float-line {
    width: 63px;
  }

  .float-line svg {
    width: 51px;
  }

  .hero-stats {
    margin-bottom: 15px;
  }

  .hero-stats strong {
    font-size: 20px;
  }

  .entry-card {
    margin-top: 23px;
    padding: 25px 21px;
    border-radius: 23px;
  }

  .entry-card::after {
    inset: 8px -7px -7px 8px;
    border-radius: 23px;
  }

  .entry-card h2 {
    font-size: 27px;
  }

  .entry-copy {
    margin-bottom: 23px;
  }

  .entry-foot {
    font-size: 8px;
  }

  .room-nav {
    grid-template-columns: 48px 1fr 48px;
  }

  .room-nav-right {
    gap: 0;
  }

  .brand-compact {
    justify-self: start;
  }

  .lobby-heading {
    align-items: flex-start;
  }

  .lobby-heading h1 {
    max-width: 285px;
    font-size: 34px;
  }

  .role-badge {
    margin-top: 3px;
    white-space: nowrap;
  }

  .invite-banner {
    min-height: 130px;
    padding: 19px;
    flex-direction: column;
    align-items: stretch;
    gap: 13px;
  }

  .share-button {
    width: 100%;
    height: 38px;
  }

  .room-code {
    font-size: 32px;
  }

  .lobby-card {
    padding: 19px 16px;
  }

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

  .player-card {
    height: 61px;
    padding: 8px;
  }

  .player-avatar {
    width: 33px;
    height: 33px;
    border-radius: 9px;
  }

  .setup-row {
    padding: 12px 0;
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
  }

  .setup-row:first-of-type {
    border-top: 0;
  }

  .pill-options {
    display: grid;
    width: 100%;
    grid-template-columns: repeat(4, 1fr);
  }

  .pill-options button {
    padding: 0 5px;
  }

  #durationOptions {
    grid-template-columns: repeat(3, 1fr);
  }

  .card-heading {
    gap: 9px;
  }

  .text-button {
    padding: 0 8px;
    white-space: nowrap;
  }

  .pack-card {
    min-height: 99px;
  }

  .start-card {
    min-height: 262px;
    padding: 24px;
  }

  .game-panel {
    padding-top: 10px;
  }

  .game-top {
    margin-bottom: 13px;
  }

  .game-top h1 {
    font-size: 27px;
  }

  .game-top .section-kicker {
    font-size: 7px;
  }

  .player-ribbon {
    max-width: 46%;
  }

  .ribbon-player {
    padding-right: 7px;
  }

  .ribbon-player b {
    display: none;
  }

  .ribbon-player span {
    max-width: 40px;
    font-size: 8px;
  }

  .game-dashboard {
    min-height: 67px;
    gap: 10px;
    border-radius: 15px;
  }

  .timer-ring {
    width: 44px;
    height: 44px;
  }

  .timer-ring svg {
    width: 44px;
    height: 44px;
  }

  .timer-ring strong {
    font-size: 14px;
  }

  .timer-ring circle {
    transform-origin: 26px 26px;
  }

  .timer-block {
    gap: 8px;
  }

  .timer-block b {
    font-size: 9px;
  }

  .hud-label {
    font-size: 7px;
  }

  .my-score strong {
    font-size: 24px;
  }

  .score-block {
    gap: 10px;
  }

  .streak-chip {
    height: 33px;
    padding: 0 9px;
  }

  .streak-chip span {
    font-size: 7px;
  }

  .board-section {
    padding: 10px;
    border-radius: 18px;
  }

  .board-heading {
    min-height: 31px;
    margin-bottom: 9px;
    padding: 0 2px;
  }

  .board-instruction {
    max-width: 230px;
    font-size: 8px;
    line-height: 1.35;
  }

  .ranking-button {
    width: 30px;
    padding: 0;
    justify-content: center;
  }

  .ranking-button:not(svg) {
    font-size: 0;
  }

  .ranking-button svg {
    width: 14px;
    height: 14px;
  }

  .board-grid {
    gap: 6px;
  }

  .word-tile {
    min-height: 64px;
    padding: 20px 4px 7px;
    border-radius: 10px;
  }

  .word-tile::before {
    top: 5px;
    left: 5px;
    width: 15px;
    height: 15px;
    font-size: 5px;
  }

  .tile-word {
    font-size: clamp(11px, 3.75vw, 15px);
  }

  .word-tile[data-long="true"] .tile-word {
    font-size: clamp(9px, 2.75vw, 11px);
  }

  .board-footer {
    margin-top: 9px;
    gap: 10px;
    padding: 0 2px;
    font-size: 7px;
  }

  .board-footer span:last-child {
    display: none;
  }

  .modal-backdrop {
    padding: 12px;
    align-items: end;
  }

  .modal {
    width: 100%;
    max-height: calc(100svh - 24px);
    padding: 23px 20px calc(20px + env(safe-area-inset-bottom));
    border-radius: 22px;
  }

  .modal-header h2 {
    font-size: 24px;
  }

  #wordsTextarea {
    height: 170px;
  }

  .import-tools {
    gap: 7px;
  }

  .import-count {
    width: 100%;
    margin: -4px 0 4px;
  }

  .modal-actions {
    display: grid;
    grid-template-columns: 1fr 1.25fr;
  }

  .modal-actions > * {
    width: 100%;
    min-width: 0;
  }

  .result-modal {
    padding-top: 31px;
  }

  .podium {
    gap: 5px;
  }

  .podium-place {
    min-width: 0;
    width: 31%;
    padding-right: 4px;
    padding-left: 4px;
  }

  .answer-reveal {
    grid-template-columns: 1fr;
  }

  .toast-stack {
    top: calc(10px + env(safe-area-inset-top));
  }
}

@media (max-width: 390px) {
  .hero h1 {
    font-size: 48px;
  }

  .home-nav-tag {
    display: none;
  }

  .float-card {
    width: 108px;
  }

  .float-line {
    width: 56px;
  }

  .entry-card {
    padding: 23px 18px;
  }

  .lobby-heading h1 {
    font-size: 30px;
  }

  .game-top h1 {
    font-size: 24px;
  }

  .player-ribbon {
    max-width: 42%;
  }

  .streak-chip span {
    display: none;
  }

  .word-tile {
    min-height: 61px;
  }
}

@media (hover: none) {
  .word-tile:hover,
  .pack-card:hover {
    transform: none;
  }

  .word-tile.selected:hover {
    transform: translateY(-2px);
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
