:root {
  color-scheme: dark;
  --bg: #070b16;
  --bg-alt: #0b1324;
  --panel: rgba(15, 24, 42, 0.86);
  --panel-strong: rgba(17, 26, 48, 0.96);
  --line: rgba(154, 177, 214, 0.18);
  --line-strong: rgba(154, 177, 214, 0.32);
  --text: #f4f7fb;
  --muted: #95a8c6;
  --muted-strong: #b0c0db;
  --accent: #52d9ff;
  --accent-strong: #7ff0ff;
  --success: #4ce0b3;
  --warning: #ff9f6d;
  --danger: #ff6f7d;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.38);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --safe-bottom: max(20px, env(safe-area-inset-bottom));
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Avenir Next", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(82, 217, 255, 0.16), transparent 32%),
    radial-gradient(circle at 90% 10%, rgba(255, 111, 125, 0.14), transparent 30%),
    linear-gradient(180deg, #09101d 0%, #05070d 100%);
  color: var(--text);
}

button,
input {
  font: inherit;
}

button {
  border: none;
  background: none;
  color: inherit;
}

button:disabled {
  opacity: 0.42;
  pointer-events: none;
}

#app {
  min-height: 100vh;
}

.app-shell {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
  padding: 22px 16px calc(32px + var(--safe-bottom));
}

.app-shell--game {
  padding-left: 12px;
  padding-right: 12px;
  padding-top: 16px;
  padding-bottom: calc(190px + var(--safe-bottom));
}

.ambient {
  position: absolute;
  inset: auto;
  width: 18rem;
  height: 18rem;
  border-radius: 999px;
  filter: blur(28px);
  opacity: 0.6;
  pointer-events: none;
}

.ambient--one {
  top: -3rem;
  right: -5rem;
  background: rgba(82, 217, 255, 0.16);
}

.ambient--two {
  bottom: 10rem;
  left: -7rem;
  background: rgba(255, 111, 125, 0.12);
}

.hero-card,
.panel,
.sheet-card,
.overlay-card,
.end-card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.01)),
    var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero-card,
.lobby-shell,
.end-shell {
  position: relative;
  z-index: 1;
}

.hero-card {
  max-width: 42rem;
  margin: 0 auto;
  padding: 28px 22px;
}

.hero-mark {
  width: 3.4rem;
  height: 3.4rem;
  border-radius: 18px;
  display: grid;
  place-items: center;
  margin-bottom: 1.1rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, rgba(82, 217, 255, 0.3), rgba(255, 111, 125, 0.22));
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.eyebrow {
  margin: 0 0 0.5rem;
  color: var(--accent-strong);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.72rem;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(2.4rem, 8vw, 4.6rem);
  line-height: 0.92;
  letter-spacing: -0.04em;
}

h2 {
  font-size: 1.2rem;
}

.hero-copy,
.helper-copy,
.board-copy,
.selected-piece__copy p,
.selected-piece__status,
.lobby-note,
.info-card p,
.overlay-list,
.score-chip__foot,
.score-chip__corner,
.piece-button__meta {
  color: var(--muted);
}

.hero-copy {
  margin-top: 1rem;
  font-size: 1rem;
  line-height: 1.55;
  max-width: 31rem;
}

.hero-actions,
.lobby-actions,
.sheet-actions,
.control-row,
.end-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.8rem;
}

.hero-actions {
  margin-top: 1.6rem;
}

.button {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  transition:
    transform 180ms ease,
    box-shadow 180ms ease,
    border-color 180ms ease,
    background 180ms ease;
  cursor: pointer;
}

.button:hover,
.button:focus-visible {
  transform: translateY(-1px);
}

.button--primary {
  background: linear-gradient(135deg, #52d9ff, #86f7ff);
  color: #04111d;
  box-shadow: 0 16px 34px rgba(82, 217, 255, 0.28);
}

.button--secondary {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.button--ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted-strong);
}

.button--sm {
  min-height: 44px;
  padding: 0 14px;
}

.hero-pills,
.score-rules,
.board-legend,
.chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.hero-pills {
  margin-top: 1.2rem;
}

.hero-pills span,
.score-rules span,
.board-legend span,
.choice-chip,
.turn-pill,
.room-code {
  border-radius: 999px;
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
}

.home-showcase {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 1rem;
  max-width: 42rem;
  margin: 1rem auto 0;
}

.info-card {
  padding: 20px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: rgba(8, 14, 25, 0.82);
}

