:root {
  color-scheme: dark;
  --bg: #071c20;
  --ink: #fff9ef;
  --muted: #d5efe9;
  --line: rgba(255, 249, 239, 0.22);
  --panel: rgba(7, 28, 32, 0.68);
  --panel-soft: rgba(7, 28, 32, 0.46);
  --teal: #2ee8d0;
  --coral: #ff7aa8;
  --gold: #ffe36d;
  --board-width: min(100vw, 50vh, 430px);
  --board-safe-top: max(116px, calc(env(safe-area-inset-top) + 112px));
  --board-safe-bottom: 62px;
}

@supports (height: 100svh) {
  :root {
    --board-width: min(100vw, 50svh, 430px);
  }
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  -ms-touch-action: auto;
  touch-action: auto;
}

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

body {
  height: 100vh;
  height: 100svh;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(46, 232, 208, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(255, 122, 168, 0.14), transparent 36%),
    var(--bg);
  color: var(--ink);
  font-family:
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

.app {
  width: 100vw;
  height: 100vh;
  height: 100svh;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.playfield {
  position: relative;
  width: var(--board-width);
  height: calc(var(--board-width) * 2);
  max-height: 100vh;
  max-height: 100svh;
  border: 1px solid rgba(255, 248, 232, 0.28);
  border-radius: 8px;
  overflow: hidden;
  background: #7edc64;
  box-shadow:
    0 20px 48px rgba(0, 0, 0, 0.34),
    0 0 0 1px rgba(0, 0, 0, 0.22);
  touch-action: auto;
}

.playfield.is-gesture-enabled {
  touch-action: none;
}

.level-backdrops {
  position: absolute;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background: #7edc64;
  pointer-events: none;
  transition: filter 160ms ease;
}

.playfield.is-opponent-peeking .level-backdrops {
  filter: grayscale(1);
}

.level-backdrops::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: linear-gradient(180deg, rgba(7, 12, 10, 0.24), rgba(7, 12, 10, 0.08) 44%, rgba(7, 12, 10, 0.3));
}

.level-backdrop {
  position: absolute;
  inset: 0;
  z-index: 1;
  opacity: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  transform: scale(1.025);
  transition:
    opacity 1400ms ease,
    transform 4200ms ease;
  will-change: opacity, transform;
}

.level-backdrop.is-active {
  opacity: 1;
  transform: scale(1);
}

.title-art {
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  pointer-events: none;
  background:
    linear-gradient(180deg, rgba(7, 12, 10, 0.18), rgba(7, 12, 10, 0.36) 48%, rgba(7, 12, 10, 0.2)),
    url("assets/pumaru-falling-puzzle-title-fluffy-v2.webp?v=1") center / cover no-repeat;
  transition: opacity 220ms ease;
}

.playfield.is-title .title-art {
  opacity: 1;
}

.playfield.is-title .board-zone,
.playfield.is-title .game-hud {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.playfield::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(90deg, transparent 0 10.2%, rgba(255, 255, 255, 0.035) 10.2% 11.1%, transparent 11.1% 21.3%),
    linear-gradient(0deg, transparent 0 5.1%, rgba(255, 255, 255, 0.025) 5.1% 5.55%, transparent 5.55% 10.65%);
  pointer-events: none;
}

.playfield::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  opacity: 0;
  background: rgba(255, 248, 232, 0.42);
  mix-blend-mode: normal;
  pointer-events: none;
  will-change: opacity;
}

.playfield.is-clearing::after {
  animation: field-flash 420ms ease-out both;
}

.playfield.is-clear-big::after {
  animation-duration: 560ms;
}

.playfield.is-clear-big:not(.is-pumaru-spin)::after {
  background: rgba(255, 238, 170, 0.34);
  animation-name: field-flash-big;
}

.playfield.is-pumaru-spin::after {
  animation-name: field-flash-pumaru-spin;
  animation-duration: 720ms;
  background: rgba(255, 227, 109, 0.52);
}

.board-zone {
  position: absolute;
  top: var(--board-safe-top);
  left: 50%;
  z-index: 2;
  width: min(calc(100% - 72px), 320px);
  height: min(calc(100% - var(--board-safe-top) - var(--board-safe-bottom)), 640px);
  aspect-ratio: 9 / 19;
  border: 1px solid rgba(255, 248, 232, 0.44);
  border-radius: 8px;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 16%, rgba(255, 249, 239, 0.06), transparent 30%),
    radial-gradient(circle at 82% 76%, rgba(173, 246, 239, 0.06), transparent 34%),
    linear-gradient(180deg, rgba(22, 75, 90, 0.88), rgba(11, 44, 56, 0.92));
  box-shadow:
    inset 0 0 0 1px rgba(194, 245, 239, 0.16),
    inset 0 0 24px rgba(46, 232, 208, 0.06),
    0 12px 28px rgba(0, 0, 0, 0.22);
  transform: translateX(-50%);
  transition: border-color 140ms ease;
  touch-action: none;
}

@media (prefers-reduced-motion: reduce) {
  .level-backdrop {
    transition-duration: 1ms;
  }
}

.playfield.is-clearing .board-zone {
  border-color: rgba(255, 248, 232, 0.42);
}

.playfield.is-clear-big .board-zone {
  border-color: rgba(255, 227, 109, 0.46);
}

.playfield.is-pumaru-spin .board-zone {
  border-color: rgba(255, 248, 232, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 232, 0.28),
    inset 0 0 42px rgba(46, 232, 208, 0.34),
    0 0 42px rgba(255, 122, 168, 0.42),
    0 0 72px rgba(255, 227, 109, 0.3);
}

.playfield.is-skill-aiming .board-zone {
  border-color: rgba(255, 227, 109, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(255, 227, 109, 0.32),
    inset 0 0 34px rgba(255, 122, 168, 0.24),
    0 0 30px rgba(255, 227, 109, 0.22);
}

.playfield.is-skill-aiming #board {
  cursor: pointer;
}

.playfield.is-firestorm .board-zone {
  animation: firestorm-field-pulse 1880ms ease-out both;
}

.playfield.is-firestorm #board {
  animation: firestorm-board-impact 1880ms ease-out both;
}

.playfield.is-firestorm .level-backdrops {
  filter: saturate(1.5) contrast(1.08) sepia(0.22);
}

.playfield.is-typhoon .board-zone {
  animation: typhoon-field-pulse 1880ms ease-out both;
}

#board,
.clear-art {
  position: absolute;
  inset: 0;
}

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

#board {
  z-index: 2;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

#board:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: -3px;
}

.clear-art {
  z-index: 1;
  opacity: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  mix-blend-mode: normal;
  pointer-events: none;
  transform: scale(0.98);
  contain: paint;
  will-change: opacity, transform;
}

.pumaru-spin-bg,
.pumaru-spin-dog {
  position: absolute;
  inset: 0;
  opacity: 0;
  background-position: center;
  background-repeat: no-repeat;
  pointer-events: none;
  will-change: opacity, transform;
}

.pumaru-spin-bg {
  background-size: cover;
}

.pumaru-spin-dog {
  background-size: contain;
  filter:
    drop-shadow(0 0 5px rgba(255, 248, 232, 1))
    drop-shadow(0 0 20px rgba(255, 122, 168, 0.68))
    drop-shadow(0 0 32px rgba(46, 232, 208, 0.44))
    drop-shadow(0 12px 18px rgba(0, 0, 0, 0.22));
  transform-origin: 50% 50%;
}

.clear-art[data-clear-mode="pumaru-spin"]::before,
.clear-art[data-clear-mode="pumaru-spin"]::after {
  content: "";
  position: absolute;
  inset: -13%;
  opacity: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  will-change: opacity, transform;
}

.clear-art[data-clear-mode="pumaru-spin"]::before {
  background:
    radial-gradient(circle at 50% 50%, transparent 0 21%, rgba(255, 248, 232, 0.9) 22%, transparent 25%, rgba(46, 232, 208, 0.46) 29%, transparent 34%, rgba(255, 122, 168, 0.34) 38%, transparent 43%),
    conic-gradient(from -12deg, transparent 0 7deg, rgba(255, 248, 232, 0.86) 8deg 10deg, transparent 11deg 24deg, rgba(255, 122, 168, 0.66) 25deg 29deg, transparent 30deg 48deg, rgba(255, 227, 109, 0.74) 49deg 53deg, transparent 54deg 76deg, rgba(46, 232, 208, 0.66) 77deg 81deg, transparent 82deg 118deg, rgba(255, 248, 232, 0.72) 119deg 122deg, transparent 123deg 360deg);
}

.clear-art[data-clear-mode="pumaru-spin"]::after {
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 248, 232, 0.42), transparent 21%),
    radial-gradient(circle at 28% 24%, rgba(255, 227, 109, 0.95) 0 1.8%, transparent 2.4%),
    radial-gradient(circle at 72% 28%, rgba(255, 122, 168, 0.9) 0 1.7%, transparent 2.3%),
    radial-gradient(circle at 22% 68%, rgba(46, 232, 208, 0.92) 0 1.7%, transparent 2.3%),
    radial-gradient(circle at 80% 72%, rgba(255, 248, 232, 0.95) 0 2%, transparent 2.6%),
    radial-gradient(circle at 58% 13%, rgba(185, 131, 255, 0.86) 0 1.6%, transparent 2.2%),
    radial-gradient(circle at 38% 84%, rgba(255, 227, 109, 0.8) 0 1.4%, transparent 2%),
    radial-gradient(circle at 88% 46%, rgba(46, 232, 208, 0.78) 0 1.3%, transparent 1.9%);
}

.clear-art.is-showing {
  animation: clear-pop 1120ms ease-out both;
}

.clear-art[data-clear-count="4"].is-showing {
  animation-name: clear-pop-big;
}

.clear-art[data-clear-mode="combo"].is-showing {
  animation-name: clear-pop-combo;
  animation-duration: 1220ms;
}

.clear-art[data-clear-mode="skill"].is-showing {
  animation-name: clear-pop-combo;
  animation-duration: 1350ms;
}

.clear-art[data-clear-count="skill-firestorm"].is-showing {
  animation-duration: 1780ms;
}

.clear-art[data-clear-count="skill-typhoon"].is-showing {
  animation-duration: 1780ms;
}

.clear-art[data-clear-count="skill-megatonBomb"].is-showing {
  animation-duration: 1550ms;
}

@keyframes firestorm-field-pulse {
  0% {
    border-color: rgba(255, 255, 255, 0.96);
    box-shadow:
      inset 0 0 54px rgba(255, 246, 188, 0.92),
      0 0 30px rgba(255, 224, 88, 0.92),
      0 0 74px rgba(255, 72, 18, 0.82);
  }

  14% {
    border-color: rgba(255, 220, 92, 1);
    box-shadow:
      inset 0 0 62px rgba(255, 105, 22, 0.72),
      0 0 42px rgba(255, 230, 108, 0.88),
      0 0 96px rgba(255, 44, 12, 0.78);
  }

  42% {
    border-color: rgba(255, 116, 28, 0.88);
    box-shadow:
      inset 0 0 46px rgba(255, 58, 12, 0.56),
      0 0 30px rgba(255, 188, 54, 0.65),
      0 0 72px rgba(229, 30, 9, 0.5);
  }

  100% {
    border-color: rgba(255, 248, 232, 0.28);
    box-shadow: none;
  }
}

@keyframes firestorm-board-impact {
  0%, 100% {
    transform: translate3d(0, 0, 0) scale(1);
    filter: brightness(1);
  }

  4% {
    transform: translate3d(-2px, 1px, 0) scale(1.012);
    filter: brightness(1.4);
  }

  8% {
    transform: translate3d(2px, -1px, 0) scale(1.016);
  }

  13% {
    transform: translate3d(-1px, -1px, 0) scale(1.01);
  }

  20% {
    transform: translate3d(1px, 0, 0) scale(1.006);
    filter: brightness(1.16);
  }
}

