:root {
  --bg-1: #fff7fb;
  --bg-2: #e8fff7;
  --bg-3: #fff4d8;
  --ink: #2f2637;
  --muted: #7d7187;
  --pink: #ff6ea8;
  --pink-dark: #e64b8a;
  --mint: #53dfb9;
  --yellow: #ffd76b;
  --glass: rgba(255, 255, 255, 0.68);
  --glass-strong: rgba(255, 255, 255, 0.9);
  --shadow: 0 10px 28px rgba(85, 49, 92, 0.08);
  --soft-border: rgba(255, 255, 255, 0.72);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: var(--app-height, 100svh);
  min-height: var(--app-height, 100svh);
  margin: 0;
  overflow: hidden;
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Nunito", "Inter", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 170, 205, 0.55), transparent 26%),
    radial-gradient(circle at 88% 14%, rgba(108, 231, 197, 0.5), transparent 23%),
    radial-gradient(circle at 50% 100%, rgba(255, 216, 113, 0.48), transparent 32%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 52%, var(--bg-3));
  -webkit-font-smoothing: antialiased;
  touch-action: none;
  user-select: none;
}

button,
input {
  font: inherit;
}

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

.app-shell {
  position: relative;
  width: 100vw;
  height: var(--app-height, 100svh);
  min-height: var(--app-height, 100svh);
  max-height: var(--app-height, 100svh);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: calc(max(8px, env(safe-area-inset-top)) + 12px) 12px calc(max(10px, env(safe-area-inset-bottom)) + var(--browser-bottom-pad, 0px));
  isolation: isolate;
}

.app-shell::before,
.app-shell::after {
  content: "";
  position: fixed;
  border-radius: 999px;
  filter: blur(4px);
  opacity: 0.82;
  pointer-events: none;
}

.app-shell::before {
  width: 180px;
  height: 180px;
  left: -74px;
  bottom: 11%;
  background: rgba(255, 110, 168, 0.2);
}

.app-shell::after {
  width: 210px;
  height: 210px;
  right: -82px;
  top: 22%;
  background: rgba(83, 223, 185, 0.2);
}

.hud {
  width: min(100%, 480px);
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: stretch;
  z-index: 3;
}

.back-button,
.brand-pill,
.score-card,
.next-card {
  min-height: 60px;
  display: flex;
  align-items: center;
  border: 1px solid var(--soft-border);
  background: var(--glass);
  box-shadow: 0 8px 22px rgba(68, 41, 80, 0.07);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
}

.back-button {
  min-width: 64px;
  justify-content: center;
  gap: 0;
  padding: 7px;
  border-radius: 24px;
  color: var(--ink);
  position: relative;
  overflow: hidden;
}

.back-button::before {
  content: "";
  position: absolute;
  inset: 7px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 30% 27%, rgba(255, 255, 255, 0.95), transparent 24%),
    linear-gradient(145deg, rgba(255, 105, 158, 0.34), rgba(255, 216, 113, 0.18) 48%, rgba(83, 223, 185, 0.26));
}

.back-button::after {
  content: "";
  position: absolute;
  right: 11px;
  top: 13px;
  width: 13px;
  height: 8px;
  border-radius: 80% 20% 80% 20%;
  background: #59c96d;
  transform: rotate(24deg);
  opacity: .92;
}

.back-arrow {
  position: relative;
  z-index: 1;
  width: 39px;
  height: 39px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  color: #ffffff;
  background: linear-gradient(135deg, #ff6ea8, #ff9d35);
  font-size: 25px;
  line-height: 1;
  font-weight: 1000;
  transform: translateX(-1px);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.45), 0 6px 14px rgba(230,75,138,.22);
}

.back-button:active {
  transform: scale(0.985);
}

.brand-pill {
  gap: 8px;
  padding: 8px 10px;
  border-radius: 22px;
}

.brand-icon-only {
  justify-content: center;
  padding: 8px;
}

.brand-pill img {
  flex: 0 0 auto;

}

.brand-pill strong,
.score-card strong {
  display: block;
  line-height: 1;
}

.brand-pill strong {
  font-size: 15px;
  letter-spacing: -0.02em;
}

.brand-pill span,
.score-card span,
.next-card span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.score-card {
  justify-content: center;
  flex-direction: column;
  padding: 8px 10px;
  border-radius: 20px;
}

.score-card strong {
  margin-top: 2px;
  font-size: clamp(30px, 11vw, 44px);
  letter-spacing: -0.06em;
}

.next-card {
  justify-content: center;
  gap: 6px;
  padding: 7px 8px;
  border-radius: 20px;
}

.next-card img {
  width: 34px;
  height: 34px;
  object-fit: contain;

}

.game-stage {
  position: relative;
  width: min(100%, 480px);
  flex: 1 1 auto;
  min-height: 0;
  margin-top: 10px;
  border-radius: 28px;
  overflow: hidden;
  box-shadow: var(--shadow);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.58), rgba(255, 255, 255, 0.2)),
    radial-gradient(circle at 50% 10%, rgba(255, 255, 255, 0.92), transparent 34%);
}

