/* RITUALRUSH — single-screen dashboard · RitualDoc palette */
@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@500;600;700;800&family=Rajdhani:wght@500;600;700&display=swap');

:root {
  --primary: #8bff4d;
  --primary-dim: #6edc3f;
  --accent: #d4ffc2;
  --bg: #070a07;
  --surface: #0b110b;
  --elevated: #101a10;
  --panel: linear-gradient(165deg, #142014 0%, #0c140c 55%, #0a100a 100%);
  --border: rgba(139, 255, 77, 0.18);
  --border-green: rgba(139, 255, 77, 0.4);
  --border-strong: rgba(139, 255, 77, 0.7);
  --text: #f5fff0;
  --soft: #c8f5a8;
  --muted-green: #8fd96a;
  --destructive: #ff4d4d;
  --radius: 16px;
  --radius-sm: 12px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --font-d: 'Orbitron', system-ui, sans-serif;
  --font-b: 'Rajdhani', system-ui, sans-serif;
  --top-h: 58px;
  --foot-h: 40px;
}

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

html,
body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-b);
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.01em;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

body.playing {
  touch-action: none;
  user-select: none;
}

input,
textarea {
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
  font: inherit;
  color: inherit;
}

button {
  font: inherit;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

a {
  color: var(--primary);
  text-decoration: none;
}

.text-primary {
  color: var(--primary);
}
.text-danger {
  color: var(--destructive);
}
.soft-text {
  color: var(--soft);
}
.small {
  font-size: 0.8rem;
}
.mono {
  font-family: var(--font-d);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
}

/* ═══════════ DASHBOARD SHELL (no scroll) ═══════════ */
.dash {
  position: relative;
  height: 100dvh;
  max-height: 100dvh;
  display: grid;
  /* top | main | foot — mobile-strip is display:none on desktop */
  grid-template-rows: var(--top-h) 1fr var(--foot-h);
  overflow: hidden;
  padding-top: var(--safe-top);
  padding-bottom: var(--safe-bottom);
  isolation: isolate;
}

/* Place strip in flow only when visible (mobile media overrides rows) */
.mobile-strip {
  grid-row: auto;
}

.grid-bg {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(rgba(139, 255, 77, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139, 255, 77, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  z-index: 0;
}

/* Main/foot sit under the header so wallet dropdown is never covered */
.dash-main,
.dash-foot,
.mobile-strip {
  position: relative;
  z-index: 1;
}

/* TOP — highest layer in the dash (account menu must paint above columns) */
.dash-top {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.5rem;
  padding: 0 0.85rem;
  border-bottom: 1px solid var(--border);
  background: rgba(9, 9, 9, 0.95);
  min-height: var(--top-h);
  position: relative;
  z-index: 500;
  overflow: visible;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  justify-self: start;
}

.brand-logo {
  width: 38px;
  height: 38px;
  object-fit: contain;
  mix-blend-mode: screen;
}

.logo-rush {
  mix-blend-mode: screen;
  background: transparent !important;
}

.brand-name {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 1.05rem;
  letter-spacing: 0.1em;
}

.brand-ritual {
  color: #fff;
}
.brand-rush {
  color: var(--primary);
  text-shadow: 0 0 12px rgba(139, 255, 77, 0.45);
}

.dash-tagline {
  font-family: var(--font-d);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  color: var(--primary);
  text-align: center;
  white-space: nowrap;
  text-shadow: 0 0 18px rgba(139, 255, 77, 0.35);
}

.dash-top-right {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  justify-self: end;
  overflow: visible;
  z-index: 510;
}

/* RainbowKit mount only — does not change dash grid layout */
#wallet-root {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-height: 40px;
  max-width: min(280px, 46vw);
}

.chain-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-family: var(--font-d);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--primary);
  border: 1px solid var(--border-green);
  padding: 0.3rem 0.55rem;
  border-radius: 999px;
  background: rgba(139, 255, 77, 0.06);
}

.chain-badge img {
  width: 12px;
  height: 12px;
}

.chain-badge.wrong {
  color: #ffd166;
  border-color: rgba(255, 209, 102, 0.4);
}

.btn-wallet {
  font-family: var(--font-d);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.55rem 0.9rem;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  color: #070a07;
  max-width: 150px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 0 18px rgba(139, 255, 77, 0.25);
}

.btn-wallet.connected {
  background: var(--elevated);
  color: var(--primary);
  border: 1px solid var(--border-green);
}

/* MAIN 3-COL */
.dash-main {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(320px, 440px) minmax(240px, 300px);
  gap: 0.85rem;
  padding: 0.75rem 1rem;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
  justify-content: center;
}

.dash-col {
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow: hidden;
}

.dash-center {
  align-items: center;
}

/* Side panels */
.panel-block {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.85rem 0.9rem;
  flex-shrink: 0;
  box-shadow: inset 0 1px 0 rgba(139, 255, 77, 0.06);
}

.brand-block {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  flex: 0 0 auto;
  padding-top: 0.45rem;
  padding-bottom: 0.45rem;
}

.side-runner {
  width: min(132px, 62%);
  height: auto;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 10px 24px rgba(139, 255, 77, 0.3));
  animation: runnerBob 1.8s ease-in-out infinite;
  will-change: transform;
}

@keyframes runnerBob {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  40% {
    transform: translateY(-7px) scale(1.02);
  }
  70% {
    transform: translateY(-3px) scale(1.01);
  }
}

.side-pitch {
  font-family: var(--font-d);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--primary);
  font-weight: 600;
}

/* How-to gets more room now that logo is gone */
.dash-left .howto-block {
  flex: 1 1 auto;
  min-height: 0;
}

.block-title {
  font-family: var(--font-d);
  font-size: 0.82rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-align: center;
  margin-bottom: 0.25rem;
  color: #fff;
}

/* How-to live panel */
.howto-block {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border-color: var(--border-green);
}

.howto-live {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.38rem;
  margin-top: 0.35rem;
  overflow-y: auto;
  min-height: 0;
  flex: 1;
  padding-right: 0.35rem;
  touch-action: pan-y;
  scrollbar-gutter: stable;
}