@keyframes typhoon-field-pulse {
  0% {
    border-color: rgba(220, 252, 255, 0.82);
    box-shadow:
      inset 0 0 38px rgba(88, 213, 255, 0.42),
      0 0 22px rgba(91, 225, 255, 0.62),
      0 0 52px rgba(16, 81, 211, 0.48);
  }

  13% {
    border-color: rgba(238, 255, 255, 1);
    box-shadow:
      inset 0 0 54px rgba(28, 157, 255, 0.68),
      0 0 34px rgba(182, 251, 255, 0.86),
      0 0 76px rgba(28, 91, 235, 0.68);
  }

  58% {
    border-color: rgba(92, 203, 255, 0.88);
    box-shadow:
      inset 0 0 46px rgba(5, 67, 162, 0.58),
      0 0 28px rgba(93, 225, 255, 0.58),
      0 0 64px rgba(22, 55, 171, 0.48);
  }

  100% {
    border-color: rgba(236, 252, 255, 0.28);
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .playfield.is-firestorm .board-zone,
  .playfield.is-firestorm #board,
  .playfield.is-typhoon .board-zone {
    animation: none;
  }
}

.clear-art[data-clear-count="9"].is-showing {
  animation-name: clear-pop-dragon;
  animation-duration: 1280ms;
}

.clear-art[data-clear-count="10"].is-showing {
  animation-name: clear-pop-demon;
  animation-duration: 1280ms;
}

.clear-art[data-clear-count="11"].is-showing {
  animation-name: clear-pop-overlord;
  animation-duration: 1360ms;
}

.clear-art[data-clear-count="12"].is-showing {
  animation-name: clear-pop-angel;
  animation-duration: 1420ms;
}

.clear-art[data-clear-count="13"].is-showing {
  animation-name: clear-pop-god;
  animation-duration: 1480ms;
}

.clear-art[data-clear-count="14"].is-showing {
  animation-name: clear-pop-cosmic;
  animation-duration: 1540ms;
}

.clear-art[data-clear-count="15"].is-showing {
  animation-name: clear-pop-creator;
  animation-duration: 1600ms;
}

.clear-art[data-clear-count="16"].is-showing {
  animation-name: clear-pop-creator;
  animation-duration: 1660ms;
}

.clear-art[data-clear-mode="pumaru-spin"].is-showing {
  opacity: 1;
  animation: none;
  transform: none;
}

.clear-art[data-clear-mode="pumaru-spin"].is-showing .pumaru-spin-bg {
  animation: pumaru-spin-bg 1550ms ease-out both;
}

.clear-art[data-clear-mode="pumaru-spin"].is-showing .pumaru-spin-dog {
  animation: pumaru-spin-dog 1550ms linear both;
}

.clear-art[data-clear-mode="pumaru-spin"].is-showing::before {
  animation: pumaru-spin-rings 1550ms ease-out both;
}

.clear-art[data-clear-mode="pumaru-spin"].is-showing::after {
  animation: pumaru-spin-sparks 1550ms ease-out both;
}

@keyframes clear-pop {
  0% {
    opacity: 0;
    transform: scale(0.86) rotate(-1.5deg);
  }

  14% {
    opacity: 0.68;
    transform: scale(1.04) rotate(0.8deg);
  }

  76% {
    opacity: 0.68;
    transform: scale(1.08) rotate(-0.5deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.16) rotate(1deg);
  }
}

@keyframes clear-pop-big {
  0% {
    opacity: 0;
    transform: scale(0.78) rotate(-2deg);
  }

  14% {
    opacity: 0.88;
    transform: scale(1.08) rotate(1deg);
  }

  78% {
    opacity: 0.88;
    transform: scale(1.16) rotate(-0.7deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.24) rotate(1.4deg);
  }
}

@keyframes clear-pop-combo {
  0% {
    opacity: 0;
    transform: scale(0.74) rotate(-2deg);
  }

  12% {
    opacity: 0.86;
    transform: scale(1.08) rotate(1deg);
  }

  78% {
    opacity: 0.86;
    transform: scale(1.17) rotate(-0.7deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.26) rotate(1.2deg);
  }
}

@keyframes clear-pop-dragon {
  0% {
    opacity: 0;
    transform: scale(0.74) rotate(-3deg);
  }

  11% {
    opacity: 0.84;
    transform: scale(1.08) rotate(1.4deg);
  }

  78% {
    opacity: 0.84;
    transform: scale(1.17) rotate(-1deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.3) rotate(1.6deg);
  }
}

@keyframes clear-pop-demon {
  0% {
    opacity: 0;
    transform: scale(0.7) rotate(3deg);
  }

  10% {
    opacity: 0.9;
    transform: scale(1.09) rotate(-1.8deg);
  }

  78% {
    opacity: 0.9;
    transform: scale(1.18) rotate(1.1deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.34) rotate(-1.7deg);
  }
}

@keyframes clear-pop-overlord {
  0% {
    opacity: 0;
    transform: scale(0.68) rotate(-3deg);
  }

  10% {
    opacity: 0.94;
    transform: scale(1.1) rotate(1.8deg);
  }

  78% {
    opacity: 0.94;
    transform: scale(1.2) rotate(-1.2deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.38) rotate(1.8deg);
  }
}

@keyframes clear-pop-angel {
  0% {
    opacity: 0;
    transform: scale(0.72) translateY(2%) rotate(1.5deg);
  }

  12% {
    opacity: 0.92;
    transform: scale(1.08) translateY(-1%) rotate(-1deg);
  }

  78% {
    opacity: 0.92;
    transform: scale(1.18) translateY(-3%) rotate(0.7deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.34) translateY(-6%) rotate(-1deg);
  }
}

@keyframes clear-pop-god {
  0% {
    opacity: 0;
    transform: scale(0.64) rotate(-2deg);
  }

  9% {
    opacity: 0.98;
    transform: scale(1.12) rotate(1.2deg);
  }

  80% {
    opacity: 0.98;
    transform: scale(1.24) rotate(-0.8deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.42) rotate(1.2deg);
  }
}

@keyframes clear-pop-cosmic {
  0% {
    opacity: 0;
    transform: scale(0.62) rotate(-5deg);
  }

  9% {
    opacity: 0.96;
    transform: scale(1.1) rotate(2.4deg);
  }

  80% {
    opacity: 0.96;
    transform: scale(1.24) rotate(-2deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.46) rotate(3deg);
  }
}

@keyframes clear-pop-creator {
  0% {
    opacity: 0;
    transform: scale(0.6) translateY(3%) rotate(1deg);
  }

  10% {
    opacity: 1;
    transform: scale(1.12) translateY(-1%) rotate(-0.8deg);
  }

  80% {
    opacity: 1;
    transform: scale(1.26) translateY(-3%) rotate(0.6deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.5) translateY(-7%) rotate(-0.8deg);
  }
}

@keyframes pumaru-spin-bg {
  0% {
    opacity: 0;
    transform: scale(1);
  }

  12% {
    opacity: 0.78;
    transform: scale(1.02);
  }

  84% {
    opacity: 0.72;
    transform: scale(1.04);
  }

  100% {
    opacity: 0;
    transform: scale(1.05);
  }
}

@keyframes pumaru-spin-dog {
  0% {
    opacity: 0;
    transform: scale(1.5) rotate(-900deg);
  }

  7% {
    opacity: 1;
    transform: scale(1.36) rotate(-650deg);
  }

  15% {
    opacity: 1;
    transform: scale(1.22) rotate(-390deg);
  }

  24% {
    opacity: 1;
    transform: scale(1.08) rotate(-120deg);
  }

  32% {
    opacity: 1;
    transform: scale(1.04) rotate(12deg);
  }

  42% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }

  84% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.03) rotate(0deg);
  }
}

@keyframes pumaru-spin-rings {
  0% {
    opacity: 0;
    transform: scale(0.42) rotate(-40deg);
  }

  10% {
    opacity: 1;
    transform: scale(0.86) rotate(8deg);
  }

  40% {
    opacity: 0.9;
    transform: scale(1.16) rotate(46deg);
  }

  76% {
    opacity: 0.42;
    transform: scale(1.36) rotate(94deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.62) rotate(126deg);
  }
}

@keyframes pumaru-spin-sparks {
  0% {
    opacity: 0;
    transform: scale(0.68) rotate(0deg);
  }

  8% {
    opacity: 1;
    transform: scale(0.94) rotate(18deg);
  }

  36% {
    opacity: 0.96;
    transform: scale(1.18) rotate(78deg);
  }

  72% {
    opacity: 0.5;
    transform: scale(1.34) rotate(132deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.5) rotate(176deg);
  }
}

@keyframes field-flash {
  0% {
    opacity: 0.52;
  }

  38% {
    opacity: 0.24;
  }

  100% {
    opacity: 0;
  }
}

@keyframes field-flash-big {
  0% {
    opacity: 0.24;
  }

  34% {
    opacity: 0.1;
  }

  100% {
    opacity: 0;
  }
}

@keyframes field-flash-pumaru-spin {
  0% {
    opacity: 0.68;
  }

  32% {
    opacity: 0.38;
  }

  100% {
    opacity: 0;
  }
}

.game-hud {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.topbar {
  position: absolute;
  top: max(6px, env(safe-area-inset-top));
  left: 6px;
  right: 6px;
  min-height: 36px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 6px;
}

.menu-button {
  min-height: 36px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: clamp(0.66rem, 3vw, 0.78rem);
  font-weight: 900;
  backdrop-filter: blur(5px);
  pointer-events: auto;
  touch-action: manipulation;
}

.topbar-actions {
  display: flex;
  align-items: flex-start;
  gap: 6px;
  pointer-events: auto;
}

.game-menu {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(5, 10, 8, 0.68);
  backdrop-filter: blur(4px);
}

.game-menu[hidden] {
  display: none;
}

.game-menu-panel {
  width: min(280px, 100%);
  display: grid;
  gap: 10px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(17, 21, 15, 0.96);
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.45);
}

.game-menu-panel strong {
  margin-bottom: 4px;
  font-size: 1.15rem;
  text-align: center;
}

.game-menu-panel button {
  min-height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 232, 0.12);
  color: var(--ink);
  font: inherit;
  font-weight: 900;
  touch-action: manipulation;
}

.room-status {
  min-width: 68px;
  padding: 6px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: var(--gold);
  font-size: clamp(0.56rem, 2.8vw, 0.68rem);
  line-height: 1.15;
  font-weight: 900;
  text-align: center;
  backdrop-filter: blur(5px);
}

.room-status.is-online {
  color: var(--teal);
}

.room-status.is-waiting {
  color: var(--gold);
}

.score-strip {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: 6px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.score-item,
.mini-panel,
.combo-badge {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-soft);
  backdrop-filter: blur(5px);
}

.score-item {
  padding: 4px 5px;
}

.star-score-item {
  position: relative;
  overflow: visible;
}

.opponent-peek-button {
  align-self: stretch;
  min-width: 0;
  min-height: 34px;
  display: grid;
  place-items: center;
  padding: 2px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 248, 232, 0.9);
  pointer-events: auto;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  cursor: pointer;
  transition: color 120ms ease, filter 120ms ease, transform 120ms ease;
}

.opponent-peek-button[hidden] {
  display: none;
}

.opponent-peek-button svg {
  width: min(42px, 72%);
  height: 27px;
  overflow: visible;
  fill: none;
  stroke: currentColor;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.62));
}

