:root {
  --ink: #4d2333;
  --ink-soft: #8e5b6e;
  --ink-faint: #ab7a8b;
  --berry: #9d2b50;
  --berry-deep: #761a3a;
  --rose: #df5b82;
  --rose-bright: #ee6d91;
  --gold: #bd842c;
  --gold-deep: #9d6720;
  --cream: #fff3d6;
  --white: #fffdfd;
  --line: rgba(255, 255, 255, 0.7);
  --glass: rgba(255, 255, 255, 0.42);
  --glass-strong: rgba(255, 255, 255, 0.72);
  --shadow-soft: 0 20px 44px -22px rgba(128, 37, 76, 0.36);
  --shadow-card: 0 16px 36px -20px rgba(125, 35, 72, 0.3);
  --board-gap: 10px;
  --tile-radius: 17px;
  --title-size: clamp(34px, 8vw, 54px);
  --font-sans: "PingFang SC", "Hiragino Sans GB", "Noto Sans SC", "Microsoft YaHei",
    "Helvetica Neue", Arial, sans-serif;
  --font-display: "Avenir Next", "Helvetica Neue", "PingFang SC", sans-serif;
  --font-serif: "Songti SC", "STSong", "Noto Serif SC", Georgia, serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background:
    radial-gradient(100% 75% at 8% 0%, rgba(255, 255, 255, 0.96), transparent 60%),
    radial-gradient(80% 60% at 98% 8%, rgba(255, 239, 211, 0.86), transparent 62%),
    radial-gradient(105% 80% at 55% 105%, rgba(255, 211, 222, 0.9), transparent 68%),
    linear-gradient(145deg, #fff6f7 0%, #ffe3ec 34%, #ffd1e1 62%, #ffe1d1 100%);
  font-family: var(--font-sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

body.has-overlay {
  overflow: hidden;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--berry);
  outline-offset: 3px;
}

::selection {
  color: #fff;
  background: var(--rose);
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.sr-only {
  position: absolute !important;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 100;
  padding: 10px 16px;
  color: #fff;
  text-decoration: none;
  background: var(--berry-deep);
  border-radius: 10px;
  transform: translateY(-160%);
  transition: transform 160ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

/* ---------- Ambient background ---------- */

.ambient {
  position: fixed;
  inset: 0;
  z-index: -1;
  overflow: hidden;
  pointer-events: none;
}

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

.ambient__orb--one {
  top: -12%;
  right: -14%;
  width: 52vmax;
  height: 52vmax;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 245, 230, 0.92),
    rgba(255, 210, 225, 0.42) 46%,
    transparent 70%
  );
}

.ambient__orb--two {
  bottom: -18%;
  left: -18%;
  width: 46vmax;
  height: 46vmax;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(255, 255, 255, 0.76),
    rgba(255, 187, 210, 0.3) 52%,
    transparent 72%
  );
  animation-delay: -7s;
}

.ambient__orb--three {
  top: 42%;
  left: 38%;
  width: 28vmax;
  height: 28vmax;
  background: radial-gradient(circle, rgba(255, 194, 210, 0.35), transparent 68%);
  animation-delay: -12s;
}

.ambient__ring {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(82vw, 920px);
  aspect-ratio: 1;
  border: 1px solid rgba(255, 255, 255, 0.46);
  border-radius: 50%;
  box-shadow:
    inset 0 0 0 32px rgba(255, 255, 255, 0.035),
    inset 0 0 0 33px rgba(255, 255, 255, 0.3);
  transform: translate(-50%, -50%);
}

.ambient__note {
  position: absolute;
  color: rgba(133, 39, 76, 0.13);
  font-family: var(--font-serif);
  line-height: 1;
  text-shadow: 0 8px 22px rgba(255, 255, 255, 0.6);
  animation: noteFloat 11s ease-in-out infinite alternate;
}

.ambient__note--one {
  top: 18%;
  left: 7%;
  font-size: clamp(36px, 7vw, 72px);
  transform: rotate(-14deg);
}

.ambient__note--two {
  top: 12%;
  right: 9%;
  font-size: clamp(26px, 5vw, 52px);
  animation-delay: -4s;
}

.ambient__note--three {
  right: 6%;
  bottom: 17%;
  font-size: clamp(44px, 9vw, 92px);
  color: rgba(255, 255, 255, 0.52);
  animation-delay: -7s;
  transform: rotate(10deg);
}

.ambient__grain {
  position: absolute;
  inset: -40%;
  opacity: 0.2;
  background-image: url("assets/grain.svg");
  background-size: 280px 280px;
  mix-blend-mode: soft-light;
  transform: rotate(8deg);
}

/* ---------- Layout ---------- */

.app {
  position: relative;
  width: min(100% - 32px, 580px);
  margin: 0 auto;
  padding: clamp(20px, 4vh, 38px) 0 32px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.brand {
  min-width: 0;
  padding-top: 2px;
}

.brand__kicker {
  margin: 0 0 5px;
  color: #9c526c;
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.24em;
  line-height: 1;
  text-transform: none;
}

.brand__title {
  display: flex;
  align-items: baseline;
  gap: 1px;
  margin: 0;
  font-size: var(--title-size);
  font-weight: 900;
  letter-spacing: -0.065em;
  line-height: 0.94;
  white-space: nowrap;
}

.brand__cn {
  color: var(--berry-deep);
  background: linear-gradient(135deg, #a92d56 8%, #7a1738 94%);
  -webkit-background-clip: text;
  background-clip: text;
  text-shadow: 0 7px 22px rgba(255, 255, 255, 0.45);
}

.brand__number {
  font-family: var(--font-display);
  letter-spacing: -0.075em;
  background: linear-gradient(135deg, #e3688b 8%, #cc8b3f 92%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 8px 18px rgba(201, 96, 126, 0.16));
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-shrink: 0;
}

.icon-button {
  position: relative;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--berry);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.54));
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-radius: 50%;
  box-shadow:
    0 10px 22px -12px rgba(122, 33, 69, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.86);
  backdrop-filter: blur(12px);
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

.icon-button:hover {
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 12px 24px -10px rgba(122, 33, 69, 0.46);
  transform: translateY(-2px);
}

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

.icon-button.is-muted {
  color: #ad8390;
}

.icon-button.is-muted::after {
  position: absolute;
  width: 18px;
  height: 1.5px;
  content: "";
  background: currentColor;
  border-radius: 2px;
  transform: rotate(-45deg);
}

.icon {
  width: 21px;
  height: 21px;
  pointer-events: none;
}

.icon--small {
  width: 16px;
  height: 16px;
}

.restart-button {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 44px;
  padding: 0 16px;
  color: #fff;
  background:
    linear-gradient(135deg, #e96085 0%, #d44972 48%, #b62d5c 100%);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 999px;
  box-shadow:
    0 13px 25px -12px rgba(159, 35, 78, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.32);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    filter 160ms ease;
}

.restart-button:hover {
  filter: saturate(1.08) brightness(1.03);
  box-shadow: 0 16px 28px -12px rgba(159, 35, 78, 0.82);
  transform: translateY(-2px);
}

.restart-button:active {
  transform: scale(0.96);
}

/* ---------- Scores ---------- */

.scoreboard {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 11px;
  margin-top: 18px;
}

.score-card {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-width: 0;
  min-height: 72px;
  padding: 13px 17px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 21px;
  box-shadow:
    var(--shadow-card),
    inset 0 1px 0 rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(16px) saturate(130%);
}

.score-card--current {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.86), rgba(255, 248, 251, 0.54));
}

.score-card--best {
  background:
    linear-gradient(135deg, rgba(255, 248, 223, 0.96), rgba(255, 232, 187, 0.7));
  border-color: rgba(255, 248, 221, 0.92);
}

.score-card__label {
  position: relative;
  z-index: 1;
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.1em;
}

.score-card--best .score-card__label {
  color: #9c6c2d;
}

.score-card__value {
  position: relative;
  z-index: 1;
  min-width: 0;
  overflow: hidden;
  color: #5b2d46;
  font-family: var(--font-display);
  font-size: clamp(26px, 5.5vw, 36px);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.035em;
  line-height: 1;
  text-align: right;
  text-overflow: clip;
  transition: transform 180ms ease;
}

.score-card__value[data-digits="7"] {
  font-size: clamp(21px, 4.7vw, 30px);
}

.score-card__value[data-digits="8"] {
  font-size: clamp(19px, 4.25vw, 27px);
}

.score-card--best .score-card__value {
  color: #b27927;
}

.score-card__value.is-bumping {
  animation: scorePunch 360ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.score-card__spark {
  position: absolute;
  right: 9px;
  bottom: -2px;
  color: rgba(201, 116, 145, 0.12);
  font-size: 34px;
  line-height: 1;
  transform: rotate(12deg);
}

.score-card--best .score-card__spark {
  color: rgba(191, 139, 44, 0.15);
}

/* ---------- Board ---------- */

.game-stage {
  position: relative;
  margin-top: 15px;
}

.board-frame {
  position: relative;
  padding: 12px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.54), rgba(255, 255, 255, 0.17));
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 31px;
  box-shadow:
    0 34px 65px -30px rgba(131, 43, 80, 0.46),
    0 7px 18px -12px rgba(131, 43, 80, 0.2),
    inset 0 1px 0 rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(25px) saturate(145%);
}