#gameCanvas {
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

.danger-label {
  position: absolute;
  left: 50%;
  top: 18.9%;
  transform: translateX(-50%);
  padding: 3px 10px;
  border-radius: 999px;
  color: rgba(218, 55, 96, 0.76);
  background: rgba(255, 255, 255, 0.54);
  border: 1px solid rgba(255, 99, 139, 0.22);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 0.16em;
  pointer-events: none;
  opacity: 0.86;
}

.screen-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(255, 245, 250, 0.3);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
}

.screen-overlay.is-visible {
  display: flex;
}

.panel {
  width: min(100%, 430px);
  max-height: min(calc(var(--app-height, 100svh) - 28px), 780px);
  overflow: auto;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.72)),
    radial-gradient(circle at top left, rgba(255, 126, 178, 0.16), transparent 28%),
    radial-gradient(circle at bottom right, rgba(83, 223, 185, 0.18), transparent 28%);
  box-shadow: 0 28px 90px rgba(73, 40, 87, 0.22);
}

.loading-panel,
.hero-panel {
  padding: 34px 24px 26px;
  text-align: center;
}

.hero-panel .primary-btn {
  margin-top: 12px;
}

.leave-panel {
  padding: 28px 22px 22px;
  text-align: center;
}

.leave-badge {
  width: 58px;
  height: 58px;
  display: grid;
  place-items: center;
  margin: 0 auto 10px;
  border-radius: 22px;
  background: linear-gradient(135deg, rgba(255, 110, 168, 0.18), rgba(83, 223, 185, 0.18));
  border: 1px solid rgba(255,255,255,.82);
  font-size: 28px;
}

.leave-panel .secondary-btn {
  margin-top: 10px;
}

.hero-wordmark,
.loading-wordmark {
  display: block;
  width: min(82vw, 330px);
  height: auto;
  margin: 0 auto 6px;
}

.panel h1,
.panel h2 {
  margin: 10px 0 4px;
  line-height: 0.96;
  letter-spacing: -0.08em;
}

.panel h1 {
  font-size: clamp(44px, 13vw, 68px);
}

.panel h2 {
  font-size: clamp(34px, 10vw, 48px);
}

.panel p {
  margin: 8px auto 0;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.35;
}

.primary-btn,
.secondary-btn {
  width: 100%;
  min-height: 54px;
  margin-top: 18px;
  border-radius: 19px;
  font-weight: 1000;
  letter-spacing: -0.02em;
  transition: transform 140ms ease, filter 140ms ease, opacity 140ms ease;
}

.primary-btn {
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--pink-dark));
  box-shadow: 0 16px 34px rgba(230, 75, 138, 0.28);
}

.secondary-btn {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid rgba(255, 255, 255, 0.86);
  box-shadow: 0 12px 26px rgba(71, 46, 85, 0.12);
}

.primary-btn:active,
.secondary-btn:active {
  transform: scale(0.985);
}

.primary-btn:disabled {
  opacity: 0.6;
  cursor: wait;
}

.loader-bar {
  width: 100%;
  height: 10px;
  margin-top: 22px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
}

.loader-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--yellow), var(--mint));
  animation: loaderMove 1.1s ease-in-out infinite alternate;
}

@keyframes loaderMove {
  from { transform: translateX(-18%); }
  to { transform: translateX(160%); }
}

.mini-leaderboard {
  margin-top: 18px;
  display: grid;
  gap: 7px;
}

.mini-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid rgba(255, 255, 255, 0.76);
  color: var(--ink);
  font-weight: 900;
}

.mini-row span:nth-child(2) {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  text-align: left;
}


.mini-row em {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 900;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mini-king {
  min-height: 62px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, .76), rgba(255,255,255,.52)),
    radial-gradient(circle at 15% 20%, rgba(255, 216, 113, .32), transparent 36%);
}

.king-crown {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: rgba(255, 216, 113, .44);
  font-size: 18px;
}

.game-over-panel {
  padding: 18px;
}

.game-over-head {
  text-align: center;
  padding: 10px 4px 16px;
}

.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 28px;
  padding: 4px 12px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, #ff8abd, #ffb85f);
  font-size: 12px;
  font-weight: 1000;
  box-shadow: 0 10px 22px rgba(255, 105, 158, 0.24);
}

.leaderboard-box,
.submit-form {
  padding: 12px;
  border-radius: 24px;
  border: 1px solid rgba(255, 255, 255, 0.84);
  background: rgba(255, 255, 255, 0.56);
}

.section-title {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}

.section-title strong {
  font-size: 15px;
  letter-spacing: -0.02em;
}

.section-title span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.leaderboard-list {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 9px;
  align-items: center;
  min-height: 42px;
  padding: 7px 10px;
  border-radius: 15px;
  background: rgba(255, 255, 255, 0.68);
  border: 1px solid rgba(255, 255, 255, 0.8);
}

.leaderboard-row.is-empty {
  color: var(--muted);
}

.rank {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(255, 216, 113, 0.36);
  font-weight: 1000;
  font-size: 13px;
}