.sheet-backdrop,
.overlay-shell {
  position: fixed;
  inset: 0;
  padding: 24px 16px;
  display: grid;
  place-items: center;
  background: rgba(3, 7, 14, 0.6);
  z-index: 20;
}

.sheet-card,
.overlay-card {
  width: min(100%, 28rem);
  padding: 22px;
}

.input-label {
  display: block;
  margin: 1rem 0 0.35rem;
  color: var(--muted-strong);
  font-weight: 600;
}

.text-input {
  width: 100%;
  min-height: 54px;
  border-radius: 16px;
  border: 1px solid var(--line-strong);
  background: rgba(5, 11, 23, 0.88);
  color: var(--text);
  padding: 0 14px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.choice-chip {
  cursor: pointer;
  transition: all 180ms ease;
}

.choice-chip--active {
  color: #04111d;
  border-color: transparent;
  background: linear-gradient(135deg, #52d9ff, #86f7ff);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.9rem;
}

.room-code {
  font-weight: 800;
  letter-spacing: 0.18em;
}

.room-code--small {
  padding: 0.35rem 0.65rem;
  font-size: 0.78rem;
}

.lobby-shell,
.end-shell {
  max-width: 40rem;
  margin: 0 auto;
}

.lobby-shell .panel,
.end-card {
  padding: 24px;
}

.player-list,
.score-list {
  display: grid;
  gap: 0.8rem;
}

.player-list {
  margin: 1.1rem 0;
}

.player-list__item,
.score-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 14px 16px;
  border-radius: 20px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
}

.game-shell {
  position: relative;
  z-index: 1;
}

.game-layout {
  display: grid;
  gap: 1rem;
}

.game-main,
.game-side {
  display: grid;
  gap: 1rem;
}

.panel {
  padding: 18px;
}

.panel-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.score-list {
  gap: 0.75rem;
}

.score-chip {
  position: relative;
  overflow: hidden;
}

.score-chip::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at left, var(--glow), transparent 58%);
  opacity: 0.6;
}

.score-chip > * {
  position: relative;
  z-index: 1;
}

.score-chip--active {
  border-color: rgba(255, 255, 255, 0.16);
  transform: translateY(-1px);
}

.score-chip__meta {
  display: grid;
  gap: 0.15rem;
}

.score-chip__name {
  font-weight: 700;
}

.score-chip__value {
  font-size: 1.55rem;
  font-weight: 800;
}

.board-wrap {
  position: relative;
}

.board-panel {
  overflow: hidden;
}

.board-shell {
  position: relative;
  padding: 10px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.02), rgba(255, 255, 255, 0)),
    rgba(5, 11, 22, 0.92);
  transition: transform 180ms ease, border-color 180ms ease;
}

.board-shell--invalid {
  border-color: rgba(255, 111, 125, 0.44);
  animation: boardShake 360ms ease;
}

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

.board-cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition:
    transform 140ms ease,
    background 180ms ease,
    border-color 180ms ease,
    box-shadow 180ms ease;
}

.board-cell::after {
  content: "";
  position: absolute;
  inset: 26%;
  border-radius: 999px;
  opacity: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.board-cell--occupied {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.22), var(--player));
  border-color: transparent;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.12);
}

.board-cell--occupied::after {
  inset: 16%;
  opacity: 1;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.24), transparent 50%);
}

.board-cell--corner {
  border-color: rgba(255, 255, 255, 0.15);
}

.board-cell--corner:not(.board-cell--occupied)::after {
  opacity: 1;
  transform: scale(0.78);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.34), transparent 65%);
}

.board-cell--legal-anchor::after {
  opacity: 1;
  background: radial-gradient(circle, var(--player), transparent 72%);
  box-shadow: 0 0 18px var(--glow);
}

.board-cell--preview-valid {
  border-color: rgba(76, 224, 179, 0.42);
  background: linear-gradient(180deg, rgba(76, 224, 179, 0.2), rgba(76, 224, 179, 0.08));
}

.board-cell--preview-invalid {
  border-color: rgba(255, 111, 125, 0.46);
  background: linear-gradient(180deg, rgba(255, 111, 125, 0.16), rgba(255, 111, 125, 0.04));
}

.board-cell--clearing {
  animation: clearPulse 720ms ease forwards;
}

.board-copy {
  margin-top: 0.9rem;
  font-size: 0.95rem;
  line-height: 1.5;
}