.board-frame::before {
  position: absolute;
  inset: 5px;
  pointer-events: none;
  content: "";
  border: 1px solid rgba(255, 255, 255, 0.4);
  border-radius: 27px;
}

.board-frame::after {
  position: absolute;
  top: 10px;
  right: 14%;
  left: 14%;
  height: 1px;
  pointer-events: none;
  content: "";
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.82), transparent);
}

.board {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  background:
    radial-gradient(90% 90% at 18% 12%, rgba(255, 255, 255, 0.3), transparent 58%),
    linear-gradient(145deg, rgba(255, 245, 249, 0.26), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.48);
  border-radius: 22px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.5),
    inset 0 -20px 38px -30px rgba(139, 40, 81, 0.36);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.board::before {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  content: "";
  background: radial-gradient(70% 70% at 50% 110%, rgba(255, 208, 224, 0.2), transparent 65%);
}

.board.is-shaking {
  animation: boardShake 320ms ease;
}

.board__cells {
  position: absolute;
  inset: 0;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: var(--board-gap);
  padding: var(--board-gap);
  pointer-events: none;
}

.board-cell {
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0.23));
  border: 1px solid rgba(255, 255, 255, 0.6);
  border-radius: var(--tile-radius);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.72),
    inset 0 -8px 16px -12px rgba(132, 52, 82, 0.2);
}