.opponent-peek-button:not(:disabled):focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 1px;
}

.opponent-peek-button:not(:disabled):active,
.opponent-peek-button.is-peeking {
  color: var(--teal);
  filter: drop-shadow(0 0 8px rgba(46, 232, 208, 0.68));
  transform: scale(1.08);
}

.opponent-peek-button:disabled {
  color: rgba(255, 248, 232, 0.3);
  cursor: default;
}

.playfield.is-opponent-peeking .board-zone {
  border-color: rgba(46, 232, 208, 0.82);
  box-shadow:
    inset 0 0 0 1px rgba(46, 232, 208, 0.22),
    0 0 24px rgba(46, 232, 208, 0.24),
    0 12px 28px rgba(0, 0, 0, 0.22);
}

.score-item.star-score-item strong {
  display: flex;
  align-items: baseline;
  gap: 0;
  color: var(--gold);
}

.star-score-item em {
  font-style: normal;
  font-variant-numeric: tabular-nums;
}

.star-score-item small {
  color: rgba(255, 249, 239, 0.78);
  font-size: 0.66em;
  font-weight: 900;
}

.star-score-item.is-star-received {
  animation: star-counter-received 720ms cubic-bezier(.16,.84,.22,1) both;
}

.star-score-item.is-star-received::after {
  content: "★";
  position: absolute;
  inset: 50% auto auto 50%;
  color: var(--gold);
  font-size: 30px;
  line-height: 1;
  opacity: 0;
  pointer-events: none;
  text-shadow: 0 0 10px rgba(255, 248, 232, 0.9), 0 0 18px rgba(255, 227, 109, 0.82);
  animation: star-counter-arrival 720ms ease-out both;
}

.star-counter-flight {
  position: absolute;
  z-index: 6;
  left: var(--star-start-x);
  top: var(--star-start-y);
  width: 54px;
  height: 54px;
  display: grid;
  place-items: center;
  color: var(--gold);
  font-size: 51px;
  line-height: 1;
  pointer-events: none;
  text-shadow:
    0 2px 0 rgba(219, 157, 38, 0.92),
    0 0 10px rgba(255, 248, 232, 0.96),
    0 0 22px rgba(255, 227, 109, 0.9),
    0 0 34px rgba(255, 184, 92, 0.54);
  transform: translate(-50%, -50%);
  animation: star-to-counter var(--star-move-duration) linear both;
  will-change: left, top, opacity, transform;
}

.star-rainbow-trail {
  position: absolute;
  z-index: 5;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  opacity: 0;
  pointer-events: none;
  animation: star-rainbow-trail var(--trail-duration) linear both;
  will-change: opacity;
}

.star-rainbow-trail-glow,
.star-rainbow-trail-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-dasharray: var(--trail-length);
  stroke-dashoffset: var(--trail-length);
  vector-effect: non-scaling-stroke;
  animation: star-rainbow-trail-draw var(--trail-move-duration) linear 40ms both;
  will-change: stroke-dashoffset;
}

.star-rainbow-trail-glow {
  stroke: rgba(255, 248, 232, 0.38);
  stroke-width: 17px;
  filter: blur(3px);
}

.star-rainbow-trail-line {
  stroke-width: 9px;
  filter: drop-shadow(0 0 5px rgba(255, 248, 232, 0.46));
}

@keyframes star-to-counter {
  0% {
    left: var(--star-start-x);
    top: var(--star-start-y);
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.08) rotate(-28deg);
  }
  16% {
    left: var(--star-start-x);
    top: var(--star-start-y);
    opacity: 1;
    transform: translate(-50%, -50%) scale(1.4) rotate(8deg);
  }
  28% {
    left: var(--star-start-x);
    top: var(--star-start-y);
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotate(0);
  }
  37% {
    left: var(--star-curve-x-1);
    top: var(--star-curve-y-1);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.93) rotate(24deg);
  }
  46% {
    left: var(--star-curve-x-2);
    top: var(--star-curve-y-2);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.86) rotate(49deg);
  }
  55% {
    left: var(--star-curve-x-3);
    top: var(--star-curve-y-3);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.78) rotate(74deg);
  }
  64% {
    left: var(--star-curve-x-4);
    top: var(--star-curve-y-4);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.7) rotate(98deg);
  }
  73% {
    left: var(--star-curve-x-5);
    top: var(--star-curve-y-5);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.62) rotate(123deg);
  }
  82% {
    left: var(--star-curve-x-6);
    top: var(--star-curve-y-6);
    opacity: 1;
    transform: translate(-50%, -50%) scale(0.54) rotate(147deg);
  }
  91% {
    left: var(--star-curve-x-7);
    top: var(--star-curve-y-7);
    opacity: 0.98;
    transform: translate(-50%, -50%) scale(0.46) rotate(172deg);
  }
  100% {
    left: var(--star-end-x);
    top: var(--star-end-y);
    opacity: 0.94;
    transform: translate(-50%, -50%) scale(0.38) rotate(196deg);
  }
}

@keyframes star-rainbow-trail {
  0%, 24% {
    opacity: 0;
  }
  28% {
    opacity: 0.76;
  }
  78% {
    opacity: 0.72;
  }
  100% {
    opacity: 0;
  }
}

@keyframes star-rainbow-trail-draw {
  0%, 28% {
    stroke-dashoffset: var(--trail-length);
  }
  37% {
    stroke-dashoffset: var(--trail-offset-1);
  }
  46% {
    stroke-dashoffset: var(--trail-offset-2);
  }
  55% {
    stroke-dashoffset: var(--trail-offset-3);
  }
  64% {
    stroke-dashoffset: var(--trail-offset-4);
  }
  73% {
    stroke-dashoffset: var(--trail-offset-5);
  }
  82% {
    stroke-dashoffset: var(--trail-offset-6);
  }
  91% {
    stroke-dashoffset: var(--trail-offset-7);
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@keyframes star-counter-received {
  0%, 100% { transform: scale(1); }
  28% { transform: scale(1.16); border-color: rgba(255, 227, 109, 0.92); box-shadow: 0 0 18px rgba(255, 227, 109, 0.6); }
  58% { transform: scale(0.96); }
}

@keyframes star-counter-arrival {
  0% { opacity: 0.92; transform: translate(-50%, -50%) scale(0.35) rotate(-30deg); }
  44% { opacity: 1; transform: translate(-50%, -50%) scale(1.3) rotate(8deg); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.8) rotate(24deg); }
}


.score-item span,
.mini-panel span {
  display: block;
  color: var(--muted);
  font-size: clamp(0.48rem, 2.25vw, 0.58rem);
  line-height: 1;
  font-weight: 850;
}

.score-item strong {
  display: block;
  margin-top: 2px;
  font-variant-numeric: tabular-nums;
  font-size: clamp(0.72rem, 3.5vw, 0.95rem);
  line-height: 1;
}

#score.is-score-punch {
  animation: total-score-punch 420ms cubic-bezier(.18,.86,.22,1) both;
}

@keyframes total-score-punch {
  0% { color: #fff; transform: scale(1); text-shadow: none; }
  28% { color: var(--gold); transform: scale(1.2); text-shadow: 0 0 10px rgba(255, 227, 109, 0.9); }
  58% { transform: scale(0.96); }
  100% { color: #fff; transform: scale(1); text-shadow: none; }
}

.preview-row {
  --preview-panel-width: clamp(44px, 13vw, 56px);
  position: absolute;
  top: max(56px, calc(env(safe-area-inset-top) + 56px));
  left: 6px;
  right: 6px;
  display: flex;
  align-items: stretch;
  gap: 4px;
}

.preview-row > .skill-panel {
  flex: 0 0 calc(var(--preview-panel-width) * 2 + 4px);
}

.next-previews {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: repeat(2, var(--preview-panel-width));
  gap: 4px;
  margin-left: auto;
}

.mini-panel {
  height: clamp(40px, 12vw, 52px);
  padding: 4px;
}

.mini-panel canvas {
  display: block;
  width: min(44px, 13vw);
  height: clamp(24px, 7vw, 34px);
  margin: 1px auto 0;
}

.next-panel {
  position: relative;
  overflow: hidden;
  isolation: isolate;
  text-align: center;
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.next-panel > span,
.next-panel > canvas {
  position: relative;
  z-index: 1;
}

.next-panel canvas {
  width: min(36px, 10.5vw);
}

.following-panel {
  background: rgba(7, 28, 32, 0.36);
}

.following-panel span {
  font-size: clamp(0.42rem, 1.95vw, 0.52rem);
}

.following-panel canvas {
  width: min(32px, 9.5vw);
  opacity: 0.84;
}

.next-panel.is-helper-preview {
  --helper-preview-rgb: 155, 255, 86;
  border-color: rgba(var(--helper-preview-rgb), 0.82);
  background:
    radial-gradient(circle at 50% 62%, rgba(var(--helper-preview-rgb), 0.42), rgba(7, 28, 32, 0.42) 72%),
    rgba(7, 28, 32, 0.62);
  box-shadow:
    0 0 13px rgba(var(--helper-preview-rgb), 0.58),
    inset 0 0 12px rgba(var(--helper-preview-rgb), 0.28);
}

.next-panel.is-helper-metal {
  --helper-preview-rgb: 137, 218, 255;
}

.next-panel.is-helper-preview::before,
.next-panel.is-helper-preview::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.next-panel.is-helper-preview::before {
  inset: -70%;
  z-index: 0;
  background: conic-gradient(
    from 0deg,
    transparent 0 16%,
    rgba(var(--helper-preview-rgb), 0.08) 22%,
    rgba(255, 255, 255, 0.68) 28%,
    rgba(var(--helper-preview-rgb), 0.12) 35%,
    transparent 42% 66%,
    rgba(var(--helper-preview-rgb), 0.34) 74%,
    transparent 83% 100%
  );
  filter: blur(3px);
  animation: helper-next-preview-glow 1450ms linear infinite;
}

.next-panel.is-helper-preview::after {
  inset: 2px;
  z-index: 0;
  border: 1px solid rgba(255, 255, 255, 0.36);
  border-radius: 6px;
  box-shadow: inset 0 0 9px rgba(var(--helper-preview-rgb), 0.34);
}

.following-panel.is-helper-preview {
  background:
    radial-gradient(circle at 50% 62%, rgba(var(--helper-preview-rgb), 0.24), rgba(7, 28, 32, 0.38) 74%),
    rgba(7, 28, 32, 0.42);
  box-shadow:
    0 0 7px rgba(var(--helper-preview-rgb), 0.3),
    inset 0 0 7px rgba(var(--helper-preview-rgb), 0.18);
  animation: helper-following-panel-glow 1050ms ease-out both;
}

.following-panel.is-helper-preview::before {
  animation: helper-following-preview-glow 1050ms ease-out both;
}

@keyframes helper-next-preview-glow {
  0% { opacity: 0.36; transform: rotate(0deg) scale(0.94); }
  50% { opacity: 0.82; transform: rotate(180deg) scale(1.04); }
  100% { opacity: 0.36; transform: rotate(360deg) scale(0.94); }
}

@keyframes helper-following-panel-glow {
  0% { border-color: rgba(var(--helper-preview-rgb), 0.24); box-shadow: 0 0 0 rgba(var(--helper-preview-rgb), 0); }
  34% { border-color: rgba(var(--helper-preview-rgb), 0.72); box-shadow: 0 0 12px rgba(var(--helper-preview-rgb), 0.48), inset 0 0 8px rgba(var(--helper-preview-rgb), 0.28); }
  100% { border-color: rgba(var(--helper-preview-rgb), 0.42); box-shadow: 0 0 7px rgba(var(--helper-preview-rgb), 0.3), inset 0 0 7px rgba(var(--helper-preview-rgb), 0.18); }
}

@keyframes helper-following-preview-glow {
  0% { opacity: 0; transform: rotate(-22deg) scale(0.68); }
  36% { opacity: 0.62; transform: rotate(14deg) scale(1.08); }
  100% { opacity: 0.16; transform: rotate(34deg) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .next-panel.is-helper-preview,
  .next-panel.is-helper-preview::before {
    animation: none;
  }

  .next-panel.is-helper-preview::before {
    opacity: 0.34;
  }
}

.skill-panel {
  position: relative;
  z-index: 1;
  overflow: visible;
  isolation: isolate;
  color: inherit;
  font: inherit;
  cursor: default;
  touch-action: manipulation;
  appearance: none;
  -webkit-appearance: none;
}

.skill-panel > span {
  transition: opacity 160ms ease;
}

.skill-panel.is-empty > span,
.skill-panel.is-empty canvas {
  opacity: 0;
}

.skill-panel.is-ready,
.skill-panel.is-aiming {
  cursor: pointer;
  pointer-events: auto;
}

.skill-panel.is-ready:active,
.skill-panel.is-aiming:active {
  transform: scale(0.96);
}

.skill-panel:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.skill-panel.is-ready,
.skill-panel.is-aiming {
  border-color: rgba(255, 227, 109, 0.58);
  background: rgba(65, 38, 23, 0.54);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 232, 0.1),
    0 0 16px rgba(255, 227, 109, 0.2);
}

.skill-panel.is-aiming {
  border-color: rgba(255, 122, 168, 0.66);
}

.skill-panel canvas {
  width: calc(100% - 4px);
  max-width: 96px;
  transition:
    opacity 160ms ease,
    filter 160ms ease;
}

.skill-panel.is-ready canvas,
.skill-panel.is-aiming canvas {
  filter:
    drop-shadow(0 0 6px rgba(255, 227, 109, 0.74))
    drop-shadow(0 0 12px rgba(255, 122, 168, 0.36));
}

.skill-panel.is-acquired canvas,
.skill-panel.is-evolved canvas {
  filter:
    drop-shadow(0 0 8px rgba(255, 248, 232, 0.98))
    drop-shadow(0 0 16px rgba(255, 227, 109, 0.86))
    drop-shadow(0 0 24px rgba(255, 122, 168, 0.64));
}

.skill-panel.is-acquired {
  animation: skill-panel-acquired 1100ms ease-out both;
}

.skill-panel.is-evolved {
  animation: skill-panel-evolved 1450ms ease-out both;
}

.skill-panel::after {
  content: "";
  position: absolute;
  inset: -210%;
  z-index: 0;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 50%, rgba(255, 248, 232, 0.98), transparent 14%),
    radial-gradient(circle at 50% 50%, rgba(255, 227, 109, 0.72), transparent 42%),
    conic-gradient(from -18deg, transparent 0 7deg, rgba(255, 248, 232, 0.96) 8deg 14deg, transparent 15deg 38deg, rgba(255, 122, 168, 0.78) 39deg 48deg, transparent 49deg 77deg, rgba(46, 232, 208, 0.72) 78deg 88deg, transparent 89deg 128deg, rgba(255, 227, 109, 0.88) 129deg 140deg, transparent 141deg 188deg, rgba(255, 248, 232, 0.82) 189deg 197deg, transparent 198deg 246deg, rgba(255, 122, 168, 0.68) 247deg 256deg, transparent 257deg 360deg);
  mix-blend-mode: screen;
  pointer-events: none;
}

.skill-panel > * {
  position: relative;
  z-index: 1;
}

.skill-panel.is-acquired::after {
  animation: skill-panel-acquired-flash 1100ms ease-out both;
}

.skill-panel.is-evolved::after {
  animation: skill-panel-evolved-flash 1450ms ease-out both;
}

.combo-badge {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: clamp(78px, 26vw, 110px);
  transform: translateX(-50%);
  display: grid;
  place-items: center;
  padding: 4px;
  text-align: center;
}

.score-gain {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 7px);
  z-index: 3;
  width: max-content;
  max-width: min(160px, 42vw);
  isolation: isolate;
  padding: 5px 12px 6px;
  border: 2px solid rgba(255, 227, 109, 0.64);
  border-radius: 999px;
  background: linear-gradient(120deg, rgba(28, 17, 39, 0.94), rgba(65, 37, 35, 0.92));
  box-shadow: 0 0 10px rgba(255, 227, 109, 0.36), 0 5px 16px rgba(13, 8, 18, 0.4);
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 5px) scale(0.82);
  backdrop-filter: blur(5px);
}