.howto-live li {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 0.4rem;
  align-items: start;
}

.ht-n {
  font-family: var(--font-d);
  font-size: 0.7rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1.25;
  text-shadow: 0 0 10px rgba(139, 255, 77, 0.35);
}

.howto-live strong {
  display: block;
  font-family: var(--font-d);
  font-size: 0.64rem;
  letter-spacing: 0.06em;
  color: #fff;
  margin-bottom: 0.08rem;
}

.howto-live p {
  font-size: 0.78rem;
  line-height: 1.22;
  color: var(--soft);
  font-weight: 600;
}

.dual-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
  padding: 0.65rem;
}

.mini-col {
  text-align: center;
  padding: 0.45rem 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}

.mini-col.good {
  border-color: var(--border-green);
  background: rgba(139, 255, 77, 0.08);
}

.mini-col.bad {
  border-color: rgba(255, 77, 77, 0.35);
  background: rgba(255, 60, 60, 0.08);
}

.mini-col h3 {
  font-family: var(--font-d);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  margin-bottom: 0.3rem;
}

.item-row.tight {
  gap: 0.15rem;
  font-size: 1.05rem;
}

.stats-glance .glance-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.glance-grid > div {
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 0.45rem;
  text-align: center;
}

.g-label {
  display: block;
  font-family: var(--font-d);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: var(--muted-green);
  margin-bottom: 0.15rem;
}

.g-val {
  font-family: var(--font-d);
  font-size: 0.85rem;
  font-weight: 800;
  color: #fff;
}

.collect-title {
  color: var(--primary);
  text-shadow: 0 0 12px rgba(139, 255, 77, 0.4);
}

.avoid-title {
  color: var(--destructive);
  text-shadow: 0 0 12px rgba(255, 92, 92, 0.35);
}

.block-sub {
  font-family: var(--font-d);
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  color: var(--soft);
  text-align: center;
  margin-bottom: 0.45rem;
}

.block-note {
  font-family: var(--font-d);
  font-size: 0.5rem;
  letter-spacing: 0.08em;
  color: var(--primary-dim);
  text-align: center;
  margin-top: 0.4rem;
}

.item-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  font-size: 1.15rem;
}

.avoid-block {
  border-color: rgba(255, 92, 92, 0.3);
  background: linear-gradient(180deg, rgba(255, 60, 60, 0.08), var(--elevated));
}

.panel-block:has(.collect-title) {
  border-color: var(--border-green);
  background: linear-gradient(180deg, rgba(139, 255, 77, 0.08), var(--elevated));
}

.ctrl-row {
  display: flex;
  justify-content: center;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.ctrl-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
}

.key {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.55rem;
  height: 1.55rem;
  padding: 0 0.3rem;
  margin: 0 0.05rem;
  border-radius: 6px;
  font-family: var(--font-d);
  font-size: 0.62rem;
  font-weight: 700;
  color: #090909;
  background: linear-gradient(180deg, #c8ffd2, #8bff4d);
  box-shadow: 0 2px 0 #4a9a28;
}

.key-wide {
  min-width: 2.8rem;
  font-size: 0.5rem;
  letter-spacing: 0.04em;
}

.ctrl-label {
  font-family: var(--font-d);
  font-size: 0.48rem;
  letter-spacing: 0.08em;
  color: var(--soft);
}

/* Leaderboard column */
.lb-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.lb-head {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.2rem;
}

.lb-head .block-title {
  margin: 0;
}

.lb-list-live {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  margin: 0.35rem 0 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.28rem;
  touch-action: pan-y;
  padding-right: 0.25rem;
  scrollbar-gutter: stable;
}

.lb-item {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 0.55rem;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  border-radius: 10px;
  font-size: 0.9rem;
  cursor: pointer;
  transition: border-color 0.12s, background 0.12s;
}

.lb-item:hover {
  border-color: rgba(139, 255, 77, 0.45);
  background: rgba(139, 255, 77, 0.06);
}

.lb-item.top {
  border-color: var(--border-green);
  background: rgba(139, 255, 77, 0.07);
}

.lb-item.you {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 1px rgba(139, 255, 77, 0.15);
}

.lb-rank {
  font-family: var(--font-d);
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary);
}

.lb-name {
  font-weight: 700;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-meta {
  font-size: 0.75rem;
  color: var(--soft);
  font-weight: 600;
}

.lb-score {
  font-family: var(--font-d);
  font-weight: 800;
  color: var(--primary);
  font-size: 0.9rem;
}

.lb-hint,
.lb-hint-mobile {
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--muted, #8fd96a);
  margin: 0 0 0.45rem;
  opacity: 0.9;
}

.lb-body {
  min-width: 0;
  flex: 1;
}

/* Run history panel — 1 wide row: photo · user/score · VIEW */
#screenHistory.overlay {
  align-items: flex-start;
  padding: 0.65rem 0.55rem;
  padding-top: max(0.65rem, env(safe-area-inset-top, 0px));
  padding-bottom: max(0.65rem, env(safe-area-inset-bottom, 0px));
}

#screenHistory .panel-inner.history-panel {
  max-width: min(440px, 100%);
  width: 100%;
  margin: 0 auto;
  padding: 0.85rem 0.7rem 1rem;
  box-sizing: border-box;
  overflow: visible;
}

.history-panel {
  max-width: min(440px, 100%);
  width: 100%;
  box-sizing: border-box;
}

.history-head-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.75rem;
  text-align: left;
  min-width: 0;
}

.history-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: 2px solid rgba(139, 255, 77, 0.5);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #0c140c;
  flex-shrink: 0;
  font-size: 1.25rem;
}

.history-av-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.history-av-letter {
  font-family: var(--font-d);
  font-weight: 800;
  color: var(--primary);
  font-size: 1.05rem;
}

.history-head-text {
  min-width: 0;
  flex: 1;
  overflow: hidden;
}

.history-title {
  margin: 0 !important;
  text-align: left !important;
  font-size: 0.92rem !important;
  word-break: break-word;
}

#historySub {
  word-break: break-word;
  white-space: normal;
  line-height: 1.35;
}