.board__tiles {
  position: absolute;
  inset: var(--board-gap);
  z-index: 2;
  pointer-events: none;
}

.tile {
  --x: 0;
  --y: 0;
  position: absolute;
  top: 0;
  left: 0;
  width: calc((100% - 3 * var(--board-gap)) / 4);
  aspect-ratio: 1;
  transform: translate(
    calc(var(--x) * (100% + var(--board-gap))),
    calc(var(--y) * (100% + var(--board-gap)))
  );
  transition: transform 132ms cubic-bezier(0.22, 0.68, 0.36, 1);
  will-change: transform;
}

.tile--absorbed {
  z-index: 1;
}

.tile--survivor {
  z-index: 3;
}

.tile__inner {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: linear-gradient(145deg, #ffdce8, #ffb1ca);
  border: 1.5px solid rgba(255, 255, 255, 0.62);
  border-radius: var(--tile-radius);
  box-shadow:
    0 10px 22px -12px rgba(91, 23, 49, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.5);
  transform: translateZ(0);
}

.tile__inner::after {
  position: absolute;
  inset: 0;
  pointer-events: none;
  content: "";
  border-radius: inherit;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.18),
    inset 0 -20px 30px -22px rgba(60, 15, 35, 0.32);
}

.tile__img {
  display: block;
  -webkit-user-drag: none;
  width: 100%;
  height: 100%;
  object-fit: cover;
  pointer-events: none;
  user-select: none;
}

.tile__badge {
  position: absolute;
  right: 5px;
  bottom: 5px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 31px;
  height: 23px;
  padding: 0 7px;
  color: #632d42;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 999px;
  box-shadow:
    0 3px 8px -2px rgba(83, 28, 48, 0.35),
    inset 0 1px 0 #fff;
  font-family: var(--font-display);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1;
}

.tile__badge[data-digits="4"] {
  min-width: 36px;
  padding: 0 6px;
  font-size: 11px;
}

.tile__badge[data-digits="5"] {
  min-width: 40px;
  padding: 0 5px;
  font-size: 10px;
}

.tile__badge[data-digits="6"] {
  min-width: 43px;
  padding: 0 5px;
  font-size: 9.5px;
}

.tile--new .tile__inner {
  animation: tileSpawn 230ms cubic-bezier(0.2, 0.85, 0.3, 1.16);
}

.tile.is-vanishing {
  z-index: 5;
}

.tile.is-vanishing .tile__inner {
  opacity: 0;
  transform: scale(0.45) rotate(4deg);
  transition:
    opacity 340ms ease,
    transform 380ms cubic-bezier(0.4, 0, 0.2, 1);
}

.board-frame.is-reviving {
  animation: reviveGlow 900ms ease;
}

.board__glow {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  border-radius: inherit;
  box-shadow: inset 0 0 70px -30px rgba(255, 255, 255, 0.75);
}

.score-float {
  position: absolute;
  top: 18px;
  right: 26px;
  z-index: 8;
  color: var(--berry);
  font-family: var(--font-display);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  opacity: 0;
  pointer-events: none;
  text-shadow:
    0 2px 0 rgba(255, 255, 255, 0.8),
    0 8px 18px rgba(255, 255, 255, 0.6);
}

.score-float.is-playing {
  animation: scoreFloat 720ms cubic-bezier(0.2, 0.7, 0.3, 1) forwards;
}

/* ---------- Help ---------- */

.game-help {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  margin-top: 17px;
}