.score-gain::after {
  content: "";
  position: absolute;
  inset: 50% auto auto 50%;
  z-index: -1;
  width: 190%;
  aspect-ratio: 1;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.25) rotate(0deg);
}

.score-gain::after {
  width: 125%;
  border: 3px solid rgba(255, 248, 232, 0.9);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(255, 227, 109, 0.92), inset 0 0 8px rgba(255, 122, 168, 0.72);
}

.score-gain strong,
.combo-badge .score-gain small {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.score-gain strong {
  color: #fff8e8;
  font-size: clamp(1rem, 4.8vw, 1.3rem);
  line-height: 1;
  font-weight: 950;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.02em;
  text-shadow: 0 2px 0 rgba(126, 55, 28, 0.9), 0 0 9px rgba(255, 227, 109, 0.95);
}

.combo-badge .score-gain small {
  margin-top: 2px;
  color: var(--gold);
  font-size: clamp(0.43rem, 1.9vw, 0.54rem);
  line-height: 1;
  font-weight: 900;
}

.combo-badge .score-gain small[hidden] {
  display: none;
}

.score-gain.is-showing {
  animation: score-gain-pop 980ms cubic-bezier(.16,.88,.22,1) both;
}

.score-gain.is-showing::after {
  animation: score-gain-ring 640ms ease-out both;
}

.score-gain.is-big {
  border-color: rgba(255, 227, 109, 0.72);
  background: rgba(66, 35, 24, 0.86);
  box-shadow: 0 0 18px rgba(255, 227, 109, 0.3);
  transform-origin: center;
}

.score-gain.is-special {
  border-color: rgba(255, 122, 168, 0.76);
  background: linear-gradient(105deg, rgba(75, 37, 74, 0.9), rgba(37, 62, 79, 0.9));
  box-shadow: 0 0 20px rgba(46, 232, 208, 0.3);
}

.score-gain.is-special strong {
  color: #fff;
  text-shadow: 0 0 7px rgba(255, 122, 168, 0.9), 0 0 13px rgba(46, 232, 208, 0.66);
}

@keyframes score-gain-pop {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(0.35) rotate(-5deg); filter: brightness(2); }
  13% { opacity: 1; transform: translate(-50%, -2px) scale(1.28) rotate(2deg); }
  24% { transform: translate(-50%, 1px) scale(0.94) rotate(-1deg); }
  34%, 72% { opacity: 1; transform: translate(-50%, 0) scale(1) rotate(0); filter: brightness(1); }
  100% { opacity: 0; transform: translate(-50%, -13px) scale(1.08); }
}

@keyframes score-gain-ring {
  0% { opacity: 0.95; transform: translate(-50%, -50%) scale(0.2); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.3); }
}

@media (prefers-reduced-motion: reduce) {
  .star-rainbow-trail {
    display: none;
  }

  .score-gain.is-showing {
    animation: score-gain-fade 700ms ease-out both;
  }

  .score-gain.is-showing::after,
  #score.is-score-punch {
    animation: none;
  }
}

@keyframes score-gain-fade {
  0%, 18% { opacity: 1; transform: translate(-50%, 0); }
  100% { opacity: 0; transform: translate(-50%, 0); }
}

.combo-badge span {
  max-width: 100%;
  color: var(--gold);
  font-size: clamp(0.66rem, 3.4vw, 0.9rem);
  line-height: 1.05;
  font-weight: 950;
  overflow-wrap: anywhere;
}

.combo-badge small {
  max-width: 100%;
  color: var(--coral);
  font-size: clamp(0.48rem, 2.1vw, 0.58rem);
  line-height: 1;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.skill-sidebar {
  position: absolute;
  top: var(--board-safe-top);
  right: 6px;
  width: 26px;
  min-height: 116px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  justify-items: center;
  gap: 5px;
  opacity: 0.92;
  pointer-events: none;
}

.skill-gauge {
  position: relative;
  width: 12px;
  height: 100%;
  min-height: 96px;
  overflow: hidden;
  border: 1px solid rgba(255, 248, 232, 0.36);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 248, 232, 0.12), rgba(255, 248, 232, 0.03)),
    rgba(5, 16, 14, 0.72);
  box-shadow:
    inset 0 0 0 1px rgba(0, 0, 0, 0.22),
    0 6px 14px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(4px);
}

.skill-gauge::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 2;
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent calc(10% - 1px),
    rgba(255, 248, 232, 0.22) calc(10% - 1px),
    rgba(255, 248, 232, 0.22) 10%
  );
  pointer-events: none;
}

.skill-sidebar.is-upgrading .skill-gauge::before {
  background: repeating-linear-gradient(
    0deg,
    transparent 0,
    transparent calc(6.6667% - 1px),
    rgba(255, 248, 232, 0.18) calc(6.6667% - 1px),
    rgba(255, 248, 232, 0.18) 6.6667%
  );
}

.skill-gauge::after {
  content: "";
  position: absolute;
  inset: -30%;
  z-index: 3;
  opacity: 0;
  background:
    radial-gradient(circle at 50% 82%, rgba(255, 248, 232, 0.78), transparent 18%),
    conic-gradient(from 0deg, transparent 0 42deg, rgba(255, 248, 232, 0.78) 48deg 56deg, transparent 62deg 160deg, rgba(255, 122, 168, 0.48) 166deg 174deg, transparent 180deg 360deg);
  mix-blend-mode: screen;
  pointer-events: none;
}

.skill-gauge-fill {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 0;
  background:
    linear-gradient(180deg, rgba(255, 248, 232, 0.95), rgba(255, 227, 109, 0.95) 38%, rgba(255, 122, 168, 0.88));
  box-shadow:
    0 0 10px rgba(255, 227, 109, 0.54),
    0 0 18px rgba(255, 122, 168, 0.28);
  transition: height 180ms ease;
}

.skill-sidebar span {
  color: var(--gold);
  font-size: clamp(0.46rem, 2vw, 0.54rem);
  line-height: 1;
  font-weight: 950;
  text-align: center;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 1px 5px rgba(0, 0, 0, 0.72);
}

.skill-sidebar.is-ready .skill-gauge,
.skill-sidebar.is-aiming .skill-gauge {
  border-color: rgba(255, 227, 109, 0.78);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 232, 0.16),
    0 0 16px rgba(255, 227, 109, 0.36);
}

.skill-sidebar.is-ready .skill-gauge {
  animation: skill-ready-gauge 1200ms ease-in-out infinite;
}

.skill-sidebar.is-ready .skill-gauge::after {
  animation: skill-ready-sweep 1300ms linear infinite;
}

.skill-sidebar.is-ready .skill-gauge-fill {
  animation: skill-ready-fill 920ms ease-in-out infinite;
}

.skill-sidebar.is-ready span {
  color: #fff9ef;
  animation: skill-ready-text 920ms ease-in-out infinite;
}

.skill-sidebar.is-aiming .skill-gauge {
  border-color: rgba(255, 122, 168, 0.78);
}

.skill-sidebar.is-acquired .skill-gauge {
  animation: skill-gauge-acquired 900ms ease-out both;
}

.skill-sidebar.is-evolved .skill-gauge {
  border-color: rgba(46, 232, 208, 0.88);
  animation: skill-gauge-evolved 1150ms ease-out both;
}