.history-list {
  list-style: none;
  margin: 0 0 0.85rem;
  padding: 0;
  max-height: min(58dvh, 420px);
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
  -webkit-overflow-scrolling: touch;
}

.history-item {
  display: grid;
  grid-template-columns: 40px minmax(0, 1fr) 3.4rem;
  align-items: center;
  column-gap: 0.45rem;
  width: 100%;
  max-width: 100%;
  padding: 0.5rem 0.45rem;
  border-radius: 12px;
  border: 1px solid rgba(139, 255, 77, 0.28);
  background: rgba(8, 16, 8, 0.9);
  box-sizing: border-box;
  overflow: visible;
  min-height: 3.4rem;
}

.history-item .history-av {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid rgba(139, 255, 77, 0.4);
  overflow: hidden;
  display: grid;
  place-items: center;
  background: #0a120a;
  flex-shrink: 0;
}

.history-main {
  min-width: 0;
  max-width: 100%;
  text-align: left;
  overflow: hidden;
}

.history-name {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.history-score {
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 0.95rem;
  line-height: 1.2;
  margin-top: 0.05rem;
}

.history-meta {
  font-size: 0.58rem;
  color: #9fe07a;
  margin-top: 0.1rem;
  white-space: normal;
  line-height: 1.3;
  word-break: break-word;
  overflow: visible;
}

/* Compact VIEW — text fully inside button */
.btn-history-dl {
  justify-self: end;
  align-self: center;
  width: 3.35rem;
  min-width: 3.35rem;
  max-width: 3.35rem;
  height: 2.15rem;
  padding: 0;
  margin: 0;
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
  line-height: 2.15rem;
  text-align: center;
  border-radius: 999px;
  box-sizing: border-box;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  #screenHistory .panel-inner.history-panel {
    max-width: 100%;
    padding: 0.75rem 0.6rem 0.9rem;
  }

  .history-item {
    grid-template-columns: 36px minmax(0, 1fr) 3.2rem;
    column-gap: 0.4rem;
    padding: 0.48rem 0.4rem;
  }

  .history-item .history-av {
    width: 36px;
    height: 36px;
  }

  .history-avatar {
    width: 42px;
    height: 42px;
  }

  .history-name {
    font-size: 0.64rem;
  }

  .history-score {
    font-size: 0.88rem;
  }

  .history-meta {
    font-size: 0.55rem;
  }

  .btn-history-dl {
    width: 3.15rem;
    min-width: 3.15rem;
    max-width: 3.15rem;
    height: 2rem;
    font-size: 0.55rem;
    line-height: 2rem;
  }

  .history-list {
    max-height: min(55dvh, 380px);
  }
}

#goSaveHint {
  margin: 0.35rem 0 0.15rem;
  text-align: center;
}

/* History card preview popup */
.card-preview-popup {
  position: fixed;
  inset: 0;
  z-index: 100050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.card-preview-popup[hidden] {
  display: none !important;
}

.card-preview-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 4, 0.88);
  backdrop-filter: blur(10px);
}

.card-preview-popup-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  max-height: min(92dvh, 720px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: linear-gradient(165deg, #142014 0%, #0a120a 100%);
  border: 1px solid rgba(139, 255, 77, 0.4);
  border-radius: 18px;
  padding: 0.85rem 0.85rem 1rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 40px rgba(139, 255, 77, 0.12);
  text-align: center;
}

.card-preview-popup-title {
  font-family: var(--font-d);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: #fff;
  margin: 0 0 0.65rem;
}

.card-preview-popup-frame {
  flex: 1;
  min-height: 0;
  overflow: auto;
  border-radius: 12px;
  border: 1px solid rgba(139, 255, 77, 0.25);
  background: #050805;
  -webkit-overflow-scrolling: touch;
}

.card-preview-popup-frame img {
  display: block;
  width: 100%;
  height: auto;
  vertical-align: top;
}

.card-preview-popup-hint {
  margin: 0.55rem 0 0;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  opacity: 0.9;
}

.card-preview-popup-actions {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.65rem;
}

.card-preview-popup-actions .btn-primary,
.card-preview-popup-actions .btn-ghost {
  min-width: 7rem;
}

.lb-empty {
  text-align: center;
  color: var(--soft);
  font-family: var(--font-d);
  font-size: 0.7rem;
  letter-spacing: 0.06em;
  padding: 1.25rem 0.5rem;
  list-style: none;
}

.flow-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.flow-list li {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-family: var(--font-d);
  font-size: 0.58rem;
  letter-spacing: 0.06em;
  color: var(--soft);
}

.flow-list span {
  color: var(--primary);
  font-weight: 700;
  min-width: 1.4rem;
}

.ritualdoc-mini {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-green);
  background: rgba(139, 255, 77, 0.06);
  font-family: var(--font-d);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  color: var(--primary);
  flex-shrink: 0;
}

.ritualdoc-mini img {
  width: 18px;
  height: 18px;
  border-radius: 50%;
}

/* GAME SHELL */
.game-shell {
  width: 100%;
  max-width: 440px;
  height: 100%;
  min-height: 0;
  border-radius: 20px;
  border: 1px solid var(--border-green);
  box-shadow:
    0 0 0 1px rgba(139, 255, 77, 0.08),
    0 16px 48px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(139, 255, 77, 0.1);
  overflow: hidden;
  background: #080c08;
}

.app {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: radial-gradient(ellipse 80% 50% at 50% 100%, rgba(139, 255, 77, 0.05), transparent 60%),
    #0a0c0a;
  overflow: hidden;
}

/* Ensure absolute HUD / touch controls anchor to stage */
.stage .touch-pad {
  position: absolute;
}

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

/* HUD */
.hud {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 10;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 0.25rem;
  padding: 0.45rem 0.5rem;
  pointer-events: none;
  background: linear-gradient(to bottom, rgba(9, 9, 9, 0.8), transparent);
}

.hud-label {
  font-family: var(--font-d);
  font-size: 0.62rem;
  letter-spacing: 0.12em;
  color: var(--primary-dim);
  font-weight: 600;
}