.key-guide {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.key-group {
  display: inline-flex;
  gap: 4px;
}

.key-guide kbd {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 26px;
  height: 26px;
  padding: 0 5px;
  color: #7b4055;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.9);
  border-bottom-color: rgba(182, 112, 137, 0.24);
  border-radius: 7px;
  box-shadow: 0 2px 0 rgba(143, 66, 94, 0.08);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}

.wasd {
  display: inline-flex;
  gap: 3px;
}

.wasd kbd {
  min-width: 22px;
  height: 24px;
  padding: 0 4px;
  font-size: 10px;
}

.key-separator {
  color: rgba(117, 62, 83, 0.45);
  font-family: var(--font-serif);
  font-size: 15px;
  font-style: italic;
}

.game-help__copy {
  margin: 0;
  color: #8f5b6e;
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: 0.045em;
  line-height: 1.5;
  text-align: center;
}

.fan-note {
  margin: 1px 0 0;
  color: rgba(143, 91, 110, 0.62);
  font-size: 9.5px;
  font-weight: 500;
  letter-spacing: 0.035em;
  line-height: 1.5;
  text-align: center;
}

/* ---------- Overlay & sheets ---------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 18px;
  overflow: hidden;
}

.overlay[hidden] {
  display: none;
}

.overlay__veil {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(80% 70% at 50% 30%, rgba(255, 238, 244, 0.26), transparent 80%),
    rgba(62, 25, 42, 0.41);
  backdrop-filter: blur(14px) saturate(120%);
  animation: veilIn 220ms ease both;
}

.sheet {
  position: relative;
  z-index: 1;
  width: min(100%, 442px);
  max-height: calc(100vh - 36px);
  max-height: calc(100dvh - 36px);
  padding: 26px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  color: var(--ink);
  background:
    radial-gradient(120% 80% at 100% 0%, rgba(255, 231, 240, 0.9), transparent 55%),
    radial-gradient(90% 70% at 0% 100%, rgba(255, 241, 217, 0.55), transparent 58%),
    rgba(255, 252, 253, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.95);
  border-radius: 30px;
  box-shadow:
    0 44px 90px -28px rgba(54, 13, 30, 0.55),
    inset 0 1px 0 #fff;
  backdrop-filter: blur(28px) saturate(120%);
  animation: sheetIn 300ms cubic-bezier(0.2, 0.8, 0.28, 1) both;
  scrollbar-width: thin;
  scrollbar-color: rgba(166, 92, 119, 0.3) transparent;
}

.sheet::-webkit-scrollbar {
  width: 6px;
}

.sheet::-webkit-scrollbar-thumb {
  background: rgba(166, 92, 119, 0.3);
  border-radius: 999px;
}

.sheet--ranking {
  width: min(100%, 460px);
}

.sheet__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.modal-kicker {
  margin: 0 0 5px;
  color: #a26b7f;
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.28em;
  line-height: 1.2;
  text-transform: uppercase;
}

.modal-title {
  margin: 0;
  color: #3b1f2b;
  font-size: clamp(27px, 7vw, 34px);
  font-weight: 900;
  letter-spacing: -0.04em;
  line-height: 1.12;
}

.modal-subtitle {
  margin: 8px 0 0;
  color: #916779;
  font-size: 12.5px;
  line-height: 1.6;
}

.close-button {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 38px;
  height: 38px;
  margin-top: -3px;
  color: #7e5464;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(151, 96, 117, 0.16);
  border-radius: 50%;
  box-shadow: 0 6px 14px -10px rgba(75, 30, 48, 0.35);
  transition:
    background 150ms ease,
    transform 150ms ease;
}

.close-button:hover {
  background: #fff;
  transform: rotate(4deg);
}

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

/* ---------- Game over ---------- */

.gameover-head {
  text-align: center;
}

.gameover-head .modal-kicker {
  color: #9e5a72;
}

.gameover-head .modal-title {
  font-size: clamp(30px, 8vw, 38px);
}

.record-badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-top: 10px;
  padding: 6px 12px;
  color: #9a671e;
  background: linear-gradient(135deg, #fff3c9, #ffe6a3);
  border: 1px solid rgba(225, 190, 109, 0.55);
  border-radius: 999px;
  box-shadow: 0 5px 15px -10px rgba(140, 94, 21, 0.45);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.record-badge .icon {
  width: 12px;
  height: 12px;
}

.result-hero {
  margin-top: 17px;
  padding: 15px 16px 17px;
  text-align: center;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.82), rgba(255, 244, 248, 0.66));
  border: 1px solid rgba(231, 179, 197, 0.36);
  border-radius: 22px;
  box-shadow:
    inset 0 1px 0 #fff,
    0 10px 26px -22px rgba(101, 33, 57, 0.36);
}

.result-hero__label {
  display: block;
  color: #966174;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
}

.result-hero__score {
  display: block;
  margin-top: 2px;
  color: var(--berry);
  font-family: var(--font-display);
  font-size: clamp(46px, 13vw, 61px);
  font-variant-numeric: tabular-nums;
  font-weight: 900;
  letter-spacing: -0.05em;
  line-height: 1.08;
  background: linear-gradient(135deg, #cb4d75 4%, #9b244a 58%, #d48d42 110%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.result-hero__score[data-chars="7"],
.result-hero__score[data-chars="8"] {
  font-size: clamp(39px, 11vw, 56px);
}

.result-hero__score[data-chars="9"],
.result-hero__score[data-chars="10"] {
  font-size: clamp(32px, 9vw, 50px);
}

.result-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 9px;
}

.result-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 11px 13px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(236, 196, 209, 0.45);
  border-radius: 15px;
}

.result-stat span {
  color: #956979;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  white-space: nowrap;
}

.result-stat strong {
  max-width: 100%;
  overflow: hidden;
  color: #552b3d;
  font-family: var(--font-display);
  font-size: clamp(15px, 4.5vw, 19px);
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.03em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.submit-panel {
  margin-top: 12px;
  padding: 14px;
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.7), rgba(255, 248, 250, 0.4));
  border: 1px solid rgba(231, 190, 204, 0.44);
  border-radius: 20px;
}

.field-label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
  color: #663447;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.field-label span {
  color: #a27c8b;
  font-size: 10.5px;
  font-weight: 500;
  letter-spacing: 0.02em;
}

.input-shell {
  position: relative;
  display: flex;
  align-items: center;
}

.nickname-input {
  width: 100%;
  height: 48px;
  padding: 0 54px 0 14px;
  color: #452232;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(190, 132, 153, 0.35);
  border-radius: 13px;
  box-shadow:
    inset 0 2px 4px rgba(115, 46, 72, 0.04),
    0 1px 0 rgba(255, 255, 255, 0.8);
  font-size: 16px;
  letter-spacing: 0.04em;
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease;
}