.skill-sidebar.is-evolved span {
  color: #fff9ef;
  animation: skill-ready-text 920ms ease-in-out infinite;
}

@keyframes skill-ready-gauge {
  0%,
  100% {
    transform: translateY(0);
    box-shadow:
      inset 0 0 0 1px rgba(255, 248, 232, 0.16),
      0 0 15px rgba(255, 227, 109, 0.38);
  }

  50% {
    transform: translateY(-1px);
    box-shadow:
      inset 0 0 0 1px rgba(255, 248, 232, 0.24),
      0 0 24px rgba(255, 227, 109, 0.72),
      0 0 32px rgba(255, 122, 168, 0.34);
  }
}

@keyframes skill-ready-sweep {
  0% {
    opacity: 0;
    transform: translateY(42%) rotate(0deg);
  }

  22%,
  58% {
    opacity: 0.9;
  }

  100% {
    opacity: 0;
    transform: translateY(-42%) rotate(160deg);
  }
}

@keyframes skill-ready-fill {
  0%,
  100% {
    filter: saturate(1) brightness(1);
  }

  50% {
    filter: saturate(1.25) brightness(1.28);
  }
}

@keyframes skill-ready-text {
  0%,
  100% {
    text-shadow: 0 1px 5px rgba(0, 0, 0, 0.72);
  }

  50% {
    text-shadow:
      0 0 6px rgba(255, 248, 232, 0.9),
      0 0 12px rgba(255, 227, 109, 0.76);
  }
}

@keyframes skill-panel-acquired-flash {
  0% {
    opacity: 0;
    transform: scale(0.32) rotate(-18deg);
  }

  12% {
    opacity: 1;
    transform: scale(0.98) rotate(44deg);
  }

  34% {
    opacity: 0.92;
    transform: scale(1.34) rotate(132deg);
  }

  58% {
    opacity: 0.58;
    transform: scale(1.58) rotate(236deg);
  }

  100% {
    opacity: 0;
    transform: scale(1.9) rotate(360deg);
  }
}

@keyframes skill-panel-evolved-flash {
  0% {
    opacity: 0;
    transform: scale(0.28) rotate(0deg);
  }

  14% {
    opacity: 1;
    transform: scale(0.9) rotate(72deg);
  }

  36% {
    opacity: 0.96;
    transform: scale(1.45) rotate(164deg);
  }

  64% {
    opacity: 0.6;
    transform: scale(1.82) rotate(286deg);
  }

  100% {
    opacity: 0;
    transform: scale(2.18) rotate(420deg);
  }
}

@keyframes skill-panel-acquired {
  0% {
    transform: scale(1);
    border-color: rgba(255, 227, 109, 0.58);
  }

  12% {
    transform: scale(1.12);
    border-color: rgba(255, 248, 232, 0.96);
    background: rgba(96, 62, 28, 0.84);
    box-shadow:
      inset 0 0 0 2px rgba(255, 248, 232, 0.72),
      inset 0 0 22px rgba(255, 248, 232, 0.46),
      0 0 18px rgba(255, 248, 232, 0.86),
      0 0 34px rgba(255, 227, 109, 0.9),
      0 0 48px rgba(255, 122, 168, 0.58),
      0 0 58px rgba(46, 232, 208, 0.38);
  }

  34% {
    transform: scale(1.03);
    border-color: rgba(46, 232, 208, 0.86);
    box-shadow:
      inset 0 0 0 1px rgba(255, 248, 232, 0.48),
      0 0 20px rgba(46, 232, 208, 0.62),
      0 0 36px rgba(255, 122, 168, 0.52);
  }

  52% {
    transform: scale(1.09);
    border-color: rgba(255, 122, 168, 0.94);
    box-shadow:
      inset 0 0 0 2px rgba(255, 248, 232, 0.52),
      0 0 22px rgba(255, 248, 232, 0.72),
      0 0 40px rgba(255, 227, 109, 0.78),
      0 0 54px rgba(255, 122, 168, 0.56);
  }

  100% {
    transform: scale(1);
    border-color: rgba(255, 227, 109, 0.58);
  }
}

@keyframes skill-panel-evolved {
  0% {
    transform: scale(1);
    border-color: rgba(255, 227, 109, 0.58);
  }

  16% {
    transform: scale(1.16);
    border-color: rgba(255, 248, 232, 0.98);
    background: rgba(34, 79, 78, 0.82);
    box-shadow:
      inset 0 0 0 2px rgba(255, 248, 232, 0.72),
      inset 0 0 24px rgba(46, 232, 208, 0.58),
      0 0 18px rgba(255, 248, 232, 0.86),
      0 0 36px rgba(46, 232, 208, 0.82),
      0 0 54px rgba(255, 227, 109, 0.72);
  }

  38% {
    transform: scale(1.04);
    border-color: rgba(255, 227, 109, 0.96);
    box-shadow:
      inset 0 0 0 1px rgba(255, 248, 232, 0.52),
      0 0 24px rgba(255, 227, 109, 0.76),
      0 0 42px rgba(46, 232, 208, 0.62),
      0 0 56px rgba(255, 122, 168, 0.42);
  }

  62% {
    transform: scale(1.12);
    border-color: rgba(255, 248, 232, 0.94);
    box-shadow:
      inset 0 0 0 2px rgba(255, 248, 232, 0.56),
      0 0 24px rgba(255, 248, 232, 0.82),
      0 0 46px rgba(46, 232, 208, 0.78),
      0 0 60px rgba(255, 227, 109, 0.58);
  }

  100% {
    transform: scale(1);
    border-color: rgba(255, 227, 109, 0.58);
  }
}

@keyframes skill-gauge-acquired {
  0%,
  100% {
    transform: scaleY(1);
  }

  18% {
    transform: scaleY(1.06);
    box-shadow:
      inset 0 0 0 1px rgba(255, 248, 232, 0.22),
      0 0 20px rgba(255, 227, 109, 0.68),
      0 0 30px rgba(46, 232, 208, 0.26);
  }
}

@keyframes skill-gauge-evolved {
  0%,
  100% {
    transform: scaleY(1);
  }

  18% {
    transform: scaleY(1.08);
    box-shadow:
      inset 0 0 0 1px rgba(255, 248, 232, 0.26),
      0 0 18px rgba(255, 248, 232, 0.72),
      0 0 28px rgba(46, 232, 208, 0.58);
  }

  46% {
    transform: scaleY(0.94);
    box-shadow:
      inset 0 0 0 1px rgba(46, 232, 208, 0.34),
      0 0 24px rgba(46, 232, 208, 0.74),
      0 0 36px rgba(255, 227, 109, 0.42);
  }

  68% {
    transform: scaleY(1.04);
  }
}

.overlay {
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(17, 21, 15, 0.42);
  backdrop-filter: blur(4px);
}

.playfield.is-title .overlay {
  place-items: stretch;
  padding: 0;
  background:
    linear-gradient(180deg, rgba(7, 12, 10, 0.64), rgba(7, 12, 10, 0.06) 36%, rgba(7, 12, 10, 0.76));
  backdrop-filter: none;
}

.playfield.is-challenger .overlay {
  padding: 22px;
  background:
    radial-gradient(circle at 50% 42%, rgba(46, 232, 208, 0.2), transparent 38%),
    linear-gradient(145deg, rgba(7, 38, 45, 0.9), rgba(20, 18, 45, 0.92));
  backdrop-filter: blur(7px);
}

.playfield.is-challenger .overlay-panel {
  width: min(100%, 320px);
  padding: 28px 22px 26px;
  gap: 14px;
  border: 2px solid rgba(46, 232, 208, 0.7);
  border-radius: 20px;
  background: rgba(10, 25, 31, 0.88);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 232, 0.12),
    0 0 34px rgba(46, 232, 208, 0.24),
    0 18px 50px rgba(0, 0, 0, 0.42);
  animation: challenger-panel-in 420ms cubic-bezier(0.2, 0.85, 0.24, 1) both;
}

.playfield.is-challenger .overlay-panel::before {
  content: "VS";
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(255, 227, 109, 0.78);
  border-radius: 50%;
  background: radial-gradient(circle at 36% 28%, #fff9d9, #ffe36d 44%, #ff8a5b 100%);
  color: #16323a;
  font-size: 1.65rem;
  font-weight: 1000;
  letter-spacing: -0.08em;
  text-shadow: 0 1px rgba(255, 255, 255, 0.55);
  box-shadow: 0 0 24px rgba(255, 227, 109, 0.38);
  animation: challenger-vs-pulse 1.15s ease-in-out infinite;
}

.playfield.is-challenger .overlay-panel > #overlayTitle {
  color: #fff9ef;
  font-size: clamp(1.25rem, 6vw, 1.65rem);
  line-height: 1.25;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.52);
}

.playfield.is-challenger .overlay-panel > span {
  display: block;
  color: #a9f8ed;
  font-size: 0.88rem;
  font-weight: 900;
}

.playfield.is-challenger .ranking-boards,
.playfield.is-challenger .ranking-form,
.playfield.is-challenger .room-form,
.playfield.is-challenger .title-buttons,
.playfield.is-challenger .howto-panel,
.playfield.is-challenger .completed-panel,
.playfield.is-challenger .ending-continue {
  display: none;
}