.hud-score {
  font-family: var(--font-d);
  font-size: 1.65rem;
  font-weight: 800;
  color: #8bff4d;
  line-height: 1.05;
  text-shadow: 0 0 16px rgba(139, 255, 77, 0.45);
}

.hud-combo {
  font-family: var(--font-d);
  font-size: 0.62rem;
  font-weight: 700;
  color: var(--accent);
  min-height: 1em;
}

.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.1rem;
}

.hud-lives {
  display: flex;
  gap: 0.1rem;
  font-size: 0.95rem;
}

.hud-lives .heart.lost {
  opacity: 0.22;
  filter: grayscale(1);
}

.hud-dist {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 0.72rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.hud-side {
  display: flex;
  justify-content: flex-end;
  gap: 0.25rem;
  pointer-events: auto;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(17, 17, 17, 0.9);
  border: 1px solid var(--border);
  font-size: 0.85rem;
  display: grid;
  place-items: center;
}

.fx-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 8;
  overflow: hidden;
}

.fx-pop {
  position: absolute;
  font-family: var(--font-d);
  font-weight: 800;
  font-size: 0.95rem;
  color: var(--primary);
  text-shadow: 0 0 12px rgba(139, 255, 77, 0.7);
  animation: popUp 0.7s ease-out forwards;
  white-space: nowrap;
}

.fx-pop.bad {
  color: var(--destructive);
  text-shadow: 0 0 12px rgba(255, 92, 92, 0.7);
}

@keyframes popUp {
  0% {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translateY(-48px) scale(1.12);
  }
}

/* OVERLAYS inside game */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem;
  background: rgba(9, 9, 9, 0.78);
  backdrop-filter: blur(8px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
}

.overlay[hidden] {
  display: none !important;
}

.panel-inner {
  width: 100%;
  max-width: 340px;
  background: linear-gradient(165deg, #162416 0%, #0d140d 100%);
  border: 1px solid var(--border-green);
  border-radius: var(--radius);
  padding: 1.15rem 1.05rem;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5), 0 0 36px rgba(139, 255, 77, 0.1);
  text-align: center;
}

/* START RUN must always receive clicks above canvas/fx */
#btnStart {
  position: relative;
  z-index: 30;
  pointer-events: auto !important;
  cursor: pointer !important;
  touch-action: manipulation;
}

.start-panel {
  position: relative;
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.35rem;
}

.start-hero-logo {
  width: min(200px, 72%);
  height: auto;
  object-fit: contain;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 24px rgba(139, 255, 77, 0.35));
}

.start-line {
  font-family: var(--font-d);
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin: 0.2rem 0 0.45rem;
}

.panel-title {
  font-family: var(--font-d);
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  margin-bottom: 0.45rem;
}

.danger-title {
  color: var(--destructive);
}

/* Forms */
.start-name-form {
  width: 100%;
  text-align: left;
  margin: 0.25rem 0 0.5rem;
}

.start-name-form label {
  display: block;
  font-family: var(--font-d);
  font-size: 0.55rem;
  letter-spacing: 0.12em;
  color: var(--primary);
  margin-bottom: 0.3rem;
  text-align: center;
}

.start-name-form input {
  width: 100%;
  padding: 0.8rem 0.85rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-green);
  background: #0a100a;
  color: #fff;
  text-align: center;
  font-family: var(--font-d);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  outline: none;
  text-transform: uppercase;
}

.start-name-form input:focus {
  border-color: var(--border-strong);
  box-shadow: 0 0 0 3px rgba(139, 255, 77, 0.12);
}

.start-name-form input.error {
  border-color: rgba(255, 92, 92, 0.65);
}

.field-hint {
  margin-top: 0.3rem;
  font-family: var(--font-d);
  font-size: 0.52rem;
  letter-spacing: 0.06em;
  color: var(--soft);
  text-align: center;
}

.field-hint.error {
  color: var(--destructive);
}

.start-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.4rem;
  width: 100%;
  margin-bottom: 0.5rem;
}

.stat {
  background: rgba(139, 255, 77, 0.05);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.4rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-items: center;
}

.stat-label {
  font-family: var(--font-d);
  font-size: 0.5rem;
  letter-spacing: 0.1em;
  color: var(--primary-dim);
}

.stat-value {
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 0.95rem;
  color: var(--primary);
}

/* Buttons */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.9rem 1rem;
  border-radius: 999px;
  font-family: var(--font-d);
  font-weight: 700;
  font-size: 0.85rem;
  letter-spacing: 0.1em;
  background: linear-gradient(135deg, var(--primary), #a8ff70 40%, var(--accent));
  color: #070a07;
  box-shadow: 0 0 24px rgba(139, 255, 77, 0.32);
}

.btn-primary.btn-lg {
  padding: 0.85rem 1rem;
}

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0.65rem 0.9rem;
  border-radius: 999px;
  font-family: var(--font-d);
  font-weight: 600;
  font-size: 0.65rem;
  letter-spacing: 0.06em;
  background: var(--elevated);
  color: var(--primary);
  border: 1px solid var(--border-green);
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0.75rem;
  border-radius: 999px;
  font-family: var(--font-d);
  font-weight: 600;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--soft);
  width: 100%;
  margin-top: 0.2rem;
}

.go-actions {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  width: 100%;
  margin-top: 0.35rem;
}

.go-scores {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem;
  margin: 0.55rem 0;
}

.go-score-card {
  background: var(--elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 0.45rem 0.3rem;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  align-items: center;
}

.go-score {
  font-family: var(--font-d);
  font-size: 1rem;
  font-weight: 800;
}

.go-player-line {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.8rem;
  margin: 0.2rem 0;
}

.go-player-line strong {
  font-family: var(--font-d);
  font-size: 0.95rem;
  letter-spacing: 0.06em;
}

.howto-list {
  text-align: left;
  list-style: none;
  margin: 0.5rem 0 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--soft);
  line-height: 1.35;
}

.howto-list li {
  padding-left: 0.85rem;
  position: relative;
  font-family: var(--font-d);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
}

.howto-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--primary);
}