.nickname-input::placeholder {
  color: #bea0ad;
  font-size: 13px;
  letter-spacing: 0.02em;
}

.nickname-input:focus {
  border-color: rgba(198, 67, 110, 0.65);
  outline: none;
  box-shadow:
    0 0 0 3px rgba(220, 99, 138, 0.12),
    inset 0 2px 4px rgba(115, 46, 72, 0.03);
}

.nickname-input[aria-invalid="true"] {
  border-color: rgba(191, 59, 67, 0.62);
  box-shadow: 0 0 0 3px rgba(191, 59, 67, 0.08);
}

.char-counter {
  position: absolute;
  right: 12px;
  color: #b18a99;
  font-family: var(--font-display);
  font-size: 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  pointer-events: none;
}

.field-hint {
  min-height: 17px;
  margin: 7px 2px 10px;
  color: #a37f8d;
  font-size: 10.5px;
  line-height: 1.55;
}

.field-hint.is-error {
  color: #bd3b4b;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  width: 100%;
  min-height: 48px;
  padding: 0 18px;
  color: #fff;
  background:
    linear-gradient(135deg, #df5d83 0%, #ce3e6c 52%, #ad2353 100%);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 14px;
  box-shadow:
    0 13px 26px -14px rgba(161, 30, 75, 0.72),
    inset 0 1px 0 rgba(255, 255, 255, 0.3);
  font-size: 14.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  transition:
    transform 160ms ease,
    filter 160ms ease,
    box-shadow 160ms ease;
}

.primary-button:hover:not(:disabled) {
  filter: brightness(1.04) saturate(1.04);
  box-shadow: 0 16px 30px -14px rgba(161, 30, 75, 0.82);
  transform: translateY(-1px);
}

.primary-button:active:not(:disabled) {
  transform: scale(0.985);
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
}

.primary-button--soft {
  color: var(--berry-deep);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.95), rgba(255, 235, 243, 0.86));
  border-color: rgba(208, 135, 161, 0.34);
  box-shadow: 0 8px 20px -16px rgba(120, 35, 66, 0.46);
}

.primary-button--soft:hover:not(:disabled) {
  background: #fff;
  box-shadow: 0 10px 22px -16px rgba(120, 35, 66, 0.55);
}

.secondary-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 17px;
  margin: 12px 0;
}

.text-button {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 0;
  color: #8b4f64;
  background: transparent;
  border-bottom: 1px solid rgba(140, 78, 100, 0.28);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.025em;
  transition:
    color 150ms ease,
    border-color 150ms ease;
}

.text-button:hover {
  color: var(--berry-deep);
  border-color: rgba(120, 29, 60, 0.5);
}

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

.submitted-note {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 12px;
  padding: 13px 14px;
  color: #6c4957;
  background: rgba(255, 247, 224, 0.76);
  border: 1px solid rgba(225, 194, 128, 0.4);
  border-radius: 17px;
  font-size: 12px;
  line-height: 1.55;
}

.submitted-note .icon {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  color: var(--gold);
}

.submitted-note strong {
  color: #97651e;
}

/* ---------- Ranking ---------- */

.ranking-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.ranking-title-row {
  min-width: 0;
}

.ranking-count {
  display: flex;
  align-items: center;
  gap: 7px;
  margin: 13px 0 9px;
  color: #9a7181;
  font-size: 11px;
  letter-spacing: 0.04em;
}

.ranking-count::after {
  flex: 1;
  height: 1px;
  content: "";
  background: linear-gradient(90deg, rgba(204, 154, 174, 0.34), transparent);
}

.ranking-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(54vh, 440px);
  margin: 0;
  padding: 2px 3px 2px 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-width: thin;
  scrollbar-color: rgba(166, 92, 119, 0.3) transparent;
}

.ranking-list::-webkit-scrollbar {
  width: 6px;
}

.ranking-list::-webkit-scrollbar-thumb {
  background: rgba(166, 92, 119, 0.3);
  border-radius: 999px;
}

.rank-row {
  position: relative;
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  align-items: center;
  gap: 9px;
  flex: 0 0 auto;
  min-height: 56px;
  padding: 9px 12px 9px 9px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(231, 200, 211, 0.45);
  border-radius: 15px;
  box-shadow: 0 3px 12px -11px rgba(100, 36, 60, 0.4);
}

.rank-row.is-podium {
  background:
    linear-gradient(100deg, rgba(255, 248, 219, 0.95), rgba(255, 252, 240, 0.78));
  border-color: rgba(231, 198, 112, 0.46);
}

.rank-row.is-me {
  border-color: rgba(198, 64, 108, 0.62);
  box-shadow:
    0 0 0 1px rgba(219, 112, 146, 0.22),
    0 9px 20px -18px rgba(145, 36, 78, 0.65);
}

.rank-number {
  color: #a77d8c;
  font-family: var(--font-display);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: 0.01em;
  text-align: center;
}

.rank-row.is-podium .rank-number {
  color: #b67a22;
  font-size: 13px;
}

.rank-identity {
  min-width: 0;
}

.rank-name {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  color: #462434;
  font-size: 13.5px;
  font-weight: 800;
  letter-spacing: 0.02em;
  line-height: 1.35;
}