@keyframes challenger-panel-in {
  from { opacity: 0; transform: translateY(16px) scale(0.94); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes challenger-vs-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.overlay.is-hidden {
  display: none;
}

.complete-sequence {
  position: absolute;
  inset: 0;
  z-index: 12;
  overflow: hidden;
  width: 100%;
  padding: 0;
  border: 0;
  background: radial-gradient(circle at 50% 48%, rgba(255, 227, 109, 0.2), rgba(7, 12, 26, 0.9) 72%);
  color: var(--ink);
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

.complete-glow {
  position: absolute;
  inset: -35%;
  opacity: 0;
  background: conic-gradient(from 0deg, transparent 0 8%, rgba(255, 227, 109, 0.34) 9% 11%, transparent 12% 22%, rgba(46, 232, 208, 0.26) 23% 25%, transparent 26% 39%, rgba(255, 122, 168, 0.28) 40% 42%, transparent 43% 100%);
}

.complete-stars {
  position: absolute;
  top: 50%;
  left: 50%;
  color: var(--gold);
  font-size: clamp(7rem, 42vw, 11rem);
  line-height: 1;
  opacity: 0;
  filter: drop-shadow(0 0 24px rgba(255, 227, 109, 0.8));
}

.complete-copy {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  opacity: 0;
  transform: scale(0.65);
  text-shadow: 0 3px 10px rgba(0, 0, 0, 0.65), 0 0 24px rgba(255, 227, 109, 0.5);
}

.complete-copy small { color: var(--teal); font-size: 0.7rem; font-weight: 950; letter-spacing: 0.15em; }
.complete-copy strong { color: #fff9ef; font-size: clamp(2.35rem, 13vw, 3.5rem); line-height: 0.95; font-weight: 1000; }
.complete-copy > span { color: var(--gold); font-size: 1.15rem; font-weight: 950; letter-spacing: 0.24em; }

.complete-particle {
  position: absolute;
  top: 48%;
  left: 50%;
  width: var(--size);
  height: calc(var(--size) * 0.48);
  border-radius: 2px;
  opacity: 0;
  background: var(--color);
  box-shadow: 0 0 7px var(--color);
}

.complete-skip {
  position: absolute;
  bottom: max(18px, calc(env(safe-area-inset-bottom) + 12px));
  left: 0;
  right: 0;
  opacity: 0;
  color: rgba(255, 249, 239, 0.7);
  font-size: 0.68rem;
  font-weight: 800;
}

.complete-sequence.is-running .complete-glow { animation: complete-rays 3.2s ease-out both; }
.complete-sequence.is-running .complete-stars { animation: complete-star 3.2s ease-out both; }
.complete-sequence.is-running .complete-copy { animation: complete-copy 3.2s cubic-bezier(.2,.8,.2,1) both; }
.complete-sequence.is-running .complete-particle { animation: complete-confetti 2.5s var(--delay) cubic-bezier(.12,.7,.25,1) both; }
.complete-sequence.is-running .complete-skip { animation: complete-skip 3.2s ease both; }

@keyframes complete-rays {
  0%, 8% { opacity: 0; transform: rotate(0) scale(0.4); }
  24% { opacity: 1; }
  100% { opacity: 0.24; transform: rotate(42deg) scale(1.2); }
}

@keyframes complete-star {
  0%, 8% { opacity: 0; transform: translate(-50%, -50%) scale(0.05) rotate(-45deg); }
  22% { opacity: 1; transform: translate(-50%, -50%) scale(1.12) rotate(8deg); }
  42%, 100% { opacity: 0.12; transform: translate(-50%, -50%) scale(2.3) rotate(22deg); }
}

@keyframes complete-copy {
  0%, 28% { opacity: 0; transform: scale(0.65) translateY(12px); }
  40% { opacity: 1; transform: scale(1.08) translateY(0); }
  48%, 92% { opacity: 1; transform: scale(1); }
  100% { opacity: 0; transform: scale(1.04); }
}

@keyframes complete-confetti {
  0% { opacity: 0; transform: translate(-50%, -50%) rotate(0); }
  10% { opacity: 1; }
  100% { opacity: 0; transform: translate(calc(-50% + var(--x)), calc(-50% + var(--y))) rotate(var(--spin)); }
}

@keyframes complete-skip { 0%, 55% { opacity: 0; } 72%, 92% { opacity: 1; } 100% { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .playfield.is-challenger .overlay-panel,
  .playfield.is-challenger .overlay-panel::before {
    animation: none;
  }

  .star-counter-flight {
    animation-name: star-to-counter-reduced;
  }

  .star-score-item.is-star-received,
  .star-score-item.is-star-received::after {
    animation-duration: 300ms;
  }

  .complete-sequence.is-running .complete-glow,
  .complete-sequence.is-running .complete-stars,
  .complete-sequence.is-running .complete-particle { animation: none; }
  .complete-sequence.is-running .complete-copy { animation: complete-copy-reduced 800ms ease both; }
  @keyframes complete-copy-reduced { 0% { opacity: 0; } 20%, 85% { opacity: 1; transform: none; } 100% { opacity: 0; } }
}

@keyframes star-to-counter-reduced {
  0% { left: var(--star-end-x); top: var(--star-end-y); opacity: 0; transform: translate(-50%, -50%) scale(0.7); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { left: var(--star-end-x); top: var(--star-end-y); opacity: 0; transform: translate(-50%, -50%) scale(0.75); }
}

.overlay-panel {
  width: min(100%, 240px);
  padding: 18px;
  display: grid;
  gap: 10px;
  justify-items: center;
  border: 1px solid rgba(255, 248, 232, 0.28);
  border-radius: 8px;
  background: rgba(17, 21, 15, 0.86);
  text-align: center;
}

.playfield.is-title .overlay-panel {
  position: relative;
  width: 100%;
  height: 100%;
  padding: max(10px, env(safe-area-inset-top)) 12px max(12px, calc(env(safe-area-inset-bottom) + 12px));
  display: block;
  border: 0;
  background: transparent;
  box-shadow: none;
}

#overlayTitle,
.overlay-panel strong {
  margin: 0;
  font-size: 1.18rem;
  line-height: 1.1;
}

.overlay-panel span {
  color: var(--muted);
  font-size: 0.9rem;
}

.playfield.is-title .overlay-panel > span {
  display: none;
}

.playfield.is-ending .overlay {
  place-items: end center;
  padding: 0 14px max(18px, calc(env(safe-area-inset-bottom) + 14px));
  background:
    linear-gradient(180deg, rgba(7, 12, 26, 0.06) 42%, rgba(7, 12, 26, 0.78) 100%);
  backdrop-filter: none;
}

.playfield.is-ending .board-zone,
.playfield.is-ending .game-hud {
  visibility: hidden;
  pointer-events: none;
}

.ending-flower-shower {
  position: absolute;
  inset: 0;
  z-index: 3;
  overflow: hidden;
  pointer-events: none;
}

.ending-petal,
.ending-blossom {
  position: absolute;
  top: -12%;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 0.62);
  color: var(--flower-color);
  opacity: 0;
  animation: ending-flower-fall var(--duration) var(--delay) linear infinite;
  will-change: transform;
}

.ending-petal {
  border-radius: 80% 20% 70% 30%;
  background: var(--flower-color);
  box-shadow: inset -2px -1px 2px rgba(125, 55, 92, 0.16), 0 1px 3px rgba(0, 0, 0, 0.16);
}

.ending-blossom {
  display: grid;
  place-items: center;
  height: var(--size);
  font-size: calc(var(--size) * 1.35);
  line-height: 1;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2), 0 0 6px currentColor;
}

@keyframes ending-flower-fall {
  0% { opacity: 0; transform: translate3d(0, -8vh, 0) rotate(0deg); }
  8% { opacity: 0.92; }
  30% { transform: translate3d(var(--sway), 30vh, 0) rotate(180deg); }
  62% { transform: translate3d(calc(var(--drift) - var(--sway)), 66vh, 0) rotate(420deg); }
  92% { opacity: 0.9; }
  100% { opacity: 0; transform: translate3d(var(--drift), 116vh, 0) rotate(var(--turn)); }
}

.playfield.is-ending .overlay-panel {
  width: min(calc(100% - 28px), 300px);
  gap: 12px;
  border-color: rgba(255, 227, 109, 0.62);
  background: rgba(10, 18, 34, 0.76);
  backdrop-filter: blur(8px);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 232, 0.14),
    0 0 28px rgba(255, 227, 109, 0.28),
    0 18px 48px rgba(0, 0, 0, 0.4);
}

.playfield.is-ending .ranking-boards,
.playfield.is-ending .room-form {
  display: none;
}

.playfield.is-ending .ranking-form label {
  color: #fff3bd;
  text-align: center;
}

.ending-continue {
  width: 100%;
  min-height: 44px;
  border: 1px solid rgba(255, 227, 109, 0.64);
  background: linear-gradient(135deg, #ffe36d, #ffb96d);
  color: #251609;
  font-weight: 950;
  box-shadow: 0 0 22px rgba(255, 227, 109, 0.28);
  animation: ending-continue-pulse 1.8s ease-in-out infinite;
}

.playfield.is-ending-message .title-buttons {
  display: none;
}

.playfield.is-ending-message .overlay-panel {
  width: min(calc(100% - 24px), 340px);
}

.playfield.is-ending-message .overlay-panel > span {
  color: #fff3bd;
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.55;
  white-space: pre-line;
}

@keyframes ending-continue-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.025); }
}

.playfield.is-ending .overlay-panel > #overlayTitle {
  color: #fff9ef;
  font-size: 1.34rem;
  line-height: 1.18;
  white-space: pre-line;
  text-shadow:
    0 2px 8px rgba(0, 0, 0, 0.56),
    0 0 18px rgba(255, 227, 109, 0.42);
}

.playfield.is-ending .overlay-panel > span {
  color: #ffe36d;
  font-weight: 900;
}

.playfield.is-title .overlay-panel > #overlayTitle {
  position: absolute;
  top: max(42px, calc(env(safe-area-inset-top) + 40px));
  left: 16px;
  right: 16px;
  z-index: 2;
  display: block;
  margin: 0 auto;
  color: #fff6d6;
  font-size: clamp(2rem, calc(var(--board-width) * 0.11), 3.2rem);
  line-height: 1.05;
  font-weight: 950;
  text-align: center;
  white-space: pre-line;
  text-shadow:
    0 2px 0 rgba(7, 39, 38, 0.9),
    0 -1px 0 rgba(7, 39, 38, 0.78),
    2px 0 0 rgba(7, 39, 38, 0.78),
    -2px 0 0 rgba(7, 39, 38, 0.78),
    0 8px 18px rgba(0, 0, 0, 0.5),
    0 0 16px rgba(255, 225, 128, 0.42);
  -webkit-text-stroke: 1px rgba(5, 34, 33, 0.62);
  transform: translateY(0);
  transition:
    opacity 260ms ease,
    transform 360ms ease;
}

.playfield.is-title.is-rankings-visible .overlay-panel > #overlayTitle {
  opacity: 0;
  transform: translateY(-14px);
}

.ranking-boards {
  width: 100%;
  display: grid;
  gap: 8px;
}

.ranking-board {
  width: 100%;
  display: grid;
  gap: 4px;
}

.ranking-board h2 {
  margin: 0;
  color: var(--gold);
  font-size: 0.72rem;
  line-height: 1;
  font-weight: 950;
  text-align: left;
}

.ranking-list {
  width: 100%;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
  list-style: none;
}

.ranking-list li {
  min-width: 0;
  display: grid;
  grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 6px;
  align-items: center;
  padding: 5px 7px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 248, 232, 0.08);
  font-size: 0.78rem;
  line-height: 1.1;
}

.ranking-list span {
  font-size: inherit;
  line-height: inherit;
}

.ranking-list .ranking-rank,
.ranking-list .ranking-score {
  color: var(--gold);
  font-weight: 950;
}

.ranking-list .ranking-name {
  min-width: 0;
  overflow: hidden;
  color: var(--ink);
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ranking-list .ranking-score {
  font-variant-numeric: tabular-nums;
}

.ranking-list li.is-completed {
  border-color: rgba(255, 227, 109, 0.54);
  background: rgba(255, 227, 109, 0.12);
}

.playfield.is-title .ranking-boards {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 12px;
  right: 12px;
  width: auto;
  gap: 5px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition:
    opacity 360ms ease,
    visibility 0s linear 360ms;
}

.playfield.is-title.is-rankings-visible .ranking-boards {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.playfield.is-title .ranking-board {
  gap: 3px;
}

.playfield.is-title .ranking-board h2 {
  font-size: clamp(0.56rem, 2.6vw, 0.68rem);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.65);
}

.playfield.is-title .ranking-list li {
  grid-template-columns: 28px minmax(0, 1fr) auto;
  padding: 4px 7px;
  font-size: clamp(0.58rem, 2.7vw, 0.72rem);
  background: rgba(13, 18, 14, 0.88);
  border-color: rgba(255, 248, 232, 0.24);
}

.room-form,
.ranking-form {
  width: 100%;
  display: grid;
  gap: 5px;
}

.room-form label,
.ranking-form label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 800;
  text-align: left;
}

.room-entry,
.ranking-entry {
  display: grid;
  grid-template-columns: 1fr 64px;
  gap: 6px;
}

.room-entry input,
.room-entry button,
.ranking-entry input,
.ranking-entry button,
.ranking-skip-button,
.howto-button,
.howto-close,
.completed-button,
.solo-button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font: inherit;
  font-weight: 900;
}

.room-entry input,
.ranking-entry input {
  min-width: 0;
  padding: 0 10px;
  background: rgba(255, 248, 232, 0.1);
  color: var(--ink);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  -webkit-user-select: text;
  user-select: text;
  touch-action: manipulation;
}