/* Card profile */
.card-panel {
  max-height: min(90dvh, 640px);
  overflow-y: auto;
  touch-action: pan-y;
}

.card-top-logo {
  width: min(140px, 50%);
  height: auto;
  margin: 0 auto 0.35rem;
  display: block;
  mix-blend-mode: screen;
}

.profile-selector {
  text-align: left;
  margin: 0.5rem 0;
  padding: 0.6rem;
  background: rgba(139, 255, 77, 0.04);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
}

.profile-selector-title {
  font-family: var(--font-d);
  font-size: 0.55rem;
  letter-spacing: 0.1em;
  color: var(--soft);
  margin-bottom: 0.5rem;
}

.profile-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.profile-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  padding: 0.3rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--elevated);
}

.profile-card.selected {
  border-color: var(--border-strong);
}

.profile-card-inner {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: #0a0a0a;
  overflow: hidden;
}

.profile-card-inner.dashed {
  border: 1px dashed var(--border-green);
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  color: var(--soft);
  font-size: 0.55rem;
}

.profile-card-inner img,
.profile-card-photo {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile-option-label {
  font-family: var(--font-d);
  font-size: 0.52rem;
  letter-spacing: 0.08em;
  color: var(--soft);
}

.handle-input-row {
  display: flex;
  align-items: center;
  background: #0a0a0a;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.x-at {
  padding: 0 0.3rem 0 0.55rem;
  color: var(--soft);
  font-family: var(--font-d);
  font-size: 0.75rem;
}

.x-input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  padding: 0.55rem 0.35rem;
  outline: none;
  font-size: 0.85rem;
}

.btn-x-connect {
  flex-shrink: 0;
  padding: 0.5rem 0.55rem;
  font-family: var(--font-d);
  font-size: 0.55rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  background: var(--primary);
  color: #090909;
}

.profile-status {
  margin-top: 0.3rem;
  font-size: 0.72rem;
  color: var(--soft);
  min-height: 1em;
}

.profile-status.error {
  color: var(--destructive);
}
.profile-status.ok {
  color: var(--primary);
}

.card-preview-wrap {
  margin: 0.4rem 0 0.55rem;
}

.preview-label {
  font-family: var(--font-d);
  font-size: 0.52rem;
  letter-spacing: 0.12em;
  color: var(--soft);
  margin-bottom: 0.3rem;
  text-align: left;
}

.card-preview-frame {
  border-radius: 12px;
  border: 1px solid var(--border-green);
  overflow: hidden;
  background: #090909;
  aspect-ratio: 720 / 1100;
}

#previewCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.ritualdoc-link {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.55rem;
  padding: 0.55rem 0.65rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-green);
  background: rgba(139, 255, 77, 0.05);
  text-align: left;
}

.ritualdoc-link img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
}

.ritualdoc-link strong {
  display: block;
  font-family: var(--font-d);
  font-size: 0.65rem;
  letter-spacing: 0.08em;
  color: var(--primary);
}

.ritualdoc-link small {
  font-size: 0.65rem;
  color: var(--soft);
}

/* Touch pad — floating circular controls during play */
.touch-pad {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  pointer-events: none;
  padding: 0 1.15rem calc(1.1rem + var(--safe-bottom));
  justify-content: space-between;
  align-items: flex-end;
  background: transparent;
  border: none;
}

body.playing .touch-pad {
  display: flex;
}

.pad-btn {
  pointer-events: auto;
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, rgba(200, 255, 210, 0.35), rgba(16, 28, 16, 0.92) 55%);
  border: 2px solid rgba(139, 255, 77, 0.65);
  color: var(--primary);
  font-size: 1.35rem;
  font-weight: 700;
  box-shadow:
    0 0 0 1px rgba(139, 255, 77, 0.15),
    0 8px 24px rgba(0, 0, 0, 0.45),
    0 0 20px rgba(139, 255, 77, 0.25);
  backdrop-filter: blur(8px);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.pad-btn:active {
  transform: scale(0.94);
  background: radial-gradient(circle at 35% 30%, rgba(139, 255, 77, 0.55), rgba(20, 40, 20, 0.95) 60%);
  box-shadow: 0 0 28px rgba(139, 255, 77, 0.45);
}

/* First-visit How to Play popup */
.howto-popup {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem;
}

.howto-popup[hidden] {
  display: none !important;
}

.howto-popup-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 4, 0.82);
  backdrop-filter: blur(10px);
}

.howto-popup-card {
  position: relative;
  z-index: 1;
  width: min(400px, 100%);
  max-height: min(92dvh, 640px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: linear-gradient(165deg, #142014 0%, #0a120a 100%);
  border: 1px solid rgba(139, 255, 77, 0.4);
  border-radius: 18px;
  padding: 1rem 1rem 1.1rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 40px rgba(139, 255, 77, 0.12);
  text-align: center;
}

.howto-popup-x {
  position: absolute;
  top: 0.45rem;
  right: 0.55rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(139, 255, 77, 0.35);
  background: rgba(0, 0, 0, 0.35);
  color: #8bff4d;
  font-size: 1.4rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.howto-popup-logo {
  width: min(160px, 52%);
  height: auto;
  margin: 0.15rem auto 0.35rem;
  display: block;
  mix-blend-mode: screen;
  filter: drop-shadow(0 0 16px rgba(139, 255, 77, 0.3));
}

.howto-popup-title {
  font-family: var(--font-d);
  font-size: 1.05rem;
  letter-spacing: 0.1em;
  color: #fff;
  margin-bottom: 0.65rem;
}

/* Match classic .howto-list font style (click version) */
.howto-popup-list.howto-list {
  text-align: left;
  list-style: none;
  margin: 0 0 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-size: 0.82rem;
  color: var(--soft);
  line-height: 1.35;
  padding: 0 0.2rem;
}

.howto-popup-list.howto-list li {
  padding-left: 0.85rem;
  position: relative;
  font-family: var(--font-d);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  font-weight: 600;
  color: var(--soft);
}

.howto-popup-list.howto-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--primary);
}

.howto-popup-list.howto-list strong {
  color: #fff;
  font-weight: 700;
}

.howto-popup-items {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-bottom: 0.55rem;
}

.howto-popup-col {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 0.45rem 0.35rem;
}

.howto-popup-col.good {
  border-color: rgba(139, 255, 77, 0.4);
  background: rgba(139, 255, 77, 0.08);
}

.howto-popup-col.bad {
  border-color: rgba(255, 80, 80, 0.4);
  background: rgba(255, 60, 60, 0.08);
}

.howto-popup-sub {
  font-family: var(--font-d);
  font-size: 0.52rem;
  letter-spacing: 0.06em;
  color: var(--soft);
  margin: 0.25rem 0 0.2rem;
}

.howto-popup-note {
  font-size: 0.82rem;
  color: var(--soft);
  line-height: 1.35;
  margin-bottom: 0.75rem;
  font-weight: 600;
}

.howto-popup-note strong {
  color: #fff;
}

body.howto-open {
  overflow: hidden;
}

.app {
  position: relative;
}

/* FOOT */
.dash-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0 1rem;
  border-top: 1px solid var(--border);
  background: rgba(7, 10, 7, 0.96);
  font-family: var(--font-d);
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--soft);
  min-height: var(--foot-h);
}