.player-name {
  min-width: 0;
}

.player-name strong,
.player-name span {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.player-name strong {
  font-size: 14px;
  letter-spacing: -0.02em;
}

.player-name span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.player-score {
  font-weight: 1000;
  letter-spacing: -0.04em;
}


.leaderboard-toggle {
  width: 100%;
  min-height: 38px;
  margin-top: 9px;
  border-radius: 14px;
  color: var(--pink-dark);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 1000;
}

.play-again-cta {
  margin-top: 14px;
  box-shadow: 0 18px 40px rgba(230, 75, 138, 0.34);
}

.submit-form {
  display: none;
  margin-top: 12px;
}

.submit-form.is-visible {
  display: block;
}

.submit-form label {
  display: block;
  margin-top: 10px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 1000;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.submit-form input {
  width: 100%;
  height: 48px;
  margin-top: 5px;
  padding: 0 14px;
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.9);
  outline: 0;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.82);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.submit-form input:focus {
  border-color: rgba(255, 110, 168, 0.58);
  box-shadow: 0 0 0 4px rgba(255, 110, 168, 0.12);
}

.form-message {
  min-height: 20px;
  font-size: 12px;
  font-weight: 900;
}

@media (min-width: 760px) {
  html,
  body {
    display: flex;
    align-items: center;
    justify-content: center;
  }

  .app-shell {
    width: min(440px, calc(100vw - 36px));
    height: min(840px, calc(var(--app-height, 100svh) - 36px));
    min-height: min(840px, calc(var(--app-height, 100svh) - 36px));
    max-height: min(840px, calc(var(--app-height, 100svh) - 36px));
    padding: 18px 14px;
    border-radius: 34px;
    overflow: hidden;
    box-shadow: 0 22px 80px rgba(67, 42, 82, .16);
    background:
      radial-gradient(circle at 12% 18%, rgba(255, 170, 205, 0.38), transparent 28%),
      radial-gradient(circle at 88% 14%, rgba(108, 231, 197, 0.36), transparent 26%),
      linear-gradient(160deg, rgba(255,247,251,.88), rgba(232,255,247,.86) 52%, rgba(255,244,216,.88));
  }

  .hud,
  .game-stage {
    width: 100%;
    max-width: 412px;
  }

  .game-stage {
    max-height: none;
    border-radius: 30px;
  }

  .screen-overlay {
    position: absolute;
    inset: 0;
    border-radius: 34px;
  }
}

@media (max-width: 370px) {
  .hud {
    grid-template-columns: 54px minmax(0, 1fr);
    gap: 10px;
  }

  .back-button,
  .brand-pill,
  .score-card {
    min-height: 56px;
    border-radius: 20px;
  }

  .score-card strong {
    font-size: clamp(28px, 10vw, 40px);
  }

  .panel {
    border-radius: 28px;
  }
}


/* V12: mobile keyboard + desktop frame polish */
input {
  user-select: text;
  -webkit-user-select: text;
  font-size: 16px;
}

body.keyboard-open {
  touch-action: pan-y;
}

body.keyboard-open .screen-overlay.is-visible {
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: max(8px, env(safe-area-inset-top)) 14px 12px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

body.keyboard-open .game-over-panel {
  width: min(100%, 430px);
  max-height: none;
  overflow: visible;
  border-radius: 28px;
  padding: 14px;
  margin: 0 auto 12px;
}

body.keyboard-open .game-over-head {
  padding: 6px 4px 10px;
}

body.keyboard-open .leaderboard-box {
  max-height: 178px;
  overflow: auto;
}

body.keyboard-open .submit-form input {
  height: 46px;
}

body.keyboard-open .play-again-cta {
  margin-top: 10px;
}

@media (min-width: 760px) {
  html,
  body {
    width: 100%;
    min-height: 100%;
    height: 100%;
    overflow: auto;
    padding: 0;
  }

  body {
    min-height: 100vh;
    min-height: 100dvh;
    background:
      radial-gradient(circle at 20% 16%, rgba(255, 170, 205, 0.32), transparent 28%),
      radial-gradient(circle at 80% 18%, rgba(108, 231, 197, 0.28), transparent 26%),
      linear-gradient(160deg, #fff9fc, #f1fffb 54%, #fff7df);
  }

  .app-shell {
    width: min(390px, calc(100vw - 88px));
    height: min(760px, calc(100vh - 88px));
    height: min(760px, calc(100dvh - 88px));
    min-height: 620px;
    max-height: 760px;
    margin: auto;
    padding: 16px 13px;
    border-radius: 38px;
    flex: 0 0 auto;
    box-shadow: 0 30px 110px rgba(67, 42, 82, .18), inset 0 1px 0 rgba(255,255,255,.72);
    border: 1px solid rgba(255,255,255,.82);
  }

  .hud,
  .game-stage {
    width: 100%;
    max-width: none;
  }

  .hud {
    grid-template-columns: 58px minmax(0, 1fr);
    gap: 10px;
  }

  .back-button,
  .score-card {
    min-height: 56px;
  }

  .score-card strong {
    font-size: 40px;
  }

  .game-stage {
    margin-top: 10px;
    border-radius: 32px;
  }

  .panel {
    width: min(100%, 360px);
    max-height: calc(100% - 26px);
  }

  .hero-wordmark,
  .loading-wordmark {
    width: min(280px, 78vw);
  }
}

@media (min-width: 1120px) and (min-height: 780px) {
  .app-shell {
    width: 400px;
    height: 780px;
  }
}


/* V13: desktop performance frame + game-over actions */
.back-home-cta {
  margin-top: 10px;
  min-height: 48px;
  color: #7b617f;
  background: rgba(255, 255, 255, 0.78);
}

.auto-home-note {
  margin: 8px auto 0 !important;
  color: rgba(125, 113, 135, 0.72) !important;
  font-size: 11px;
  font-weight: 900;
  text-align: center;
}

@media (min-width: 760px) {
  html,
  body {
    width: 100% !important;
    height: 100% !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
  }

  body {
    touch-action: auto !important;
    background:
      radial-gradient(circle at 18% 14%, rgba(255, 170, 205, 0.30), transparent 26%),
      radial-gradient(circle at 82% 18%, rgba(108, 231, 197, 0.28), transparent 25%),
      radial-gradient(circle at 50% 102%, rgba(255, 216, 113, 0.22), transparent 28%),
      linear-gradient(160deg, #fffafd 0%, #f4fffc 54%, #fff8e8 100%) !important;
  }

  .app-shell {
    width: clamp(370px, 31vw, 430px) !important;
    height: min(840px, calc(100dvh - 48px)) !important;
    min-height: min(720px, calc(100dvh - 48px)) !important;
    max-height: calc(100dvh - 48px) !important;
    margin: 0 !important;
    padding: 16px 14px !important;
    border-radius: 38px !important;
    overflow: hidden !important;
    flex: none !important;
    contain: layout paint style !important;
    transform: translateZ(0);
    box-shadow: 0 34px 110px rgba(67, 42, 82, 0.16), inset 0 1px 0 rgba(255,255,255,0.72) !important;
  }

  .hud {
    width: 100% !important;
    max-width: none !important;
    grid-template-columns: 58px minmax(0, 1fr) !important;
    gap: 10px !important;
    flex: 0 0 auto !important;
  }

  .game-stage {
    width: 100% !important;
    max-width: none !important;
    flex: 1 1 auto !important;
    min-height: 0 !important;
    margin-top: 10px !important;
    border-radius: 32px !important;
    contain: layout paint size !important;
    transform: translateZ(0);
  }

  #gameCanvas {
    transform: translateZ(0);
    backface-visibility: hidden;
  }

  .screen-overlay {
    position: absolute !important;
    inset: 0 !important;
    border-radius: 38px !important;
    padding: 16px !important;
  }

  .panel {
    width: min(100%, 368px) !important;
    max-height: calc(100% - 24px) !important;
  }
}

@media (min-width: 760px) and (max-height: 760px) {
  .app-shell {
    height: calc(100dvh - 28px) !important;
    min-height: 0 !important;
    padding: 12px !important;
  }
  .hud { grid-template-columns: 54px minmax(0, 1fr) !important; }
  .back-button, .score-card { min-height: 52px !important; }
  .score-card strong { font-size: 34px !important; }
}


/* V14: Gamerush candy theme + desktop polish */
:root {
  --bg-1: #fff9fd;
  --bg-2: #f6fffe;
  --bg-3: #fff8ea;
  --ink: #392b48;
  --muted: #8a7d96;
  --pink: #ff6da9;
  --pink-dark: #ef418f;
  --orange: #ff9f2f;
  --yellow: #ffd84d;
  --lime: #b9ef3c;
  --violet: #9f67ff;
  --blue: #66d4ff;
  --mint: #67e6c6;
  --glass: rgba(255,255,255,0.74);
  --glass-strong: rgba(255,255,255,0.92);
  --soft-border: rgba(255,255,255,0.84);
  --shadow: 0 16px 40px rgba(104, 69, 118, 0.10);
}
html, body {
  background:
    radial-gradient(circle at 8% 14%, rgba(255, 109, 169, 0.20), transparent 24%),
    radial-gradient(circle at 84% 12%, rgba(102, 212, 255, 0.18), transparent 22%),
    radial-gradient(circle at 88% 78%, rgba(185, 239, 60, 0.14), transparent 18%),
    radial-gradient(circle at 16% 84%, rgba(255, 216, 77, 0.18), transparent 24%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2) 56%, var(--bg-3));
}
.app-shell::before { background: rgba(255, 109, 169, 0.16); }
.app-shell::after { background: rgba(102, 212, 255, 0.14); }
.hud { width: min(100%, 520px); grid-template-columns: 70px minmax(0, 1fr); }
.back-button, .score-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.86), rgba(255,255,255,0.68));
  border-color: rgba(255,255,255,.90);
  box-shadow: 0 12px 28px rgba(82, 53, 101, 0.08);
}
.back-button {
  min-width: 70px;
  border-radius: 26px;
}
.back-button::before {
  inset: 8px;
  border-radius: 20px;
  background:
    radial-gradient(circle at 30% 24%, rgba(255,255,255,.95), transparent 22%),
    linear-gradient(145deg, rgba(255, 111, 167, .30), rgba(255, 200, 72, .22) 45%, rgba(102, 212, 255, .20));
}
.back-arrow {
  width: 42px;
  height: 42px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--pink), var(--orange));
  box-shadow: inset 0 2px 0 rgba(255,255,255,.44), 0 8px 18px rgba(255, 109, 169, .24);
}
.score-card {
  border-radius: 24px;
  padding: 10px 12px;
}
.score-card span {
  color: #8a6b96;
  letter-spacing: 0.15em;
  font-size: 12px;
}
.score-card strong { font-size: clamp(34px, 11vw, 48px); color: #392b48; }
.game-stage {
  width: min(100%, 520px);
  margin-top: 12px;
  border-radius: 34px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.68), rgba(255,255,255,.22)),
    radial-gradient(circle at 50% 7%, rgba(255,255,255,.98), transparent 34%),
    linear-gradient(180deg, rgba(255,255,255,.30), rgba(255,255,255,.14));
  box-shadow: 0 18px 44px rgba(92, 60, 107, .10);
}
.danger-label {
  color: rgba(228, 74, 125, .85);
  background: rgba(255,255,255,.68);
  border-color: rgba(255, 121, 164, .26);
  font-size: 10px;
  letter-spacing: .18em;
}
.screen-overlay { background: rgba(255, 248, 251, 0.34); }
.panel {
  border-radius: 36px;
  background:
    linear-gradient(180deg, rgba(255,255,255,.96), rgba(255,255,255,.80)),
    radial-gradient(circle at top left, rgba(255, 109, 169, 0.13), transparent 28%),
    radial-gradient(circle at top right, rgba(102, 212, 255, 0.12), transparent 26%),
    radial-gradient(circle at bottom center, rgba(255, 216, 77, 0.10), transparent 30%);
  box-shadow: 0 28px 80px rgba(84, 53, 98, .18);
}
.loading-panel, .hero-panel {
  padding: 32px 22px 24px;
}
.hero-wordmark, .loading-wordmark {
  display: block;
  width: min(92vw, 520px);
  height: auto;
  margin: 0 auto 12px;
  filter: drop-shadow(0 10px 18px rgba(175, 101, 164, 0.12));
}
.hero-bubbles {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 0;
}
.hero-bubbles span {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(255,255,255,.94), rgba(255,255,255,.74));
  border: 1px solid rgba(255,255,255,.92);
  box-shadow: 0 8px 18px rgba(84, 53, 98, .08);
  color: #7d6a90;
  font-size: 12px;
  font-weight: 900;
}
.home-footnote {
  margin-top: 14px !important;
  color: #8f7f99 !important;
  font-size: 12px;
}
.primary-btn, .secondary-btn {
  border-radius: 22px;
  min-height: 56px;
}
.primary-btn {
  background: linear-gradient(135deg, var(--pink), var(--orange) 40%, var(--yellow));
  box-shadow: 0 16px 32px rgba(255, 110, 168, .24);
}
.secondary-btn {
  background: rgba(255,255,255,.82);
}
.loader-bar { background: rgba(255,255,255,.84); }
.loader-bar span { background: linear-gradient(90deg, var(--pink), var(--orange), var(--yellow), var(--mint), var(--blue), var(--violet)); }
.mini-row {
  min-height: 64px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(255,255,255,.84), rgba(255,255,255,.66));
  box-shadow: 0 10px 20px rgba(84,53,98,.06);
}
.king-crown {
  background: linear-gradient(135deg, rgba(255,215,74,.55), rgba(255,178,64,.28));
}
.badge {
  background: linear-gradient(135deg, var(--pink), var(--orange));
}
.leaderboard-box, .submit-form {
  border-radius: 26px;
  background: rgba(255,255,255,.64);
}
.leaderboard-row, .leaderboard-toggle, .submit-form input {
  background: rgba(255,255,255,.80);
}
.rank {
  background: linear-gradient(135deg, rgba(255, 214, 71, .42), rgba(255, 180, 92, .18));
}
.submit-form input:focus { border-color: rgba(255,109,169,.58); box-shadow: 0 0 0 4px rgba(255,109,169,.11); }
.back-home-cta {
  color: #7a6890;
  background: linear-gradient(180deg, rgba(255,255,255,.86), rgba(255,255,255,.68));
}
.leave-badge {
  background: linear-gradient(135deg, rgba(255,109,169,.16), rgba(102,212,255,.14), rgba(255,216,77,.18));
}
@media (min-width: 760px) {
  html, body {
    overflow: auto !important;
    display: block !important;
    min-height: 100dvh !important;
  }
  body {
    padding: 28px 0 !important;
    background:
      radial-gradient(circle at 18% 14%, rgba(255, 109, 169, 0.18), transparent 24%),
      radial-gradient(circle at 82% 18%, rgba(102, 212, 255, 0.16), transparent 22%),
      radial-gradient(circle at 50% 102%, rgba(255, 216, 77, 0.18), transparent 24%),
      linear-gradient(160deg, #fffafd 0%, #f7fffd 54%, #fff9ef 100%) !important;
  }
  .app-shell {
    width: min(520px, calc(100vw - 72px)) !important;
    height: min(900px, calc(100dvh - 56px)) !important;
    min-height: 760px !important;
    max-height: 900px !important;
    margin: 0 auto !important;
    padding: 18px 16px 16px !important;
    border-radius: 40px !important;
    background:
      radial-gradient(circle at 12% 18%, rgba(255, 109, 169, 0.18), transparent 28%),
      radial-gradient(circle at 88% 14%, rgba(102, 212, 255, 0.16), transparent 26%),
      radial-gradient(circle at 50% 100%, rgba(255, 216, 77, 0.15), transparent 28%),
      linear-gradient(160deg, rgba(255,250,253,.92), rgba(247,255,253,.92) 56%, rgba(255,249,239,.92));
    box-shadow: 0 28px 88px rgba(84, 53, 98, .14), inset 0 1px 0 rgba(255,255,255,.72) !important;
  }
  .hud, .game-stage { width: 100% !important; max-width: none !important; }
  .hud { grid-template-columns: 78px minmax(0, 1fr) !important; gap: 12px !important; }
  .back-button { min-width: 78px; min-height: 62px !important; }
  .score-card { min-height: 62px !important; }
  .score-card strong { font-size: 48px !important; }
  .game-stage {
    flex: 1 1 auto !important;
    min-height: 640px !important;
    border-radius: 36px !important;
  }
  .screen-overlay {
    position: absolute !important;
    inset: 0 !important;
    border-radius: 40px !important;
    padding: 20px !important;
    backdrop-filter: blur(10px) !important;
    -webkit-backdrop-filter: blur(10px) !important;
  }
  .panel {
    width: min(100%, 420px) !important;
    max-height: calc(100% - 12px) !important;
  }
  .hero-wordmark, .loading-wordmark { width: min(360px, 100%); }
}
@media (min-width: 1080px) {
  .app-shell { width: 540px !important; }
}


/* V15: transparent text logo + cleaner home UI */
.loading-wordmark,
.hero-wordmark {
  width: min(86vw, 420px) !important;
  max-width: 100%;
  object-fit: contain;
  background: transparent !important;
  filter: drop-shadow(0 8px 18px rgba(147, 96, 162, 0.10));
}
.loading-panel,
.hero-panel {
  padding-top: 28px !important;
}
.hero-panel .primary-btn {
  margin-top: 18px;
}
.hero-bubbles { display: none !important; }
.home-footnote {
  margin-top: 12px !important;
  font-size: 11px !important;
  opacity: .92;
}
.back-button {
  min-width: 72px !important;
  border-radius: 28px !important;
  box-shadow: 0 14px 26px rgba(94, 60, 112, 0.10) !important;
}
.back-button::before {
  inset: 7px !important;
  border-radius: 22px !important;
  background:
    radial-gradient(circle at 28% 22%, rgba(255,255,255,.96), transparent 22%),
    linear-gradient(145deg, rgba(255, 169, 203, .42), rgba(255, 209, 122, .28) 44%, rgba(116, 217, 60, .18) 72%, rgba(77, 199, 247, .16));
}
.back-button::after {
  width: 15px !important;
  height: 9px !important;
  right: 10px !important;
  top: 12px !important;
  background: linear-gradient(135deg, #9be44a, #61c857) !important;
  opacity: 1 !important;
}
.back-arrow {
  width: 44px !important;
  height: 44px !important;
  border-radius: 17px !important;
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-size: 28px !important;
  background: linear-gradient(135deg, #ff6da9, #ff9824 58%, #ffc839) !important;
  box-shadow: inset 0 2px 0 rgba(255,255,255,.48), 0 8px 18px rgba(255,109,169,.28) !important;
}
.primary-btn {
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  font-size: 22px;
  letter-spacing: -0.03em;
  font-weight: 1000;
  text-shadow: 0 1px 0 rgba(255,255,255,.18);
}
@media (max-width: 420px) {
  .primary-btn { font-size: 20px; }
}

/* V16: final GameRush.live visual cleanup + safer mobile/desktop viewport framing */
html,
body,
.app-shell {
  overscroll-behavior: none;
}

.screen-overlay {
  height: var(--app-height, 100svh);
  min-height: var(--app-height, 100svh);
  padding: calc(max(12px, env(safe-area-inset-top)) + 6px) 16px calc(max(14px, env(safe-area-inset-bottom)) + var(--browser-bottom-pad, 0px) + 6px) !important;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.panel {
  scrollbar-width: thin;
}

.hero-panel,
.loading-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hero-wordmark,
.loading-wordmark {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  mix-blend-mode: normal;
}

.hero-panel #playButton {
  min-height: 62px;
  border-radius: 26px;
  font-size: clamp(20px, 5.4vw, 24px);
  line-height: 1;
}

.primary-btn,
.secondary-btn,
.leaderboard-toggle,
.back-button {
  -webkit-tap-highlight-color: transparent;
}

.primary-btn {
  position: relative;
  overflow: hidden;
  isolation: isolate;
}

.primary-btn::before {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  top: 6px;
  height: 42%;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,.42), rgba(255,255,255,0));
  pointer-events: none;
}

.primary-btn:hover,
.secondary-btn:hover,
.leaderboard-toggle:hover,
.back-button:hover {
  filter: saturate(1.04) brightness(1.01);
}

.mini-leaderboard {
  width: 100%;
}

.mini-king {
  grid-template-columns: 42px minmax(0, 1fr) auto;
  padding: 12px;
  border-radius: 22px;
}

.home-footnote {
  user-select: text;
  -webkit-user-select: text;
}

@media (max-width: 759px) {
  .app-shell {
    padding-left: 12px;
    padding-right: 12px;
  }

  .hud,
  .game-stage {
    width: 100%;
    max-width: 520px;
  }

  .panel {
    width: min(100%, 430px);
  }

  .hero-wordmark,
  .loading-wordmark {
    width: min(88vw, 390px) !important;
    margin-bottom: 10px !important;
  }
}

@media (max-width: 759px) and (max-height: 740px) {
  .loading-panel,
  .hero-panel {
    padding: 22px 18px 18px !important;
  }

  .hero-wordmark,
  .loading-wordmark {
    width: min(78vw, 315px) !important;
    margin-bottom: 4px !important;
  }

  .hero-panel #playButton {
    min-height: 56px;
    margin-top: 12px;
  }

  .mini-leaderboard {
    margin-top: 12px;
  }

  .mini-row {
    min-height: 56px;
    padding: 9px 10px;
  }

  .home-footnote {
    margin-top: 8px !important;
  }
}