.room-entry button,
.ranking-entry button,
.howto-button,
.completed-button,
.solo-button {
  background: linear-gradient(135deg, var(--teal), #78e19e);
  color: #05100e;
  touch-action: manipulation;
}

.ranking-skip-button {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(255, 248, 232, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 232, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 0.78rem;
  font-weight: 850;
  touch-action: manipulation;
}

.ranking-form > span {
  min-height: 1em;
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.1;
}

.ranking-privacy-note {
  margin: 0;
  color: #fff0a9;
  font-size: 0.64rem;
  line-height: 1.35;
  text-align: left;
}

.ranking-privacy-note a {
  color: inherit;
  font-weight: 900;
  text-decoration: underline;
  text-underline-offset: 2px;
}

.room-form .room-form-status {
  min-height: 1em;
  color: #fff0a9;
  font-size: 0.72rem;
  font-weight: 850;
  line-height: 1.25;
  text-align: left;
}

.room-form .room-form-status:empty {
  display: none;
}

.room-form .room-form-status.is-error {
  color: #ffd0d8;
}

.room-generate-button {
  min-height: 34px;
  border: 1px solid rgba(255, 248, 232, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 232, 0.08);
  color: var(--ink);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 850;
  touch-action: manipulation;
}

.room-entry button:disabled {
  opacity: 0.62;
  cursor: wait;
}

.title-buttons {
  width: 100%;
  display: grid;
  gap: 6px;
}

.title-controls {
  width: 100%;
  display: grid;
  gap: 8px;
}

.game-policy-link {
  grid-column: 1 / -1;
  justify-self: center;
  padding: 3px 2px;
  color: rgba(255, 248, 232, 0.82);
  font-size: 0.64rem;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.howto-button {
  display: none;
  background: rgba(255, 248, 232, 0.14);
  color: var(--ink);
}

.completed-button {
  display: none;
  background: rgba(255, 227, 109, 0.16);
  color: var(--ink);
}

.completed-panel {
  width: 100%;
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid rgba(255, 227, 109, 0.42);
  border-radius: 10px;
  background: rgba(12, 17, 28, 0.94);
  box-shadow: 0 18px 46px rgba(0, 0, 0, 0.48);
  backdrop-filter: blur(8px);
}

.completed-header {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 8px;
  align-items: center;
}

.completed-header strong {
  color: var(--gold);
  font-size: 1rem;
}

.completed-close {
  min-height: 34px;
  padding: 0;
  background: rgba(255, 248, 232, 0.1);
  color: var(--ink);
}

.completed-columns,
.completed-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 78px;
  gap: 6px;
  align-items: center;
}

.completed-columns {
  padding: 0 7px;
  color: var(--muted);
  font-size: 0.64rem;
  font-weight: 800;
}

.completed-columns span:last-child,
.completed-list li > span {
  text-align: right;
}

.completed-list {
  min-height: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 5px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  list-style: none;
}

.completed-list li {
  padding: 7px;
  border: 1px solid rgba(255, 248, 232, 0.14);
  border-radius: 7px;
  background: rgba(255, 248, 232, 0.07);
  font-size: 0.7rem;
}

.completed-list strong {
  min-width: 0;
  overflow: hidden;
  color: #fff9ef;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.completed-list time { color: var(--muted); }
.completed-list span { color: var(--gold); font-weight: 900; }
.completed-empty { margin: 14px 0; color: var(--muted); font-size: 0.78rem; }

.howto-panel {
  width: 100%;
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid rgba(255, 248, 232, 0.3);
  border-radius: 8px;
  background: rgba(17, 21, 15, 0.9);
  box-shadow:
    0 14px 34px rgba(0, 0, 0, 0.34),
    inset 0 0 0 1px rgba(255, 248, 232, 0.08);
  text-align: left;
  backdrop-filter: blur(6px);
}

.howto-header {
  display: grid;
  grid-template-columns: 1fr 34px;
  gap: 8px;
  align-items: center;
}

.howto-header strong {
  color: var(--gold);
  font-size: 0.92rem;
  line-height: 1.1;
}

.howto-close {
  min-height: 34px;
  padding: 0;
  background: rgba(255, 248, 232, 0.1);
  color: var(--ink);
  line-height: 1;
}

.howto-content {
  display: grid;
  gap: 10px;
  color: var(--ink);
  font-size: clamp(0.72rem, 3vw, 0.82rem);
  line-height: 1.5;
}

.howto-guide {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
}

.howto-guide img {
  width: 58px;
  height: 58px;
  border: 2px solid rgba(255, 240, 169, 0.8);
  border-radius: 50%;
  background: rgba(255, 248, 232, 0.12);
  object-fit: cover;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.28));
}

.howto-guide p {
  position: relative;
  margin: 0;
  padding: 9px 11px;
  border: 2px solid rgba(255, 240, 169, 0.58);
  border-radius: 12px;
  background: rgba(255, 248, 232, 0.1);
  color: #fff8dc;
  font-weight: 800;
  line-height: 1.55;
}

.howto-guide p::before {
  content: "";
  position: absolute;
  left: -8px;
  top: 20px;
  width: 12px;
  height: 12px;
  border-bottom: 2px solid rgba(255, 240, 169, 0.58);
  border-left: 2px solid rgba(255, 240, 169, 0.58);
  background: #292d24;
  transform: rotate(45deg);
}

.howto-section {
  display: grid;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(255, 248, 232, 0.14);
  border-radius: 8px;
  background: rgba(255, 248, 232, 0.055);
}

.howto-section h3,
.howto-section p,
.howto-section dl,
.howto-section ul {
  margin: 0;
}

.howto-section h3 {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--gold);
  font-size: 0.82rem;
}

.howto-section h3 span {
  display: inline-grid;
  width: 22px;
  height: 22px;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #172016;
  font-size: 0.72rem;
}

.howto-section p,
.howto-section li,
.howto-controls dd {
  font-weight: 700;
}

.howto-section strong {
  color: #fff0a9;
}

.howto-controls {
  display: grid;
  gap: 4px;
}

.howto-controls div {
  display: grid;
  grid-template-columns: minmax(112px, 0.85fr) minmax(0, 1fr);
  gap: 8px;
  padding: 5px 7px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.18);
}

.howto-controls dt {
  color: #a9f1d1;
  font-weight: 900;
}

.howto-controls dd {
  margin: 0;
}

.howto-note {
  padding: 7px 8px;
  border-left: 3px solid var(--teal);
  background: rgba(46, 196, 166, 0.09);
  color: var(--muted);
  font-size: 0.7rem;
}

.howto-skills,
.howto-bonuses {
  padding-left: 1.2em;
  display: grid;
  gap: 4px;
}

.howto-score-table {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(255, 248, 232, 0.18);
  border-radius: 7px;
}

.howto-score-table > div {
  display: contents;
}

.howto-score-table span,
.howto-score-table b {
  padding: 5px 8px;
  border-bottom: 1px solid rgba(255, 248, 232, 0.1);
}

.howto-score-table b {
  text-align: right;
  color: #fff0a9;
}

.howto-score-table > div:first-child span,
.howto-score-table > div:first-child b {
  background: rgba(46, 196, 166, 0.13);
  color: #a9f1d1;
}

.howto-score-table > div:last-child span,
.howto-score-table > div:last-child b {
  border-bottom: 0;
}

.solo-button {
  width: 100%;
  background: linear-gradient(135deg, var(--teal), #78e19e);
  color: #05100e;
}

.playfield.is-title .title-controls {
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: max(14px, calc(env(safe-area-inset-bottom) + 14px));
  width: auto;
}

.playfield.is-title .room-form {
  width: 100%;
}

.playfield.is-title .howto-panel {
  position: absolute;
  z-index: 5;
  top: max(10%, calc(env(safe-area-inset-top) + 8px));
  left: 14px;
  right: 14px;
  bottom: max(154px, calc(env(safe-area-inset-bottom) + 154px));
  width: auto;
  height: auto;
  min-height: 0;
  max-height: none;
  overflow: auto;
}

.playfield.is-title .title-buttons {
  width: 100%;
  grid-template-columns: minmax(68px, 0.72fr) minmax(82px, 0.9fr) minmax(0, 1.2fr);
}

.playfield.is-title .howto-button,
.playfield.is-title .completed-button {
  display: block;
}

.playfield.is-title .howto-button,
.playfield.is-title .completed-button,
.playfield.is-title .solo-button {
  background: rgba(17, 21, 15, 0.72);
  box-shadow:
    0 12px 28px rgba(0, 0, 0, 0.3),
    inset 0 0 0 1px rgba(255, 248, 232, 0.08);
  backdrop-filter: blur(5px);
}

.playfield.is-title .solo-button {
  background: linear-gradient(135deg, var(--teal), #78e19e);
  color: #05100e;
}

.playfield.is-title .completed-panel {
  position: absolute;
  z-index: 5;
  top: max(10%, calc(env(safe-area-inset-top) + 8px));
  left: 14px;
  right: 14px;
  bottom: max(154px, calc(env(safe-area-inset-bottom) + 154px));
  width: auto;
  height: auto;
  min-height: 0;
  max-height: none;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.playfield.is-title .ranking-boards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
}

.playfield.is-title .ranking-list li {
  grid-template-columns: 24px minmax(0, 1fr);
}

.playfield.is-title .ranking-list .ranking-score {
  grid-column: 2;
  font-size: 0.58rem;
}

.playfield.is-paused .overlay,
.playfield.is-game-over .overlay {
  padding: 10px;
}

.playfield.is-paused .overlay-panel,
.playfield.is-game-over .overlay-panel {
  width: min(100%, 390px);
  max-height: 100%;
  padding: 12px;
  gap: 6px;
  overflow: hidden;
}

.playfield.is-paused .ranking-boards,
.playfield.is-game-over .ranking-boards {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-items: start;
  gap: 7px;
}

.playfield.is-paused .ranking-board,
.playfield.is-game-over .ranking-board {
  min-width: 0;
  gap: 3px;
}

.playfield.is-paused .ranking-list,
.playfield.is-game-over .ranking-list {
  gap: 2px;
}

.playfield.is-paused .ranking-list li,
.playfield.is-game-over .ranking-list li {
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 2px 4px;
  padding: 3px 5px;
  font-size: clamp(0.56rem, 2.5vw, 0.68rem);
}

.playfield.is-paused .ranking-list .ranking-score,
.playfield.is-game-over .ranking-list .ranking-score {
  grid-column: 2;
  font-size: 0.56rem;
  text-align: left;
}

.playfield.is-paused .room-form,
.playfield.is-paused .title-buttons,
.playfield.is-game-over .room-form,
.playfield.is-game-over .title-buttons {
  flex: none;
}

.playfield.is-room-waiting .overlay {
  padding: 22px;
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 227, 109, 0.15), transparent 40%),
    linear-gradient(145deg, rgba(7, 38, 45, 0.92), rgba(20, 18, 45, 0.94));
  backdrop-filter: blur(7px);
}

.playfield.is-room-waiting .overlay-panel {
  width: min(100%, 320px);
  padding: 28px 22px 24px;
  gap: 14px;
  border: 2px solid rgba(255, 227, 109, 0.58);
  border-radius: 20px;
  background: rgba(10, 25, 31, 0.9);
  box-shadow:
    inset 0 0 0 1px rgba(255, 248, 232, 0.1),
    0 0 34px rgba(255, 227, 109, 0.18),
    0 18px 50px rgba(0, 0, 0, 0.42);
}

.playfield.is-room-waiting .overlay-panel::before {
  content: "•••";
  width: 70px;
  height: 70px;
  display: grid;
  place-items: center;
  border: 2px solid rgba(46, 232, 208, 0.68);
  border-radius: 50%;
  background: rgba(46, 232, 208, 0.12);
  color: #a9f8ed;
  font-size: 1.35rem;
  font-weight: 1000;
  letter-spacing: 0.12em;
  box-shadow: 0 0 24px rgba(46, 232, 208, 0.22);
  animation: challenger-vs-pulse 1.15s ease-in-out infinite;
}