.foot-left,
.foot-right {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  flex-wrap: wrap;
}

.foot-logo {
  width: 18px;
  height: 18px;
  object-fit: contain;
  mix-blend-mode: screen;
}

.foot-ritual {
  display: inline-flex;
  align-items: center;
  gap: 0.2rem;
  color: var(--primary);
}

.foot-ritual img {
  width: 11px;
  height: 11px;
}

.sep {
  opacity: 0.4;
}

/* ── Neon scrollbars (RitualRush) ── */
.howto-live,
.lb-list-live,
.card-panel,
.overlay,
.panel-block.howto-block {
  scrollbar-width: thin;
  scrollbar-color: rgba(139, 255, 77, 0.55) rgba(139, 255, 77, 0.06);
}

.howto-live::-webkit-scrollbar,
.lb-list-live::-webkit-scrollbar,
.card-panel::-webkit-scrollbar,
.overlay::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

.howto-live::-webkit-scrollbar-track,
.lb-list-live::-webkit-scrollbar-track,
.card-panel::-webkit-scrollbar-track,
.overlay::-webkit-scrollbar-track {
  background: linear-gradient(
    180deg,
    rgba(139, 255, 77, 0.04),
    rgba(139, 255, 77, 0.08)
  );
  border-radius: 999px;
  margin: 4px 0;
  border: 1px solid rgba(139, 255, 77, 0.08);
}

.howto-live::-webkit-scrollbar-thumb,
.lb-list-live::-webkit-scrollbar-thumb,
.card-panel::-webkit-scrollbar-thumb,
.overlay::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, #c8ffd2 0%, #8bff4d 45%, #6edc3f 100%);
  border-radius: 999px;
  box-shadow:
    0 0 8px rgba(139, 255, 77, 0.55),
    inset 0 0 0 1px rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(9, 9, 9, 0.25);
}

.howto-live::-webkit-scrollbar-thumb:hover,
.lb-list-live::-webkit-scrollbar-thumb:hover,
.card-panel::-webkit-scrollbar-thumb:hover,
.overlay::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #e8ffe0 0%, #a8ff70 40%, #8bff4d 100%);
  box-shadow:
    0 0 14px rgba(139, 255, 77, 0.85),
    inset 0 0 0 1px rgba(255, 255, 255, 0.25);
}

.howto-live::-webkit-scrollbar-thumb:active,
.lb-list-live::-webkit-scrollbar-thumb:active,
.card-panel::-webkit-scrollbar-thumb:active,
.overlay::-webkit-scrollbar-thumb:active {
  background: #8bff4d;
  box-shadow: 0 0 10px rgba(139, 255, 77, 0.9);
}

.howto-live::-webkit-scrollbar-corner,
.lb-list-live::-webkit-scrollbar-corner,
.card-panel::-webkit-scrollbar-corner,
.overlay::-webkit-scrollbar-corner {
  background: transparent;
}