@media (min-width: 760px) {
  html,
  body {
    width: 100% !important;
    height: 100% !important;
    min-height: 100dvh !important;
    overflow: hidden !important;
    display: grid !important;
    place-items: center !important;
    padding: 0 !important;
  }

  body {
    touch-action: auto !important;
  }

  .app-shell {
    width: clamp(390px, 38vw, 520px) !important;
    height: clamp(640px, calc(100dvh - 40px), 860px) !important;
    min-height: 0 !important;
    max-height: calc(100dvh - 40px) !important;
    margin: 0 auto !important;
    padding: 16px 14px !important;
    border-radius: 40px !important;
  }

  .hud {
    grid-template-columns: 74px minmax(0, 1fr) !important;
    gap: 12px !important;
  }

  .back-button {
    min-width: 74px !important;
    min-height: 60px !important;
  }

  .score-card {
    min-height: 60px !important;
  }

  .game-stage {
    flex: 1 1 auto !important;
    min-height: 0 !important;
    max-height: none !important;
    margin-top: 12px !important;
  }

  .screen-overlay {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;
    border-radius: 40px !important;
    padding: 18px !important;
  }

  .panel {
    width: min(100%, 420px) !important;
    max-height: calc(100% - 12px) !important;
  }

  .hero-wordmark,
  .loading-wordmark {
    width: min(370px, 100%) !important;
  }
}