.playfield.is-room-waiting .overlay-panel > #overlayTitle {
  color: #fff9ef;
  font-size: clamp(1.2rem, 5.5vw, 1.55rem);
  line-height: 1.25;
}

.playfield.is-room-waiting .overlay-panel > span {
  color: #fff0a9;
  font-size: 0.82rem;
  font-weight: 850;
  line-height: 1.55;
  white-space: pre-line;
}

.room-wait-cancel,
.versus-result-actions button {
  min-height: 42px;
  border: 1px solid rgba(255, 248, 232, 0.26);
  border-radius: 9px;
  font: inherit;
  font-weight: 950;
  touch-action: manipulation;
}

.room-wait-cancel {
  width: 100%;
  background: rgba(255, 248, 232, 0.1);
  color: #fff9ef;
}

.playfield.is-room-waiting .ranking-boards,
.playfield.is-room-waiting .ranking-form,
.playfield.is-room-waiting .room-form,
.playfield.is-room-waiting .title-buttons,
.playfield.is-room-waiting .howto-panel,
.playfield.is-room-waiting .completed-panel,
.playfield.is-room-waiting .ending-continue,
.playfield.is-versus-result .ranking-boards,
.playfield.is-versus-result .ranking-form,
.playfield.is-versus-result .room-form,
.playfield.is-versus-result .title-buttons,
.playfield.is-versus-result .howto-panel,
.playfield.is-versus-result .completed-panel,
.playfield.is-versus-result .ending-continue,
.playfield.is-versus-result .room-wait-cancel {
  display: none;
}

.playfield.is-versus-result .overlay {
  padding: 10px;
  background:
    linear-gradient(180deg, rgba(8, 20, 29, 0.72), rgba(7, 14, 24, 0.94));
  backdrop-filter: blur(7px);
}

.playfield.is-versus-result .overlay-panel,
.playfield.is-versus-result.is-game-over .overlay-panel {
  width: min(100%, 390px);
  max-height: 100%;
  padding: 12px;
  gap: 7px;
  overflow: auto;
  border: 2px solid rgba(255, 248, 232, 0.34);
  border-radius: 18px;
  background: rgba(10, 18, 28, 0.92);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.48);
}

.playfield.is-versus-win .overlay-panel {
  border-color: rgba(255, 227, 109, 0.72);
  box-shadow: 0 0 34px rgba(255, 227, 109, 0.2), 0 18px 48px rgba(0, 0, 0, 0.48);
}

.playfield.is-versus-loss .overlay-panel {
  border-color: rgba(126, 210, 232, 0.5);
}

.playfield.is-versus-draw .overlay-panel {
  border-color: rgba(181, 156, 255, 0.68);
  box-shadow: 0 0 34px rgba(181, 156, 255, 0.18), 0 18px 48px rgba(0, 0, 0, 0.48);
}

.playfield.is-versus-result .overlay-panel > #overlayTitle {
  color: #fff9ef;
  font-size: clamp(1.35rem, 6vw, 1.75rem);
  line-height: 1.1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.58);
}

.playfield.is-versus-result .overlay-panel > span {
  color: #ffe36d;
  font-size: 0.82rem;
  font-weight: 900;
}

.versus-result {
  width: 100%;
  display: grid;
  gap: 8px;
  justify-items: center;
}

.versus-result[hidden],
.room-wait-cancel[hidden] {
  display: none;
}

.versus-result img {
  width: 100%;
  max-height: min(48vh, 410px);
  aspect-ratio: 4 / 5;
  display: block;
  border: 1px solid rgba(255, 248, 232, 0.2);
  border-radius: 13px;
  object-fit: cover;
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.34);
}

.playfield.is-versus-win .versus-result img {
  object-position: 50% 55%;
}

.playfield.is-versus-draw .versus-result img {
  object-position: 50% 50%;
}

.playfield.is-versus-loss .versus-result img {
  object-position: 50% 50%;
}

.versus-result .versus-record {
  display: block;
  color: #fff0a9;
  font-size: clamp(1.1rem, 5vw, 1.35rem);
  font-weight: 1000;
  letter-spacing: 0.08em;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

.versus-result-actions {
  width: 100%;
  display: grid;
  grid-template-columns: 1.15fr 1fr;
  gap: 7px;
}

.versus-result-actions button:first-child {
  background: linear-gradient(135deg, #2ee8d0, #78e19e);
  color: #05100e;
}

.versus-result-actions button:last-child {
  background: rgba(255, 248, 232, 0.1);
  color: #fff9ef;
}

.versus-result-actions button:disabled {
  opacity: 0.55;
}

@media (prefers-reduced-motion: reduce) {
  .playfield.is-room-waiting .overlay-panel::before {
    animation: none;
  }
}

@media (max-height: 680px) {
  :root {
    --board-safe-top: max(96px, calc(env(safe-area-inset-top) + 94px));
    --board-safe-bottom: 50px;
  }

  .menu-button {
    min-height: 32px;
    padding: 5px 8px;
  }

  .room-status {
    min-width: 62px;
    padding: 5px 6px;
  }

  .score-strip {
    bottom: 4px;
  }

  .score-item {
    padding: 3px 4px;
  }

  .preview-row {
    top: max(50px, calc(env(safe-area-inset-top) + 50px));
  }

  .mini-panel {
    height: 38px;
  }
}

/* Accessible helpers and state-specific interaction layers. */
.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.playfield.is-challenger .game-hud,
.playfield.is-room-waiting .game-hud,
.playfield.is-versus-result .game-hud {
  visibility: hidden;
  pointer-events: none;
}

.howto-panel,
.completed-panel,
.room-form,
.ranking-form {
  -webkit-user-select: text;
  user-select: text;
  touch-action: pan-y pinch-zoom;
}

.howto-panel,
.completed-list {
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}

/* Compact friend-room walkthrough and native sharing actions. */
.room-steps {
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 4px;
  list-style: none;
}

.room-steps li {
  min-width: 0;
  min-height: 34px;
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr);
  gap: 4px;
  align-items: center;
  padding: 4px;
  border: 1px solid rgba(255, 248, 232, 0.18);
  border-radius: 7px;
  background: rgba(7, 28, 32, 0.52);
  color: #fff9ef;
  font-size: clamp(0.52rem, 2.35vw, 0.64rem);
  font-weight: 850;
  line-height: 1.15;
  text-align: left;
}

.room-steps b {
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--gold);
  color: #172016;
  font-size: 0.6rem;
}

.room-number-actions {
  display: grid;
  grid-template-columns: 1.25fr 0.8fr 0.8fr;
  gap: 5px;
}

.room-number-actions button {
  min-width: 0;
  min-height: 44px;
  padding: 5px 7px;
  border: 1px solid rgba(255, 248, 232, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 232, 0.1);
  color: var(--ink);
  font: inherit;
  font-size: clamp(0.65rem, 2.8vw, 0.74rem);
  font-weight: 900;
  touch-action: manipulation;
}

.room-number-actions .room-generate-button {
  min-height: 44px;
  color: #071c20;
  background: linear-gradient(135deg, var(--gold), #ffb96d);
}

.room-number-actions button:disabled {
  opacity: 0.46;
  cursor: default;
}

.touch-controls[hidden],
.orientation-notice[hidden] {
  display: none;
}

/* Optional, explicit controls for players who prefer buttons to gestures. */
.touch-controls {
  position: absolute;
  left: 6px;
  right: 6px;
  bottom: max(52px, calc(env(safe-area-inset-bottom) + 48px));
  z-index: 8;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 4px;
  padding: 5px;
  border: 1px solid rgba(255, 248, 232, 0.24);
  border-radius: 12px;
  background: rgba(7, 28, 32, 0.82);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(7px);
  touch-action: manipulation;
}

.touch-controls button {
  min-width: 0;
  min-height: 44px;
  padding: 4px;
  border: 1px solid rgba(255, 248, 232, 0.24);
  border-radius: 9px;
  background: rgba(255, 248, 232, 0.12);
  color: #fff9ef;
  font: inherit;
  font-size: 1.1rem;
  font-weight: 950;
}

.touch-controls .touch-hard-drop {
  grid-column: 1 / -1;
  min-height: 40px;
  color: #071c20;
  background: linear-gradient(135deg, var(--gold), #ffb96d);
  font-size: 0.75rem;
}

/* Mobile landscape warning; JS lets players explicitly continue. */
.orientation-notice {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  overflow: auto;
  background: rgba(5, 14, 18, 0.94);
  color: #fff9ef;
  touch-action: pan-y pinch-zoom;
}

.orientation-notice-panel {
  width: min(420px, 100%);
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 8px 14px;
  align-items: center;
  padding: 18px;
  border: 2px solid rgba(46, 232, 208, 0.62);
  border-radius: 16px;
  background: rgba(10, 25, 31, 0.98);
}

.orientation-notice-panel > span {
  grid-row: 1 / 3;
  color: var(--gold);
  font-size: 2.4rem;
}

.orientation-notice-panel strong {
  font-size: 1.05rem;
}

.orientation-notice-panel p {
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
}

.orientation-notice-panel button {
  grid-column: 1 / -1;
  min-height: 44px;
  border: 1px solid rgba(255, 248, 232, 0.28);
  border-radius: 9px;
  background: rgba(255, 248, 232, 0.12);
  color: #fff9ef;
  font: inherit;
  font-weight: 900;
}

/* Comfortable touch targets for the controls used during active play. */
.menu-button,
.opponent-peek-button,
.room-entry input,
.room-entry button,
.ranking-entry input,
.ranking-entry button,
.howto-button,
.completed-button,
.solo-button,
.howto-close,
.completed-close,
.room-wait-cancel,
.versus-result-actions button {
  min-height: 44px;
}

.howto-close,
.completed-close {
  min-width: 44px;
}

.playfield.is-title .howto-panel,
.playfield.is-title .completed-panel {
  bottom: max(228px, calc(env(safe-area-inset-bottom) + 228px));
}

@keyframes reduced-art-fade {
  0% { opacity: 0; transform: none; }
  20%, 72% { opacity: 0.78; transform: none; }
  100% { opacity: 0; transform: none; }
}

@media (prefers-reduced-motion: reduce) {
  .clear-art.is-showing,
  .clear-art[data-clear-mode="pumaru-spin"].is-showing .pumaru-spin-bg,
  .clear-art[data-clear-mode="pumaru-spin"].is-showing .pumaru-spin-dog,
  .clear-art[data-clear-mode="pumaru-spin"].is-showing::before,
  .clear-art[data-clear-mode="pumaru-spin"].is-showing::after {
    animation: reduced-art-fade 650ms ease-out both !important;
    transform: none !important;
  }

  .playfield.is-clearing::after,
  .playfield.is-clear-big::after,
  .playfield.is-pumaru-spin::after,
  .skill-sidebar.is-ready .skill-gauge,
  .skill-sidebar.is-ready .skill-gauge::after,
  .skill-sidebar.is-ready .skill-gauge-fill,
  .skill-sidebar.is-ready span,
  .skill-panel.is-acquired,
  .skill-panel.is-acquired::after,
  .skill-panel.is-evolved,
  .skill-panel.is-evolved::after,
  .skill-sidebar.is-acquired .skill-gauge,
  .skill-sidebar.is-evolved .skill-gauge,
  .ending-petal,
  .ending-blossom {
    animation: none !important;
  }

  .ending-flower-shower {
    display: none !important;
  }
}

@media (orientation: landscape) and (max-height: 520px) {
  .playfield {
    border-radius: 0;
  }
}
