:root {
  --ink: #4a3a66;
  --ink-soft: #7a6c95;
  --ivory: #fffbf2;
  --ivory-2: #f5ecdc;
  --pink: #ff8fb1;
  --pink-soft: #ffc4d2;
  --mint: #b4e8c4;
  --sky: #a9d6f5;
  --lav: #d7c8f7;
  --butter: #ffe29a;
  --shadow: 0 4px 0 rgba(90, 70, 130, 0.18), 0 10px 24px rgba(90, 70, 130, 0.14);
  --font: "Fredoka", "Baloo 2", "Nunito", system-ui, -apple-system, sans-serif;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #c9eef0;
  color: var(--ink);
  font-family: var(--font);
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  touch-action: none;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* The app frame never scrolls or zooms; only overlays scroll (vertically). */
#app { position: fixed; inset: 0; overflow: hidden; touch-action: none; }

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
  cursor: pointer;
}

button { font-family: inherit; color: inherit; touch-action: manipulation; }

/* ---------------------------------------------------------------- top bar */

#topbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: calc(10px + var(--safe-t)) 12px 8px;
  pointer-events: none;
}
#topbar > * { pointer-events: auto; }

.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; }
.logo-tile {
  display: inline-grid;
  place-items: center;
  width: 30px;
  height: 36px;
  border-radius: 7px;
  background: var(--ivory);
  color: #e2485e;
  font-family: "Noto Sans SC", sans-serif;
  font-size: 18px;
  box-shadow: 0 4px 0 var(--pink-soft), 0 6px 10px rgba(90, 70, 130, 0.18);
}
.pills { display: flex; gap: 6px; margin-left: auto; align-items: center; }
.pill {
  background: rgba(255, 251, 242, 0.92);
  border-radius: 999px;
  padding: 5px 12px;
  font-weight: 600;
  font-size: 15px;
  box-shadow: 0 3px 0 rgba(90, 70, 130, 0.12);
  white-space: nowrap;
}
.pill.score { min-width: 54px; text-align: center; color: #e2487a; }
.hearts { letter-spacing: 1px; font-size: 15px; }
.hearts .lost { filter: grayscale(1); opacity: 0.35; }
.buttons { display: flex; gap: 6px; }
.icon-btn {
  width: 36px;
  height: 36px;
  border: 0;
  border-radius: 12px;
  background: var(--ivory);
  box-shadow: 0 3px 0 rgba(90, 70, 130, 0.18);
  font-weight: 700;
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
  padding: 0;
}
.icon-btn svg { width: 20px; height: 20px; }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(90, 70, 130, 0.18); }
.icon-btn.active { background: var(--pink-soft); }

@media (max-width: 560px) {
  .brand { display: none; }
  .pills { margin-left: 0; flex: 1; }
  .pill { padding: 4px 9px; font-size: 13.5px; }
  .hearts { font-size: 13px; }
  .icon-btn { width: 33px; height: 33px; }
}

/* ------------------------------------------------------------------ banner */

.banner {
  position: absolute;
  left: 50%;
  top: calc(64px + var(--safe-t));
  transform: translate(-50%, -12px) scale(0.96);
  opacity: 0;
  background: var(--ivory);
  border-radius: 18px;
  padding: 10px 18px;
  font-weight: 600;
  font-size: 16px;
  box-shadow: var(--shadow);
  text-align: center;
  max-width: min(92vw, 460px);
  transition: opacity 0.25s, transform 0.25s;
  pointer-events: none;
}
.banner.show { opacity: 1; transform: translate(-50%, 0) scale(1); }
.banner.ready { background: #fff3c4; }
.banner .big { display: block; font-size: 22px; font-weight: 700; color: #e2487a; }
.banner .chips { display: flex; justify-content: center; gap: 4px; margin-top: 6px; flex-wrap: wrap; }

.map-hint {
  position: absolute;
  left: 50%;
  top: calc(var(--top-h, 56px) + 56px);
  transform: translateX(-50%);
  background: rgba(74, 58, 102, 0.85);
  color: white;
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 14px;
  pointer-events: none;
  white-space: nowrap;
}

/* -------------------------------------------------------------------- rack */

#rack-wrap {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  padding: 8px 6px calc(10px + var(--safe-b));
  background: linear-gradient(to top, rgba(255, 251, 242, 0.97), rgba(255, 251, 242, 0.9));
  border-top-left-radius: 22px;
  border-top-right-radius: 22px;
  box-shadow: 0 -6px 20px rgba(90, 70, 130, 0.1);
}
.analysis {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 6px;
  align-items: center;
  justify-content: center;
  min-height: 24px;
  font-size: 13px;
  margin-bottom: 6px;
  color: var(--ink-soft);
}
.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  background: var(--lav);
  color: var(--ink);
  border-radius: 999px;
  padding: 2px 9px;
  font-weight: 600;
  font-size: 12.5px;
  white-space: nowrap;
}
.analysis.tappable { cursor: pointer; }
.chip.goal-more { background: none; padding: 0 2px; font-size: 15px; color: var(--ink-soft); }
.chip.gold { background: var(--butter); }
.chip.pink { background: var(--pink-soft); }
.chip.mint { background: var(--mint); }
.chip .fan { opacity: 0.7; font-weight: 500; }