@media (min-width: 760px) and (max-height: 700px) {
  .app-shell {
    width: clamp(360px, 35vw, 470px) !important;
    height: calc(100dvh - 24px) !important;
    max-height: calc(100dvh - 24px) !important;
    padding: 12px !important;
  }

  .hud {
    grid-template-columns: 64px minmax(0, 1fr) !important;
    gap: 10px !important;
  }

  .back-button,
  .score-card {
    min-height: 54px !important;
  }

  .back-button {
    min-width: 64px !important;
  }

  .score-card strong {
    font-size: 38px !important;
  }
}


/* V17: final logo/home/form clarity cleanup */
.loading-panel,
.hero-panel {
  padding-top: 28px;
}

.hero-wordmark,
.loading-wordmark {
  width: min(94vw, 460px) !important;
  max-width: 100%;
  margin: 0 auto 14px;
  filter: drop-shadow(0 10px 18px rgba(175, 101, 164, 0.14));
}

.loading-panel .loader-bar {
  margin-top: 14px;
}

.home-footnote {
  margin-top: 12px !important;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: #8b7b96 !important;
}

.mini-row {
  grid-template-columns: 40px minmax(0, 1fr) 72px;
  gap: 10px;
  align-items: center;
}

.mini-copy {
  min-width: 0;
  display: block;
  text-align: left;
}

