:root {
  --ink: #32180f;
  --muted: #7c5844;
  --cream: #fff4d6;
  --paper: rgba(255, 250, 236, 0.82);
  --card: #fff9eb;
  --line: rgba(82, 45, 26, 0.16);
  --accent: #f35f3d;
  --accent-2: #ffc247;
  --green: #53bf86;
  --shadow: 0 22px 70px rgba(92, 45, 20, 0.22);
  --tile-w: clamp(58px, 13.5vw, 86px);
  --tile-h: clamp(68px, 15vw, 96px);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #ffe5aa;
}

body {
  min-height: 100%;
  margin: 0;
  color: var(--ink);
  font-family: "Microsoft YaHei", "PingFang SC", "Noto Sans SC", sans-serif;
  background:
    radial-gradient(circle at 16% 10%, rgba(255, 255, 255, 0.9) 0 7%, transparent 18%),
    radial-gradient(circle at 78% 4%, rgba(255, 194, 71, 0.95) 0 10%, transparent 24%),
    linear-gradient(135deg, #ff7b52 0%, #ffd36e 42%, #6ad5b0 100%);
  overflow-x: hidden;
}

body::before,
body::after {
  position: fixed;
  z-index: -1;
  width: 42vmax;
  height: 42vmax;
  border-radius: 41% 59% 56% 44%;
  content: "";
  filter: blur(2px);
  opacity: 0.28;
}

body::before {
  left: -18vmax;
  top: 22vh;
  background: #fff4d6;
  animation: floatBlob 16s ease-in-out infinite alternate;
}

body::after {
  right: -20vmax;
  bottom: -14vmax;
  background: #f35f3d;
  animation: floatBlob 13s ease-in-out infinite alternate-reverse;
}

button {
  color: inherit;
  font: inherit;
}

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) 0 34px;
}

.hero {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 20px;
  border: 1px solid rgba(255, 255, 255, 0.44);
  border-radius: 32px;
  background: rgba(255, 248, 228, 0.54);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.hero h1 {
  margin: 0;
  font-size: clamp(2.1rem, 8vw, 5.5rem);
  letter-spacing: -0.08em;
  line-height: 0.92;
  text-shadow: 0 5px 0 rgba(255, 255, 255, 0.55);
}

.eyebrow {
  margin: 0 0 8px;
  color: #8c3d27;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

.hero__line {
  max-width: 700px;
  margin: 12px 0 0;
  color: #643a24;
  font-size: clamp(0.98rem, 2vw, 1.22rem);
  font-weight: 700;
}

.install-button,
.button {
  border: 0;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  box-shadow: 0 10px 24px rgba(95, 43, 20, 0.14);
  cursor: pointer;
  font-weight: 900;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.install-button {
  flex: 0 0 auto;
  padding: 14px 18px;
}

.button {
  min-height: 46px;
  padding: 11px 16px;
}

.fortune-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff8ec;
  text-decoration: none;
  background: linear-gradient(135deg, #35a977, #ffc247);
  box-shadow: 0 14px 28px rgba(53, 169, 119, 0.24);
}

.fortune-entry {
  display: grid;
  gap: 4px;
  margin-bottom: 12px;
  padding: 15px 16px;
  border: 1px solid rgba(255, 255, 255, 0.54);
  border-radius: 22px;
  color: #fff8ec;
  text-decoration: none;
  background: linear-gradient(135deg, #35a977 0%, #ffc247 100%);
  box-shadow: 0 16px 34px rgba(53, 169, 119, 0.26);
}

.fortune-entry span {
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.14em;
}

.fortune-entry strong {
  font-size: clamp(1.28rem, 4vw, 1.8rem);
  font-weight: 1000;
  letter-spacing: -0.04em;
}

.fortune-entry em {
  font-style: normal;
  font-size: 0.88rem;
  font-weight: 850;
  opacity: 0.92;
}

.button--primary {
  color: #fff8ec;
  background: linear-gradient(135deg, #f35f3d, #d93d28);
}

.button:active,
.install-button:active {
  transform: translateY(2px) scale(0.98);
}

.button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.game-layout {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) 250px;
  gap: 18px;
  margin-top: 18px;
}

.panel,
.game-card {
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 28px;
  background: var(--paper);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.panel {
  padding: 18px;
  align-self: start;
}

.panel__title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.panel h2 {
  margin: 0;
  font-size: 1.15rem;
}

.tiny-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #7a3b21;
  background: rgba(255, 194, 71, 0.42);
  font-size: 0.72rem;
  font-weight: 900;
  white-space: nowrap;
}

.cast-grid {
  display: grid;
  gap: 12px;
}

.cast-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.44);
}

.cast-avatar {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  color: #fff;
  font-size: 1.35rem;
  font-weight: 1000;
  overflow: hidden;
  box-shadow: inset 0 -8px 16px rgba(0, 0, 0, 0.16);
}

.cast-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.cast-card h3 {
  margin: 0 0 3px;
  font-size: 1rem;
}

.cast-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.35;
}

.game-card {
  padding: clamp(12px, 2vw, 18px);
}

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

.hud__item {
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.46);
}

