/* =========================================================
   崽崽數字探索 — a soft, playful number adventure
   ========================================================= */

@font-face {
  font-family: "Baloo 2";
  src: url("assets/baloo2-latin.woff2") format("woff2");
  font-weight: 500 800;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Nunito";
  src: url("assets/nunito-latin.woff2") format("woff2");
  font-weight: 600 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #3d2f49;
  --ink-soft: #735f7d;
  --ink-mute: #9b85a1;
  --paper: #fffdfb;
  --cream: #fff7ef;
  --pink: #ff6f9e;
  --pink-deep: #e62d72;
  --pink-soft: #ffd9e7;
  --pink-pale: #fff0f6;
  --yellow: #ffce4d;
  --yellow-soft: #fff0b8;
  --mint: #5ee0b0;
  --mint-soft: #dcfaee;
  --mint-deep: #0f9468;
  --lilac: #a98bff;
  --lilac-soft: #ece5ff;
  --lilac-deep: #6642f5;
  --blue: #55c7fa;
  --blue-soft: #def5ff;
  --line: #f0dee7;
  --shadow-ink: rgba(61, 47, 73, 0.15);
  --font-round: "Nunito", "Arial Rounded MT Bold", "Hiragino Maru Gothic ProN",
    "PingFang TC", "Microsoft JhengHei", sans-serif;
  --font-display: "Baloo 2", "Nunito", "Arial Rounded MT Bold",
    "Hiragino Maru Gothic ProN", "PingFang TC", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: var(--font-round);
  font-weight: 700;
  background-color: var(--cream);
  background-image:
    radial-gradient(circle at 7% 17%, rgba(255, 111, 158, 0.42), transparent 26%),
    radial-gradient(circle at 93% 8%, rgba(169, 139, 255, 0.42), transparent 28%),
    radial-gradient(circle at 82% 88%, rgba(94, 224, 176, 0.34), transparent 29%),
    radial-gradient(circle at 18% 82%, rgba(255, 206, 77, 0.22), transparent 22%),
    linear-gradient(180deg, #fff9f0 0%, #fff1f5 56%, #f3fff9 100%);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0.32;
  background-image: radial-gradient(#e9bfd0 0.9px, transparent 1px);
  background-size: 22px 22px;
  mask-image: linear-gradient(to bottom, black, transparent 78%);
}

button {
  font: inherit;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

button:focus-visible {
  outline: 2.5px solid var(--ink);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

body.modal-open {
  overflow: hidden;
}

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

.icon {
  width: 20px;
  height: 20px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.1;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ---------- Background scenery ---------- */

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

.sun-glow {
  position: absolute;
  top: -180px;
  right: -140px;
  width: 640px;
  height: 640px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 218, 105, 0.68), rgba(255, 218, 105, 0) 68%);
  filter: blur(4px);
}

.cloud {
  position: absolute;
  height: 40px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.82);
  filter: blur(0.4px);
  box-shadow: 0 12px 24px rgba(209, 166, 189, 0.1);
  animation: cloud-float 11s ease-in-out infinite;
}

.cloud::before,
.cloud::after {
  content: "";
  position: absolute;
  border-radius: 50%;
  background: inherit;
}

.cloud::before {
  width: 55%;
  height: 130%;
  left: 12%;
  bottom: 26%;
}

.cloud::after {
  width: 43%;
  height: 110%;
  right: 10%;
  bottom: 32%;
}

.cloud--one {
  top: 14%;
  left: -28px;
  width: 150px;
  opacity: 0.72;
}

.cloud--two {
  top: 30%;
  right: -34px;
  width: 185px;
  opacity: 0.55;
  animation-delay: -4s;
}

.cloud--three {
  bottom: 13%;
  left: 5%;
  width: 115px;
  opacity: 0.45;
  animation-delay: -7s;
}

.sparkle {
  position: absolute;
  color: #ffb1c2;
  font-family: var(--font-display);
  animation: twinkle 4.4s ease-in-out infinite;
  text-shadow: 0 3px 8px rgba(255, 143, 165, 0.25);
}

.sparkle--one {
  top: 13%;
  left: 13%;
  font-size: 26px;
}

.sparkle--two {
  top: 44%;
  right: 9%;
  font-size: 33px;
  color: #c4b1ff;
  animation-delay: -1.3s;
}

.sparkle--three {
  bottom: 26%;
  left: 7%;
  font-size: 20px;
  color: #ffd26a;
  animation-delay: -2.4s;
}

.sparkle--four {
  top: 8%;
  right: 25%;
  font-size: 18px;
  color: #8edebc;
  animation-delay: -0.8s;
}

.float-flower {
  position: absolute;
  color: rgba(255, 157, 180, 0.5);
  font-size: 48px;
  animation: sway 8s ease-in-out infinite;
}

.float-flower--one {
  bottom: 18%;
  right: 4%;
}

.float-flower--two {
  top: 26%;
  left: 3%;
  font-size: 32px;
  color: rgba(179, 157, 244, 0.46);
  animation-delay: -3s;
}

.hill {
  position: absolute;
  left: -15%;
  width: 130%;
  border-radius: 50% 50% 0 0 / 100% 100% 0 0;
}

.hill--back {
  bottom: -128px;
  height: 245px;
  background: rgba(94, 224, 176, 0.28);
  transform: rotate(-2deg);
}

.hill--front {
  bottom: -176px;
  height: 265px;
  background: rgba(255, 111, 158, 0.19);
  transform: rotate(2deg);
}

/* ---------- Page frame ---------- */

.page {
  position: relative;
  z-index: 2;
  width: min(100%, 1000px);
  margin: 0 auto;
  padding: 18px 24px 22px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 60px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 13px;
  min-width: 0;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 57px;
  height: 57px;
  flex: none;
  border: 2.5px solid var(--ink);
  border-radius: 19px;
  background: linear-gradient(145deg, #ffd2e0, #ff9dbb);
  box-shadow:
    0 5px 0 rgba(74, 58, 79, 0.16),
    inset 0 3px 0 rgba(255, 255, 255, 0.55);
  transform: rotate(-3deg);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  gap: 0;
  line-height: 1;
}

.brand-eyebrow {
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.22em;
  color: var(--pink-deep);
  margin-bottom: 3px;
}

.brand-title {
  font-family: var(--font-display);
  font-size: 31px;
  font-weight: 800;
  letter-spacing: 0.01em;
  color: var(--ink);
  line-height: 1;
  white-space: nowrap;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 47px;
  height: 47px;
  flex: none;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 15px;
  background: rgba(255, 253, 251, 0.9);
  box-shadow: 0 4px 0 rgba(74, 58, 79, 0.13);
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(74, 58, 79, 0.13);
  background: #fff;
}

.icon-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(74, 58, 79, 0.13);
}

.icon-btn .icon {
  width: 21px;
  height: 21px;
}

.sound-btn.is-muted {
  color: var(--ink-mute);
  background: #f8eff4;
}

.primary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 47px;
  padding: 0 20px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  color: var(--ink);
  background: linear-gradient(180deg, #ff9fba, #ff6f9e);
  box-shadow: 0 5px 0 #d92e6b, inset 0 2px 0 rgba(255, 255, 255, 0.46);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.primary-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.025);
  box-shadow: 0 7px 0 #d92e6b, inset 0 2px 0 rgba(255, 255, 255, 0.46);
}

.primary-btn:active {
  transform: translateY(3px);
  box-shadow: 0 2px 0 #d92e6b;
}

.new-game-btn {
  padding-inline: 18px;
}

.new-game-btn .icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.6;
}

.secondary-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 46px;
  padding: 0 18px;
  border: 2px solid var(--ink);
  border-radius: 16px;
  background: #fffdfb;
  box-shadow: 0 4px 0 rgba(74, 58, 79, 0.13);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.16s ease, background 0.16s ease, box-shadow 0.16s ease;
}

.secondary-btn:hover {
  transform: translateY(-2px);
  background: #fff5f7;
}

.secondary-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(74, 58, 79, 0.13);
}

/* ---------- Main layout ---------- */

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
  max-width: 932px;
  margin: 14px auto 0;
}

.game-card {
  min-width: 0;
  padding: 17px 18px 16px;
  border: 2.5px solid var(--ink);
  border-radius: 34px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.9), rgba(255, 250, 252, 0.97)),
    var(--paper);
  box-shadow:
    0 9px 0 rgba(74, 58, 79, 0.1),
    0 28px 55px rgba(181, 133, 156, 0.16);
}

.game-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 2px 11px;
}

.game-title-group {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
}

.eyebrow {
  display: block;
  font-family: var(--font-display);
  font-size: 9.5px;
  font-weight: 800;
  letter-spacing: 0.2em;
  color: var(--pink-deep);
  text-transform: uppercase;
}

.level-pill {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  width: fit-content;
  padding: 4px 9px 4px 7px;
  border: 1.5px solid #4ad2a1;
  border-radius: 999px;
  color: #087d58;
  background: var(--mint-soft);
  font-size: 11px;
  line-height: 1;
  white-space: nowrap;
}

.level-pill .icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.2;
}

.level-pill strong {
  font-size: 12px;
  font-weight: 900;
}

.level-pill span:last-child {
  color: #3a9b74;
  font-size: 9.5px;
  font-weight: 800;
}

.level-pill[data-level="medium"] {
  border-color: #e8cc82;
  color: #88651f;
  background: var(--yellow-soft);
}

.level-pill[data-level="medium"] span:last-child {
  color: #a98c4b;
}

.level-pill[data-level="hard"] {
  border-color: #c9b9f2;
  color: #6b53bf;
  background: var(--lilac-soft);
}

.level-pill[data-level="hard"] span:last-child {
  color: #9180c9;
}

.head-stats {
  display: flex;
  align-items: center;
  gap: 6px;
}

.stat-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  height: 35px;
  padding: 0 10px;
  border: 1.5px solid rgba(74, 58, 79, 0.16);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 2.5px 0 rgba(74, 58, 79, 0.07);
  white-space: nowrap;
}

.stat-chip .icon {
  width: 15px;
  height: 15px;
  color: var(--ink-soft);
}

.time-chip span {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.heart-chip {
  padding-inline: 8px;
}

.hearts {
  display: flex;
  align-items: center;
  gap: 1px;
}

.heart-slot {
  display: grid;
  place-items: center;
  width: 15px;
  height: 15px;
}

.heart-slot svg {
  width: 15px;
  height: 15px;
  fill: var(--pink);
  stroke: var(--ink);
  stroke-width: 1.6;
  transition: fill 0.25s ease, opacity 0.25s ease, transform 0.25s ease;
}

.heart-slot.is-lost svg {
  fill: #eee3e9;
  stroke: #cbbac3;
  opacity: 0.65;
  transform: scale(0.84);
}

.heart-slot.just-lost svg {
  animation: heart-break 0.4s ease;
}

.pause-btn {
  width: 35px;
  height: 35px;
  border-width: 1.5px;
  border-radius: 12px;
  box-shadow: 0 2.5px 0 rgba(74, 58, 79, 0.09);
}

.pause-btn .icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.4;
}

/* ---------- Sudoku board ---------- */