.rank-name__text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.me-chip {
  flex: 0 0 auto;
  padding: 2px 5px;
  color: #fff;
  background: var(--rose);
  border-radius: 5px;
  font-size: 8px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.rank-meta {
  display: block;
  margin-top: 2px;
  color: #a1808d;
  font-size: 9.5px;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
}

.rank-score {
  color: #5a2b40;
  font-family: var(--font-display);
  font-size: 16px;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  letter-spacing: -0.02em;
  text-align: right;
}

.ranking-empty,
.ranking-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 34px 18px;
  text-align: center;
}

.ranking-empty__note {
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  margin-bottom: 12px;
  color: #bd7c93;
  background: rgba(255, 240, 246, 0.76);
  border: 1px solid rgba(229, 185, 200, 0.45);
  border-radius: 50%;
  font-family: var(--font-serif);
  font-size: 22px;
}

.ranking-empty p,
.ranking-error p {
  margin: 0;
  color: #7d5766;
  font-size: 12.5px;
  line-height: 1.7;
}

.ranking-error p {
  color: #a84b5c;
}

.ranking-error .primary-button {
  width: auto;
  min-height: 40px;
  margin-top: 14px;
  padding: 0 18px;
  border-radius: 11px;
  font-size: 12.5px;
}

.ranking-note {
  margin: 10px 0 0;
  color: #a38390;
  font-size: 10px;
  line-height: 1.55;
  text-align: center;
}

.ranking-footer {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 13px;
}

.ranking-footer .primary-button {
  min-height: 45px;
  border-radius: 13px;
}

.ranking-footer .text-button {
  align-self: center;
}

.rank-status {
  padding: 10px 12px;
  color: #7d5766;
  background: rgba(255, 246, 220, 0.76);
  border: 1px solid rgba(226, 193, 121, 0.38);
  border-radius: 11px;
  font-size: 10.5px;
  line-height: 1.55;
  text-align: center;
}

.rank-skeleton {
  display: grid;
  gap: 7px;
}

.rank-skeleton__row {
  height: 56px;
  border-radius: 15px;
  background: linear-gradient(
    100deg,
    rgba(255, 255, 255, 0.46) 20%,
    rgba(255, 255, 255, 0.82) 38%,
    rgba(255, 255, 255, 0.46) 56%
  );
  background-size: 240% 100%;
  animation: skeleton 1.25s ease infinite;
}

/* ---------- Revive dialogue ---------- */

.revive-sheet {
  overflow: hidden;
  background:
    radial-gradient(105% 70% at 100% 0%, rgba(255, 212, 228, 0.86), transparent 56%),
    radial-gradient(90% 70% at 0% 100%, rgba(255, 235, 201, 0.55), transparent 55%),
    rgba(255, 252, 253, 0.97);
}

.revive-head {
  text-align: center;
}

.revive-head .modal-kicker {
  color: #a9617a;
}

.revive-head .modal-title {
  font-size: clamp(28px, 7.5vw, 35px);
}

.revive-sub {
  margin: 7px 0 0;
  color: #956d7c;
  font-size: 11.5px;
  line-height: 1.55;
}

.dialogue {
  margin-top: 18px;
}

.question-box {
  position: relative;
  padding: 21px 18px;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(135deg, #527fcd 0%, #416dbb 52%, #345ca5 100%);
  border: 1px solid rgba(255, 255, 255, 0.34);
  border-radius: 17px;
  box-shadow:
    0 16px 30px -16px rgba(42, 77, 146, 0.7),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  font-size: clamp(20px, 5.6vw, 25px);
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.4;
  text-align: center;
  text-shadow: 0 2px 8px rgba(21, 44, 96, 0.35);
  animation: questionIn 260ms ease both;
}

.question-box::before,
.question-box::after {
  position: absolute;
  color: rgba(255, 255, 255, 0.12);
  font-family: var(--font-serif);
  font-size: 54px;
  line-height: 1;
  content: "♪";
  pointer-events: none;
}

.question-box::before {
  top: -9px;
  left: 10px;
  transform: rotate(-15deg);
}

.question-box::after {
  right: 12px;
  bottom: -16px;
  content: "♫";
  transform: rotate(12deg);
}

.question-text {
  position: relative;
  z-index: 1;
}

.choices {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin-top: 15px;
}

.choice-button {
  min-width: 78px;
  min-height: 43px;
  padding: 8px 19px;
  color: #5e4310;
  background:
    linear-gradient(135deg, #fff4b1 0%, #ffe68e 56%, #ffd86b 100%);
  border: 1px solid rgba(230, 190, 74, 0.72);
  border-radius: 10px;
  box-shadow:
    0 6px 0 -2px rgba(202, 157, 35, 0.22),
    0 12px 20px -14px rgba(167, 119, 18, 0.6),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  font-size: 15px;
  font-weight: 900;
  letter-spacing: 0.05em;
  transition:
    transform 150ms ease,
    filter 150ms ease,
    box-shadow 150ms ease;
}

.choice-button:hover {
  filter: brightness(1.035) saturate(1.05);
  box-shadow:
    0 7px 0 -2px rgba(202, 157, 35, 0.24),
    0 14px 22px -14px rgba(167, 119, 18, 0.68),
    inset 0 1px 0 rgba(255, 255, 255, 0.8);
  transform: translateY(-2px);
}

.choice-button:active {
  transform: translateY(1px) scale(0.985);
}

.revive-foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 16px 0 0;
  color: #a88290;
  font-size: 10px;
  letter-spacing: 0.07em;
}

.revive-foot .icon {
  width: 12px;
  height: 12px;
  color: #c18b42;
}

.dialogue.is-changing {
  animation: dialogueSwap 240ms ease;
}

/* ---------- Restart confirm ---------- */

.confirm-sheet {
  width: min(100%, 390px);
  text-align: center;
}

.confirm-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin: 0 auto 13px;
  color: #b33c62;
  background: linear-gradient(145deg, #fff5f8, #ffe3ec);
  border: 1px solid rgba(238, 193, 208, 0.55);
  border-radius: 50%;
  box-shadow: 0 10px 22px -16px rgba(128, 39, 73, 0.55);
}

.confirm-icon .icon {
  width: 25px;
  height: 25px;
}

.confirm-sheet .modal-title {
  font-size: 27px;
}

.confirm-sheet .modal-subtitle {
  margin-top: 8px;
  font-size: 12.5px;
}

.confirm-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 9px;
  margin-top: 20px;
}