.hud__item span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
}

.hud__item strong {
  display: block;
  margin-top: 2px;
  font-size: 1.18rem;
}

.meter {
  height: 14px;
  margin: 12px 0;
  overflow: hidden;
  border: 1px solid rgba(89, 41, 21, 0.12);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.62);
}

.meter span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #53bf86, #ffc247 54%, #f35f3d);
  transition: width 0.28s ease;
}

.level-strip {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.level-pill {
  flex: 1;
  min-width: 132px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.45);
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 900;
  text-align: left;
}

.level-pill.is-active {
  color: #fff;
  background: linear-gradient(135deg, #32180f, #8d3d23);
}

.board-wrap {
  position: relative;
  height: clamp(390px, 58vh, 650px);
  overflow: hidden;
  border: 1px solid rgba(93, 45, 22, 0.18);
  border-radius: 30px;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.22) 1px, transparent 1px) 0 0 / 34px 34px,
    linear-gradient(rgba(255, 255, 255, 0.22) 1px, transparent 1px) 0 0 / 34px 34px,
    radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.66), transparent 45%),
    rgba(255, 243, 203, 0.66);
}

.board {
  position: absolute;
  inset: 0;
}

.tile {
  position: absolute;
  display: grid;
  grid-template-rows: 1fr auto;
  align-items: center;
  justify-items: center;
  width: var(--tile-w);
  height: var(--tile-h);
  padding: 8px 7px 7px;
  border: 1px solid rgba(75, 35, 18, 0.24);
  border-radius: 18px;
  background:
    radial-gradient(circle at 30% 15%, rgba(255, 255, 255, 0.92), transparent 34%),
    linear-gradient(145deg, var(--tile-color), color-mix(in srgb, var(--tile-color), #32180f 19%));
  box-shadow:
    0 12px 0 color-mix(in srgb, var(--tile-color), #32180f 28%),
    0 16px 22px rgba(68, 31, 15, 0.24);
  cursor: pointer;
  user-select: none;
  transition:
    transform 0.16s ease,
    filter 0.16s ease,
    opacity 0.16s ease,
    left 0.22s ease,
    top 0.22s ease;
}

.tile:hover {
  transform: translateY(-4px) rotate(var(--rotation));
}

.tile.is-blocked {
  cursor: not-allowed;
  filter: grayscale(0.75) brightness(0.78);
}

.tile.is-blocked::after {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  border-radius: inherit;
  color: rgba(255, 255, 255, 0.92);
  background: rgba(37, 21, 14, 0.42);
  content: "压住";
  font-size: 0.82rem;
  font-weight: 1000;
  letter-spacing: 0.1em;
}

.tile.is-flying {
  pointer-events: none;
  transform: scale(0.7) rotate(7deg);
  opacity: 0;
}

.tile__icon {
  color: #fff;
  font-size: clamp(1.4rem, 5vw, 2rem);
  font-weight: 1000;
  line-height: 1;
  text-shadow: 0 3px 0 rgba(0, 0, 0, 0.12);
}

.tile__label {
  max-width: 100%;
  padding: 3px 6px;
  border-radius: 999px;
  color: #4c2414;
  background: rgba(255, 255, 255, 0.78);
  font-size: clamp(0.62rem, 2.8vw, 0.72rem);
  font-weight: 1000;
  text-align: center;
  white-space: nowrap;
}

.tray-wrap {
  margin-top: 13px;
}

.tray-label {
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.tray {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 7px;
  min-height: 82px;
  padding: 8px;
  border: 2px dashed rgba(83, 42, 23, 0.24);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.38);
}

.tray-slot {
  display: grid;
  place-items: center;
  min-height: 64px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.5);
}

.tray .mini-tile {
  width: 100%;
  min-height: 64px;
  padding: 7px 4px;
  border-radius: 15px;
  color: #fff;
  background: var(--tile-color);
  box-shadow: inset 0 -7px 14px rgba(0, 0, 0, 0.14);
  text-align: center;
  animation: popIn 0.2s ease both;
}

.mini-tile strong,
.mini-tile span {
  display: block;
}

.mini-tile strong {
  font-size: 1.24rem;
}

.mini-tile span {
  margin-top: 3px;
  color: rgba(255, 255, 255, 0.94);
  font-size: 0.62rem;
  font-weight: 900;
}

.mini-tile.is-clearing {
  animation: clearOut 0.28s ease forwards;
}

.controls {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1fr 1fr;
  gap: 9px;
  margin-top: 13px;
}

.rules-list {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
  font-weight: 750;
  line-height: 1.65;
}

.quote-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: 20px;
  color: #fff8ed;
  background: linear-gradient(135deg, #32180f, #8c3d27);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2);
  font-weight: 900;
  line-height: 1.55;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: calc(22px + env(safe-area-inset-bottom));
  z-index: 30;
  max-width: min(520px, calc(100% - 28px));
  padding: 12px 16px;
  border-radius: 999px;
  color: #fff8ed;
  background: rgba(50, 24, 15, 0.9);
  box-shadow: 0 16px 38px rgba(45, 20, 10, 0.32);
  font-weight: 900;
  pointer-events: none;
  transform: translate(-50%, 18px);
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  place-items: center;
  padding: 18px;
}

.modal.is-open {
  display: grid;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 17, 9, 0.5);
  backdrop-filter: blur(6px);
}

.modal__card {
  position: relative;
  width: min(520px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: 30px;
  background: #fff7df;
  box-shadow: 0 30px 80px rgba(24, 10, 4, 0.36);
}

.modal__card h2 {
  margin: 0 0 8px;
  font-size: clamp(1.8rem, 6vw, 3rem);
  letter-spacing: -0.06em;
}

.modal__card p:not(.eyebrow) {
  color: var(--muted);
  font-weight: 750;
  line-height: 1.65;
}

.modal__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 1020px) {
  .game-layout {
    grid-template-columns: 1fr;
  }

  .family-panel {
    order: 2;
  }

  .rules-panel {
    order: 3;
  }

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

@media (max-width: 680px) {
  :root {
    --tile-w: 58px;
    --tile-h: 72px;
  }

  .app-shell {
    width: min(100% - 18px, 1180px);
    padding-bottom: 18px;
  }

  .hero {
    display: block;
    padding: 17px;
    border-radius: 24px;
  }

  .install-button {
    width: 100%;
    margin-top: 14px;
  }

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

  .board-wrap {
    height: 430px;
    border-radius: 24px;
  }

  .tray {
    gap: 5px;
    padding: 6px;
  }

  .tray-slot,
  .tray .mini-tile {
    min-height: 58px;
  }

  .mini-tile strong {
    font-size: 1.05rem;
  }

  .mini-tile span {
    display: none;
  }

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

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

@keyframes floatBlob {
  from {
    transform: translate3d(0, 0, 0) rotate(0deg);
  }

  to {
    transform: translate3d(3vmax, -2vmax, 0) rotate(16deg);
  }
}

@keyframes popIn {
  from {
    transform: scale(0.6);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes clearOut {
  to {
    transform: translateY(-8px) scale(0.5) rotate(10deg);
    opacity: 0;
  }
}

.online-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.46);
}

.online-bar span {
  display: block;
  color: var(--muted);
  font-size: 0.74rem;
  font-weight: 900;
}

.online-bar strong {
  display: block;
  margin-top: 2px;
  font-size: 1.12rem;
}

.online-bar__actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.score-status {
  margin-top: 12px;
  padding: 11px 13px;
  border-radius: 18px;
  color: #6b4028;
  background: rgba(255, 255, 255, 0.5);
  font-size: 0.86rem;
  font-weight: 900;
  line-height: 1.5;
}

.score-status[data-tone="ok"] {
  color: #17603d;
  background: rgba(83, 191, 134, 0.18);
}

.score-status[data-tone="error"] {
  color: #8c2d1b;
  background: rgba(243, 95, 61, 0.15);
}

.score-status__retry {
  border: 0;
  border-radius: 999px;
  padding: 6px 10px;
  color: #fff8ec;
  background: #32180f;
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 1000;
}

.leaderboard-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  place-items: center;
  padding: 18px;
}

.leaderboard-overlay.is-open {
  display: grid;
}

.leaderboard-overlay__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(38, 17, 9, 0.56);
  backdrop-filter: blur(8px);
}

.leaderboard-modal {
  position: relative;
  width: min(760px, 100%);
  max-height: min(82vh, 760px);
  overflow: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.62);
  border-radius: 30px;
  background: #fff7df;
  box-shadow: 0 30px 90px rgba(28, 12, 5, 0.38);
}