.board-shell {
  position: relative;
  width: min(100%, 500px);
  margin: 0 auto;
  padding: 7px;
  border: 2px solid var(--ink);
  border-radius: 24px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.6), transparent 40%),
    #f8e3ee;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.82),
    0 5px 0 rgba(74, 58, 79, 0.1);
}

.board-glow {
  position: absolute;
  inset: 12px;
  border-radius: 18px;
  background: radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.95), transparent 58%);
  pointer-events: none;
}

.sudoku-board {
  position: relative;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  width: 100%;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1.5px solid #64506b;
  border-radius: 16px;
  background: var(--paper);
  box-shadow:
    0 2px 0 rgba(255, 255, 255, 0.9) inset,
    0 4px 12px rgba(74, 58, 79, 0.07);
  touch-action: manipulation;
}

.sudoku-board:focus {
  outline: none;
}

.sudoku-board:focus-visible {
  outline: none;
}

.game-card.is-paused .keypad,
.game-card.is-paused .toolbar,
.keypad.is-locked {
  opacity: 0.45;
  pointer-events: none;
}

.cell {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  border-right: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  color: var(--ink);
  background: #fffdfb;
  font-family: var(--font-display);
  font-size: clamp(18px, 2.4vw, 30px);
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  user-select: none;
  -webkit-user-select: none;
  transition: background-color 0.14s ease, color 0.14s ease;
}

.cell.block-alt {
  background: #fff5fa;
}

.cell:nth-child(9n) {
  border-right: 0;
}

.cell:nth-child(9n + 3),
.cell:nth-child(9n + 6) {
  border-right: 2px solid #78627f;
}

.cell:nth-child(n + 19):nth-child(-n + 27),
.cell:nth-child(n + 46):nth-child(-n + 54) {
  border-bottom: 2px solid #78627f;
}

.cell:nth-child(n + 73) {
  border-bottom: 0;
}

.cell:hover {
  background: #fff1c8;
}

.cell.is-peer {
  background: #fff0b8;
}

.cell.is-same {
  background: #ffdce9;
  color: var(--pink-deep);
}

.cell.is-selected {
  background: #ffd45f;
  color: var(--ink);
  box-shadow: inset 0 0 0 3px var(--ink);
  z-index: 2;
}

.cell.is-given {
  color: #4c3b55;
  font-weight: 800;
}

.cell.is-user {
  color: #6242e8;
  font-weight: 700;
}

.cell.is-wrong {
  color: #e21f63;
}

.cell.is-wrong::before {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 6px;
  background: #ffe0e8;
  z-index: 0;
}

.cell.is-wrong .cell-value,
.cell.is-wrong .cell-notes {
  position: relative;
  z-index: 1;
}

.cell.is-hinted {
  animation: hint-glow 0.9s ease 2;
}

.cell-value {
  position: relative;
  z-index: 1;
  display: block;
  transform-origin: center;
  pointer-events: none;
}

.cell.just-placed .cell-value {
  animation: number-pop 0.28s cubic-bezier(0.2, 1.5, 0.5, 1);
}

.cell.is-shaking {
  animation: cell-shake 0.38s ease;
}

.cell-notes {
  position: absolute;
  inset: 4px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  color: #927c9d;
  font-family: var(--font-round);
  font-size: clamp(6.5px, 0.72vw, 9.5px);
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
  z-index: 1;
}

.cell-notes span {
  display: block;
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 0.12s ease, transform 0.12s ease;
}

.cell-notes span.is-on {
  opacity: 1;
  transform: scale(1);
}

.cell.is-same .cell-notes,
.cell.is-selected .cell-notes {
  color: #8e718b;
}

/* ---------- Pause overlay ---------- */

.board-overlay {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 22px;
  background: rgba(255, 248, 242, 0.55);
  -webkit-backdrop-filter: blur(9px) saturate(0.9);
  backdrop-filter: blur(9px) saturate(0.9);
  animation: fade-in 0.2s ease;
}

.pause-card {
  width: min(100%, 265px);
  padding: 24px 22px 22px;
  border: 2.5px solid var(--ink);
  border-radius: 26px;
  text-align: center;
  background: var(--paper);
  box-shadow: 0 9px 0 rgba(74, 58, 79, 0.14);
}

.pause-emoji {
  display: block;
  margin-bottom: 5px;
  font-size: 43px;
  line-height: 1;
  filter: drop-shadow(0 5px 4px rgba(122, 85, 103, 0.12));
}

.pause-card h2 {
  margin: 6px 0 7px;
  font-size: 22px;
  font-weight: 900;
  letter-spacing: 0.02em;
}

.pause-card p {
  margin: 0 0 17px;
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.65;
}

.pause-card .primary-btn {
  width: 100%;
  min-height: 44px;
}

/* ---------- Keypad ---------- */

.keypad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 7px;
  width: min(100%, 500px);
  margin: 12px auto 0;
}

.key {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 52px;
  padding: 0;
  border: 2px solid var(--ink);
  border-radius: 15px;
  color: var(--ink);
  background: #fffdfb;
  box-shadow:
    0 4px 0 #d9cbd6,
    inset 0 2px 0 rgba(255, 255, 255, 0.9);
  font-family: var(--font-display);
  font-size: 25px;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.12s ease, background 0.12s ease;
}

.key:hover {
  background: #fff7e2;
  transform: translateY(-2px);
  box-shadow:
    0 6px 0 #d9cbd6,
    inset 0 2px 0 rgba(255, 255, 255, 0.9);
}

.key:active {
  transform: translateY(2px);
  box-shadow:
    0 2px 0 #d9cbd6,
    inset 0 2px 0 rgba(255, 255, 255, 0.9);
}

.key-count {
  position: absolute;
  top: -5px;
  right: -3px;
  display: grid;
  place-items: center;
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  border: 1.5px solid #e78ba0;
  border-radius: 99px;
  background: #ffe8ed;
  color: #cc4966;
  font-family: var(--font-round);
  font-size: 8px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 1px 0 rgba(74, 58, 79, 0.08);
}

.key.is-complete {
  color: #c6b6c4;
  border-color: #d8c9d3;
  background: #f8f1f5;
  box-shadow: 0 2px 0 #e8dde4;
  cursor: default;
  pointer-events: none;
}

.key.is-complete .key-count {
  color: #8cbc9f;
  border-color: #b5dfc9;
  background: #e9f9f0;
}

/* ---------- Toolbar ---------- */

.toolbar {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  width: min(100%, 500px);
  margin: 10px auto 0;
}

.tool {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-width: 0;
  height: 49px;
  padding: 0 8px;
  border: 1.8px solid rgba(74, 58, 79, 0.22);
  border-radius: 15px;
  background: #faf3f7;
  box-shadow: 0 3px 0 rgba(74, 58, 79, 0.08);
  font-size: 12px;
  font-weight: 900;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease,
    box-shadow 0.14s ease;
}

.tool:hover:not(:disabled) {
  border-color: var(--ink);
  background: #fff;
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(74, 58, 79, 0.08);
}

.tool:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(74, 58, 79, 0.08);
}

.tool:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  box-shadow: 0 2px 0 rgba(74, 58, 79, 0.05);
}

.tool-icon {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  flex: none;
  border-radius: 9px;
}

.tool-icon .icon {
  width: 15px;
  height: 15px;
  stroke-width: 2.1;
}

.tool-icon--lilac {
  background: var(--lilac-soft);
  color: #6d56cf;
}

.tool-icon--peach {
  background: #fff0e6;
  color: #be6c4a;
}

.tool-icon--mint {
  background: var(--mint-soft);
  color: #458967;
}

.tool-icon--butter {
  background: var(--yellow-soft);
  color: #a77913;
}

.tool-status {
  position: absolute;
  top: 5px;
  right: 6px;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  transition: background 0.15s ease;
}

.tool.is-active {
  border-color: var(--ink);
  background: var(--mint-soft);
  box-shadow: 0 3px 0 #4bca9d;
}

.tool.is-active .tool-status {
  background: #57b88b;
}

.tool.is-active .tool-icon {
  background: #cdf1df;
}

.tool-badge {
  position: absolute;
  top: -6px;
  right: -5px;
  display: grid;
  place-items: center;
  min-width: 19px;
  height: 19px;
  padding: 0 4px;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  background: var(--yellow);
  font-family: var(--font-round);
  font-size: 9px;
  font-weight: 900;
  line-height: 1;
  box-shadow: 0 1.5px 0 rgba(74, 58, 79, 0.14);
}

.tool-badge.is-empty {
  background: #eee4ea;
  color: var(--ink-mute);
  border-color: #c7b8c2;
}

/* ---------- Sidebar ---------- */

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-width: 0;
}

.mascot-card {
  position: relative;
  overflow: hidden;
  padding: 14px 14px 10px;
  border: 2.5px solid var(--ink);
  border-radius: 28px;
  background:
    radial-gradient(circle at 80% 12%, rgba(255, 255, 255, 0.94), transparent 33%),
    linear-gradient(155deg, #ffe6ef 0%, #ede4ff 58%, #dcfff0 100%);
  box-shadow: 0 7px 0 rgba(74, 58, 79, 0.09);
  isolation: isolate;
}

.card-doodle {
  position: absolute;
  color: rgba(215, 116, 148, 0.25);
  font-family: var(--font-display);
  font-size: 30px;
  z-index: 0;
  pointer-events: none;
}

.card-doodle--one {
  right: 15px;
  top: 12px;
  transform: rotate(12deg);
}

.card-doodle--two {
  left: 14px;
  bottom: 13px;
  color: rgba(135, 111, 205, 0.23);
  font-size: 23px;
}

.speech-bubble {
  position: relative;
  z-index: 2;
  min-height: 58px;
  padding: 10px 13px;
  border: 2px solid var(--ink);
  border-radius: 17px 17px 17px 5px;
  background: rgba(255, 253, 251, 0.94);
  box-shadow: 0 3px 0 rgba(74, 58, 79, 0.08);
  color: #655367;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.58;
  text-align: center;
}

.speech-bubble.is-bouncing {
  animation: bubble-bounce 0.38s ease;
}

.mascot-stage {
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  height: 152px;
  margin-top: 1px;
  z-index: 1;
}

.mascot-cloud {
  position: absolute;
  bottom: 9px;
  left: 50%;
  width: 188px;
  height: 93px;
  border-radius: 50%;
  transform: translateX(-50%);
  background: radial-gradient(ellipse, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0) 70%);
}

.mascot {
  position: relative;
  width: 188px;
  height: auto;
  display: block;
  filter: drop-shadow(0 7px 5px rgba(151, 111, 135, 0.13));
  animation: mascot-bob 4.5s ease-in-out infinite;
  transform-origin: 50% 88%;
}

.mascot-name {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 7px;
  margin-top: -5px;
  padding-bottom: 2px;
}

.mascot-name strong {
  font-size: 17px;
  font-weight: 900;
  letter-spacing: 0.06em;
}