.confirm-actions .primary-button {
  min-height: 44px;
  border-radius: 12px;
  font-size: 13px;
  letter-spacing: 0.03em;
}

.command-caption {
  margin: 13px 0 0;
  color: #c04444;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

/* ---------- Toast & confetti ---------- */

.toast {
  position: fixed;
  right: 50%;
  bottom: max(24px, env(safe-area-inset-bottom));
  z-index: 90;
  width: max-content;
  max-width: min(86vw, 360px);
  padding: 10px 16px;
  color: #fff8fa;
  background: rgba(72, 30, 47, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 999px;
  box-shadow: 0 14px 34px -16px rgba(45, 14, 27, 0.65);
  backdrop-filter: blur(12px);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.03em;
  line-height: 1.4;
  text-align: center;
  transform: translateX(50%);
  animation: toastIn 220ms ease both;
}

.toast[hidden] {
  display: none;
}

.toast.is-leaving {
  animation: toastOut 220ms ease both;
}

.confetti {
  position: fixed;
  inset: 0;
  z-index: 80;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

/* ---------- Animations ---------- */

@keyframes drift {
  from {
    transform: translate3d(-2%, -1%, 0) scale(0.96);
  }
  to {
    transform: translate3d(3%, 2%, 0) scale(1.06);
  }
}

@keyframes noteFloat {
  from {
    transform: translateY(-6px) rotate(-8deg);
  }
  to {
    transform: translateY(10px) rotate(5deg);
  }
}

@keyframes scorePunch {
  0% {
    transform: scale(1);
  }
  38% {
    transform: scale(1.13);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes tileSpawn {
  0% {
    opacity: 0.25;
    transform: scale(0.35);
  }
  68% {
    opacity: 1;
    transform: scale(1.035);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

@keyframes boardShake {
  0%,
  100% {
    transform: translateX(0);
  }
  22% {
    transform: translateX(-5px) rotate(-0.3deg);
  }
  45% {
    transform: translateX(4px) rotate(0.25deg);
  }
  68% {
    transform: translateX(-2px);
  }
  84% {
    transform: translateX(1px);
  }
}

@keyframes scoreFloat {
  0% {
    opacity: 0;
    transform: translateY(5px) scale(0.88);
  }
  18% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-32px) scale(1.03);
  }
}

@keyframes reviveGlow {
  0% {
    box-shadow:
      0 34px 65px -30px rgba(131, 43, 80, 0.46),
      inset 0 1px 0 rgba(255, 255, 255, 0.88);
  }
  32% {
    box-shadow:
      0 0 0 2px rgba(255, 246, 201, 0.85),
      0 0 55px rgba(255, 220, 140, 0.65),
      0 34px 65px -30px rgba(131, 43, 80, 0.46);
  }
  100% {
    box-shadow:
      0 34px 65px -30px rgba(131, 43, 80, 0.46),
      inset 0 1px 0 rgba(255, 255, 255, 0.88);
  }
}

@keyframes veilIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes sheetIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.965);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes dialogueSwap {
  from {
    opacity: 0.35;
    transform: translateX(8px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes skeleton {
  from {
    background-position: 120% 0;
  }
  to {
    background-position: -120% 0;
  }
}

@keyframes toastIn {
  from {
    opacity: 0;
    transform: translate(50%, 10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translate(50%, 0) scale(1);
  }
}

@keyframes toastOut {
  from {
    opacity: 1;
    transform: translate(50%, 0) scale(1);
  }
  to {
    opacity: 0;
    transform: translate(50%, 8px) scale(0.97);
  }
}

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

/* ---------- Responsive ---------- */

@media (max-width: 480px) {
  :root {
    --board-gap: 8px;
    --tile-radius: 14px;
    --title-size: clamp(33px, 8.6vw, 40px);
  }

  .app {
    width: min(100% - 24px, 580px);
    padding-top: max(18px, env(safe-area-inset-top));
    padding-bottom: max(22px, env(safe-area-inset-bottom));
  }

  .topbar {
    gap: 9px;
  }

  .brand__kicker {
    margin-bottom: 4px;
    font-size: 8.5px;
    letter-spacing: 0.18em;
  }

  .top-actions {
    gap: 6px;
  }

  .icon-button {
    width: 40px;
    height: 40px;
  }

  .restart-button {
    height: 40px;
    padding: 0 12px;
    gap: 4px;
    font-size: 12.5px;
  }

  .restart-button .icon {
    width: 14px;
    height: 14px;
  }

  .scoreboard {
    gap: 8px;
    margin-top: 15px;
  }

  .score-card {
    min-height: 64px;
    padding: 10px 13px;
    border-radius: 18px;
  }

  .score-card__label {
    font-size: 11.5px;
  }

  .score-card__value {
    font-size: clamp(24px, 6.8vw, 31px);
  }

  .score-card__spark {
    font-size: 28px;
  }

  .game-stage {
    margin-top: 12px;
  }

  .board-frame {
    padding: 9px;
    border-radius: 26px;
  }

  .board-frame::before {
    inset: 4px;
    border-radius: 22px;
  }

  .board {
    border-radius: 19px;
  }

  .board__cells {
    padding: var(--board-gap);
  }

  .tile__badge {
    right: 4px;
    bottom: 4px;
    min-width: 27px;
    height: 20px;
    padding: 0 6px;
    font-size: 10.5px;
  }

  .tile__badge[data-digits="4"] {
    min-width: 32px;
    font-size: 9.5px;
  }

  .tile__badge[data-digits="5"] {
    min-width: 35px;
    font-size: 9px;
  }

  .tile__badge[data-digits="6"] {
    min-width: 38px;
    font-size: 8px;
  }

  .game-help {
    gap: 6px;
    margin-top: 14px;
  }

  .key-guide kbd {
    min-width: 23px;
    height: 23px;
    font-size: 10px;
  }

  .wasd kbd {
    min-width: 19px;
    height: 22px;
    font-size: 9px;
  }

  .game-help__copy {
    font-size: 11.5px;
  }

  .overlay {
    padding: 10px;
  }

  .sheet {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    padding: 22px 18px 20px;
    border-radius: 27px;
  }

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

  .result-hero {
    margin-top: 14px;
    padding: 12px 13px 14px;
  }

  .result-hero__score {
    font-size: 51px;
  }

  .submit-panel {
    padding: 12px;
  }

  .ranking-list {
    max-height: 48vh;
  }

  .rank-row {
    grid-template-columns: 31px minmax(0, 1fr) auto;
    gap: 7px;
    padding: 8px 10px 8px 7px;
  }

  .rank-score {
    font-size: 15px;
  }
}

@media (max-width: 340px) {
  .restart-button {
    width: 40px;
    padding: 0;
  }

  .restart-button span {
    display: none;
  }

  .brand__kicker {
    letter-spacing: 0.13em;
  }

  .score-card__value[data-digits="7"] {
    font-size: 18px;
  }

  .score-card__value[data-digits="8"] {
    font-size: 16px;
  }

  .choice-button {
    min-width: 68px;
    padding: 8px 14px;
    font-size: 14px;
  }
}

@media (min-width: 820px) {
  :root {
    --board-gap: 11px;
    --tile-radius: 18px;
  }

  .app {
    width: min(100% - 32px, 580px, clamp(440px, calc(100dvh - 250px), 580px));
    padding-top: 34px;
  }

  .sheet {
    padding: 28px;
  }
}

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

@supports not (backdrop-filter: blur(1px)) {
  .board-frame,
  .score-card,
  .icon-button,
  .sheet {
    background-color: rgba(255, 249, 251, 0.94);
  }
}

/* Tile coordinates are class-based so the page needs no inline styles. */
.pos-r0-c0 { --x: 0; --y: 0; }
.pos-r0-c1 { --x: 1; --y: 0; }
.pos-r0-c2 { --x: 2; --y: 0; }
.pos-r0-c3 { --x: 3; --y: 0; }
.pos-r1-c0 { --x: 0; --y: 1; }
.pos-r1-c1 { --x: 1; --y: 1; }
.pos-r1-c2 { --x: 2; --y: 1; }
.pos-r1-c3 { --x: 3; --y: 1; }
.pos-r2-c0 { --x: 0; --y: 2; }
.pos-r2-c1 { --x: 1; --y: 2; }
.pos-r2-c2 { --x: 2; --y: 2; }
.pos-r2-c3 { --x: 3; --y: 2; }
.pos-r3-c0 { --x: 0; --y: 3; }
.pos-r3-c1 { --x: 1; --y: 3; }
.pos-r3-c2 { --x: 2; --y: 3; }
.pos-r3-c3 { --x: 3; --y: 3; }

.tile__inner--fallback {
  background:
    radial-gradient(circle at 25% 20%, rgba(255, 255, 255, 0.65), transparent 48%),
    linear-gradient(145deg, #f5a9c3, #c65380 55%, #8d2e54);
}

.tile__inner--fallback::before {
  position: absolute;
  top: 50%;
  left: 50%;
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--font-serif);
  font-size: 36%;
  content: "♪";
  transform: translate(-50%, -56%);
}