.selected-piece {
  display: grid;
  gap: 1rem;
}

.selected-piece__preview {
  padding: 18px;
  border-radius: 20px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  place-items: center;
}

.selected-piece__copy {
  display: grid;
  gap: 0.35rem;
}

.selected-piece__status {
  min-height: 1.3rem;
  font-size: 0.94rem;
}

.selected-piece__status--valid {
  color: var(--success);
}

.selected-piece__status--invalid {
  color: var(--danger);
}

.piece-tray {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(104px, 1fr);
  gap: 0.75rem;
  overflow-x: auto;
  padding-bottom: 0.4rem;
  scroll-snap-type: x proximity;
}

.piece-button {
  min-height: 126px;
  padding: 14px 12px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  display: grid;
  justify-items: center;
  align-content: center;
  gap: 0.45rem;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
  scroll-snap-align: start;
}

.piece-button--active {
  transform: translateY(-2px);
  border-color: rgba(82, 217, 255, 0.42);
  background: rgba(82, 217, 255, 0.08);
  box-shadow: 0 0 0 1px rgba(82, 217, 255, 0.1), 0 14px 26px rgba(82, 217, 255, 0.12);
}

.piece-button__name {
  font-weight: 700;
}

.piece-glyph {
  display: grid;
  grid-template-columns: repeat(var(--cols), 1fr);
  grid-template-rows: repeat(var(--rows), 1fr);
  gap: 4px;
  align-items: stretch;
  justify-items: stretch;
}

.piece-glyph--small {
  width: min(56px, calc(var(--cols) * 14px + 12px));
  height: min(56px, calc(var(--rows) * 14px + 12px));
}

.piece-glyph--large {
  width: min(112px, calc(var(--cols) * 24px + 20px));
  height: min(112px, calc(var(--rows) * 24px + 20px));
}

.piece-glyph__cell {
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(82, 217, 255, 0.88), rgba(52, 150, 255, 0.76));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 10px 24px rgba(82, 217, 255, 0.22);
}

.piece-glyph__cell--anchor {
  outline: 2px solid rgba(255, 255, 255, 0.42);
  outline-offset: -2px;
}

.score-pop {
  position: absolute;
  transform: translate(-50%, 0);
  color: var(--accent-strong);
  font-weight: 800;
  text-shadow: 0 0 20px rgba(82, 217, 255, 0.4);
  animation: floatUp 1.2s ease forwards;
  pointer-events: none;
}

.turn-pill {
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.04), 0 0 32px var(--glow);
}

.toast {
  border-radius: 999px;
  padding: 0.7rem 1rem;
  width: fit-content;
  max-width: min(90vw, 36rem);
  background: rgba(9, 18, 34, 0.94);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: var(--shadow);
}

.toast--inline {
  justify-self: start;
}

.toast--floating {
  position: fixed;
  left: 50%;
  bottom: calc(148px + var(--safe-bottom));
  transform: translateX(-50%);
  z-index: 30;
}

.toast--success {
  border-color: rgba(76, 224, 179, 0.24);
}

.toast--warning {
  border-color: rgba(255, 159, 109, 0.3);
}

.automation-canvas {
  position: absolute;
  width: 1px;
  height: 1px;
  left: -9999px;
  top: -9999px;
  opacity: 0.001;
  pointer-events: none;
}

.overlay-card h2 {
  margin-bottom: 0.75rem;
}

.overlay-list {
  display: grid;
  gap: 0.55rem;
  margin: 0 0 1.1rem;
  padding-left: 1.1rem;
  line-height: 1.5;
}

.game-layout {
  max-width: 42rem;
  margin: 0 auto;
}

.game-main {
  gap: 0.9rem;
}

.topbar--game {
  max-width: 42rem;
  margin: 0 auto 0.7rem;
}

.topbar__cluster {
  display: flex;
  align-items: center;
  gap: 0.55rem;
}

.turn-mini {
  border-radius: 999px;
  padding: 0.38rem 0.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--line);
  color: var(--text);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.03), 0 0 24px color-mix(in srgb, var(--player) 22%, transparent);
}

.turn-panel,
.board-panel,
.tray-panel,
.selected-piece--dock {
  padding: 14px;
  border-radius: 24px;
}

.turn-panel {
  display: grid;
  gap: 0.85rem;
}

.turn-panel__hero,
.board-panel__head,
.tray-panel__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.9rem;
}

.turn-panel__copy {
  display: grid;
  gap: 0.3rem;
}