.mini-copy strong,
.mini-copy em {
  display: block;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.mini-copy strong {
  font-size: 13px;
  line-height: 1.1;
}

.mini-copy em {
  margin-top: 3px;
  font-size: 11px;
  color: var(--muted);
  font-style: normal;
  font-weight: 900;
}

.mini-score {
  min-width: 64px;
  justify-self: end;
  text-align: center;
  padding: 10px 8px;
  border-radius: 14px;
  background: rgba(255,255,255,0.82);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.85);
  color: #392b48;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.04em;
}

.submit-form {
  background: rgba(255,255,255,0.84) !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
}

.submit-form input {
  background: #ffffff !important;
  color: #2f2637 !important;
  text-shadow: none !important;
  filter: none !important;
  -webkit-filter: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  opacity: 1;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.92), 0 2px 8px rgba(77, 48, 92, 0.05) !important;
}

.submit-form input::placeholder {
  color: #94859f;
  opacity: 1;
}

.submit-form input,
.submit-form input::placeholder,
.submit-form label {
  -webkit-font-smoothing: antialiased;
}

.submit-form input:-webkit-autofill,
.submit-form input:-webkit-autofill:hover,
.submit-form input:-webkit-autofill:focus {
  -webkit-text-fill-color: #2f2637;
  transition: background-color 5000s ease-in-out 0s;
  box-shadow: 0 0 0 1000px #fff inset, 0 2px 8px rgba(77, 48, 92, 0.05) !important;
}