.mascot-name span {
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.stats-card,
.progress-card {
  padding: 14px 15px 15px;
  border: 2px solid var(--ink);
  border-radius: 24px;
  background: rgba(255, 253, 251, 0.93);
  box-shadow: 0 5px 0 rgba(74, 58, 79, 0.08);
}

.side-card-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.side-card-heading h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.side-card-heading > span {
  color: var(--pink);
  font-size: 18px;
  line-height: 1;
}

.side-card-heading > strong {
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.03em;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
}

.mini-stat {
  display: grid;
  grid-template-columns: 25px 1fr;
  grid-template-rows: auto auto;
  column-gap: 7px;
  align-items: center;
  min-width: 0;
  padding: 8px 8px 7px;
  border-radius: 13px;
  background: #fbf5f8;
}

.mini-stat-icon {
  display: grid;
  place-items: center;
  grid-row: 1 / span 2;
  width: 25px;
  height: 25px;
  border-radius: 8px;
}

.mini-stat-icon .icon {
  width: 13px;
  height: 13px;
  stroke-width: 2.2;
}

.mini-stat-icon--blue {
  background: var(--blue-soft);
  color: #4a95b2;
}

.mini-stat-icon--pink {
  background: var(--pink-soft);
  color: var(--pink-deep);
}

.mini-stat-icon--butter {
  background: var(--yellow-soft);
  color: #a77b19;
}

.mini-stat-icon--mint {
  background: var(--mint-soft);
  color: var(--mint-deep);
}

.mini-stat-label {
  overflow: hidden;
  color: var(--ink-mute);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-stat strong {
  overflow: hidden;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.15;
  letter-spacing: 0.02em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.progress-card {
  background:
    linear-gradient(140deg, rgba(255, 255, 255, 0.8), transparent 52%),
    #fffdfb;
}

.progress-track {
  position: relative;
  height: 11px;
  margin: 13px 2px 16px;
  border: 1.5px solid rgba(74, 58, 79, 0.17);
  border-radius: 99px;
  background: #f2e8ee;
  box-shadow: inset 0 1px 2px rgba(74, 58, 79, 0.06);
}

.progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6f9e 0%, #ffce4d 52%, #5ee0b0 100%);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.55) inset;
  transition: width 0.45s cubic-bezier(0.22, 1, 0.36, 1);
}

.progress-marker {
  position: absolute;
  top: 50%;
  left: 0%;
  font-size: 16px;
  line-height: 1;
  transform: translate(-45%, -52%);
  transition: left 0.45s cubic-bezier(0.22, 1, 0.36, 1);
  filter: drop-shadow(0 2px 1px rgba(177, 93, 110, 0.2));
  pointer-events: none;
}

.progress-note {
  margin: 0;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 700;
  line-height: 1.55;
}

.tip-card {
  padding: 13px 14px;
  border: 1.8px dashed #dfbc6c;
  border-radius: 20px;
  background: rgba(255, 246, 214, 0.75);
  color: #7c6638;
}

.tip-badge {
  display: inline-block;
  margin-bottom: 5px;
  padding: 2px 6px;
  border-radius: 6px;
  background: #ffe49a;
  color: #8c6812;
  font-family: var(--font-display);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.tip-card p {
  margin: 0 0 7px;
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.55;
}

.tip-keys {
  display: block;
  color: #a18b5a;
  font-size: 9px;
  font-weight: 800;
  line-height: 1.7;
}

kbd {
  display: inline-grid;
  place-items: center;
  min-width: 17px;
  height: 17px;
  margin: 0 1px;
  padding: 0 4px;
  border: 1px solid #d8bd82;
  border-bottom-width: 2px;
  border-radius: 5px;
  background: #fffdf4;
  color: #80652b;
  font-family: var(--font-round);
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1;
  vertical-align: 1px;
}

.page-footer {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  padding: 17px 0 2px;
  color: #a28ca0;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.11em;
}

.footer-heart {
  color: var(--pink);
  font-size: 14px;
  line-height: 1;
}

/* ---------- Modals ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(63, 47, 68, 0.42);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  animation: fade-in 0.2s ease;
}

.modal {
  position: relative;
  width: min(100%, 430px);
  max-height: min(90vh, 760px);
  overflow: auto;
  padding: 28px 26px 22px;
  border: 2.5px solid var(--ink);
  border-radius: 31px;
  background:
    radial-gradient(circle at 90% 0%, rgba(255, 195, 150, 0.46), transparent 31%),
    radial-gradient(circle at 4% 100%, rgba(169, 139, 255, 0.16), transparent 35%),
    var(--paper);
  box-shadow:
    0 14px 0 rgba(40, 27, 45, 0.2),
    0 36px 80px rgba(40, 27, 45, 0.28);
  text-align: center;
  animation: modal-in 0.3s cubic-bezier(0.2, 1.25, 0.35, 1);
  scrollbar-width: thin;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 1.5px solid rgba(74, 58, 79, 0.18);
  border-radius: 11px;
  background: rgba(255, 255, 255, 0.8);
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s ease, transform 0.15s ease;
}

.modal-close:hover {
  background: var(--pink-soft);
  transform: rotate(5deg);
}

.modal-close .icon {
  width: 16px;
  height: 16px;
}

.modal .eyebrow {
  margin-bottom: 5px;
}

.modal h2 {
  margin: 3px 0 7px;
  color: var(--ink);
  font-size: 23px;
  font-weight: 900;
  letter-spacing: 0.01em;
  line-height: 1.35;
}

.modal-sub {
  margin: 0 auto 17px;
  max-width: 310px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.65;
}

.difficulty-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
  margin-bottom: 15px;
}

.difficulty-option {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  border: 1.8px solid rgba(74, 58, 79, 0.16);
  border-radius: 17px;
  background: #fffdfb;
  box-shadow: 0 3px 0 rgba(74, 58, 79, 0.07);
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.difficulty-option:hover {
  border-color: var(--ink);
  transform: translateY(-2px);
  box-shadow: 0 5px 0 rgba(74, 58, 79, 0.09);
}

.difficulty-option:active {
  transform: translateY(1px);
  box-shadow: 0 2px 0 rgba(74, 58, 79, 0.07);
}

.difficulty-emoji {
  display: grid;
  place-items: center;
  width: 45px;
  height: 45px;
  flex: none;
  border-radius: 14px;
  font-size: 23px;
  line-height: 1;
}

.difficulty-emoji--mint {
  background: var(--mint-soft);
}

.difficulty-emoji--butter {
  background: var(--yellow-soft);
}

.difficulty-emoji--lilac {
  background: var(--lilac-soft);
}

.difficulty-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.difficulty-copy strong {
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.difficulty-copy strong small {
  margin-left: 4px;
  color: var(--ink-mute);
  font-size: 8.5px;
  font-weight: 800;
}

.difficulty-copy > span {
  color: var(--ink-mute);
  font-size: 9px;
  font-weight: 700;
}

.difficulty-arrow {
  width: 16px;
  height: 16px;
  margin-left: auto;
  color: var(--pink-deep);
}

.text-btn {
  padding: 6px 10px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-mute);
  font-size: 10.5px;
  font-weight: 800;
  cursor: pointer;
  transition: color 0.15s ease, background 0.15s ease;
}

.text-btn:hover {
  background: var(--pink-pale);
  color: var(--pink-deep);
}

/* Confetti */
.confetti {
  position: absolute;
  inset: 0;
  overflow: hidden;
  border-radius: inherit;
  pointer-events: none;
}

.confetti i {
  position: absolute;
  top: -14px;
  left: var(--left);
  width: var(--size);
  height: calc(var(--size) * 0.55);
  border-radius: 2px;
  background: var(--color);
  opacity: 0.9;
  transform: rotate(var(--rotate));
  animation: confetti-fall var(--duration) linear var(--delay) infinite;
}

.win-modal,
.gameover-modal {
  overflow: hidden;
}

.win-medal {
  position: relative;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin: 2px auto 11px;
  border: 2.5px solid var(--ink);
  border-radius: 27px;
  background: linear-gradient(145deg, #ffe68b, #ffc72e);
  box-shadow:
    0 6px 0 rgba(74, 58, 79, 0.15),
    inset 0 3px 0 rgba(255, 255, 255, 0.62);
  transform: rotate(-4deg);
}



.win-medal-flower {
  position: absolute;
  top: -8px;
  right: -8px;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: #ff9eb2;
  color: #fff8ef;
  font-size: 15px;
  line-height: 1;
  transform: rotate(14deg);
}

.win-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
  margin: 15px 0 17px;
  padding: 11px 8px;
  border-radius: 18px;
  background: #faf2f6;
}

.win-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px 2px;
  border-right: 1px solid #eadde4;
}

.win-stats div:last-child {
  border-right: 0;
}

.win-stats span {
  color: var(--ink-mute);
  font-size: 8.5px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.win-stats strong {
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 700;
  color: var(--ink);
}

.modal-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.modal-actions .primary-btn,
.modal-actions .secondary-btn {
  min-height: 46px;
  padding-inline: 10px;
  font-size: 12.5px;
}

.gameover-face {
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin: 2px auto 10px;
  border: 2.5px solid var(--ink);
  border-radius: 26px;
  background: var(--lilac-soft);
  box-shadow: 0 6px 0 rgba(74, 58, 79, 0.12);
  font-size: 39px;
  line-height: 1;
  transform: rotate(3deg);
}

.gameover-modal .modal-sub {
  margin-bottom: 20px;
}

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  z-index: 80;
  max-width: min(92vw, 360px);
  padding: 10px 17px;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: var(--ink);
  color: #fff9f3;
  box-shadow: 0 5px 0 rgba(40, 27, 45, 0.22);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px) scale(0.96);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

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

/* ---------- Motion ---------- */

@keyframes cloud-float {
  0%,
  100% {
    transform: translate3d(0, 0, 0);
  }
  50% {
    transform: translate3d(10px, -9px, 0);
  }
}

@keyframes twinkle {
  0%,
  100% {
    opacity: 0.45;
    transform: scale(0.85) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1.1) rotate(10deg);
  }
}

@keyframes sway {
  0%,
  100% {
    transform: rotate(-5deg) translateY(0);
  }
  50% {
    transform: rotate(7deg) translateY(-8px);
  }
}

@keyframes mascot-bob {
  0%,
  100% {
    transform: translateY(0) rotate(-1deg);
  }
  50% {
    transform: translateY(-4px) rotate(1deg);
  }
}

@keyframes bubble-bounce {
  0% {
    transform: scale(1);
  }
  45% {
    transform: scale(1.045) rotate(-0.6deg);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes number-pop {
  0% {
    transform: scale(0.7);
    opacity: 0.5;
  }
  60% {
    transform: scale(1.16);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes cell-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  18% {
    transform: translateX(-3px);
  }
  36% {
    transform: translateX(3px);
  }
  54% {
    transform: translateX(-2px);
  }
  72% {
    transform: translateX(2px);
  }
}

@keyframes hint-glow {
  0%,
  100% {
    box-shadow: inset 0 0 0 0 rgba(87, 184, 139, 0);
  }
  40% {
    box-shadow: inset 0 0 0 3px #57b88b;
    background: #dcf7ea;
  }
}

@keyframes heart-break {
  0% {
    transform: scale(1);
  }
  40% {
    transform: scale(1.3) rotate(-10deg);
  }
  100% {
    transform: scale(0.84) rotate(0);
  }
}

@keyframes modal-in {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.96);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

@keyframes confetti-fall {
  0% {
    opacity: 0;
    transform: translateY(-20px) rotate(var(--rotate));
  }
  10% {
    opacity: 1;
  }
  100% {
    opacity: 0.9;
    transform: translateY(430px) rotate(calc(var(--rotate) + 240deg));
  }
}

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

@media (max-width: 980px) {
  .page {
    padding-inline: 20px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr) 305px;
    gap: 16px;
  }

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

  .mascot {
    width: 176px;
  }

  .mascot-stage {
    height: 145px;
  }
}

@media (max-width: 860px) {
  .page {
    max-width: 640px;
    padding: 14px 16px 22px;
  }

  .layout {
    grid-template-columns: minmax(0, 1fr);
    max-width: 540px;
    margin-top: 12px;
  }

  .game-card {
    border-radius: 30px;
  }

  .sidebar {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
  }

  .mascot-card {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 150px;
    grid-template-rows: auto auto;
    align-items: center;
    column-gap: 4px;
    padding: 15px;
    min-height: 178px;
  }

  .speech-bubble {
    grid-column: 1;
    grid-row: 1;
    align-self: end;
    margin-right: 0;
    text-align: left;
  }

  .mascot-stage {
    grid-column: 2;
    grid-row: 1 / span 2;
    height: 150px;
    margin-top: 0;
  }

  .mascot {
    width: 158px;
  }

  .mascot-cloud {
    width: 160px;
  }

  .mascot-name {
    grid-column: 1;
    grid-row: 2;
    justify-content: flex-start;
    align-self: start;
    padding-left: 11px;
    margin-top: 8px;
  }

  .stats-card,
  .progress-card,
  .tip-card {
    grid-column: 1 / -1;
  }

  .stats-card,
  .progress-card {
    padding: 13px 14px;
  }

  .tip-card {
    display: none;
  }

  .page-footer {
    padding-top: 15px;
  }
}

@media (max-width: 620px) {
  .page {
    padding: 10px 10px 18px;
  }

  .topbar {
    min-height: 52px;
    gap: 8px;
  }

  .brand {
    gap: 9px;
  }

  .brand-mark {
    width: 47px;
    height: 47px;
    border-radius: 15px;
  }

  .brand-eyebrow {
    font-size: 8.5px;
    letter-spacing: 0.13em;
  }

  .brand-title {
    font-size: 23px;
  }

  .topbar-actions {
    gap: 6px;
  }

  .icon-btn {
    width: 39px;
    height: 39px;
    border-radius: 12px;
    box-shadow: 0 3px 0 rgba(74, 58, 79, 0.13);
  }

  .icon-btn .icon {
    width: 18px;
    height: 18px;
  }

  .primary-btn {
    min-height: 39px;
    border-radius: 13px;
    font-size: 12px;
  }

  .new-game-btn {
    padding-inline: 12px;
  }

  .new-game-btn .icon {
    width: 14px;
    height: 14px;
  }

  .layout {
    margin-top: 10px;
  }

  .game-card {
    padding: 12px 10px 12px;
    border-radius: 25px;
    box-shadow:
      0 6px 0 rgba(74, 58, 79, 0.1),
      0 20px 40px rgba(181, 133, 156, 0.13);
  }

  .game-head {
    padding: 0 3px 9px;
    gap: 6px;
  }

  .game-title-group {
    gap: 2px;
  }

  .eyebrow {
    font-size: 8px;
    letter-spacing: 0.14em;
  }

  .level-pill {
    padding: 4px 8px 4px 6px;
    font-size: 10px;
  }

  .level-pill strong {
    font-size: 11px;
  }

  .level-pill span:last-child {
    font-size: 8.5px;
  }

  .head-stats {
    gap: 4px;
  }

  .stat-chip {
    height: 32px;
    padding: 0 7px;
    border-radius: 10px;
  }

  .stat-chip .icon {
    width: 13px;
    height: 13px;
  }

  .time-chip span {
    font-size: 14px;
  }

  .heart-slot,
  .heart-slot svg {
    width: 13px;
    height: 13px;
  }

  .heart-chip {
    padding-inline: 6px;
  }

  .pause-btn {
    width: 32px;
    height: 32px;
    border-radius: 10px;
  }

  .pause-btn .icon {
    width: 14px;
    height: 14px;
  }

  .board-shell {
    padding: 5px;
    border-radius: 18px;
  }

  .sudoku-board {
    border-radius: 13px;
  }

  .cell {
    font-size: clamp(16px, 6.2vw, 28px);
  }

  .cell-notes {
    inset: 2px;
    font-size: clamp(5.5px, 1.6vw, 8px);
  }

  .keypad {
    gap: 4px;
    margin-top: 9px;
  }

  .key {
    height: 44px;
    border-width: 1.5px;
    border-radius: 11px;
    font-size: 21px;
    box-shadow:
      0 3px 0 #d9cbd6,
      inset 0 2px 0 rgba(255, 255, 255, 0.9);
  }

  .key-count {
    top: -4px;
    right: -3px;
    min-width: 13px;
    height: 13px;
    padding: 0 2px;
    font-size: 6.5px;
  }

  .toolbar {
    gap: 5px;
    margin-top: 8px;
  }

  .tool {
    flex-direction: column;
    gap: 1px;
    height: 49px;
    padding: 3px 2px;
    border-radius: 12px;
    font-size: 9px;
  }

  .tool-icon {
    width: 23px;
    height: 23px;
    border-radius: 7px;
  }

  .tool-icon .icon {
    width: 13px;
    height: 13px;
  }

  .tool-status {
    top: 4px;
    right: 5px;
    width: 6px;
    height: 6px;
  }

  .tool-badge {
    top: -5px;
    right: -3px;
    min-width: 16px;
    height: 16px;
    font-size: 8px;
  }

  .sidebar {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .mascot-card {
    grid-template-columns: minmax(0, 1fr) 130px;
    min-height: 165px;
    border-radius: 24px;
    padding: 13px;
  }

  .speech-bubble {
    min-height: 54px;
    padding: 9px 11px;
    font-size: 10.5px;
  }

  .mascot-stage {
    height: 138px;
  }

  .mascot {
    width: 144px;
  }

  .mascot-name strong {
    font-size: 15px;
  }

  .mascot-name span {
    font-size: 8px;
  }

  .stats-card,
  .progress-card {
    border-radius: 20px;
    padding: 12px;
  }

  .mini-stat {
    padding: 7px;
  }

  .page-footer {
    flex-wrap: wrap;
    gap: 5px;
    padding-top: 13px;
    font-size: 8px;
    letter-spacing: 0.06em;
  }

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

  .modal h2 {
    font-size: 20px;
  }

  .difficulty-option {
    padding: 8px 10px;
  }

  .difficulty-emoji {
    width: 41px;
    height: 41px;
    font-size: 21px;
  }
}

@media (max-width: 390px) {
  .brand-eyebrow {
    display: none;
  }

  .brand-title {
    font-size: 21px;
  }

  .time-chip .icon {
    display: none;
  }

  .head-stats {
    gap: 3px;
  }

  .stat-chip {
    padding-inline: 6px;
  }

  .heart-chip {
    padding-inline: 5px;
  }
}

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


@media (max-width: 350px) {
  .sound-btn {
    display: none;
  }

  .brand-title {
    font-size: 19px;
  }

  .new-game-btn {
    padding-inline: 9px;
  }

  .new-game-btn span {
    font-size: 10px;
  }
}

/* =========================================================
   Battle mode
   ========================================================= */

.icon-btn:disabled,
.pause-btn:disabled {
  opacity: 0.42;
  cursor: not-allowed;
  pointer-events: none;
}

.battle-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 47px;
  padding: 0 14px;
  border: 2px solid var(--ink);
  border-radius: 15px;
  color: var(--ink);
  background: linear-gradient(180deg, #c9b7ff, #a98bff);
  box-shadow:
    0 4px 0 #7552df,
    inset 0 2px 0 rgba(255, 255, 255, 0.46);
  font-size: 13px;
  font-weight: 900;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
  transition: transform 0.16s ease, box-shadow 0.16s ease, filter 0.16s ease;
}

.battle-btn .icon {
  width: 17px;
  height: 17px;
  stroke-width: 2.2;
}

.battle-btn:hover {
  transform: translateY(-2px);
  filter: brightness(1.025);
  box-shadow:
    0 6px 0 #7552df,
    inset 0 2px 0 rgba(255, 255, 255, 0.46);
}

.battle-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 #7552df;
}

.battle-btn.is-live {
  background: linear-gradient(180deg, #ffa6c1, #ff5f93);
  box-shadow:
    0 4px 0 #d92e6b,
    inset 0 2px 0 rgba(255, 255, 255, 0.42);
}

.battle-btn.is-live:hover {
  box-shadow:
    0 6px 0 #d92e6b,
    inset 0 2px 0 rgba(255, 255, 255, 0.42);
}

.battle-btn.is-finished {
  background: linear-gradient(180deg, #ffe18b, #ffce4d);
  box-shadow:
    0 4px 0 #d59b12,
    inset 0 2px 0 rgba(255, 255, 255, 0.48);
}

.battle-btn.is-finished:hover {
  box-shadow:
    0 6px 0 #d59b12,
    inset 0 2px 0 rgba(255, 255, 255, 0.48);
}

.battle-live-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #ff2d68;
  box-shadow: 0 0 0 3px rgba(255, 45, 104, 0.18);
  animation: battle-live-pulse 1.25s ease-in-out infinite;
}

/* ---------- In-game battle HUD ---------- */

.battle-hud {
  display: flex;
  flex-direction: column;
  gap: 5px;
  width: min(100%, 500px);
  margin: 0 auto 10px;
  padding: 7px 8px 8px;
  border: 2px solid var(--ink);
  border-radius: 18px;
  background:
    linear-gradient(125deg, rgba(255, 255, 255, 0.5), transparent 45%),
    linear-gradient(120deg, #ffe0eb 0%, #ece5ff 52%, #d9fff0 100%);
  box-shadow: 0 4px 0 rgba(61, 47, 73, 0.11);
  animation: battle-hud-in 0.3s cubic-bezier(0.2, 1.2, 0.4, 1);
}

/* ---------- Countdown ---------- */

.battle-countdown {
  position: absolute;
  inset: 0;
  z-index: 8;
  display: grid;
  place-items: center;
  padding: 18px;
  border-radius: 22px;
  background: rgba(61, 47, 73, 0.39);
  -webkit-backdrop-filter: blur(7px) saturate(0.9);
  backdrop-filter: blur(7px) saturate(0.9);
  animation: fade-in 0.2s ease;
}

.countdown-card {
  width: min(100%, 260px);
  padding: 20px 20px 22px;
  border: 3px solid var(--ink);
  border-radius: 28px;
  text-align: center;
  background:
    radial-gradient(circle at 85% 6%, rgba(255, 206, 77, 0.42), transparent 33%),
    radial-gradient(circle at 5% 95%, rgba(169, 139, 255, 0.24), transparent 38%),
    var(--paper);
  box-shadow: 0 11px 0 rgba(35, 23, 41, 0.23);
  animation: countdown-card-in 0.33s cubic-bezier(0.2, 1.3, 0.4, 1);
}

.countdown-number {
  display: block;
  margin: -2px 0 1px;
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 82px;
  font-weight: 800;
  line-height: 0.95;
  text-shadow:
    0 4px 0 #fff,
    0 7px 0 rgba(230, 45, 114, 0.15);
}

.countdown-number.is-go {
  color: var(--mint-deep);
  font-size: 50px;
  text-shadow:
    0 4px 0 #fff,
    0 7px 0 rgba(15, 148, 104, 0.15);
}

.countdown-number.is-tick {
  animation: countdown-pop 0.42s cubic-bezier(0.2, 1.4, 0.4, 1);
}

.countdown-copy {
  display: block;
  margin-top: 7px;
  color: var(--ink-soft);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

/* ---------- Battle lobby modal ---------- */

.battle-modal {
  width: min(100%, 548px);
  overflow: auto;
  text-align: left;
}

.battle-modal-heading {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
  text-align: left;
}

.battle-modal-heading h2 {
  margin: 0;
  font-size: 25px;
  text-align: left;
}

.battle-emblem {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  flex: none;
  border: 2.5px solid var(--ink);
  border-radius: 18px;
  background: linear-gradient(145deg, #d8caff, #a98bff);
  box-shadow:
    0 4px 0 rgba(61, 47, 73, 0.16),
    inset 0 2px 0 rgba(255, 255, 255, 0.48);
  transform: rotate(-4deg);
}

.battle-emblem .icon {
  width: 27px;
  height: 27px;
  color: #fff;
  filter: drop-shadow(0 1px 0 rgba(61, 47, 73, 0.3));
}

.battle-modal > .modal-sub {
  margin: 2px 0 13px;
  max-width: none;
  text-align: left;
}

.battle-status-bar {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 34px;
  margin-bottom: 14px;
  padding: 7px 11px;
  border: 1.5px solid rgba(61, 47, 73, 0.12);
  border-radius: 11px;
  background: #f8f1f6;
  color: var(--ink-soft);
  font-size: 9.5px;
  font-weight: 800;
}

.battle-status-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: #cfbfd3;
}

.battle-status-bar.is-online {
  color: #087d58;
  background: #e6fbf2;
  border-color: #a8ebd1;
}

.battle-status-bar.is-online .battle-status-dot {
  background: #22c98d;
  box-shadow: 0 0 0 3px rgba(34, 201, 141, 0.16);
}

.battle-status-bar.is-connecting {
  color: #9a7114;
  background: #fff8db;
  border-color: #eed88a;
}

.battle-status-bar.is-connecting .battle-status-dot {
  background: #f2b72d;
  animation: battle-live-pulse 1.3s ease-in-out infinite;
}

.battle-status-bar.is-offline {
  color: #bb3158;
  background: #fff0f4;
  border-color: #ffc3d4;
}

.battle-status-bar.is-offline .battle-status-dot {
  background: #ef4778;
}

.battle-lobby {
  animation: fade-in 0.22s ease;
}

.field-label {
  display: block;
  margin-bottom: 5px;
  color: var(--ink-soft);
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-align: left;
}

.text-input {
  width: 100%;
  height: 40px;
  padding: 0 12px;
  border: 2px solid rgba(61, 47, 73, 0.17);
  border-radius: 12px;
  outline: none;
  background: #fff;
  color: var(--ink);
  font-family: var(--font-round);
  font-size: 12px;
  font-weight: 800;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.text-input::placeholder {
  color: #b7a5bd;
  font-weight: 700;
}

.text-input:focus {
  border-color: var(--ink);
  box-shadow: 0 0 0 3px var(--pink-soft);
}

.battle-lobby > #playerName {
  margin-bottom: 12px;
}

.battle-lobby-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.battle-panel {
  position: relative;
  padding: 12px;
  border: 1.8px solid rgba(61, 47, 73, 0.17);
  border-radius: 18px;
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.8), transparent 65%),
    #fff7fa;
  box-shadow: 0 3px 0 rgba(61, 47, 73, 0.06);
}

.battle-panel--join {
  background:
    linear-gradient(150deg, rgba(255, 255, 255, 0.8), transparent 65%),
    #f8f5ff;
}

.battle-panel-icon {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  margin-bottom: 6px;
  border: 1.5px solid var(--ink);
  border-radius: 11px;
  font-size: 17px;
  line-height: 1;
  box-shadow: 0 2px 0 rgba(61, 47, 73, 0.1);
}

.battle-panel-icon--pink {
  background: #ffd5e4;
}

.battle-panel-icon--lilac {
  background: #e6dcff;
}

.battle-panel h3 {
  margin: 0 0 8px;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.03em;
}

.battle-panel .field-label {
  margin-top: 7px;
}

.battle-panel .text-input {
  height: 36px;
  font-size: 11px;
}

.select-input {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 28px;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--ink) 50%),
    linear-gradient(135deg, var(--ink) 50%, transparent 50%);
  background-position:
    calc(100% - 17px) 50%,
    calc(100% - 12px) 50%;
  background-size: 5px 5px;
  background-repeat: no-repeat;
  cursor: pointer;
}

.room-code-input {
  text-align: center;
  text-transform: uppercase;
  font-family: var(--font-display);
  font-size: 19px !important;
  font-weight: 800 !important;
  letter-spacing: 0.18em;
}

.battle-create-btn,
.battle-join-btn {
  width: 100%;
  min-height: 38px;
  margin-top: 10px;
  padding-inline: 8px;
  border-radius: 12px;
  font-size: 11.5px;
}

.battle-join-btn {
  background: #fff;
  box-shadow: 0 4px 0 rgba(61, 47, 73, 0.13);
}

/* Waiting room */

.battle-waiting {
  padding: 4px 6px 2px;
  text-align: center;
  animation: fade-in 0.22s ease;
}

.waiting-kicker {
  display: inline-block;
  margin-bottom: 7px;
  color: var(--mint-deep);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.17em;
}

.room-code-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.room-code-row strong {
  padding: 2px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 16px;
  background:
    radial-gradient(circle at 10% 10%, rgba(255, 255, 255, 0.9), transparent 40%),
    linear-gradient(135deg, #ffe590, #ffce4d);
  box-shadow:
    0 5px 0 rgba(61, 47, 73, 0.15),
    inset 0 2px 0 rgba(255, 255, 255, 0.45);
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 800;
  letter-spacing: 0.14em;
  line-height: 1.15;
  transform: rotate(-1.5deg);
}

.copy-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 1.8px solid var(--ink);
  border-radius: 11px;
  background: #fff;
  box-shadow: 0 3px 0 rgba(61, 47, 73, 0.12);
  color: var(--ink-soft);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.copy-btn:hover {
  transform: translateY(-2px) rotate(-4deg);
  background: var(--lilac-soft);
}

.copy-btn .icon {
  width: 17px;
  height: 17px;
}

.waiting-text {
  margin: 12px 0 7px;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.6;
}

.waiting-actions {
  margin-top: 4px;
}

/* Offline / active room states */

.battle-offline {
  padding: 8px 8px 4px;
  text-align: center;
  animation: fade-in 0.22s ease;
}

.battle-offline-icon {
  font-size: 46px;
  line-height: 1;
  margin-bottom: 6px;
  filter: drop-shadow(0 5px 4px rgba(61, 47, 73, 0.12));
}

.battle-offline h3 {
  margin: 0 0 5px;
  font-size: 17px;
  font-weight: 900;
}

.battle-offline p {
  max-width: 320px;
  margin: 0 auto 15px;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.65;
}

.battle-active-panel {
  padding: 4px 2px 0;
  text-align: center;
  animation: fade-in 0.22s ease;
}

.active-room-line {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  padding: 6px 13px;
  border: 1.5px solid #d8c7f8;
  border-radius: 999px;
  background: #f3edff;
  color: var(--lilac-deep);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.09em;
}

.active-room-line strong {
  font-family: var(--font-display);
  font-size: 18px;
  letter-spacing: 0.1em;
}

.active-battle-text {
  margin: 12px 0;
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
}

.battle-active-players {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 15px;
}

.active-player-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 9px;
  border: 1.5px solid rgba(61, 47, 73, 0.13);
  border-radius: 999px;
  background: #faf4f8;
  font-size: 9.5px;
  font-weight: 800;
}

.active-player-chip .score-avatar {
  width: 22px;
  height: 22px;
  font-size: 14px;
}

.battle-active-actions {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.battle-active-actions .secondary-btn {
  width: min(100%, 220px);
}

.battle-leave-btn,
.battle-result-leave {
  color: #c62c61;
}

.battle-leave-btn.is-armed,
.battle-result-leave.is-armed {
  padding: 4px 9px;
  border-radius: 7px;
  background: #ffe1ea;
  color: #b91c4f;
}

.battle-footnote {
  margin: 13px 0 0;
  color: var(--ink-mute);
  font-size: 8.5px;
  font-weight: 700;
  line-height: 1.5;
  text-align: center;
}

/* ---------- Battle result modal ---------- */

.battle-result-modal {
  width: min(100%, 438px);
  overflow: hidden;
  background:
    radial-gradient(circle at 92% 0%, rgba(255, 206, 77, 0.35), transparent 33%),
    radial-gradient(circle at 0% 100%, rgba(169, 139, 255, 0.18), transparent 35%),
    var(--paper);
}

.battle-result-modal.is-win {
  background:
    radial-gradient(circle at 88% 0%, rgba(255, 206, 77, 0.55), transparent 36%),
    radial-gradient(circle at 5% 100%, rgba(94, 224, 176, 0.22), transparent 34%),
    var(--paper);
}

.battle-result-modal.is-lose {
  background:
    radial-gradient(circle at 88% 0%, rgba(169, 139, 255, 0.32), transparent 36%),
    radial-gradient(circle at 5% 100%, rgba(255, 111, 158, 0.17), transparent 34%),
    var(--paper);
}

.battle-result-emblem {
  position: relative;
  display: grid;
  place-items: center;
  width: 82px;
  height: 82px;
  margin: 2px auto 11px;
  border: 2.5px solid var(--ink);
  border-radius: 27px;
  background: linear-gradient(145deg, #ffe68b, #ffc72e);
  box-shadow:
    0 6px 0 rgba(61, 47, 73, 0.14),
    inset 0 3px 0 rgba(255, 255, 255, 0.6);
  line-height: 1;
  transform: rotate(-4deg);
}

.battle-result-modal.is-lose .battle-result-emblem {
  background: linear-gradient(145deg, #ded2ff, #b8a1ff);
}

.battle-result-modal .modal-sub {
  margin-bottom: 15px;
}

.score-avatar {
  display: grid;
  place-items: center;
  grid-row: 1 / span 2;
  width: 29px;
  height: 29px;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
  background: #fff;
  font-size: 18px;
  line-height: 1;
}

.battle-result-stats {
  margin: 0 0 15px;
}

.rematch-hint {
  margin: 9px 0 0;
  color: var(--ink-mute);
  font-size: 9px;
  font-weight: 700;
  line-height: 1.5;
}

.rematch-hint.is-waiting {
  color: var(--pink-deep);
}

.battle-result-leave {
  margin-top: 4px;
}

/* ---------- Battle responsive ---------- */

@media (max-width: 620px) {
  .battle-btn {
    height: 39px;
    padding-inline: 11px;
    border-radius: 12px;
    font-size: 11.5px;
    box-shadow:
      0 3px 0 #7552df,
      inset 0 2px 0 rgba(255, 255, 255, 0.46);
  }

  .battle-btn:hover {
    box-shadow:
      0 5px 0 #7552df,
      inset 0 2px 0 rgba(255, 255, 255, 0.46);
  }

  .battle-btn .icon {
    width: 15px;
    height: 15px;
  }

  .battle-modal {
    width: min(100%, 470px);
    padding-inline: 16px;
  }

  .battle-modal-heading h2 {
    font-size: 21px;
  }

  .battle-emblem {
    width: 46px;
    height: 46px;
    border-radius: 15px;
  }

  .battle-emblem .icon {
    width: 23px;
    height: 23px;
  }

  .battle-panel {
    padding: 10px;
  }

  .battle-panel-icon {
    width: 30px;
    height: 30px;
    font-size: 15px;
  }

  .room-code-row strong {
    font-size: 34px;
  }

  .countdown-number {
    font-size: 68px;
  }

  .countdown-number.is-go {
    font-size: 43px;
  }

  .battle-result-modal {
    width: min(100%, 410px);
  }
}

@media (max-width: 480px) {
  .battle-lobby-grid {
    grid-template-columns: 1fr;
  }

  .battle-panel {
    display: grid;
    grid-template-columns: 38px 1fr;
    column-gap: 9px;
    align-items: start;
    text-align: left;
  }

  .battle-panel-icon {
    grid-row: 1 / span 4;
    margin-bottom: 0;
  }

  .battle-panel h3 {
    grid-column: 2;
    margin-bottom: 3px;
  }

  .battle-panel .field-label,
  .battle-panel .text-input,
  .battle-panel button {
    grid-column: 2;
  }

  .battle-panel .field-label {
    margin-top: 2px;
  }

  .battle-create-btn,
  .battle-join-btn {
    margin-top: 7px;
  }

  .battle-modal .modal-sub {
    font-size: 10.5px;
  }

  .battle-status-bar {
    font-size: 8.5px;
  }

  .room-code-row strong {
    font-size: 30px;
  }

  .score-avatar {
    width: 25px;
    height: 25px;
    font-size: 15px;
  }

  .battle-result-modal .modal-actions {
    grid-template-columns: 1fr;
  }

  .battle-result-modal .modal-actions .primary-btn {
    order: -1;
  }
}

@media (max-width: 430px) {
  .sound-btn {
    display: none;
  }

  .battle-btn {
    width: 39px;
    padding: 0;
  }

  .battle-btn-label {
    display: none;
  }

  .battle-live-dot {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 7px;
    height: 7px;
  }

}

@media (max-width: 350px) {
  .new-game-btn {
    width: 39px;
    min-height: 39px;
    padding: 0;
  }

  .new-game-btn span {
    display: none;
  }

  .battle-btn {
    width: 39px;
  }

  .battle-hud {
    gap: 3px;
    padding: 4px;
  }
}

@keyframes battle-live-pulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.6;
    transform: scale(0.83);
  }
}

@keyframes battle-hud-in {
  from {
    opacity: 0;
    transform: translateY(-7px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes countdown-card-in {
  from {
    opacity: 0;
    transform: scale(0.86) rotate(-3deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes countdown-pop {
  0% {
    transform: scale(0.8);
  }
  55% {
    transform: scale(1.16);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes waiting-bounce {
  0%,
  100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  50% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* =========================================================
   Multiplayer roster (1–5 players)
   ========================================================= */

.battle-hud-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 0 2px;
  line-height: 1;
}

.battle-hud-kicker {
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 800;
  letter-spacing: 0.14em;
}

.battle-hud-room {
  color: var(--ink-mute);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.battle-roster {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  gap: 5px;
}

.roster-player {
  min-width: 0;
  padding: 4px 5px 5px;
  border: 1.5px solid rgba(61, 47, 73, 0.14);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.84);
  transition: box-shadow 0.2s ease, border-color 0.2s ease, opacity 0.2s ease;
}

.roster-player.is-you {
  border-color: #ff8dac;
  background: #fff8fb;
}

.roster-player.is-leading {
  box-shadow: inset 0 0 0 2px var(--yellow);
}

.roster-player.is-completed {
  background: #e7fbf2;
}

.roster-player.is-eliminated {
  opacity: 0.5;
  filter: grayscale(0.35);
}

.roster-top {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  margin-bottom: 3px;
}

.roster-avatar {
  display: grid;
  place-items: center;
  width: 19px;
  height: 19px;
  flex: none;
  border: 1px solid var(--ink);
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  line-height: 1;
}

.roster-name {
  overflow: hidden;
  flex: 1;
  min-width: 0;
  color: var(--ink);
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.roster-pct {
  flex: none;
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 8px;
  font-weight: 700;
  line-height: 1;
}

.roster-player.is-you .roster-pct {
  color: var(--pink-deep);
}

.roster-track {
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: #f0e3eb;
}

.roster-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6f9e, #ffce4d);
  transition: width 0.32s ease;
}

.roster-player.is-you .roster-track span {
  background: linear-gradient(90deg, #ff5d93, #ffce4d);
}

.roster-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 3px;
  margin-top: 3px;
  line-height: 1;
}

.roster-hearts {
  color: var(--pink-deep);
  font-size: 6.5px;
  letter-spacing: -0.06em;
  white-space: nowrap;
}

.roster-state {
  color: var(--ink-mute);
  font-size: 6.5px;
  font-weight: 900;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

/* ---------- Waiting room roster ---------- */

.waiting-roster-wrap {
  width: 100%;
  margin: 4px 0 10px;
  padding: 9px;
  border: 1.5px solid rgba(61, 47, 73, 0.12);
  border-radius: 16px;
  background: #f9f3f8;
}

.waiting-roster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 7px;
  color: var(--ink-soft);
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.waiting-roster-head strong {
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.waiting-roster {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
}

.waiting-player {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
  min-height: 38px;
  padding: 4px 6px;
  border: 1.5px solid rgba(61, 47, 73, 0.12);
  border-radius: 10px;
  background: #fff;
}

.waiting-player-avatar {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  flex: none;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: #fff8fb;
  font-size: 15px;
  line-height: 1;
}

.waiting-player-copy {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
  flex: 1;
  text-align: left;
}

.waiting-player-copy strong {
  overflow: hidden;
  font-size: 8.5px;
  font-weight: 900;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.waiting-player-copy small {
  color: var(--ink-mute);
  font-size: 6.5px;
  font-weight: 700;
  line-height: 1.2;
}

.waiting-tags {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: none;
}

.waiting-tag {
  display: inline-block;
  padding: 1px 4px;
  border-radius: 4px;
  font-size: 6px;
  font-style: normal;
  font-weight: 900;
  line-height: 1.25;
  white-space: nowrap;
}

.waiting-tag--host {
  background: var(--yellow-soft);
  color: #8b6610;
}

.waiting-tag--you {
  background: var(--pink-soft);
  color: var(--pink-deep);
}

.waiting-player.is-empty {
  border-style: dashed;
  background: rgba(255, 255, 255, 0.4);
  opacity: 0.65;
}

.waiting-player.is-empty .waiting-player-avatar {
  border-style: dashed;
  border-color: #c9b9c6;
  background: transparent;
  color: #bba8b7;
  font-size: 16px;
}

.waiting-player.is-offline {
  opacity: 0.5;
}

.waiting-start-btn {
  display: flex;
  width: min(100%, 260px);
  margin: 0 auto 5px;
}

.waiting-host-hint {
  margin: 0 0 7px;
  color: var(--ink-mute);
  font-size: 8.5px;
  font-weight: 800;
  text-align: center;
}

/* ---------- Result ranking ---------- */

.battle-result-rankline {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 2px 2px 7px;
  padding: 7px 10px;
  border-radius: 11px;
  background: #faf2f7;
  color: var(--ink-soft);
  font-size: 8.5px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.battle-result-rankline strong {
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.03em;
}

.battle-result-roster {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 13px;
}

.result-roster-row {
  display: grid;
  grid-template-columns: 17px 27px 1fr 42px;
  gap: 5px;
  align-items: center;
  min-height: 35px;
  padding: 4px 7px;
  border: 1.5px solid rgba(61, 47, 73, 0.1);
  border-radius: 10px;
  background: #fff;
  text-align: left;
}

.result-roster-row.is-you {
  border-color: #ff9bb8;
  background: #fff7fa;
}

.result-roster-row.is-winner {
  border-color: #e8b92e;
  background: linear-gradient(90deg, #fff8d7, #fffdf6);
}

.result-roster-row.is-eliminated {
  opacity: 0.64;
}

.result-place {
  display: grid;
  place-items: center;
  width: 17px;
  height: 17px;
  border-radius: 5px;
  background: #f1e6ee;
  color: var(--ink-soft);
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
}

.result-roster-row.is-winner .result-place {
  background: var(--yellow);
  color: #644a00;
}

.result-roster-row .score-avatar {
  width: 27px;
  height: 27px;
  border-radius: 8px;
  font-size: 17px;
}

.result-roster-main {
  min-width: 0;
}

.result-roster-name {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
  margin-bottom: 3px;
}

.result-roster-name strong {
  overflow: hidden;
  font-size: 9px;
  font-weight: 900;
  line-height: 1.15;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.result-you-tag,
.result-winner-tag {
  flex: none;
  padding: 1px 3px;
  border-radius: 3px;
  font-family: var(--font-display);
  font-size: 5.5px;
  font-weight: 800;
  letter-spacing: 0.06em;
  line-height: 1.3;
}

.result-you-tag {
  background: var(--pink);
  color: #fff;
}

.result-winner-tag {
  background: var(--yellow);
  color: #624900;
}

.result-roster-track {
  height: 4px;
  overflow: hidden;
  border-radius: 99px;
  background: #f0e4eb;
}

.result-roster-track span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6f9e, #ffce4d);
}

.result-roster-row.is-winner .result-roster-track span {
  background: linear-gradient(90deg, #ffce4d, #5ee0b0);
}

.result-roster-status {
  color: var(--ink-mute);
  font-size: 7.5px;
  font-weight: 900;
  text-align: right;
  white-space: nowrap;
}

.result-roster-row.is-winner .result-roster-status {
  color: #9a7114;
}

/* Result modal can grow with a five-player ranking on short screens. */
.battle-result-modal {
  max-height: min(92vh, 780px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-width: thin;
}

@media (max-width: 620px) {
  .battle-hud {
    margin-bottom: 8px;
    padding: 6px;
    border-radius: 15px;
  }

  .battle-hud-head {
    font-size: 7px;
  }

  .battle-roster {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 4px;
  }

  .roster-player {
    padding: 3px 4px 4px;
  }

  .roster-avatar {
    width: 17px;
    height: 17px;
    border-radius: 5px;
    font-size: 11px;
  }

  .roster-name {
    font-size: 7.5px;
  }

  .roster-pct {
    font-size: 7px;
  }

  .roster-hearts,
  .roster-state {
    font-size: 5.5px;
  }

  .waiting-roster {
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 4px;
  }

  .waiting-player {
    min-height: 35px;
    padding: 3px 5px;
  }

  .waiting-player-avatar {
    width: 22px;
    height: 22px;
    border-radius: 7px;
    font-size: 13px;
  }

  .waiting-player-copy strong {
    font-size: 7.5px;
  }

  .waiting-player-copy small {
    font-size: 5.5px;
  }

  .waiting-tag {
    font-size: 5px;
    padding-inline: 3px;
  }

  .battle-result-rankline {
    padding: 6px 8px;
  }

  .result-roster-row {
    grid-template-columns: 16px 24px 1fr 39px;
    min-height: 32px;
    padding: 3px 6px;
  }

  .result-roster-row .score-avatar {
    width: 24px;
    height: 24px;
    font-size: 15px;
  }

  .result-roster-name strong {
    font-size: 8px;
  }

  .result-roster-status {
    font-size: 6.5px;
  }

  .result-you-tag,
  .result-winner-tag {
    font-size: 5px;
  }
}

/* =========================================================
   Mobile battle ergonomics
   ========================================================= */

button,
.key,
.copy-btn {
  touch-action: manipulation;
}

@media (max-width: 620px) {
  /* Prevent iOS Safari from zooming the page when a text field is focused. */
  .text-input,
  .battle-panel .text-input {
    height: 44px;
    font-size: 16px;
    line-height: 1.2;
  }

  .room-code-input {
    height: 44px;
    font-size: 22px !important;
  }

  .battle-lobby > #playerName {
    margin-bottom: 10px;
  }

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

  .waiting-start-btn {
    min-height: 48px;
  }

  .page {
    padding-bottom: max(18px, env(safe-area-inset-bottom));
  }
}

@media (max-width: 480px) {
  /* Two rows of number keys are easier to hit with a thumb than 9 tiny keys. */
  .keypad {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 6px;
  }

  .key {
    width: calc((100% - 24px) / 5);
    height: 48px;
    flex: 0 0 calc((100% - 24px) / 5);
    border-radius: 13px;
    font-size: 23px;
  }

  .battle-result-modal {
    max-height: calc(100dvh - 18px);
  }
}

@supports (height: 100dvh) {
  @media (max-width: 620px) {
    .modal {
      max-height: 92dvh;
    }

    .battle-result-modal {
      max-height: calc(100dvh - 18px);
    }
  }
}


/* Touch-friendly controls on phones. */
@media (max-width: 620px) {
  .topbar-actions .icon-btn,
  .topbar-actions .battle-btn,
  .topbar-actions .new-game-btn {
    height: 44px;
    min-height: 44px;
  }

  .modal-close {
    width: 44px;
    height: 44px;
  }

  .waiting-actions .text-btn,
  .battle-result-leave,
  .battle-leave-btn {
    min-height: 40px;
    padding: 8px 12px;
  }

  .waiting-host-hint {
    font-size: 9px;
    line-height: 1.5;
  }
}

@media (max-width: 430px) {
  .topbar-actions .battle-btn {
    width: 44px;
    padding: 0;
  }
}

@media (max-width: 350px) {
  .topbar-actions .new-game-btn {
    width: 44px;
  }
}

/* =========================================================
   Audio panel + mobile info popup
   ========================================================= */

.audio-panel {
  position: fixed;
  top: 76px;
  right: max(16px, calc((100vw - 1000px) / 2 + 24px));
  z-index: 70;
  width: min(282px, calc(100vw - 24px));
  padding: 13px 14px 12px;
  border: 2.5px solid var(--ink);
  border-radius: 20px;
  background:
    radial-gradient(circle at 95% 0%, rgba(255, 206, 77, 0.3), transparent 38%),
    linear-gradient(160deg, #fff8fb, #f3edff);
  box-shadow:
    0 8px 0 rgba(61, 47, 73, 0.14),
    0 24px 40px rgba(61, 47, 73, 0.2);
  animation: audio-panel-in 0.22s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.audio-panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  padding-bottom: 7px;
  border-bottom: 1.5px dashed rgba(61, 47, 73, 0.15);
}

.audio-panel-head strong {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
}

.audio-close {
  display: grid;
  place-items: center;
  width: 27px;
  height: 27px;
  padding: 0;
  border: 1.5px solid rgba(61, 47, 73, 0.18);
  border-radius: 8px;
  background: #fff;
  color: var(--ink-soft);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
}

.audio-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 38px;
  border-bottom: 1px solid rgba(61, 47, 73, 0.08);
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 900;
  cursor: pointer;
}

.audio-switch {
  position: relative;
  display: block;
  width: 40px;
  height: 22px;
  flex: none;
}

.audio-switch input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.audio-switch i {
  position: absolute;
  inset: 0;
  border: 1.5px solid var(--ink);
  border-radius: 99px;
  background: #ead9e4;
  box-shadow: inset 0 1px 2px rgba(61, 47, 73, 0.08);
  transition: background 0.18s ease;
}

.audio-switch i::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 13px;
  height: 13px;
  border: 1.5px solid var(--ink);
  border-radius: 50%;
  background: #fff;
  transition: transform 0.18s cubic-bezier(0.2, 1.2, 0.4, 1);
}

.audio-switch input:checked + i {
  background: var(--mint);
}

.audio-switch input:checked + i::after {
  transform: translateX(18px);
}

.audio-switch input:focus-visible + i {
  outline: 2.5px solid var(--ink);
  outline-offset: 2px;
}

.audio-volume-row {
  display: grid;
  grid-template-columns: 1fr 92px;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  color: var(--ink-soft);
  font-size: 9px;
  font-weight: 800;
}

.audio-volume-row input {
  width: 100%;
  height: 4px;
  accent-color: var(--pink-deep);
  cursor: pointer;
}

.audio-hint {
  margin: 7px 0 0;
  color: var(--ink-mute);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.5;
}

.mobile-info-btn {
  display: none;
}

.mobile-info-modal {
  width: min(100%, 376px);
  padding: 24px 20px 20px;
  text-align: center;
}

.mobile-info-bunny {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  margin: 0 auto 9px;
  border: 2.5px solid var(--ink);
  border-radius: 25px;
  background:
    radial-gradient(circle at 30% 20%, #fff, transparent 45%),
    linear-gradient(145deg, #ffe0ea, #e6dbff 60%, #dcfff1);
  box-shadow:
    0 5px 0 rgba(61, 47, 73, 0.14),
    inset 0 2px 0 rgba(255, 255, 255, 0.7);
  font-size: 42px;
  line-height: 1;
  transform: rotate(-3deg);
}

.mobile-info-modal h2 {
  margin-top: 0;
}

.mobile-speech {
  min-height: 58px;
  margin: 2px 0 13px;
  padding: 12px 13px;
  border: 1.5px solid rgba(61, 47, 73, 0.13);
  border-radius: 15px 15px 15px 5px;
  background: #fff8fb;
  color: var(--ink-soft);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.65;
  text-align: left;
}

.mobile-info-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 5px;
  margin-bottom: 8px;
  padding: 9px 5px;
  border-radius: 14px;
  background: #faf2f7;
}

.mobile-info-stats div {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  border-right: 1px solid #eadde4;
}

.mobile-info-stats div:last-child {
  border-right: 0;
}

.mobile-info-stats span {
  color: var(--ink-mute);
  font-size: 7.5px;
  font-weight: 800;
}

.mobile-info-stats strong {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
}

.mobile-info-progress {
  height: 8px;
  overflow: hidden;
  margin-bottom: 14px;
  border-radius: 99px;
  background: #f0e4eb;
}

.mobile-info-progress span {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6f9e, #ffce4d, #5ee0b0);
  transition: width 0.35s ease;
}

.mobile-info-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.mobile-info-actions .primary-btn,
.mobile-info-actions .secondary-btn {
  min-height: 45px;
  padding-inline: 8px;
  font-size: 12px;
}

.mobile-info-tip {
  margin: 11px 0 0;
  color: var(--ink-mute);
  font-size: 8px;
  font-weight: 700;
  line-height: 1.5;
}

@media (max-width: 620px) {
  .audio-panel {
    top: 62px;
    right: 10px;
  }

  .sidebar {
    display: none !important;
  }

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

  .mobile-info-btn {
    display: flex;
  }

  .mobile-info-btn .tool-icon {
    background: #f0e6ff;
    font-size: 15px;
  }

  .mobile-info-modal {
    max-height: 92dvh;
    overflow-y: auto;
  }

  .mobile-info-actions .primary-btn,
  .mobile-info-actions .secondary-btn {
    min-height: 48px;
  }
}

@media (max-width: 430px) {
  .new-game-btn {
    width: 44px;
    padding: 0;
  }

  .new-game-btn span {
    display: none;
  }
}

@media (min-width: 351px) and (max-width: 430px) {
  .sound-btn {
    display: grid;
  }
}

@media (max-width: 350px) {
  .mobile-info-stats {
    grid-template-columns: 1fr 1fr;
  }

  .mobile-info-stats div:nth-child(even) {
    border-right: 0;
  }

  .audio-panel {
    top: 58px;
  }
}

@keyframes audio-panel-in {
  from {
    opacity: 0;
    transform: translateY(-7px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* =========================================================
   New character artwork
   ========================================================= */

.brand-mark img {
  display: block;
  width: 47px;
  height: 47px;
  border-radius: 50%;
  object-fit: contain;
}

.mascot-stage {
  height: 168px;
}

.mascot {
  width: 100%;
  height: 168px;
  object-fit: contain;
  border-radius: 18px;
}

.mascot.mood-pop {
  animation: mascot-mood-pop 0.36s cubic-bezier(0.2, 1.45, 0.4, 1);
}

.tool-icon--bunny img {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  object-fit: contain;
}

.mobile-info-bunny {
  overflow: hidden;
  padding: 3px;
}

.mobile-info-bunny img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

@media (max-width: 980px) {
  .mascot-stage {
    height: 158px;
  }

  .mascot {
    height: 158px;
  }
}

@media (max-width: 860px) {
  .mascot-stage {
    height: 154px;
  }

  .mascot {
    height: 154px;
  }
}

@media (max-width: 620px) {
  .mascot-stage {
    height: 142px;
  }

  .mascot {
    height: 142px;
  }
}

@keyframes mascot-mood-pop {
  0% {
    transform: scale(0.94) rotate(-1.5deg);
    opacity: 0.5;
  }
  60% {
    transform: scale(1.035) rotate(0.6deg);
    opacity: 1;
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

.win-medal-avatar {
  display: block;
  width: 57px;
  height: 57px;
  border-radius: 50%;
  object-fit: contain;
  transform: translateY(2px);
}

/* Player identity avatars now use the new character rather than animal emoji. */
.waiting-player-avatar,
.score-avatar,
.roster-avatar {
  overflow: hidden;
  padding: 2px;
}

.waiting-player-avatar img,
.score-avatar img,
.roster-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  object-fit: contain;
}

.avatar-tone-pink {
  background: #ffe0ea;
}

.avatar-tone-mint {
  background: #dcfaee;
}

.avatar-tone-lilac {
  background: #ece5ff;
}

.avatar-tone-butter {
  background: #fff0b8;
}

.avatar-tone-sky {
  background: #def5ff;
}

/* Remaining emotional emoji replaced with the same 16-sticker set. */
.gameover-face {
  padding: 4px;
}

.gameover-face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.battle-offline-icon {
  display: grid;
  place-items: center;
}

.battle-offline-icon img {
  display: block;
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.battle-result-emblem {
  padding: 3px;
  overflow: hidden;
}

.battle-result-emblem img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* =========================================================
   Leaderboard, admin entry points and legibility pass
   ========================================================= */

.side-heading-btn {
  padding: 4px 9px;
  border: 1.5px solid rgba(61, 47, 73, 0.18);
  border-radius: 999px;
  background: #fff8fb;
  color: var(--pink-deep);
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform 0.14s ease, border-color 0.14s ease, background 0.14s ease;
}

.side-heading-btn:hover {
  border-color: var(--pink-deep);
  background: #fff;
  transform: translateY(-1px);
}

.leaderboard-modal {
  width: min(100%, 590px);
  max-height: min(92vh, 820px);
  overflow-x: hidden;
  overflow-y: auto;
  text-align: left;
  scrollbar-width: thin;
}

.leaderboard-modal h2 {
  font-size: 28px;
}

.leaderboard-modal .modal-sub {
  max-width: 450px;
  margin-inline: 0;
  font-size: 12.5px;
}

.leaderboard-tabs {
  display: flex;
  gap: 7px;
  margin: 4px 0 13px;
  padding: 4px;
  border-radius: 14px;
  background: #f6edf3;
}

.leaderboard-tab {
  flex: 1;
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink-mute);
  font-size: 13px;
  font-weight: 900;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.leaderboard-tab.is-active {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 2px 0 rgba(61, 47, 73, 0.09);
}

.leaderboard-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 800;
}

.leaderboard-toolbar .text-btn {
  flex: none;
  font-size: 11.5px;
}

.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-height: 180px;
}

.leaderboard-group {
  padding: 10px 11px 8px;
  border: 1.5px solid rgba(61, 47, 73, 0.2);
  border-radius: 16px;
  background: #fffafd;
}

.leaderboard-group-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
}

.leaderboard-group-head h3 {
  margin: 0;
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.leaderboard-group-head h3 small {
  margin-left: 6px;
  color: var(--pink-deep);
  font-size: 10px;
  font-weight: 800;
}

.leaderboard-group-head > span {
  color: var(--ink-mute);
  font-size: 10px;
  font-weight: 800;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 25px 68px minmax(0, 1fr) 40px;
  gap: 7px;
  align-items: center;
  min-height: 32px;
  border-top: 1px dashed rgba(61, 47, 73, 0.1);
  color: var(--ink-soft);
  font-size: 11.5px;
  font-weight: 800;
}

.leaderboard-row:first-child {
  border-top: 0;
}

.leaderboard-rank {
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 8px;
  background: #f8ecf3;
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
}

.leaderboard-row:first-child .leaderboard-rank,
.leaderboard-battle-row:nth-child(2) .leaderboard-rank {
  background: #fff0b8;
  color: #8c6412;
}

.leaderboard-time {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
}

.leaderboard-detail {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-date {
  color: var(--ink-mute);
  font-size: 10px;
  text-align: right;
}

.leaderboard-battle-head,
.leaderboard-battle-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) 50px 64px 78px;
  gap: 6px;
  align-items: center;
}

.leaderboard-battle-head {
  padding: 0 8px 7px;
  color: var(--ink-mute);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.leaderboard-battle-head span:nth-child(n + 3) {
  text-align: right;
}

.leaderboard-battle-row {
  min-height: 44px;
  padding: 5px 8px;
  border-top: 1px dashed rgba(61, 47, 73, 0.1);
}

.leaderboard-battle-row:nth-child(2) {
  border-top: 0;
  border-radius: 11px;
  background: #fff7e1;
}

.leaderboard-player {
  display: flex;
  align-items: center;
  gap: 7px;
  min-width: 0;
}

.leaderboard-avatar {
  display: grid;
  place-items: center;
  width: 29px;
  height: 29px;
  flex: none;
  overflow: hidden;
  padding: 2px;
  border: 1.5px solid var(--ink);
  border-radius: 9px;
}

.leaderboard-avatar img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.leaderboard-player strong {
  overflow: hidden;
  color: var(--ink);
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-points {
  color: var(--pink-deep);
  font-family: var(--font-display);
  font-size: 16px;
  text-align: right;
}

.leaderboard-record,
.leaderboard-best {
  color: var(--ink-soft);
  font-size: 11px;
  font-weight: 800;
  text-align: right;
  white-space: nowrap;
}

.leaderboard-empty,
.leaderboard-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 190px;
  padding: 18px;
  border: 1.5px dashed rgba(61, 47, 73, 0.2);
  border-radius: 16px;
  background: #fffafd;
  color: var(--ink-soft);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.leaderboard-empty strong {
  color: var(--ink);
  font-size: 16px;
  font-weight: 900;
}

.leaderboard-empty-line {
  margin: 0;
  padding: 12px 3px;
  color: var(--ink-mute);
  font-size: 11.5px;
  font-weight: 700;
  text-align: center;
}

.leaderboard-note {
  margin: 12px 0 0;
  color: var(--ink-mute);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 1.55;
}

.mobile-info-actions {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.mobile-info-actions .primary-btn,
.mobile-info-actions .secondary-btn {
  padding-inline: 5px;
  font-size: 11.5px;
}

/* Slightly larger supporting text while keeping the same compact rhythm. */
.speech-bubble {
  font-size: 12.5px;
}

.mascot-name span {
  font-size: 10px;
}

.side-card-heading h2 {
  font-size: 13.5px;
}

.mini-stat-label {
  font-size: 9.5px;
}

.mini-stat strong {
  font-size: 15px;
}

.progress-note {
  font-size: 10.5px;
}

.eyebrow {
  font-size: 10px;
}

.modal-sub {
  font-size: 12px;
}

.level-pill span:last-child {
  font-size: 10px;
}

.tool {
  font-size: 12.5px;
}

.battle-hud-kicker {
  font-size: 9px;
}

.battle-hud-room {
  font-size: 9.5px;
}

.battle-roster {
  grid-template-columns: repeat(5, minmax(0, 1fr));
}

.roster-avatar {
  width: 22px;
  height: 22px;
  font-size: 14px;
}

.roster-name {
  font-size: 9.5px;
}

.roster-pct {
  font-size: 9px;
}

.roster-hearts,
.roster-state {
  font-size: 8px;
}

.mobile-info-tip {
  font-size: 9.5px;
}

@media (max-width: 620px) {
  .leaderboard-modal {
    width: min(100%, 470px);
    max-height: 90vh;
  }

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

  .leaderboard-battle-head,
  .leaderboard-battle-row {
    grid-template-columns: 26px minmax(0, 1fr) 42px 58px 64px;
    gap: 5px;
  }

  .leaderboard-battle-head {
    font-size: 9px;
  }

  .leaderboard-player strong {
    font-size: 11px;
  }

  .leaderboard-points {
    font-size: 14px;
  }

  .leaderboard-record,
  .leaderboard-best {
    font-size: 10px;
  }

  .leaderboard-avatar {
    width: 25px;
    height: 25px;
  }

  .battle-roster {
    grid-template-columns: repeat(auto-fit, minmax(88px, 1fr));
  }
}

@media (max-width: 380px) {
  .leaderboard-row {
    grid-template-columns: 23px 62px minmax(0, 1fr) 34px;
    gap: 5px;
    font-size: 10.5px;
  }

  .leaderboard-date {
    font-size: 9px;
  }

  .leaderboard-battle-head,
  .leaderboard-battle-row {
    grid-template-columns: 23px minmax(0, 1fr) 36px 50px 52px;
    gap: 4px;
  }

  .leaderboard-battle-head {
    font-size: 8.5px;
  }
}

.leaderboard-tab.is-active {
  color: var(--pink-deep);
}

.leaderboard-tab:focus-visible {
  outline: 2px solid var(--pink-deep);
  outline-offset: 2px;
}


@media (min-width: 981px) {
  .brand-eyebrow {
    font-size: 10.5px;
  }

  .brand-title {
    font-size: 33px;
  }

  .speech-bubble {
    font-size: 13.5px;
  }

  .mascot-name span {
    font-size: 11px;
  }

  .side-card-heading h2 {
    font-size: 15px;
  }

  .mini-stat-label {
    font-size: 10.5px;
  }

  .mini-stat strong {
    font-size: 16px;
  }

  .progress-note,
  .tip-card {
    font-size: 11px;
  }

  .battle-hud-kicker {
    font-size: 10px;
  }

  .battle-hud-room {
    font-size: 10px;
  }

  .roster-name {
    font-size: 10px;
  }

  .roster-pct {
    font-size: 9.5px;
  }

  .roster-hearts,
  .roster-state {
    font-size: 8.5px;
  }

  .roster-avatar {
    width: 24px;
    height: 24px;
  }

  .tool {
    font-size: 13px;
  }

  .modal-sub {
    font-size: 13px;
  }

  .leaderboard-toolbar {
    font-size: 12.5px;
  }

  .leaderboard-row {
    font-size: 12.5px;
  }

  .leaderboard-battle-row {
    min-height: 48px;
  }

  .leaderboard-player strong {
    font-size: 13px;
  }

  .leaderboard-record,
  .leaderboard-best {
    font-size: 12px;
  }
}

/* Second desktop legibility pass: the game is often viewed on a large monitor. */
@media (min-width: 981px) {
  .brand-eyebrow {
    font-size: 11px;
  }

  .brand-title {
    font-size: 34px;
  }

  .eyebrow {
    font-size: 11px;
  }

  .speech-bubble {
    font-size: 14px;
  }

  .mascot-name strong {
    font-size: 18px;
  }

  .mascot-name span {
    font-size: 11.5px;
  }

  .side-card-heading h2 {
    font-size: 16px;
  }

  .side-heading-btn {
    font-size: 11.5px;
  }

  .mini-stat-label {
    font-size: 12px;
  }

  .mini-stat strong {
    font-size: 17px;
  }

  .progress-note,
  .tip-card,
  .tip-keys {
    font-size: 12px;
  }

  .tool {
    font-size: 14px;
  }

  .modal-sub {
    font-size: 13.5px;
  }

  .battle-hud-kicker,
  .battle-hud-room {
    font-size: 10.5px;
  }

  .roster-name {
    font-size: 10.5px;
  }

  .roster-pct {
    font-size: 10px;
  }

  .roster-hearts,
  .roster-state {
    font-size: 9px;
  }

  .leaderboard-modal .modal-sub {
    font-size: 13.5px;
  }

  .leaderboard-row {
    min-height: 36px;
  }
}

/* Mobile audio troubleshooting */
.audio-test-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 9px;
  padding-top: 9px;
  border-top: 1px solid rgba(61, 47, 73, 0.08);
}

.audio-test-btn {
  min-height: 31px;
  padding: 0 10px;
  border: 1.6px solid rgba(61, 47, 73, 0.22);
  border-radius: 9px;
  background: #fff;
  color: var(--ink);
  font-size: 10.5px;
  font-weight: 900;
  cursor: pointer;
}

.audio-status {
  color: var(--ink-mute);
  font-size: 9.5px;
  font-weight: 800;
}

.audio-hint {
  font-size: 9.5px !important;
  line-height: 1.55 !important;
}

/* Prevent mobile pull-to-refresh and double-tap zoom while playing. */
html,
body {
  overscroll-behavior-y: contain;
}

body {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

button,
.cell,
.key {
  touch-action: manipulation;
}