.turn-steps {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.5rem;
}

.turn-step {
  border-radius: 999px;
  padding: 0.55rem 0.7rem;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--muted);
  text-align: center;
  font-size: 0.82rem;
  font-weight: 700;
}

.turn-step--active {
  color: var(--text);
  border-color: rgba(82, 217, 255, 0.28);
  background: rgba(82, 217, 255, 0.08);
}

.score-strip {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: minmax(104px, 1fr);
  gap: 0.55rem;
  overflow-x: auto;
  padding-bottom: 0.15rem;
  scroll-snap-type: x proximity;
}

.score-pill {
  position: relative;
  display: grid;
  gap: 0.18rem;
  min-height: 70px;
  padding: 0.75rem 0.82rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
  scroll-snap-align: start;
}

.score-pill::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at left, var(--glow), transparent 62%);
  opacity: 0.48;
}

.score-pill > * {
  position: relative;
  z-index: 1;
}

.score-pill--active {
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: 0 14px 32px rgba(0, 0, 0, 0.22);
}

.score-pill__name,
.score-pill__meta {
  font-size: 0.76rem;
}

.score-pill__name {
  font-weight: 700;
}

.score-pill__score {
  font-size: 1.35rem;
  line-height: 1;
}

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

.board-wrap {
  position: relative;
}

.board-panel {
  display: grid;
  gap: 0.75rem;
}

.board-summary {
  display: grid;
  gap: 0.7rem;
}

.board-summary__hero {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.75rem;
}

.board-summary__copy {
  display: grid;
  gap: 0.22rem;
}

.board-legend {
  justify-content: flex-start;
  gap: 0.45rem;
}

.board-legend span {
  padding: 0.42rem 0.7rem;
  font-size: 0.8rem;
}

.board-shell {
  padding: 7px;
  border-radius: 26px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.01)),
    rgba(4, 10, 21, 0.94);
  overflow: hidden;
}

.board-shell--clear {
  border-color: rgba(82, 217, 255, 0.22);
  animation: boardCelebrate 820ms ease;
}

.board-shell--clear::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(82, 217, 255, 0.04) 38%,
    rgba(82, 217, 255, 0.18) 50%,
    rgba(255, 255, 255, 0.1) 54%,
    transparent 72%
  );
  animation: boardSweep 820ms ease forwards;
  pointer-events: none;
}

.board-grid {
  gap: 2px;
}

.board-cell {
  border-radius: 9px;
}

.board-cell--focus {
  transform: scale(1.04);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.26), 0 0 24px var(--glow);
}

.board-cell--preview-valid {
  border-color: rgba(76, 224, 179, 0.58);
  background: linear-gradient(180deg, rgba(76, 224, 179, 0.24), rgba(76, 224, 179, 0.1));
}

.board-cell--preview-invalid {
  border-color: rgba(255, 111, 125, 0.56);
}

.board-cell--clearing {
  animation: clearPulse 820ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.board-copy {
  margin-top: 0;
  font-size: 0.88rem;
}

.selected-piece--dock {
  position: fixed;
  left: 50%;
  bottom: calc(8px + var(--safe-bottom));
  transform: translateX(-50%);
  width: min(calc(100vw - 12px), 42rem);
  z-index: 8;
  display: grid;
  gap: 0.45rem;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.02)),
    rgba(11, 18, 34, 0.94);
  border-color: rgba(255, 255, 255, 0.1);
  box-shadow: 0 18px 56px rgba(0, 0, 0, 0.42);
}

.selected-piece__top {
  display: grid;
  grid-template-columns: 60px minmax(0, 1fr);
  gap: 0.45rem;
  align-items: center;
}

.selected-piece__preview {
  min-height: 60px;
  padding: 6px;
}

.selected-piece__empty {
  display: grid;
  place-items: center;
  min-height: 58px;
  color: var(--muted);
  font-weight: 700;
}

.selected-piece__title-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
}

.selected-piece__size {
  border-radius: 999px;
  padding: 0.35rem 0.55rem;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.05);
  color: var(--muted-strong);
  font-size: 0.74rem;
  white-space: nowrap;
}

.selected-piece__facts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.42rem;
}

.selected-piece__facts span {
  border-radius: 999px;
  padding: 0.35rem 0.58rem;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted-strong);
  font-size: 0.74rem;
}

.selected-piece__status {
  min-height: 1rem;
  font-size: 0.74rem;
  line-height: 1.2;
  margin: 0;
}