@media (max-width: 480px) {
  .hero-wordmark,
  .loading-wordmark {
    width: min(95vw, 420px) !important;
  }

  .mini-row {
    grid-template-columns: 36px minmax(0, 1fr) 62px;
    padding: 10px;
  }

  .mini-copy strong {
    font-size: 12px;
  }

  .mini-copy em {
    font-size: 10px;
  }

  .mini-score {
    min-width: 56px;
    font-size: 20px;
    padding: 9px 6px;
  }
}

/* V18: Top 3-only leaderboard + cleaner save/restore flow */
.leaderboard-box .section-title span {
  color: #8b7596;
  white-space: nowrap;
}

.top-three-list {
  gap: 8px;
}

.top-three-row {
  min-height: 48px;
  grid-template-columns: 40px minmax(0, 1fr) minmax(58px, auto);
  border-radius: 18px;
}

.top-three-row.rank-1 {
  min-height: 56px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.92), rgba(255,255,255,.74)),
    radial-gradient(circle at 12% 25%, rgba(255, 216, 77, .34), transparent 34%);
  box-shadow: 0 10px 22px rgba(107, 74, 118, 0.08);
}

.top-three-row.rank-1 .rank {
  width: 32px;
  height: 32px;
  border-radius: 13px;
  background: linear-gradient(135deg, rgba(255, 216, 77, .66), rgba(255, 166, 62, .28));
}