.rack {
  --tile-w: min(46px, calc((100vw - 56px) / 13));
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 5px;
  max-width: 760px;
  margin: 0 auto;
}
.group { display: flex; flex-direction: column; align-items: center; gap: 3px; }
.group .tiles { display: flex; gap: 2px; }
.group .bar { height: 4px; width: 100%; border-radius: 2px; background: var(--gc, transparent); }
.group .label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--ink-soft);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  line-height: 1;
}
.rtile {
  position: relative;
  width: var(--tile-w);
  height: calc(var(--tile-w) * 1.22);
  border-radius: calc(var(--tile-w) * 0.16);
  background: var(--ivory);
  box-shadow: 0 calc(var(--tile-w) * 0.1) 0 var(--back, #ffc4d2), 0 calc(var(--tile-w) * 0.12 + 3px) 6px rgba(90, 70, 130, 0.18);
  margin-bottom: calc(var(--tile-w) * 0.1);
}
.rtile canvas { width: 100%; height: 100%; display: block; border-radius: inherit; }
.rtile.empty {
  background: rgba(215, 200, 247, 0.25);
  box-shadow: inset 0 0 0 2px rgba(150, 130, 200, 0.25);
}
.rtile.bonus { background: #fff3c4; box-shadow: inset 0 0 0 2px #ffd36b; display: grid; place-items: center; font-weight: 700; color: #d9902a; font-size: calc(var(--tile-w) * 0.5); }
.rtile.new { animation: pop 0.45s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes pop { 0% { transform: translateY(-14px) scale(1.25); } 100% { transform: none; } }

/* --------------------------------------------------------------- overlays */

/* Flex + auto margins (not place-items: center) so a card taller than the
   screen starts at the top and scrolls all the way to both ends. */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(16px + var(--safe-t)) 16px calc(24px + var(--safe-b));
  background: rgba(200, 230, 240, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  z-index: 10;
}
.overlay > .card { margin: auto; flex: none; }
.overlay.hidden, .hidden { display: none !important; }
.card {
  background: var(--ivory);
  border-radius: 26px;
  padding: 22px 22px 18px;
  box-shadow: 0 8px 0 var(--pink-soft), 0 18px 40px rgba(90, 70, 130, 0.22);
  width: min(100%, 440px);
  text-align: center;
  animation: rise 0.35s cubic-bezier(.3, 1.4, .5, 1);
}
.card h2 { margin: 0 0 6px; }

/* Home button at the top of every sub-screen */
.card-nav { display: flex; margin: -8px -8px 6px; }
.nav-home {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 36px;
  padding: 0 12px 0 9px;
  border: 0;
  border-radius: 999px;
  background: var(--ivory-2);
  font-size: 14.5px;
  font-weight: 600;
  color: var(--ink-soft);
  cursor: pointer;
}
.nav-home svg { width: 18px; height: 18px; }
.nav-home:active { transform: translateY(1px); }
@keyframes rise { from { transform: translateY(20px) scale(0.96); opacity: 0; } }

/* No ads seal: a red chop stamped over the title card's corner (game.js renderTitleNoAds) */
.title-card { position: relative; }
#screen-title.sealed { padding-top: calc(60px + var(--safe-t)); } /* room above the card on short phones */
.ad-seal { position: absolute; top: -50px; right: 10px; display: flex; align-items: center; gap: 8px; padding: 0; border: 0; background: none; font: inherit; cursor: pointer; }
.ad-seal .seal-chop {
  display: grid; place-items: center; width: 60px; height: 60px; border-radius: 11px;
  background: #d8344c; color: #fff4ec; transform: rotate(8deg);
  font: 700 18px/1 "Noto Sans SC", "PingFang SC", sans-serif; writing-mode: vertical-rl;
  box-shadow: inset 0 0 0 3px #d8344c, inset 0 0 0 5px #fff4ec, 0 4px 0 #a82238, 0 8px 16px rgba(150, 40, 70, 0.3);
}
.ad-seal .seal-tag { padding: 6px 10px; border-radius: 999px; background: var(--ink); color: #fff; font-size: 13px; font-weight: 700; white-space: nowrap; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.2); }
.ad-seal:active .seal-chop { transform: rotate(8deg) translateY(2px); box-shadow: inset 0 0 0 3px #d8344c, inset 0 0 0 5px #fff4ec, 0 2px 0 #a82238; }
.ad-seal.stamp .seal-chop { animation: seal-stamp 0.55s 0.25s cubic-bezier(.2, 1.6, .4, 1) both; }
.ad-seal.stamp .seal-tag { animation: seal-tag 0.3s 0.6s both; }
@keyframes seal-stamp { 0% { transform: rotate(-6deg) scale(2.1); opacity: 0; } 55% { transform: rotate(10deg) scale(0.92); opacity: 1; } 100% { transform: rotate(8deg) scale(1); } }
@keyframes seal-tag { from { opacity: 0; transform: translateX(8px); } }
@media (prefers-reduced-motion: reduce) { .ad-seal.stamp .seal-chop, .ad-seal.stamp .seal-tag { animation: none; } }

.title-tiles { display: flex; justify-content: center; gap: 5px; margin: 4px 0 10px; }
.title-tiles span {
  display: grid;
  place-items: center;
  width: clamp(32px, 10vw, 46px);
  height: clamp(40px, 12.5vw, 56px);
  background: var(--ivory);
  border-radius: 9px;
  font-size: clamp(20px, 6.4vw, 30px);
  font-weight: 700;
  color: var(--ink);
  box-shadow: 0 6px 0 var(--c), 0 9px 14px rgba(90, 70, 130, 0.2), inset 0 0 0 2px rgba(190, 170, 140, 0.25);
  animation: bob 2.4s ease-in-out infinite;
}
.title-tiles span:nth-child(2n) { animation-delay: 0.3s; }
.title-tiles span:nth-child(3n) { animation-delay: 0.6s; }
@keyframes bob { 50% { transform: translateY(-6px); } }
.tagline { margin: 6px 0 4px; font-size: 16px; color: var(--ink-soft); }
.day-line { font-weight: 600; color: #e2487a; margin: 6px 0; }
.how { text-align: left; padding-left: 20px; margin: 10px 0; line-height: 1.45; font-size: 15px; }
.how li { margin: 4px 0; }
.menu { display: flex; flex-direction: column; gap: 12px; margin-top: 14px; }
.menu-daily {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  background: white;
  border-radius: 20px;
  padding: 12px 14px 6px;
  box-shadow: 0 4px 0 var(--pink-soft), 0 6px 14px rgba(90, 70, 130, 0.08);
}
.menu-daily .day-line { margin: 0; }
.menu-daily .btn.primary { width: 100%; margin-top: 8px; }
.menu-daily .link { margin-top: 6px; }
.menu-daily .blitz-item { margin-bottom: 8px; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: 60px;
  padding: 10px 14px;
  border: 0;
  border-radius: 18px;
  background: var(--lav);
  box-shadow: 0 5px 0 rgba(90, 70, 130, 0.25);
  text-align: left;
  cursor: pointer;
  transition: transform 0.08s;
}
.menu-item:active:not(:disabled) { transform: translateY(4px); box-shadow: 0 1px 0 rgba(90, 70, 130, 0.25); }
.menu-item.adventure { background: var(--mint); box-shadow: 0 5px 0 #86c99c; }
.menu-item.matchplay { background: var(--sky); box-shadow: 0 5px 0 #7fb6dd; }
.menu-item.endless { background: var(--butter); box-shadow: 0 5px 0 #e9b94c; }
.new-tag {
  display: inline-block;
  background: #3b78d4;
  color: white;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
}
.mi-icon { font-size: 24px; line-height: 1; flex: none; }
.mi-text { display: flex; flex-direction: column; flex: 1; min-width: 0; line-height: 1.2; }
.mi-text b { font-size: 18px; }
.mi-text small { font-size: 13px; color: var(--ink-soft); font-weight: 500; }
.mi-side { flex: none; font-size: 14px; font-weight: 600; color: #d9902a; white-space: nowrap; }
.soon-tag {
  display: inline-block;
  background: var(--ink-soft);
  color: white;
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border-radius: 999px;
  padding: 3px 8px;
}
.menu-pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.menu-item.small { min-height: 52px; gap: 8px; padding: 8px 12px; justify-content: center; }
.menu-item.small .mi-icon { font-size: 19px; }
.menu-item.small .mi-text { flex: none; }
.menu-item.small .mi-text b { font-size: 16px; }

/* Shorter phones: the whole title menu fits without scrolling, No ads seal included */
@media (max-height: 900px) {
  #screen-title { padding-top: calc(10px + var(--safe-t)); padding-bottom: calc(10px + var(--safe-b)); }
  #screen-title.sealed { padding-top: calc(46px + var(--safe-t)); }
  .title-card { padding: 16px 16px 14px; }
  #screen-title.sealed .title-card { padding-top: 24px; } /* the chop's corner clears the tiles */
  .title-card .ad-seal { top: -46px; }
  .title-card .title-tiles { margin: 0 0 6px; }
  .title-card .title-tiles span { height: clamp(38px, 11.5vw, 50px); }
  .title-card .tagline { font-size: 15px; margin: 6px 0 0; line-height: 1.25; text-wrap: balance; }
  .title-card .menu { gap: 10px; margin-top: 10px; }
  .title-card .menu-daily { padding: 10px 12px 4px; }
  .title-card .menu-item { min-height: 54px; padding: 8px 12px; }
  .title-card .menu-item.small { min-height: 46px; }
}
@media (max-height: 760px) {
  .title-card .tagline { display: none; }
  .title-card .title-tiles span { height: 38px; font-size: 22px; box-shadow: 0 4px 0 var(--c), 0 6px 10px rgba(90, 70, 130, 0.2), inset 0 0 0 2px rgba(190, 170, 140, 0.25); }
  .title-card .mi-text small { font-size: 12.5px; }
}
@media (max-height: 700px) {
  #screen-title { padding-top: calc(6px + var(--safe-t)); padding-bottom: calc(6px + var(--safe-b)); }
  #screen-title.sealed { padding-top: calc(42px + var(--safe-t)); }
  .title-card { padding-bottom: 10px; }
  .title-card .menu { gap: 8px; }
  .title-card .menu-item { min-height: 50px; padding: 6px 12px; }
  .title-card .menu-daily .btn.primary { padding: 10px 20px; }
}

/* Wide screens (iPhone Duo open, iPad landscape): the daily on the left, the other modes on the right */
@media (min-width: 720px) and (orientation: landscape) {
  #screen-title .title-card { width: min(100%, 820px); }
  .title-card .menu { display: grid; grid-template-columns: 1fr 1fr; grid-template-rows: repeat(4, auto) 1fr; column-gap: 14px; align-items: start; }
  .title-card .menu-daily { grid-column: 1; grid-row: 1 / -1; align-self: stretch; justify-content: center; }
  .title-card .menu > :not(.menu-daily) { grid-column: 2; }
  .title-card .tagline { display: block; }
}

/* settings */
.settings-card { text-align: left; }
.settings-card h2 { text-align: center; }
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 52px;
  padding: 6px 2px;
  border-bottom: 1px dashed rgba(150, 130, 200, 0.3);
  font-size: 17px;
  font-weight: 600;
}
.btn.slim { padding: 7px 16px; font-size: 15px; box-shadow: 0 4px 0 rgba(90, 70, 130, 0.25); }
.setting-row .btn.slim { flex: none; white-space: nowrap; }
.setting-row .btn.slim:disabled { opacity: 0.5; cursor: default; transform: none; }
.switch {
  position: relative;
  width: 54px;
  height: 32px;
  border: 0;
  border-radius: 999px;
  background: #ddd3ea;
  cursor: pointer;
  transition: background 0.15s;
  flex: none;
}
.switch span {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: white;
  box-shadow: 0 2px 4px rgba(90, 70, 130, 0.3);
  transition: transform 0.15s;
}
.switch[aria-checked="true"] { background: var(--pink); }
.switch[aria-checked="true"] span { transform: translateX(22px); }
.settings-card .account:not([hidden]) { border-top: 0; margin-top: 8px; }
.setting-sub { display: block; font-size: 13px; font-weight: 500; color: var(--ink-soft); }
.setting-note { margin: 8px 2px 0; font-size: 13.5px; color: var(--ink-soft); }

/* end screen: offer the daily reminder (client/src/notify.js) */
.ad-next { margin: 10px 0 2px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 10px; font-size: 14px; font-weight: 500; color: var(--ink-soft); text-align: center; }
.ad-next .btn.slim { background: var(--butter); color: var(--ink); }
.end-nudge { margin: 12px 0 4px; padding: 12px 14px; border-radius: 18px; background: var(--ivory-2); }
.end-nudge p { margin: 0; font-size: 15px; font-weight: 600; text-wrap: balance; }
.nudge-actions { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 6px 14px; margin-top: 10px; }
.end-nudge .nudge-thanks { font-weight: 500; color: var(--ink-soft); }

.kbd-hint { color: var(--ink-soft); }
@media (pointer: coarse) { .kbd-hint { display: none; } }
.best-line { font-size: 14px; color: var(--ink-soft); }
.best-line:empty { display: none; }

.btn-row { display: flex; gap: 10px; justify-content: center; margin-top: 12px; flex-wrap: wrap; }
.btn-row.small { margin-top: 8px; gap: 18px; }
.btn {
  border: 0;
  border-radius: 16px;
  padding: 12px 20px;
  font-size: 17px;
  font-weight: 600;
  background: var(--lav);
  box-shadow: 0 5px 0 rgba(90, 70, 130, 0.25);
  cursor: pointer;
  transition: transform 0.08s;
}
.btn.primary { background: var(--pink); color: white; box-shadow: 0 5px 0 #e2668e; }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(90, 70, 130, 0.25); }
.link {
  border: 0;
  background: none;
  color: var(--ink-soft);
  text-decoration: underline;
  font-size: 14px;
  cursor: pointer;
  margin-top: 8px;
}

.end-title { font-size: 28px; font-weight: 700; }
.end-sub { color: var(--ink-soft); font-size: 15px; margin-top: 2px; }
.end-score { font-size: 56px; font-weight: 700; color: #e2487a; line-height: 1.1; margin: 6px 0 4px; }
.end-hand { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 6px; margin: 10px 0; }
.end-hand .group { --tile-w: min(30px, calc((100vw - 90px) / 15)); }
.end-yaku { display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; margin: 8px 0; }
.end-breakdown { font-size: 14px; color: var(--ink-soft); line-height: 1.6; }
.end-breakdown b { color: var(--ink); }
.end-par { font-size: 13px; color: var(--ink-soft); margin-top: 6px; }

.help-card { text-align: left; }
.help-card h2 { text-align: center; }
.help-card p { margin: 8px 0; font-size: 14.5px; line-height: 1.4; }
.rules { width: 100%; border-collapse: collapse; font-size: 14px; }
.rules td { padding: 4px 6px; border-bottom: 1px dashed rgba(150, 130, 200, 0.3); }
.rules td:last-child { text-align: right; font-weight: 700; color: #e2487a; white-space: nowrap; }
.suits-key { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 13px; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 4px; background: var(--c); vertical-align: middle; }

.toast {
  position: absolute;
  left: 50%;
  bottom: 30px;
  transform: translateX(-50%);
  background: var(--ink);
  color: white;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 14px;
  z-index: 20;
}

/* --------------------------------------------------------------- controls */

.controls {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(var(--rack-h, 120px) + 8px);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 0 12px;
  max-width: 560px;
  margin: 0 auto;
  pointer-events: none;
}
.controls > * { pointer-events: auto; }
.hop-btn {
  flex: none;
  width: 76px;
  height: 76px;
  border: 0;
  border-radius: 24px;
  background: var(--ivory);
  box-shadow: 0 6px 0 var(--pink-soft), 0 10px 18px rgba(90, 70, 130, 0.22);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  transition: transform 0.08s, box-shadow 0.08s, background 0.15s;
}
.hop-btn.left { box-shadow: 0 6px 0 var(--lav), 0 10px 18px rgba(90, 70, 130, 0.22); }
.hop-btn .arr { font-size: 34px; line-height: 1; font-weight: 700; color: #ff6f9f; }
.hop-btn .lbl { font-size: 12px; font-weight: 600; color: var(--ink-soft); text-transform: uppercase; letter-spacing: 0.06em; }
.hop-btn.pressed {
  transform: translateY(5px);
  background: #ffe1ea;
  box-shadow: 0 1px 0 var(--pink-soft), 0 3px 8px rgba(90, 70, 130, 0.2);
}
.hop-btn.dim { opacity: 0.45; }
.hop-btn.pulse { animation: btnpulse 1.4s ease-out infinite; }
@keyframes btnpulse {
  0% { box-shadow: 0 6px 0 var(--pink-soft), 0 0 0 0 rgba(255, 111, 159, 0.55); }
  100% { box-shadow: 0 6px 0 var(--pink-soft), 0 0 0 18px rgba(255, 111, 159, 0); }
}

.center-slot {
  flex: 1;
  min-width: 0;
  height: 76px;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.center-slot > * { pointer-events: auto; }
.controls-hint {
  font-size: 13px;
  color: var(--ink-soft);
  text-align: center;
  background: rgba(255, 251, 242, 0.75);
  border-radius: 14px;
  padding: 6px 10px;
  line-height: 1.35;
}

/* the charge meter: one zone per cell in the lane */
.meter {
  position: relative;
  width: 100%;
  height: 58px;
  background: rgba(255, 251, 242, 0.95);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
}
.meter-segs { position: absolute; inset: 6px 8px; }
.seg {
  position: absolute;
  top: 0;
  bottom: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 9px;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-soft);
  transition: background 0.1s, transform 0.1s;
}
.seg + .seg { border-left: 1px dashed rgba(150, 130, 200, 0.35); border-radius: 0; }
.seg.water { color: #7fb7d6; font-size: 18px; }
.seg canvas { height: 38px; width: auto; border-radius: 5px; box-shadow: 0 3px 0 var(--back, #ffc4d2); }
.seg.on { background: rgba(255, 143, 177, 0.28); }
.seg.on.water { background: rgba(120, 180, 230, 0.3); }
.seg.on canvas { transform: translateY(-2px) scale(1.08); }
.seg.sel::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 2px solid #ff6f9f;
  border-radius: 9px;
}
.meter-needle {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 8px;
  width: 4px;
  margin-left: -2px;
  border-radius: 2px;
  background: #ff4f8b;
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

/* tile inspector */
.tile-info {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 251, 242, 0.97);
  border-radius: 16px;
  padding: 7px 10px;
  box-shadow: var(--shadow);
  max-width: 100%;
  font-size: 13px;
  line-height: 1.3;
}
.tile-info canvas { height: 46px; width: auto; border-radius: 6px; flex: none; box-shadow: 0 3px 0 var(--back, #ffc4d2); }
.tile-info .ti-name { font-weight: 700; font-size: 14.5px; }
.tile-info .ti-line { color: var(--ink-soft); }
.tile-info .ti-gain { color: #e2487a; font-weight: 700; }
.tile-info .ti-bad { color: #b07a3a; }

.center-btn {
  position: absolute;
  left: 50%;
  top: calc(var(--top-h, 56px) + 8px);
  transform: translateX(-50%);
  border: 0;
  border-radius: 999px;
  padding: 8px 16px;
  background: var(--ivory);
  font-weight: 600;
  font-size: 14px;
  box-shadow: 0 3px 0 rgba(90, 70, 130, 0.18);
  cursor: pointer;
}

@media (max-width: 380px) {
  .hop-btn { width: 66px; height: 66px; }
  .center-slot { height: 66px; }
}


/* ----------------------------------------------------------------- medals */

.targets { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 6px 0 2px; }
.targets .muted, .muted { color: var(--ink-soft); font-size: 13.5px; }
.medal-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  border-radius: 999px;
  padding: 4px 10px;
  font-weight: 700;
  font-size: 14px;
  background: var(--c, #eee);
}
.medal-chip.bronze { --c: #f6d9c4; }
.medal-chip.silver { --c: #e3e6ef; }
.medal-chip.gold { --c: #ffe7a3; }
.medal-chip.got { box-shadow: inset 0 0 0 2px rgba(74, 58, 102, 0.35); }
.medal-chip.miss { opacity: 0.55; }

.end-medal { font-size: 18px; font-weight: 700; margin-top: 4px; min-height: 1em; }
.end-medal .big { display: block; font-size: 54px; line-height: 1.1; animation: medalpop 0.6s cubic-bezier(.3, 1.6, .5, 1) 0.9s both; }
@keyframes medalpop { from { transform: scale(0) rotate(-30deg); } }
.ladder { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin: 2px 0 6px; }

/* -------------------------------------------------------------- bonus tray */

.help-card h2.sub { font-size: 18px; margin: 14px 0 0; }
.tray {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: wrap;
  min-height: 26px;
  margin-bottom: 4px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
.tray .tray-label { font-weight: 700; color: var(--ink); }
.tray-set, .tray-loose {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 2px 6px 2px 3px;
  border-radius: 999px;
  background: rgba(215, 200, 247, 0.45);
}
.tray-set { background: #ffe7a3; font-weight: 700; color: var(--ink); }
.tray-set.identical { background: #ffc4d2; }
.tray-set canvas, .tray-loose canvas { height: 22px; width: auto; border-radius: 3px; box-shadow: 0 2px 0 var(--back, #d7c8f7); }
.tray-set.celebrate { animation: setpop 0.9s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes setpop {
  0% { transform: scale(0.6); box-shadow: 0 0 0 0 rgba(255, 200, 80, 0.8); }
  40% { transform: scale(1.25); }
  100% { transform: none; box-shadow: 0 0 0 16px rgba(255, 200, 80, 0); }
}
.pill.bump { animation: bump 0.6s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes bump { 40% { transform: scale(1.3); background: #ffd6e2; } }

/* ------------------------------------------------------- medal progress bar */

.medal-bar {
  position: absolute;
  right: 8px;
  top: calc(var(--top-h, 56px) + 58px);
  bottom: calc(var(--rack-h, 120px) + var(--controls-h, 84px) + 18px);
  width: 16px;
  pointer-events: none;
}
.mb-track {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: rgba(255, 251, 242, 0.8);
  box-shadow: inset 0 0 0 2px rgba(150, 130, 200, 0.25), 0 3px 8px rgba(90, 70, 130, 0.15);
  overflow: hidden;
}
.mb-fill {
  position: absolute;
  left: 3px;
  right: 3px;
  bottom: 3px;
  height: 0;
  border-radius: 999px;
  background: linear-gradient(to top, #f0b48c, #c9cfe0 45%, #ffd36b);
  background-size: 100% var(--full, 300px);
  background-position: bottom;
  transition: height 0.7s cubic-bezier(.3, 1.3, .5, 1);
}
.mb-mark { position: absolute; right: -2px; transform: translateY(50%); display: flex; align-items: center; }
.mb-mark .line { width: 20px; height: 2px; background: rgba(74, 58, 102, 0.35); order: 2; }
.mb-mark .tag {
  order: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-right: 2px;
  padding: 2px 5px;
  border-radius: 10px;
  background: rgba(255, 251, 242, 0.92);
  font-size: 15px;
  line-height: 1.05;
  box-shadow: 0 2px 0 rgba(90, 70, 130, 0.12);
  filter: grayscale(0.8);
  opacity: 0.75;
  transition: filter 0.3s, opacity 0.3s;
}
.mb-mark .tag small { font-size: 10px; font-weight: 700; color: var(--ink-soft); }
.mb-mark.got .tag { filter: none; opacity: 1; }
.mb-mark.got .line { background: #ff6f9f; }
.mb-mark.pop .tag { animation: medalhit 1s cubic-bezier(.3, 1.6, .5, 1); }
@keyframes medalhit {
  0% { transform: scale(1); }
  30% { transform: scale(1.8) rotate(-12deg); box-shadow: 0 0 0 0 rgba(255, 211, 107, 0.9); }
  100% { transform: none; box-shadow: 0 0 0 22px rgba(255, 211, 107, 0); }
}

/* --------------------------------------------------------------- good route */

.btn.route { background: #fff3c4; box-shadow: 0 5px 0 #f0c95a; width: 100%; max-width: 320px; }
.btn.route:disabled { opacity: 0.6; cursor: default; }
.replay-bar {
  position: absolute;
  left: 50%;
  bottom: calc(var(--rack-h, 120px) + 12px);
  transform: translateX(-50%);
  width: min(94vw, 520px);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(74, 58, 102, 0.92);
  color: white;
  border-radius: 18px;
  padding: 10px 10px 10px 16px;
  box-shadow: var(--shadow);
}
.replay-text { flex: 1; min-width: 0; font-size: 15px; line-height: 1.3; }
.replay-step { display: block; font-size: 12px; font-weight: 700; color: #ffc4d2; text-transform: uppercase; letter-spacing: 0.06em; }
.replay-actions { display: flex; gap: 6px; }
.replay-actions .icon-btn { color: var(--ink); }
.replay-actions .icon-btn.active { background: var(--pink-soft); }

/* -------------------------------------------------------------- adventure */

.levels-card > .muted { margin: 0 0 12px; line-height: 1.4; }
.level-list { display: flex; flex-direction: column; gap: 14px; text-align: left; }
.chapter { background: white; border-radius: 18px; padding: 10px 12px 12px; box-shadow: 0 4px 0 var(--lav), 0 6px 14px rgba(90, 70, 130, 0.08); }
.chapter.locked { opacity: 0.6; }
.ch-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-size: 16.5px; }
.ch-stars { color: #d9902a; font-size: 13.5px; font-weight: 600; white-space: nowrap; }
.ch-blurb { color: var(--ink-soft); font-size: 12.5px; line-height: 1.3; margin: 2px 0 9px; }
.ch-levels { display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.level-tile {
  border: 0;
  border-radius: 11px;
  padding: 6px 0 4px;
  background: var(--ivory);
  box-shadow: 0 5px 0 var(--pink-soft), inset 0 0 0 2px rgba(190, 170, 140, 0.25);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  cursor: pointer;
  transition: transform 0.08s;
}
.level-tile:active { transform: translateY(2px); }
.level-tile.locked { cursor: default; box-shadow: 0 5px 0 #e9e2f2, inset 0 0 0 2px rgba(190, 170, 140, 0.18); }
.level-tile.current { box-shadow: 0 5px 0 var(--pink), inset 0 0 0 2px var(--pink); animation: bob 2.4s ease-in-out infinite; }
.lt-num { font-weight: 700; font-size: 20px; line-height: 1.2; }
.level-tile.locked .lt-num { font-size: 14px; line-height: 28px; }
.level-tile .lv-stars { font-size: 11px; letter-spacing: 0; min-height: 1.3em; }
.lv-stars span, .big-stars span { color: #e3dcef; }
.lv-stars span.on, .big-stars span.on { color: #ffc23d; text-shadow: 0 2px 0 #e59a1a; }

.lv-kicker { font-size: 13px; font-weight: 600; color: #e2487a; text-transform: uppercase; letter-spacing: 0.06em; }
/* Before a mode: how it's played (game.js withIntro) */
.intro-icon {
  display: grid; place-items: center; width: 64px; height: 72px; margin: 2px auto 10px;
  border-radius: 14px; background: var(--ivory); font-size: 34px; line-height: 1;
  box-shadow: 0 7px 0 var(--c, var(--pink-soft)), 0 10px 16px rgba(90, 70, 130, 0.2), inset 0 0 0 2px rgba(190, 170, 140, 0.25);
  animation: bob 2.4s ease-in-out infinite;
}
@media (prefers-reduced-motion: reduce) { .intro-icon { animation: none; } }
.intro-card[data-mode="daily"] { --c: var(--pink-soft); }
.intro-card[data-mode="blitz"] { --c: var(--ink); }
.intro-card[data-mode="endless"] { --c: var(--butter); }
.intro-card[data-mode="adventure"] { --c: var(--mint); }
.intro-card[data-mode="matchplay"] { --c: var(--sky); }
.intro-card .how { margin: 12px 0 4px; }
.intro-card .how li { margin: 7px 0; }
.intro-card .btn.primary { min-width: 60%; }
.intro-skip { display: inline-flex; align-items: center; gap: 8px; margin-top: 14px; font-size: 15px; color: var(--ink-soft); cursor: pointer; }
.intro-skip input { width: 20px; height: 20px; margin: 0; accent-color: var(--pink); }
@media (max-height: 700px) {
  .intro-icon { width: 52px; height: 58px; font-size: 28px; margin-bottom: 8px; }
  .intro-card .how li { margin: 5px 0; }
}

.brief-blurb { color: var(--ink-soft); margin: 4px 0 12px; line-height: 1.4; }
.goal-box { background: white; border-radius: 16px; padding: 10px 12px; box-shadow: inset 0 0 0 2px var(--lav); text-align: left; }
.goal-head { font-size: 12.5px; color: var(--ink-soft); margin-bottom: 6px; line-height: 1.35; }
.goal-head b { color: var(--ink); }
.goal-list { display: flex; flex-direction: column; gap: 7px; }
.goal-item { display: flex; align-items: center; gap: 10px; }
.gi-tiles { flex: none; display: flex; gap: 2px; width: 94px; }
.gi-tiles canvas { width: 22px; height: auto; border-radius: 4px; box-shadow: 0 3px 0 var(--back, #d7c8f7); }
.gi-text { display: flex; flex-direction: column; line-height: 1.25; }
.gi-text b { font-size: 15.5px; }
.gi-text small { color: var(--ink-soft); font-size: 12.5px; }

.star-list { list-style: none; padding: 0; margin: 12px auto 0; text-align: left; display: inline-flex; flex-direction: column; gap: 4px; font-size: 14.5px; }
.star-list li { display: flex; align-items: baseline; gap: 8px; }
.star-list .st { color: #ffc23d; text-shadow: 0 1px 0 #e59a1a; }
.star-list li.miss { color: var(--ink-soft); }
.star-list li.miss .st { color: #e3dcef; text-shadow: none; }
.star-list li.got::after { content: '✓'; color: #2c9a5c; font-weight: 700; }
.star-list small { color: var(--ink-soft); }

.big-stars { font-size: 50px; line-height: 1.1; margin: 4px 0 2px; letter-spacing: 4px; }
.big-stars span { display: inline-block; animation: medalpop 0.5s cubic-bezier(.3, 1.6, .5, 1) both; }
.big-stars span:nth-child(1) { animation-delay: 0.3s; }
.big-stars span:nth-child(2) { animation-delay: 0.55s; font-size: 1.15em; }
.big-stars span:nth-child(3) { animation-delay: 0.8s; }

.chip.goal { background: white; box-shadow: inset 0 0 0 1.5px var(--lav); color: var(--ink-soft); }
.chip.goal.done { background: var(--mint); box-shadow: none; color: var(--ink); }
.chip.star-track { background: #fff3c4; }
.chip.star-track.over { opacity: 0.55; text-decoration: line-through; }

/* Account (title screen) */
.account:not([hidden]) { display: grid; justify-items: center; gap: 8px; margin-top: 14px; padding-top: 12px; border-top: 1px dashed var(--pink-soft); text-align: center; }
.account-line { margin: 0; font-size: 14px; color: var(--ink-soft); }
.account-line b { color: var(--ink); }
.account-google { min-height: 40px; }
.account-error { margin: 0; font-size: 13px; color: #c23b55; }
.account-native { display: grid; gap: 10px; width: min(100%, 280px); }
.signin-btn {
  display: flex; align-items: center; justify-content: center; gap: 8px;
  height: 44px; border-radius: 22px; font: 600 16px/1 -apple-system, system-ui, sans-serif; cursor: pointer;
}
.signin-btn.apple { background: #000; color: #fff; border: 0; }
.signin-btn.google { background: #fff; color: #1f1f1f; border: 1px solid #747775; }
.signin-logo { display: inline-flex; font-size: 19px; line-height: 1; }
.signin-logo svg { width: 18px; height: 18px; }

/* Live update download (iOS app) */
#screen-update { z-index: 30; background: rgba(200, 230, 240, 0.85); }
.update-card .title-tiles { margin-bottom: 14px; }
.update-track { height: 14px; margin: 16px 6px 6px; border-radius: 999px; background: var(--ivory-2); overflow: hidden; box-shadow: inset 0 1px 3px rgba(90, 70, 130, 0.18); }
.update-bar { width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--pink), #e2487a); transition: width 0.25s ease-out; }
.update-pct { font-size: 14px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------- matchplay */

.mp-card { text-align: left; }
.mp-card h2 { text-align: center; }
.mp-block { display: grid; gap: 10px; justify-items: center; padding: 14px; border-radius: 18px; background: var(--ivory-2); margin-bottom: 12px; }
.mp-block .btn { width: 100%; max-width: 280px; }
.menu-item.mp-local { width: 100%; justify-content: flex-start; background: var(--lav); }
.mp-rules { margin-top: 14px; font-size: 14px; line-height: 1.4; }
.mp-rules summary { cursor: pointer; font-weight: 600; color: var(--ink-soft); }
.mp-rules ul { margin: 8px 0 0; padding-left: 20px; }
.mp-rules li { margin-bottom: 5px; }

.draw-card h2 { margin-bottom: 14px; }
.draw-row { display: flex; justify-content: center; gap: 26px; perspective: 700px; }
.wtile { width: 74px; height: 96px; position: relative; transform-style: preserve-3d; transition: transform 0.6s cubic-bezier(.3, 1.4, .5, 1); }
.wtile .face, .wtile .back { position: absolute; inset: 0; border-radius: 12px; backface-visibility: hidden; display: grid; place-items: center; }
.wtile .back { background: linear-gradient(160deg, #7fc8a0, #3f9d6e); box-shadow: inset 0 -6px 0 rgba(0, 0, 0, 0.18), 0 3px 8px rgba(40, 30, 70, 0.25); }
.wtile .back::after { content: ""; width: 44px; height: 62px; border-radius: 8px; border: 2px solid rgba(255, 255, 255, 0.45); }
.wtile .face { background: var(--ivory); transform: rotateY(180deg); box-shadow: inset 0 -6px 0 var(--pink-soft), 0 3px 8px rgba(40, 30, 70, 0.25); font-family: "Noto Sans SC", sans-serif; font-size: 40px; color: #5b4fb0; align-content: center; gap: 0; }
.wtile .face small { font-family: var(--font); font-size: 11px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--ink-soft); }
.wtile.flipped { transform: rotateY(180deg); }
.wtile.shuffle { animation: wind-hop 0.32s ease-in-out 3 alternate; }
.wtile.shuffle.r { animation-delay: 0.16s; }
@keyframes wind-hop { to { transform: translateY(-18px) rotate(-6deg); } }
.draw-who { display: flex; justify-content: center; gap: 26px; margin-top: 8px; }
.draw-who span { width: 74px; font-weight: 600; font-size: 14px; color: var(--ink-soft); }
.draw-msg { min-height: 2.6em; margin-top: 10px; }
@media (prefers-reduced-motion: reduce) { .wtile, .wtile.shuffle { transition: none; animation: none; } }

.opp-strip {
  position: absolute;
  top: calc(56px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  width: min(calc(100% - 16px), 560px);
  padding: 6px 10px 7px;
  border-radius: 16px;
  background: rgba(255, 251, 242, 0.93);
  box-shadow: 0 3px 0 rgba(90, 70, 130, 0.12);
  display: grid;
  gap: 5px;
  pointer-events: none;
}
.opp-head { display: flex; align-items: center; gap: 7px; font-size: 13.5px; min-width: 0; }
.opp-head b { white-space: nowrap; }
.opp-dot { width: 10px; height: 10px; border-radius: 50%; flex: none; }
.opp-meta { color: var(--ink-soft); font-size: 12.5px; font-weight: 600; display: inline-flex; align-items: center; gap: 3px; min-width: 0; overflow: hidden; white-space: nowrap; }
.opp-meta.ready { background: #fff3c4; color: #b07400; border-radius: 8px; padding: 1px 6px; }
.opp-meta .chip { transform: scale(0.85); }
.opp-score { margin-left: auto; font-weight: 700; font-size: 16px; color: #e2487a; font-variant-numeric: tabular-nums; }
.opp-rack { display: flex; flex-wrap: wrap; gap: 2px; align-items: flex-end; min-height: 22px; --tile-w: 18px; }
.opp-rack .rtile { margin-bottom: 2px; }
.opp-tray { display: inline-flex; gap: 2px; margin-left: 6px; padding-left: 6px; border-left: 1px dashed rgba(150, 130, 200, 0.5); --tile-w: 14px; }
.match-mode .banner { top: calc(122px + var(--safe-t)); }
.match-mode .map-hint { top: calc(var(--top-h, 56px) + 110px); }

.mend-seats { display: grid; gap: 10px; margin: 14px 0 4px; }
.mend-seat { border-radius: 18px; padding: 10px 12px; background: var(--ivory-2); border: 2px solid transparent; }
.mend-seat.won { border-color: var(--seat); background: var(--ivory); }
.mend-head { display: flex; align-items: center; gap: 8px; }
.mend-wind { font-family: "Noto Sans SC", sans-serif; color: var(--seat); font-size: 20px; }
.mend-why { font-size: 13px; color: var(--ink-soft); font-weight: 600; }
.mend-score { margin-left: auto; font-size: 26px; font-weight: 700; color: var(--seat); font-variant-numeric: tabular-nums; }
.mend-seat .end-hand { margin: 6px 0 2px; }
.mend-seat .end-hand .group { --tile-w: min(24px, calc((100vw - 110px) / 15)); }
.mend-detail { font-size: 13px; color: var(--ink-soft); }

/* online matches */
.menu-item.matchplay .mi-side { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; } /* badge over New: keeps the subtitle wide */
.mp-badge:not(:empty) { display: inline-block; background: #e2485e; color: white; font-size: 11px; font-weight: 700; border-radius: 999px; padding: 3px 8px; }
.mp-h { justify-self: start; font-size: 16px; }
.mp-friends { justify-items: stretch; }
.mp-friends .btn { justify-self: center; }
.mp-friends .mp-seg { display: grid; grid-template-columns: 1fr 1fr; border-radius: 14px; }
.mp-friends .mp-seg button { border-radius: 11px; padding: 7px 6px; white-space: nowrap; }
.mp-name { display: grid; gap: 4px; font-size: 13px; font-weight: 600; color: var(--ink-soft); }
.mp-name input, .mp-join input {
  font: inherit; font-size: 16px; font-weight: 600; color: var(--ink);
  border: 0; border-radius: 12px; padding: 9px 12px; background: var(--ivory);
  box-shadow: inset 0 0 0 1.5px rgba(150, 130, 200, 0.35); min-width: 0;
}
.mp-name input:focus, .mp-join input:focus { outline: none; box-shadow: inset 0 0 0 2px var(--pink); }
.mp-join { display: flex; gap: 8px; align-items: center; }
.mp-join input { flex: 1 1 auto; width: 100%; text-transform: uppercase; letter-spacing: 0.18em; }
.mp-join .btn { flex: none; width: auto; margin: 0; }
.mp-join input::placeholder { text-transform: none; letter-spacing: 0; }
.mp-error { margin: 0; font-size: 13.5px; color: #c23b55; }
.mp-offline { margin: 0 0 12px; font-size: 14px; color: var(--ink-soft); text-align: center; }
.mp-list { display: grid; gap: 6px; margin-top: 4px; }
.mp-row {
  display: flex; align-items: center; gap: 8px; width: 100%; padding: 9px 12px;
  border: 0; border-radius: 14px; background: var(--ivory); font: inherit; font-size: 14.5px; text-align: left; cursor: pointer;
  box-shadow: 0 3px 0 rgba(90, 70, 130, 0.14);
}
.mp-row.turn { box-shadow: 0 3px 0 #e2668e, inset 0 0 0 2px var(--pink); }
.mp-row-text { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mp-row-side { font-size: 13px; font-weight: 700; color: var(--ink-soft); white-space: nowrap; }
.mp-row.turn .mp-row-side { color: #e2485e; }

.invite-card h2 { margin-bottom: 4px; }
.inv-code { font-size: 44px; font-weight: 700; letter-spacing: 0.16em; margin: 12px 0 2px; color: var(--ink); font-variant-numeric: tabular-nums; }
.inv-link { font-size: 14px; color: var(--ink-soft); word-break: break-all; user-select: text; -webkit-user-select: text; }
.inv-wait { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 16px 0 4px; font-weight: 600; color: var(--ink-soft); }
.inv-dot { width: 10px; height: 10px; border-radius: 50%; background: var(--pink); animation: inv-pulse 1.2s ease-in-out infinite; }
@keyframes inv-pulse { 50% { transform: scale(0.5); opacity: 0.4; } }
@media (prefers-reduced-motion: reduce) { .inv-dot { animation: none; } }
.inv-notify { display: flex; align-items: center; gap: 10px; margin-top: 10px; padding: 10px 12px; border-radius: 16px; background: var(--ivory-2); font-size: 14px; text-align: left; }

/* find a match */
.mp-find { width: 100%; max-width: none !important; font-size: 18px; padding: 12px; }
.mp-sub { margin-top: 6px; font-size: 14px; color: var(--ink-soft); }
.search-card h2 { margin-bottom: 12px; }
.search-tiles { display: flex; justify-content: center; gap: 8px; margin: 6px 0 14px; }
.search-tiles span {
  display: grid; place-items: center; width: 40px; height: 52px; border-radius: 9px; background: var(--ivory);
  box-shadow: 0 5px 0 var(--pink-soft), 0 6px 10px rgba(90, 70, 130, 0.18);
  font-family: "Noto Sans SC", sans-serif; font-size: 22px; color: #5b4fb0;
  animation: search-hop 1.6s ease-in-out infinite;
}
.search-tiles span:nth-child(2) { animation-delay: 0.2s; }
.search-tiles span:nth-child(3) { animation-delay: 0.4s; }
.search-tiles span:nth-child(4) { animation-delay: 0.6s; }
@keyframes search-hop { 0%, 60%, 100% { transform: none; } 30% { transform: translateY(-10px); } }
@media (prefers-reduced-motion: reduce) { .search-tiles span { animation: none; } }
.search-time { font-size: 15px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-top: 4px; }

/* ---------------------------------------------------------------- profile */

.mi-avatar { width: 30px; height: 30px; flex: none; }
.menu-item.small { position: relative; }
.mi-dot { position: absolute; top: 7px; right: 9px; width: 10px; height: 10px; border-radius: 50%; background: #ff4f8b; box-shadow: 0 0 0 2px var(--ivory); }
.nav-gear { margin-left: auto; }

.profile-card { text-align: left; display: flex; flex-direction: column; gap: 12px; }
.pf-top { display: grid; grid-template-columns: 92px 1fr; gap: 12px; align-items: center; }
.pf-avatar { position: relative; border: 0; padding: 0; background: none; cursor: pointer; width: 92px; height: 92px; border-radius: 50%; }
.pf-avatar svg { width: 92px; height: 92px; display: block; filter: drop-shadow(0 4px 0 rgba(255, 196, 210, 0.9)); }
.pf-edit {
  position: absolute; right: -2px; bottom: 0; background: var(--ink); color: white; border-radius: 999px;
  font-size: 12px; font-weight: 600; padding: 2px 8px; box-shadow: 0 2px 0 rgba(0, 0, 0, 0.15);
}
.pf-avatar .pf-medal { position: absolute; left: -4px; bottom: -2px; width: 34px; height: 34px; filter: drop-shadow(0 2px 0 rgba(0, 0, 0, 0.15)); }
.pf-avatar:focus-visible { outline: 3px solid var(--pink); outline-offset: 3px; }
.pf-who { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.pf-who input {
  font: inherit; font-size: 21px; font-weight: 600; color: var(--ink); border: 0; border-bottom: 2px dashed rgba(122, 108, 149, 0.35);
  background: transparent; padding: 2px 0; width: 100%; min-width: 0; border-radius: 0;
}
.pf-who input:focus { outline: none; border-bottom-color: var(--pink); }
.pf-who input:disabled { border-bottom-color: transparent; }
.pf-streak { font-size: 14px; color: var(--ink-soft); font-weight: 500; }
.pf-match {
  display: flex; flex-direction: column; gap: 1px; background: #e9f8ef; border-radius: 14px; padding: 8px 12px; font-size: 14px;
}
.pf-match b { font-size: 14.5px; }
.pf-match span { color: #4d7a63; }
.pf-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; text-align: center; }
.pf-stats div { background: var(--ivory-2); border-radius: 12px; padding: 6px 2px; }
.pf-stats b { display: block; font-size: 18px; font-variant-numeric: tabular-nums; }
.pf-stats small { font-size: 11.5px; color: var(--ink-soft); }
.pf-pinned { display: flex; gap: 10px; align-items: center; background: #fff3c4; border-radius: 14px; padding: 8px 12px; }
.pf-pinned svg { width: 42px; height: 42px; flex: none; }
.pf-pinned span { display: flex; flex-direction: column; line-height: 1.25; }
.pf-pinned small { color: var(--ink-soft); font-size: 13px; }
.pf-case { display: flex; flex-direction: column; gap: 8px; }
.pf-h {
  display: flex; justify-content: space-between; font-size: 12px; text-transform: uppercase; letter-spacing: 0.07em;
  color: var(--ink-soft); font-weight: 600; margin-top: 4px;
}
.pf-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(72px, 1fr)); gap: 6px 4px; }
.pf-badge {
  border: 0; background: none; padding: 2px; display: flex; flex-direction: column; align-items: center; gap: 2px;
  font: inherit; font-size: 11.5px; line-height: 1.15; color: var(--ink-soft); cursor: pointer; text-align: center; border-radius: 12px;
}
.pf-badge svg { width: 100%; max-width: 64px; aspect-ratio: 1; height: auto; }
.pf-badge:focus-visible { outline: 3px solid var(--pink); }
.pf-badge:active svg { transform: scale(0.95); }
.pf-note { font-size: 13.5px; color: var(--ink-soft); margin: 0; }

.badge-card { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.badge-card h2 { margin: 0; }
.bd-medal { width: 128px; height: 128px; }
.bd-family { font-size: 12.5px; font-weight: 600; letter-spacing: 0.07em; text-transform: uppercase; color: #e2487a; }
.bd-help { margin: 0; color: var(--ink-soft); line-height: 1.45; max-width: 34ch; }
.bd-progress { font-weight: 600; background: var(--ivory-2); border-radius: 999px; padding: 3px 12px; font-variant-numeric: tabular-nums; }
#screen-badge, #screen-avatar { z-index: 12; }

.avatar-card { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.avatar-card h2 { margin: 0; }
.av-preview { width: 140px; height: 140px; }
.av-groups { display: flex; flex-direction: column; gap: 8px; width: 100%; text-align: left; }
.av-group { display: flex; flex-direction: column; gap: 4px; }
.av-label { font-weight: 600; font-size: 14px; }
.av-label small { font-weight: 500; color: var(--ink-soft); }
.av-groups .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.av-groups .chips button {
  font: inherit; font-weight: 600; font-size: 13.5px; color: var(--ink); background: var(--ivory-2); border: 0; border-radius: 999px;
  padding: 5px 11px; cursor: pointer; box-shadow: 0 2px 0 rgba(90, 70, 130, 0.12); min-height: 32px;
}
.av-groups .chips button[aria-pressed="true"] { background: var(--pink); color: white; }
.av-groups .chips button:disabled { opacity: 0.5; cursor: default; }
.av-groups .chips .sw { display: block; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1px rgba(0, 0, 0, 0.15); }

/* new badges on the results screens */
.new-badges { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin: 10px 0 4px; }
.new-badge {
  display: flex; align-items: center; gap: 8px; border: 0; cursor: pointer; font: inherit; color: var(--ink); text-align: left;
  background: #fff3c4; border-radius: 16px; padding: 6px 12px 6px 6px; box-shadow: 0 3px 0 #f0c95a;
  animation: badgepop 0.6s cubic-bezier(.3, 1.6, .5, 1) 0.3s both;
}
.new-badge svg { width: 44px; height: 44px; flex: none; }
.new-badge span { display: flex; flex-direction: column; line-height: 1.2; }
.new-badge small { font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #b07400; }
@keyframes badgepop { from { transform: scale(0.4); opacity: 0; } }

/* flair: avatars and pinned badges next to names in matches */
.opp-av { width: 26px; height: 26px; flex: none; }
.opp-flair { display: inline-flex; align-items: center; gap: 4px; flex: none; }
.mini-medal { width: 22px; height: 22px; flex: none; }
.flame-chip { font-size: 12px; font-weight: 600; background: #ffe7cf; color: #b35a1c; border-radius: 999px; padding: 0 6px; white-space: nowrap; }
.draw-who .who { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 74px; }
.who-av { width: 52px; height: 52px; }
.mend-av { width: 28px; height: 28px; flex: none; }
.mend-head .mini-medal { width: 20px; height: 20px; }
@media (prefers-reduced-motion: reduce) { .new-badge { animation: none; } }

/* ------------------------------------------------- the Dragon Gate ranks */
.rank-badge { display: block; width: 100%; height: 100%; }
.rb { display: inline-grid; place-items: center; flex: none; vertical-align: middle; }
.rb.sm { width: 22px; height: 24px; } .rb.md { width: 34px; height: 37px; } .rb.lg { width: 56px; height: 62px; } .rb.xl { width: 104px; height: 116px; }
.rank-card {
  display: grid; grid-template-columns: auto minmax(0, 1fr); gap: 4px 12px; align-items: center; width: 100%;
  padding: 10px 12px; border: 0; border-radius: 16px; background: var(--ivory); text-align: left; cursor: pointer;
  font: inherit; color: inherit; box-shadow: 0 3px 0 rgba(90, 70, 130, 0.14);
}
.rank-card .rb { grid-row: span 4; }
.rank-card .rc-name { font-weight: 700; font-size: 17px; display: flex; align-items: center; gap: 6px; }
.rank-card .rc-jade { font-weight: 700; color: #2c9a5c; font-variant-numeric: tabular-nums; font-size: 14.5px; }
.rank-card .rc-bar { height: 8px; border-radius: 5px; background: #efe5d3; overflow: hidden; }
.rank-card .rc-bar i { display: block; height: 100%; border-radius: 5px; background: var(--rc, #2f6fc9); }
.rank-card .rc-line { grid-column: 2; font-size: 12.5px; color: var(--ink-soft); font-weight: 600; }
.pips { display: inline-flex; gap: 3px; }
.pips i { width: 8px; height: 8px; border-radius: 50%; background: rgba(150, 130, 200, 0.3); }
.pips i.on { background: #2c9a5c; }
.pf-match .rank-card { margin-bottom: 8px; }
.opp-rank:empty { display: none; }
.who-rank { display: flex; align-items: center; justify-content: center; gap: 4px; font-size: 12px; font-weight: 600; color: var(--ink-soft); min-height: 24px; }
.who-rank:empty { display: none; }
.mend-rank { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 6px; font-size: 13.5px; font-weight: 600; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.mend-rank b.up { color: #2c9a5c; } .mend-rank b.down { color: #c23b55; }
.mend-rank .climb { color: #2c9a5c; font-weight: 700; }
.mend-rank .rc-bar { flex-basis: 100%; height: 8px; border-radius: 5px; background: #efe5d3; overflow: hidden; }
.mend-rank .rc-bar i { display: block; height: 100%; border-radius: 5px; background: var(--rc, #2f6fc9); transition: width 1.4s cubic-bezier(.3, 1, .4, 1); }
.ladder-card { text-align: left; }
.ladder-card h2 { text-align: center; }
.ladder-lede { margin: 0 0 12px; text-align: center; color: var(--ink-soft); font-size: 14.5px; }
.ladder-list { display: grid; gap: 4px; }
.ladder-list .lr { display: flex; align-items: center; gap: 10px; padding: 6px 10px; border-radius: 12px; font-weight: 600; }
.ladder-list .lr.you { background: #d9f3e2; }
.ladder-list .lr small { margin-left: auto; color: var(--ink-soft); font-variant-numeric: tabular-nums; }
.ladder-how { margin: 12px 0 0; padding-left: 20px; font-size: 13.5px; line-height: 1.45; }
.ladder-how li { margin-bottom: 5px; }
.rankup-card { text-align: center; background: linear-gradient(180deg, #fff3c4, var(--ivory) 60%); }
.rankup-badges { display: flex; align-items: center; justify-content: center; gap: 10px; margin: 6px 0 10px; }
.rankup-old { opacity: 0.45; }
.rankup-carp { font-size: 28px; }
@media (prefers-reduced-motion: no-preference) {
  .rankup-carp { animation: carp-leap 1.2s ease-in-out infinite; }
  .rankup-new { animation: rank-pop 0.6s cubic-bezier(.3, 1.6, .5, 1); }
}
@keyframes carp-leap { 0%, 100% { transform: translate(-14px, 6px) rotate(-30deg); } 50% { transform: translate(14px, -16px) rotate(30deg); } }
@keyframes rank-pop { from { transform: scale(0.4); opacity: 0; } }

/* ------------------------------------------------------- endless clock */

.big-clock {
  position: absolute;
  top: calc(62px + var(--safe-t));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 5px;
  padding: 6px 18px 9px;
  border-radius: 22px;
  background: rgba(255, 251, 242, 0.94);
  box-shadow: var(--shadow);
  pointer-events: none;
  z-index: 3;
}
.clock-face {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 38px;
  font-weight: 700;
  line-height: 1;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.clock-icon { font-size: 24px; }
.clock-track { width: 128px; height: 8px; border-radius: 99px; background: #eadff5; overflow: hidden; }
.clock-fill { height: 100%; width: 100%; border-radius: 99px; background: linear-gradient(90deg, #4fbf7a, #9be0b1); transition: width 0.25s linear; }
.big-clock.gain { animation: clock-gain 0.5s ease-out; }
.big-clock.loss { animation: clock-loss 0.45s ease-out; }
@keyframes clock-gain { 30% { transform: translateX(-50%) scale(1.14); box-shadow: 0 0 0 4px #7fd39b, var(--shadow); } }
@keyframes clock-loss { 20%, 60% { transform: translateX(calc(-50% - 6px)); } 40%, 80% { transform: translateX(calc(-50% + 6px)); } }
.big-clock.low .clock-face { color: #e2485e; }
.big-clock.low .clock-fill { background: linear-gradient(90deg, #e2485e, #ff8fb1); }
.big-clock.low:not(.gain):not(.loss) { animation: clock-beat 1s ease-in-out infinite; }
.big-clock.critical:not(.gain):not(.loss) { animation-duration: 0.5s; }
@keyframes clock-beat { 50% { transform: translateX(-50%) scale(1.1); } }

/* "+5s Pung" pops out to the side of the clock and floats up */
.clock-deltas { position: absolute; left: calc(100% + 8px); top: 4px; width: 0; }
.clock-delta {
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  white-space: nowrap;
  line-height: 1.05;
  animation: delta-rise 1.4s ease-out forwards;
}
.clock-delta b { font-size: 28px; font-weight: 700; -webkit-text-stroke: 5px #fff; paint-order: stroke fill; }
.clock-delta span { font-size: 14px; font-weight: 600; -webkit-text-stroke: 4px #fff; paint-order: stroke fill; }
.clock-delta.gain { color: #2c9a5c; }
.clock-delta.loss { color: #e2485e; }
@keyframes delta-rise {
  0% { opacity: 0; transform: translateY(10px) scale(0.6); }
  15% { opacity: 1; transform: translateY(0) scale(1.15); }
  30% { transform: translateY(-2px) scale(1); }
  75% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-34px); }
}

/* Under ten seconds the screen's edges glow red; under five they pound. */
.urgency {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 9;
  opacity: 0;
  transition: opacity 0.3s;
  background: radial-gradient(ellipse 75% 65% at 50% 50%, rgba(226, 72, 94, 0) 60%, rgba(226, 72, 94, 0.5) 100%);
  box-shadow: inset 0 0 0 6px rgba(226, 72, 94, 0.9);
}
.urgency.on { opacity: 1; animation: urgency-pulse 1s ease-in-out infinite; }
.urgency.critical {
  background: radial-gradient(ellipse 70% 60% at 50% 50%, rgba(226, 50, 70, 0) 50%, rgba(226, 50, 70, 0.72) 100%);
  box-shadow: inset 0 0 0 10px rgba(226, 50, 70, 1);
  animation-duration: 0.5s;
}
@keyframes urgency-pulse { 50% { opacity: 0.55; } }
@media (prefers-reduced-motion: reduce) {
  .urgency.on, .big-clock.low:not(.gain):not(.loss) { animation: none; }
  .clock-delta { animation-duration: 1.4s; animation-name: delta-fade; }
  @keyframes delta-fade { 0%, 70% { opacity: 1; } 100% { opacity: 0; } }
}
#app.clock-mode .banner { top: calc(140px + var(--safe-t)); }

/* ---------------------------------------------------------- daily blitz */

.blitz-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 10px;
  width: 100%;
  margin-top: 8px;
  padding: 9px 14px;
  border: 0;
  border-radius: 16px;
  background: var(--ink);
  color: white;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(40, 28, 64, 0.45);
  transition: transform 0.08s;
}
.blitz-item:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(40, 28, 64, 0.45); }
.bz-clock { font-size: 24px; }
.bz-text { display: grid; line-height: 1.2; }
.bz-text b { font-size: 17px; }
.bz-text small { font-size: 13px; color: var(--butter); font-weight: 600; }
.bz-side { font-size: 14px; font-weight: 700; color: var(--mint); white-space: nowrap; }

.end-standing { margin: 2px 0 6px; display: grid; gap: 2px; }
.end-standing .st-main { font-size: 16px; font-weight: 600; color: var(--ink-soft); }
.end-standing.tier .st-main {
  justify-self: center;
  font-size: 20px;
  font-weight: 700;
  color: var(--ink);
  background: var(--butter);
  border-radius: 99px;
  padding: 3px 16px;
}
.end-standing .st-next, .end-standing .st-best { font-size: 14px; color: var(--ink-soft); }