.selected-piece__copy p {
  font-size: 0.82rem;
  line-height: 1.15;
}

.control-strip {
  display: grid;
  grid-template-columns: auto 56px 56px minmax(0, 1fr);
  gap: 0.42rem;
  align-items: center;
}

.spot-switch {
  display: grid;
  grid-template-columns: repeat(2, 40px);
  gap: 0.35rem;
}

.control-strip .button,
.spot-switch .button {
  width: 100%;
  min-height: 40px;
  padding: 0 10px;
}

.button--dock-main {
  min-height: 42px;
  font-size: 0.92rem;
}

.piece-tray {
  grid-auto-columns: minmax(128px, 42vw);
  gap: 0.8rem;
  padding-bottom: 0.55rem;
}

.dock-rack {
  display: grid;
  gap: 0.28rem;
}

.dock-rack__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  color: var(--muted);
  font-size: 0.76rem;
}

.piece-tray--dock {
  grid-auto-columns: minmax(66px, 20vw);
  gap: 0.42rem;
  padding-bottom: 0;
}

.piece-button {
  min-height: 134px;
  padding: 15px 12px;
  border-radius: 20px;
}

.piece-tray--dock .piece-button {
  min-height: 68px;
  padding: 7px 6px;
  gap: 0.2rem;
}

.piece-tray--dock .piece-button__name {
  font-size: 0.66rem;
  line-height: 1.05;
  max-width: 100%;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.piece-tray--dock .piece-button__meta {
  display: none;
}

.piece-tray--dock .piece-glyph--small {
  width: min(46px, calc(var(--cols) * 11px + 8px));
  height: min(46px, calc(var(--rows) * 11px + 8px));
}

.piece-button__name {
  font-size: 0.92rem;
}

.piece-button__meta {
  font-size: 0.78rem;
}

.piece-glyph--small {
  width: min(64px, calc(var(--cols) * 16px + 14px));
  height: min(64px, calc(var(--rows) * 16px + 14px));
}

.piece-glyph--large {
  width: min(56px, calc(var(--cols) * 11px + 8px));
  height: min(56px, calc(var(--rows) * 11px + 8px));
}

.score-pop {
  font-size: 1.12rem;
  animation: floatUp 1.35s ease forwards;
}

.overlay-card--tutorial {
  width: min(100%, 34rem);
}

.tutorial-grid {
  display: grid;
  gap: 0.7rem;
  margin: 1rem 0;
}

.tutorial-card {
  display: grid;
  gap: 0.3rem;
  padding: 0.95rem 1rem;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.04);
}

.tutorial-card h3 {
  font-size: 1rem;
}

.tutorial-card p {
  color: var(--muted);
  line-height: 1.45;
}

.tutorial-card__num {
  width: 1.8rem;
  height: 1.8rem;
  border-radius: 999px;
  display: grid;
  place-items: center;
  background: rgba(82, 217, 255, 0.14);
  color: var(--accent-strong);
  font-weight: 800;
  font-size: 0.82rem;
}

@keyframes clearPulse {
  0% {
    transform: scale(1);
    opacity: 1;
  }
  45% {
    transform: scale(1.12);
    opacity: 1;
    box-shadow: 0 0 26px rgba(82, 217, 255, 0.42);
  }
  100% {
    transform: scale(0.82);
    opacity: 0.06;
  }
}

@keyframes floatUp {
  0% {
    opacity: 0;
    transform: translate(-50%, 10px);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -40px);
  }
}

@keyframes boardShake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  40% {
    transform: translateX(4px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(2px);
  }
}

@keyframes boardCelebrate {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(82, 217, 255, 0);
  }
  32% {
    transform: scale(1.01);
    box-shadow: 0 0 34px rgba(82, 217, 255, 0.18);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(82, 217, 255, 0);
  }
}

@keyframes boardSweep {
  0% {
    transform: translateX(-100%);
    opacity: 0;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translateX(100%);
    opacity: 0;
  }
}

@media (min-width: 900px) {
  .app-shell {
    padding: 28px 22px 36px;
  }

  .hero-card {
    padding: 34px 32px;
  }

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

  .game-layout,
  .topbar--game {
    max-width: 48rem;
  }

  .turn-panel,
  .board-panel,
  .tray-panel,
  .selected-piece--dock {
    padding: 18px;
  }

  .piece-tray {
    grid-auto-columns: minmax(132px, 1fr);
  }

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