.top-three-row.rank-1 .player-name strong {
  font-size: 15px;
}

.top-three-row .player-score {
  justify-self: end;
  min-width: 56px;
  text-align: right;
  font-size: 17px;
}

.submit-form .section-title {
  align-items: flex-start;
}

.submit-form .section-title strong {
  font-size: 17px;
}

.submit-form .section-title span {
  padding-top: 2px;
  white-space: nowrap;
}

.submit-form label {
  position: relative;
}

.field-hint {
  display: block;
  margin-top: 2px;
  color: #9a8ca6;
  font-size: 10px;
  line-height: 1.2;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: none;
}

.restore-note {
  margin: 9px 2px 0 !important;
  color: #8f7f99 !important;
  font-size: 11px !important;
  line-height: 1.32 !important;
  font-weight: 850 !important;
  text-align: left;
}

.form-message {
  margin-top: 7px !important;
  text-align: left;
}

@media (max-width: 380px) {
  .top-three-row {
    grid-template-columns: 36px minmax(0, 1fr) minmax(48px, auto);
    gap: 7px;
    padding: 7px 8px;
  }

  .top-three-row .player-score {
    min-width: 48px;
    font-size: 15px;
  }

  .submit-form .section-title {
    display: block;
  }

  .submit-form .section-title span {
    display: block;
    margin-top: 2px;
  }
}

/* V21: danger warning flash + safer active-game UX */
.danger-label.is-alert {
  color: #ffffff;
  background: linear-gradient(135deg, rgba(255, 31, 91, 0.96), rgba(255, 125, 39, 0.92));
  border-color: rgba(255, 255, 255, 0.72);
  box-shadow: 0 0 0 4px rgba(255, 55, 100, 0.16), 0 0 24px rgba(255, 31, 91, 0.46);
  opacity: 1;
  animation: dangerLinePulse 0.42s ease-in-out infinite alternate;
}

@keyframes dangerLinePulse {
  from { transform: translateX(-50%) scale(0.98); filter: brightness(1); }
  to { transform: translateX(-50%) scale(1.06); filter: brightness(1.12); }
}


/* V22: clearer game-over score typography */
#finalScoreTitle {
  font-family: "Arial Rounded MT Bold", "SF Pro Rounded", "Trebuchet MS", system-ui, -apple-system, sans-serif;
  letter-spacing: -0.015em !important;
  word-spacing: 0.06em;
  line-height: 1.08 !important;
  font-weight: 950;
  font-size: clamp(32px, 9.5vw, 46px);
  color: #362846;
  text-rendering: geometricPrecision;
}

.game-over-head #finalScoreTitle {
  margin-top: 8px;
  margin-bottom: 4px;
}