/* Toast */
.toast {
  position: fixed;
  left: 50%;
  bottom: calc(48px + var(--safe-bottom));
  transform: translateX(-50%) translateY(10px);
  z-index: 100;
  background: var(--elevated);
  border: 1px solid var(--border-green);
  color: var(--text);
  font-family: var(--font-d);
  font-size: 0.65rem;
  letter-spacing: 0.04em;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  max-width: min(90vw, 320px);
  text-align: center;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.toast.error {
  border-color: rgba(255, 92, 92, 0.45);
}

/* Mobile strip — hidden on desktop (grid ignores display:none children) */
.mobile-strip {
  display: none;
}

/* PLAYING: full-screen game only */
body.playing .dash-left,
body.playing .dash-right,
body.playing .dash-tagline,
body.playing .mobile-strip,
body.playing .dash-top,
body.playing .dash-foot,
body.playing .howto-popup {
  display: none !important;
}

body.playing .dash {
  grid-template-rows: 1fr;
  height: 100dvh;
  max-height: 100dvh;
}

body.playing .dash-main {
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  grid-template-columns: none;
  padding: 0;
  gap: 0;
  min-height: 0;
  height: 100%;
}

/* Desktop playing: keep game frame centered (not stuck to edge) */
body.playing .dash-center {
  flex: 0 1 440px;
  width: min(440px, 100%);
  max-width: 440px;
  margin: 0 auto;
  min-height: 0;
  height: 100%;
}

body.playing .game-shell {
  max-width: 440px;
  width: 100%;
  height: 100%;
  margin: 0 auto;
  border-radius: 0;
  border: none;
  box-shadow: none;
}

body.playing .touch-pad {
  display: flex;
}

/*
 * Mobile = top → bottom full-width stack
 * Desktop (≥901px) = left → center → right (unchanged 3-column)
 */
@media (max-width: 900px) {
  html,
  body {
    overflow-x: hidden;
    overflow-y: auto;
    height: auto;
    min-height: 100dvh;
  }

  .dash {
    /* top | strip | main (scrolls) | foot */
    display: flex;
    flex-direction: column;
    height: auto;
    max-height: none;
    min-height: 100dvh;
    overflow: visible;
  }

  .dash-top {
    position: sticky;
    top: 0;
    grid-template-columns: 1fr auto;
    min-height: 48px;
    padding: 0.45rem 0.75rem;
    flex-shrink: 0;
    z-index: 500;
    overflow: visible;
  }

  .brand-name {
    font-size: 0.88rem;
  }

  .brand-logo {
    width: 32px;
    height: 32px;
  }

  .dash-tagline {
    display: none;
  }

  .btn-wallet {
    font-size: 0.6rem;
    padding: 0.42rem 0.65rem;
    max-width: 120px;
  }

  /* Collect / avoid / controls — full width under header */
  .mobile-strip {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    padding: 0.55rem 0.75rem;
    border-bottom: 1px solid var(--border-green);
    background: linear-gradient(180deg, #0c140c, #080c08);
    flex-shrink: 0;
  }

  .mobile-strip-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
  }

  .ms-badge {
    flex-shrink: 0;
    font-family: var(--font-d);
    font-size: 0.62rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    padding: 0.3rem 0.55rem;
    border-radius: 999px;
  }

  .ms-badge.collect {
    color: #070a07;
    background: linear-gradient(135deg, #8bff4d, #c8ffd2);
  }

  .ms-badge.avoid {
    color: #fff;
    background: linear-gradient(135deg, #ff4d4d, #ff8a5c);
  }

  .ms-emojis {
    font-size: 1.05rem;
    letter-spacing: 0.1em;
  }

  .mobile-strip-hint {
    font-family: var(--font-d);
    font-size: 0.58rem;
    letter-spacing: 0.12em;
    color: var(--primary);
    text-align: center;
  }

  /* Stack: game full width, then leaderboard full width */
  .dash-main {
    display: flex;
    flex-direction: column;
    grid-template-columns: none;
    grid-template-rows: none;
    gap: 0.75rem;
    padding: 0.65rem 0.65rem 1rem;
    min-height: 0;
    overflow: visible;
    flex: 1 1 auto;
  }

  .dash-left {
    display: none !important;
  }

  /* GAME block — full page width, tall enough for “ready when you are” */
  .dash-center {
    order: 1;
    flex: 0 0 auto;
    width: 100%;
    min-height: 0;
  }

  .game-shell {
    max-width: 100%;
    width: 100%;
    height: auto;
    min-height: min(78dvh, 720px);
    height: min(78dvh, 720px);
    border-radius: 16px;
  }

  /* Leaderboard — own full-width section (not a tiny strip) */
  .dash-right {
    order: 2;
    flex: 0 0 auto;
    width: 100%;
    max-height: none;
    min-height: 280px;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
  }

  .dash-right .stats-glance,
  .dash-right .ctrl-block {
    display: none !important;
  }

  .lb-panel {
    flex: 1 1 auto;
    width: 100%;
    min-height: 320px;
    max-height: none;
    padding: 0.85rem 0.9rem;
  }

  .lb-list-live {
    max-height: 50dvh;
    min-height: 220px;
  }

  .lb-item {
    padding: 0.55rem 0.6rem;
    font-size: 0.9rem;
  }

  .dash-foot {
    position: relative;
    font-size: 0.58rem;
    padding: 0.55rem 0.75rem calc(0.55rem + var(--safe-bottom));
    min-height: auto;
    flex-shrink: 0;
  }

  .foot-logo {
    width: 16px;
    height: 16px;
  }

  /* Start menu fills the game shell width */
  .overlay {
    align-items: stretch;
    justify-content: stretch;
    padding: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .panel-inner {
    max-width: none;
    width: 100%;
    min-height: 100%;
    margin: 0;
    border-radius: 0;
    border: none;
    box-shadow: none;
    padding: 1.25rem 1.1rem 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
  }

  .start-panel {
    width: 100%;
    max-width: 420px;
    margin: 0 auto;
    gap: 0.5rem;
  }

  .start-hero-logo {
    width: min(220px, 70%);
  }

  .start-line {
    font-size: 0.78rem;
    letter-spacing: 0.12em;
  }

  .start-name-form {
    width: 100%;
  }

  .start-name-form label {
    font-size: 0.62rem;
    letter-spacing: 0.12em;
  }

  .start-name-form input {
    font-size: 1rem;
    padding: 0.85rem 1rem;
    letter-spacing: 0.08em;
  }

  .field-hint {
    font-size: 0.58rem;
  }

  .stat-label {
    font-size: 0.55rem;
  }

  .stat-value {
    font-size: 1rem;
  }

  .block-title {
    font-size: 0.78rem;
  }

  .lb-name {
    font-size: 0.88rem;
  }

  .lb-score {
    font-size: 0.88rem;
  }

  .start-stats {
    width: 100%;
  }

  .btn-primary {
    font-size: 0.8rem;
    padding: 0.9rem 1rem;
    width: 100%;
  }

  .hud-score {
    font-size: 1.4rem;
  }

  .card-panel {
    max-height: none;
    min-height: 100%;
  }

  .gameover-panel,
  .card-panel,
  .panel-inner {
    box-sizing: border-box;
  }

  body.playing .pad-btn {
    width: 74px;
    height: 74px;
    font-size: 1.5rem;
  }

  body.playing .touch-pad {
    padding-left: 1.25rem;
    padding-right: 1.25rem;
    padding-bottom: calc(1.35rem + var(--safe-bottom));
  }
}

/* Playing on mobile: true full-screen game (edge-to-edge OK on phone) */
@media (max-width: 900px) {
  body.playing {
    overflow: hidden;
    height: 100dvh;
  }

  body.playing .dash {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }

  body.playing .dash-main {
    padding: 0;
    gap: 0;
    flex: 1;
    min-height: 0;
    flex-direction: column;
  }

  body.playing .dash-center {
    flex: 1 1 auto;
    width: 100%;
    max-width: none;
    margin: 0;
  }

  body.playing .game-shell {
    min-height: 100%;
    height: 100%;
    max-width: none;
    border-radius: 0;
  }

  body.playing .mobile-strip {
    display: none !important;
  }
}

/* Wallet picker modal — always on top of game UI (RainbowKit-style) */
.wallet-picker {
  position: fixed;
  inset: 0;
  z-index: 100000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.85rem;
}

.wallet-picker[hidden] {
  display: none !important;
}

.wallet-picker-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 4, 0.88);
  backdrop-filter: blur(10px);
}

.wallet-picker-card {
  position: relative;
  z-index: 1;
  width: min(380px, 100%);
  background: linear-gradient(165deg, #142014 0%, #0a120a 100%);
  border: 1px solid rgba(139, 255, 77, 0.4);
  border-radius: 18px;
  padding: 1.15rem 1rem 1rem;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.55), 0 0 40px rgba(139, 255, 77, 0.12);
}

.wallet-picker-x {
  position: absolute;
  top: 0.45rem;
  right: 0.55rem;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(139, 255, 77, 0.25);
  background: rgba(0, 0, 0, 0.35);
  color: #c8f5a8;
  font-size: 1.25rem;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
}

.wallet-picker-title {
  font-family: var(--font-d);
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: #fff;
  margin: 0 1.75rem 0.25rem 0;
}

.wallet-picker-sub {
  margin: 0 0 0.9rem;
  font-size: 0.72rem;
  color: var(--muted, #8fd96a);
  letter-spacing: 0.04em;
}

.wallet-picker-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.wallet-opt {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  width: 100%;
  text-align: left;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  border: 1px solid rgba(139, 255, 77, 0.28);
  background: rgba(8, 16, 8, 0.9);
  color: #fff;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, transform 0.12s;
}

.wallet-opt:hover:not(:disabled) {
  border-color: rgba(139, 255, 77, 0.65);
  background: rgba(20, 40, 20, 0.95);
  transform: translateY(-1px);
}

.wallet-opt:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.wallet-opt-icon {
  font-size: 1.45rem;
  width: 2rem;
  text-align: center;
  flex-shrink: 0;
}

.wallet-opt-text {
  display: flex;
  flex-direction: column;
  gap: 0.12rem;
  flex: 1;
  min-width: 0;
}

.wallet-opt-text strong {
  font-family: var(--font-d);
  font-size: 0.82rem;
  letter-spacing: 0.04em;
}

.wallet-opt-text small {
  font-size: 0.68rem;
  color: #9fe07a;
  opacity: 0.9;
}

.wallet-opt-chev {
  color: var(--primary);
  font-size: 1.2rem;
  opacity: 0.7;
}

.wallet-picker-foot {
  min-height: 1.1rem;
  margin: 0.75rem 0 0;
  font-size: 0.7rem;
  color: #c8f5a8;
  text-align: center;
}

.wallet-picker-foot.error {
  color: #ff8a8a;
}

/* Wallet wrap + button */
.wallet-wrap {
  position: relative;
  z-index: 510;
  overflow: visible;
}

.btn-wallet {
  position: relative;
  z-index: 511;
  pointer-events: auto;
  cursor: pointer;
}

/*
 * Account menu is portaled to <body> as position:fixed (see openWalletMenu).
 * Never clip under dash columns again.
 */
.wallet-menu {
  position: fixed;
  z-index: 100001;
  min-width: 220px;
  max-width: min(320px, calc(100vw - 16px));
  padding: 0.45rem;
  border-radius: 12px;
  border: 1px solid rgba(139, 255, 77, 0.45);
  background: linear-gradient(165deg, #162416, #0a120a);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 0 1px rgba(139, 255, 77, 0.08);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  /* top/right set in JS from button rect */
}

.wallet-menu[hidden] {
  display: none !important;
}

.wallet-menu-addr {
  padding: 0.45rem 0.55rem;
  font-size: 0.72rem;
  color: var(--primary);
  border-bottom: 1px solid rgba(139, 255, 77, 0.15);
  margin-bottom: 0.15rem;
  word-break: break-all;
}

.wallet-menu-item {
  text-align: left;
  padding: 0.5rem 0.55rem;
  border-radius: 8px;
  font-family: var(--font-d);
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  color: var(--soft);
  background: transparent;
  border: none;
  cursor: pointer;
}

.wallet-menu-item:hover {
  background: rgba(139, 255, 77, 0.1);
  color: #fff;
}

.wallet-menu-item.danger {
  color: #ff8a8a;
}

.wallet-menu-item.danger:hover {
  background: rgba(255, 80, 80, 0.12);
  color: #ffb0b0;
}

.howto-popup-live {
  margin: 0 0 0.85rem;
  max-height: min(52dvh, 360px);
  overflow-y: auto;
  text-align: left;
  padding-right: 0.25rem;
}

.howto-popup-live .ht-n {
  font-size: 0.72rem;
}

.howto-popup-live strong {
  font-size: 0.68rem;
}

.howto-popup-live p {
  font-size: 0.8rem;
}

@media (max-width: 400px) {
  .lb-list-live {
    max-height: 45dvh;
    min-height: 180px;
  }

  .game-shell {
    min-height: min(72dvh, 640px);
    height: min(72dvh, 640px);
  }

  .brand-name {
    font-size: 0.78rem;
  }

  .ms-emojis {
    font-size: 0.95rem;
  }
}

@media (min-width: 901px) {
  .mobile-strip {
    display: none !important;
  }

  /* Never show mobile how-to popup / button on desktop web */
  .howto-popup {
    display: none !important;
  }

  #btnHowTo {
    display: none !important;
  }

  html,
  body {
    overflow: hidden;
    height: 100%;
  }

  body.howto-open {
    overflow: hidden;
  }

  .dash {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
    display: grid;
    grid-template-rows: var(--top-h) 1fr var(--foot-h);
  }
}

@media (min-width: 1200px) {
  .dash-main {
    grid-template-columns: minmax(280px, 320px) minmax(380px, 460px) minmax(280px, 320px);
    gap: 1rem;
    padding: 0.85rem 1.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .side-runner {
    animation: none;
  }
}