.leaderboard-modal__close {
  position: sticky;
  top: 0;
  float: right;
  width: 38px;
  height: 38px;
  border: 0;
  border-radius: 50%;
  background: #32180f;
  color: #fff8ec;
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 1000;
}

.leaderboard-modal h2 {
  margin: 0 0 10px;
  font-size: clamp(1.8rem, 6vw, 3.2rem);
  letter-spacing: -0.06em;
}

.leaderboard-copy,
.leaderboard-loading,
.leaderboard-empty {
  color: var(--muted);
  font-weight: 850;
  line-height: 1.7;
}

.player-picker {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 10px;
  margin: 18px 0;
}

.player-chip {
  min-height: 54px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255, 194, 71, 0.52), rgba(255, 255, 255, 0.72));
  cursor: pointer;
  font-weight: 1000;
}

.custom-player-form {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.45);
}

.custom-player-form label {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 900;
}

.custom-player-form div {
  display: flex;
  gap: 8px;
}

.custom-player-form input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 14px;
  background: rgba(255, 255, 255, 0.86);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
}

.leaderboard-list {
  display: grid;
  gap: 10px;
  margin: 16px 0;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 82px 1fr;
  gap: 12px;
  padding: 13px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgba(255, 255, 255, 0.52);
}

.leaderboard-rank {
  display: grid;
  place-items: center;
  min-height: 66px;
  border-radius: 18px;
  color: #fff8ec;
  background: linear-gradient(135deg, #32180f, #8c3d27);
  font-weight: 1000;
  text-align: center;
}

.leaderboard-row h3 {
  margin: 0 0 4px;
  font-size: 1.14rem;
}

.leaderboard-row p {
  margin: 3px 0;
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 850;
  line-height: 1.5;
}

.fun-boards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 10px;
}

.fun-board {
  padding: 13px;
  border-radius: 20px;
  color: #fff8ec;
  background: linear-gradient(135deg, #f35f3d, #32180f);
}

.fun-board span,
.fun-board strong,
.fun-board p {
  display: block;
}

.fun-board span {
  font-size: 0.75rem;
  font-weight: 1000;
  letter-spacing: 0.08em;
}

.fun-board strong {
  margin: 5px 0;
  font-size: 1rem;
}

.fun-board p {
  margin: 0;
  color: rgba(255, 248, 236, 0.86);
  font-size: 0.78rem;
  font-weight: 850;
  line-height: 1.45;
}

@media (max-width: 680px) {
  .online-bar {
    display: block;
  }

  .online-bar__actions {
    justify-content: stretch;
    margin-top: 10px;
  }

  .online-bar__actions .button {
    flex: 1;
  }

  .leaderboard-modal {
    padding: 18px;
    border-radius: 24px;
  }

  .leaderboard-row {
    grid-template-columns: 1fr;
  }
}
