/* ============ TRAD BUDDY — 8-BIT RPG THEME (legible edition) ============ */
/* Identity font: Press Start 2P (logo, tabs, buttons, headings, badges)    */
/* Content font:  VT323 (tune names, lists, body) — pixel but readable      */

@font-face {
  font-family: 'Press Start 2P';
  src: url('vendor/press-start-2p.woff2') format('woff2');
  font-display: swap;
}

@font-face {
  font-family: 'VT323';
  src: url('vendor/vt323.woff2') format('woff2');
  font-display: swap;
}

:root {
  --bg: #071a0c;
  --panel: #0d2614;
  --panel2: #123620;
  --line: #1d5c33;
  --line-bright: #2e8b50;
  --green: #3ddc84;
  --bright: #b8ffc9;
  --dim: #84c79b;
  --gold: #ffd24a;
  --gold-dk: #b8860b;
  --red: #ff6b6b;
  --cream: #f3e9c9;
  --cream-dk: #d8c89a;
  --font-px: 'Press Start 2P', monospace;
  --font-body: 'VT323', monospace;
}

* { box-sizing: border-box; }

button, .chip, .tab, .card, .sp-slot { touch-action: manipulation; }

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

/* the hidden attribute always wins, whatever display a class sets */
[hidden] { display: none !important; }

html { background: var(--bg); color-scheme: dark; }

body {
  margin: 0;
  font-family: var(--font-body);
  font-size: 22px;
  line-height: 1.45;
  color: var(--bright);
  background: radial-gradient(ellipse at 50% -10%, #0e2f18 0%, var(--bg) 60%);
  min-height: 100vh;
  padding-bottom: calc(56px + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: rgba(61, 220, 132, .25);
}

/* text size setting — scales content only; the HUD stays compact */
body[data-ts="2"] main,
body[data-ts="2"] .well-inner,
body[data-ts="2"] .detail-inner,
body[data-ts="2"] .setplayer-inner,
body[data-ts="2"] .scorer-inner,
body[data-ts="2"] .tuneform-inner { zoom: 1.15; }

body[data-ts="3"] main,
body[data-ts="3"] .well-inner,
body[data-ts="3"] .detail-inner,
body[data-ts="3"] .setplayer-inner,
body[data-ts="3"] .scorer-inner,
body[data-ts="3"] .tuneform-inner { zoom: 1.3; }

/* CRT scanlines — light touch, contrast matters more than vibe */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(0, 0, 0, .14) 0px, rgba(0, 0, 0, .14) 1px,
    transparent 1px, transparent 4px
  );
  z-index: 999;
  opacity: .3;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

.sub { font-family: var(--font-px); font-size: 9px; }
.body-text { font-family: var(--font-body); font-size: 21px; line-height: 1.4; }
.dim { color: var(--dim); }

/* ---------- pixel border panels ---------- */
.pix {
  border: 3px solid var(--line);
  outline: 3px solid var(--bg);
  box-shadow:
    0 0 0 5px var(--line),
    0 6px 0 5px rgba(0, 0, 0, .5);
  background: var(--panel);
  border-radius: 0;
}

.panel { padding: 18px 16px; margin-bottom: 26px; }

/* version stepper on the tune scroll (only shows when a tune has variants) */
.version-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: 2px 0 10px;
}
.version-label {
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--dim);
  text-align: center;
  min-width: 8em;
}
.btn-step { padding: 8px 14px; font-size: 12px; }
.btn-step:disabled { opacity: .35; cursor: default; box-shadow: none; }
/* the gold "your turn to tap" state must not inherit btn-toggle's dimming */
.btn-toggle.btn-gold { opacity: 1; }
/* clear (✕) reads as destructive */
#loopsec-clear { color: var(--red); border-color: var(--red); }

/* 🎯 practice drawer: key + loop, hidden until opened */
.practice-drawer {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 14px 16px;
  margin-bottom: 20px;
}
.practice-row { display: flex; align-items: center; gap: 10px; }
.practice-cap {
  font-family: var(--font-px);
  font-size: 9px;
  color: var(--gold);
  min-width: 42px; /* lines up the KEY / LOOP captions */
}
.practice-ctls { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; flex: 1; }
.practice-drawer .btn { padding: 11px 13px; } /* slimmer than the default control buttons */
/* pitch arrows: bare glyphs (no box), big enough to tell apart at a glance */
.practice-drawer .btn-pitch {
  background: transparent;
  border: none;
  box-shadow: none;
  color: var(--bright);
  font-size: 30px;
  line-height: 1;
  min-width: 44px;
  padding: 2px 6px;
}
.btn-pitch:hover { color: var(--gold); }
.btn-pitch:active { transform: translateY(2px); }
.btn-pitch:disabled { opacity: .3; }

/* big, obvious exit at the end of the scroll — no long trip to the top-right ✕ */
.btn-bottom-close {
  display: block;
  width: 100%;
  margin-top: 24px;
  font-size: 12px;
  color: var(--bright);
  border-color: var(--green);
}
.btn-bottom-close:hover { background: var(--panel2); border-color: var(--bright); }

/* in-app confirm/prompt dialog (works in the native WKWebView, unlike browser prompt/confirm) */
.dialog {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, .62);
}
.dialog-box { width: 100%; max-width: 420px; padding: 22px 20px 20px; }
.dialog-msg {
  font-family: var(--font-body);
  font-size: 21px;
  line-height: 1.4;
  color: var(--bright);
  text-align: center;
  margin: 0 0 18px;
}
#dialog-input { width: 100%; margin-bottom: 18px; }
.dialog-btns { display: flex; gap: 12px; justify-content: center; }
.dialog-btns .btn { flex: 1; max-width: 170px; }
.practice-hint {
  margin: 0;
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--dim);
}

.panel-label {
  font-family: var(--font-px);
  font-size: 10px;
  color: var(--green);
  margin: 18px 0 10px;
}

.panel-label:first-child { margin-top: 0; }

/* ---------- HUD ---------- */
.hud {
  position: sticky;
  top: 0;
  z-index: 50;
  background: linear-gradient(to bottom, #0a2211 0%, #081d0e 100%);
  border-bottom: 4px solid var(--line);
  box-shadow: 0 4px 0 rgba(0,0,0,.5);
  padding: 14px 14px 0;
}

.hud-top {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
  max-width: 760px;
  margin: 0 auto 12px;
}

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

.logo-shamrock {
  width: 40px; height: 40px;
  flex: 0 0 40px;
  background-image: url('icons/icon-192.png');
  background-size: contain;
  image-rendering: pixelated;
  animation: bob 1.6s steps(2) infinite;
}

@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }

.logo-text {
  font-family: var(--font-px);
  font-size: 15px;
  line-height: 1.3;
  color: var(--green);
  text-shadow: 3px 3px 0 #052a12, -1px -1px 0 #052a12;
  letter-spacing: 2px;
}

.player-panel {
  flex: 1;
  max-width: 420px;
  padding: 10px 12px;
}

.player-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
}

.player-rank { font-family: var(--font-px); color: var(--gold); font-size: 10px; }
.player-lv { font-family: var(--font-px); color: var(--bright); font-size: 10px; }

.xpbar {
  height: 16px;
  margin: 8px 0 6px;
  background: #051509;
  border: 2px solid var(--line);
  position: relative;
  overflow: hidden;
}

.xpbar-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    to right,
    var(--green) 0px, var(--green) 6px,
    #2db968 6px, #2db968 8px
  );
  transition: width .4s steps(8);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,.3);
}

#xp-label, #xp-next { color: var(--dim); font-family: var(--font-px); font-size: 8px; }

#textsize { flex: 0 0 auto; }

/* ---------- TABS ---------- */
.tabs {
  display: flex;
  gap: 5px;
  max-width: 760px;
  margin: 0 auto;
}

.tab {
  flex: 1;
  font-family: var(--font-px);
  font-size: 9px;
  line-height: 1.6;
  padding: 14px 2px 12px;
  min-height: 48px;
  color: var(--dim);
  background: var(--panel);
  border: 3px solid var(--line);
  border-bottom: none;
  cursor: pointer;
  position: relative;
  top: 4px;
}

.tab:hover { color: var(--bright); }

.tab.active {
  color: var(--gold);
  background: var(--panel2);
  border-color: var(--line-bright);
  top: 0;
  padding-bottom: 16px;
}

.tab .count {
  display: inline-block;
  min-width: 16px;
  padding: 2px 4px;
  margin-left: 2px;
  background: var(--line);
  color: var(--bright);
  font-size: 8px;
}

.tab.active .count { background: var(--gold-dk); color: #fff; }

.tab-ico { margin-right: 4px; }
.tab-lbl { letter-spacing: 1px; }

/* ---------- MAIN / VIEWS ---------- */
main {
  max-width: 760px;
  margin: 0 auto;
  padding: 20px 14px;
}

.view { display: none; }
.view.active { display: block; animation: viewin .18s steps(3); }

@keyframes viewin {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.view-title {
  font-family: var(--font-px);
  font-size: 12px;
  color: var(--green);
  margin: 4px 0 8px;
  text-shadow: 2px 2px 0 #04200e;
}

.view-sub {
  font-family: var(--font-body);
  font-size: 21px;
  color: var(--dim);
  margin: 0 0 18px;
  line-height: 1.3;
}

.intro-line { line-height: 2; }

.tab-word {
  font-family: var(--font-px);
  font-size: 9px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, .3);
  color: var(--gold);
  border: 2px solid var(--gold-dk);
  cursor: pointer;
  vertical-align: middle;
  animation: wordglow 3.6s steps(2) infinite;
}

.tab-word:hover { border-color: var(--gold); background: var(--panel2); }

.tab-word:nth-of-type(1) { animation-delay: 0s; }
.tab-word:nth-of-type(2) { animation-delay: 1.2s; }
.tab-word:nth-of-type(3) { animation-delay: 2.4s; }

@keyframes wordglow {
  0%, 30%, 100% { box-shadow: none; }
  10% { box-shadow: 0 0 0 3px rgba(255, 210, 74, .35); }
}

/* ---------- WELL OF TUNES entrance (HUD button) ---------- */
.hud-left { display: flex; gap: 12px; align-items: center; flex: 0 0 auto; }

.hud-btns { display: flex; gap: 8px; flex: 0 0 auto; }

.well-btn {
  border-color: var(--gold-dk);
  box-shadow: 0 4px 0 #3d2e00;
  padding: 8px 10px;
}

.well-btn:hover { border-color: var(--gold); background: #1c3a14; }

/* beckons new players until they draw their first tune */
.well-btn.beckon {
  border-color: var(--gold);
  animation: beckon 1.6s steps(3) infinite;
}

@keyframes beckon {
  0%, 100% { box-shadow: 0 4px 0 #3d2e00; }
  50% { box-shadow: 0 4px 0 #3d2e00, 0 0 16px 3px rgba(255, 210, 74, .55); }
}

.well-btn img {
  width: 28px;
  height: 28px;
  display: block;
  image-rendering: pixelated;
}

.cloud-btn img {
  width: 26px;
  height: 26px;
  display: block;
  image-rendering: pixelated;
  filter: grayscale(1) brightness(.75);
  opacity: .6;
}

.cloud-btn.on img { filter: none; opacity: 1; }

.cloud-btn.on {
  border-color: var(--gold-dk);
  box-shadow: 0 4px 0 #3d2e00;
}

/* ---------- 8-bit checkbox toggle ---------- */
.check-toggle {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-px);
  font-size: 10px;
  color: var(--bright);
  background: none;
  border: none;
  cursor: pointer;
  padding: 10px 0;
  min-height: 48px;
}

.check-toggle .check-box {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  background: #051509;
  border: 3px solid var(--line-bright);
  box-shadow: 0 3px 0 #04200e;
  position: relative;
}

.check-toggle.on .check-box {
  background: var(--green);
  border-color: var(--bright);
}

.check-toggle.on .check-box::after {
  content: '✓';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #04200e;
  font-size: 18px;
  font-weight: bold;
}

.check-toggle:hover .check-box { border-color: var(--bright); }

/* ---------- WELL OF TUNES location ---------- */
.well {
  position: fixed;
  inset: 0;
  z-index: 80;
  overscroll-behavior: contain;
  background:
    radial-gradient(ellipse at 50% 0%, #11402233 0%, transparent 55%),
    var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.well-inner {
  max-width: 760px;
  margin: 0 auto;
  padding: 18px 14px 64px;
}

.well-head {
  position: relative;
  margin-bottom: 20px;
}

.back-btn {
  font-size: 18px;
  padding: 0;
  width: 52px;
  height: 52px;
  line-height: 1;
}

.well-hero {
  text-align: center;
  padding-top: 6px;
}

.well-hero-img {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
  filter: drop-shadow(0 6px 0 rgba(0, 0, 0, .5)) drop-shadow(0 0 14px rgba(255, 210, 74, .35));
  animation: bob 2s steps(2) infinite;
}

.well-title {
  font-family: var(--font-px);
  font-size: 16px;
  color: var(--gold);
  margin: 12px 0 8px;
  text-shadow: 3px 3px 0 #3d2e00;
}

.well-sub {
  font-family: var(--font-body);
  font-size: 21px;
  color: var(--dim);
  margin: 0;
  line-height: 1.3;
}

/* ---------- LISTS / CARDS ---------- */
.list { display: flex; flex-direction: column; gap: 16px; }

.card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px;
  min-height: 64px;
  background: var(--panel);
  border: 3px solid var(--line);
  box-shadow: 0 4px 0 rgba(0,0,0,.45);
  cursor: pointer;
}

.card:hover {
  border-color: var(--line-bright);
  background: var(--panel2);
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(0,0,0,.45);
}

.card:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(0,0,0,.45); }

.card-main { flex: 1; min-width: 0; }

.card-name {
  font-family: var(--font-body);
  font-size: 26px;
  line-height: 1.15;
  color: var(--bright);
  margin: 0 0 7px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card.learned .card-name { color: var(--gold); }

.card.rusty { opacity: .55; }
.card.rusty .card-name { text-decoration: line-through; text-decoration-thickness: 3px; }

.card-sub { display: flex; gap: 7px; flex-wrap: wrap; align-items: center; }

.card-date { color: var(--dim); font-family: var(--font-body); font-size: 18px; }

.card-btns { display: flex; gap: 8px; flex-shrink: 0; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- BADGES ---------- */
.badge {
  display: inline-block;
  font-family: var(--font-body);
  font-size: 17px;
  line-height: 1.1;
  padding: 3px 8px;
  border: 2px solid currentColor;
  color: var(--green);
  background: rgba(0,0,0,.3);
  white-space: nowrap;
}

.badge-key { color: var(--cream-dk); }
.badge-fame { color: var(--gold); border-style: dotted; }
.badge-rusty { color: #c9a06a; }

.badge.t-reel { color: #6ecbff; }
.badge.t-jig { color: #3ddc84; }
.badge.t-slipjig { color: #8aff8a; }
.badge.t-hornpipe { color: #ffb066; }
.badge.t-polka { color: #ff8ad8; }
.badge.t-waltz { color: #c9a6ff; }
.badge.t-slide { color: #ffe98a; }
.badge.t-march { color: #ff9a9a; }
.badge.t-barndance { color: #ffc966; }
.badge.t-strathspey { color: #9adfff; }
.badge.t-mazurka { color: #e0a6ff; }
.badge.t-threetwo { color: #a6fff0; }

/* ---------- BUTTONS ---------- */
.btn {
  font-family: var(--font-px);
  font-size: 10px;
  line-height: 1.5;
  padding: 13px 16px 12px;
  min-height: 48px;
  min-width: 48px;
  color: var(--bright);
  background: var(--panel2);
  border: 3px solid var(--line-bright);
  box-shadow: 0 4px 0 #04200e;
  cursor: pointer;
  text-transform: uppercase;
  white-space: nowrap;
}

.btn:hover { background: #17472a; color: #fff; }
.btn:active { transform: translateY(4px); box-shadow: 0 0 0 #04200e; }

.btn-gold {
  color: #2a1f00;
  background: var(--gold);
  border-color: #ffe9a0;
  box-shadow: 0 4px 0 var(--gold-dk);
}

.btn-gold:hover { background: #ffdd70; color: #2a1f00; }

.btn-red {
  color: #fff;
  background: #7a2727;
  border-color: var(--red);
  box-shadow: 0 4px 0 #3d0f0f;
}

.btn-red:hover { background: #963030; }

.btn-small { font-size: 9px; padding: 11px 12px 10px; min-height: 44px; }

/* square icon actions sit side by side, even on phones */
.icon-btn {
  width: 52px;
  min-width: 52px;
  padding: 0;
  font-size: 17px;
  font-weight: bold;
  line-height: 1;
}

.card-btns:has(.icon-btn) { flex-direction: row !important; align-items: center; }

/* inline "hear it" play button on cards (desktop only — hidden on phones below) */
.card-play { width: 52px; min-width: 52px; padding: 0; font-size: 17px; line-height: 1; color: var(--bright); }
.card-play.playing { background: var(--green); color: #04200e; border-color: var(--bright); }

/* quiet secondary action — present, not shouting */
.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--dim);
  box-shadow: none;
  opacity: .8;
}

.btn-danger {
  background: var(--red);
  color: #3a0a0a;
  border-color: #ffb3b3;
  box-shadow: 0 4px 0 #7a1f1f;
}

.btn-ghost:hover {
  background: var(--panel2);
  border-color: var(--line-bright);
  color: var(--bright);
  opacity: 1;
}

/* small rest/wake icon toggle in My Tunes */
.rusty-btn {
  font-size: 15px;
  padding: 8px 11px;
  min-width: 44px;
}

.rusty-btn:not(.on) { filter: grayscale(1); }

.rusty-btn.on {
  border-color: var(--gold-dk);
  background: rgba(255, 210, 74, .08);
  box-shadow: 0 3px 0 #3d2e00;
}

.btn-big {
  width: 100%;
  font-size: 13px;
  padding: 18px;
  margin-top: 20px;
}

.btn-toggle { opacity: .55; }
.btn-toggle.active {
  opacity: 1;
  background: var(--green);
  color: #04200e;
  border-color: var(--bright);
  box-shadow: 0 4px 0 #1c7a48;
}

.btn:disabled {
  opacity: .35;
  cursor: not-allowed;
  transform: none;
}

/* ---------- SEARCH / CHIPS ---------- */
.searchbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  margin-bottom: 16px;
}

.searchbox.inset {
  border: 3px solid var(--line);
  background: #0a2010;
  box-shadow: none;
  outline: none;
}

.searchbox input {
  flex: 1;
  font-family: var(--font-body);
  font-size: 24px;
  color: var(--bright);
  background: transparent;
  border: none;
  outline: none;
  min-height: 36px;
}

.searchbox input::placeholder { color: var(--dim); }
.search-clear { padding: 6px 11px; font-size: 13px; color: var(--dim); border-color: var(--line); flex-shrink: 0; }

.chips {
  display: flex;
  gap: 9px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  margin-bottom: 18px;
  padding: 4px 2px;
}

.chips::-webkit-scrollbar { display: none; }

.chip-new { border-color: var(--gold-dk); color: var(--gold); }

.chip-new.active {
  background: var(--gold);
  color: #2a1f00;
  border-color: #ffe9a0;
}

.chips[hidden] { display: none; }

.chip {
  flex: 0 0 auto;
  white-space: nowrap;
  font-family: var(--font-body);
  font-size: 19px;
  line-height: 1;
  padding: 11px 13px;
  min-height: 44px;
  background: var(--panel);
  color: var(--dim);
  border: 2px solid var(--line);
  cursor: pointer;
}

.chip:hover { color: var(--bright); }

.chip.active {
  background: var(--green);
  color: #04200e;
  border-color: var(--bright);
}

.chip:disabled { opacity: .35; cursor: not-allowed; }

/* the RUSTY filter chip in My Tunes — rust-tinted so it stands apart from types */
.chip-rusty { border-color: #6e5328; color: #c9a06a; }
.chip-rusty.active { background: #c9a06a; color: #2a1d07; border-color: #e0bd84; }

.big-chips { margin-bottom: 6px; }
.big-chips .chip { font-size: 22px; padding: 12px 15px; min-height: 48px; }

.show-more { margin: 8px auto; display: block; }


/* ---------- EMPTY STATES ---------- */
.empty { text-align: center; padding: 48px 16px; color: var(--bright); }
.empty p:not(.body-text) { font-family: var(--font-px); font-size: 12px; line-height: 2; }
.empty-sprite { font-size: 44px; margin-bottom: 16px; animation: bob 1.6s steps(2) infinite; }
.empty .btn { margin-top: 18px; }

.gold { color: var(--gold); }
#acct-msg { min-height: 1.2em; margin-top: 12px; }
#acct-signedin .ctl-group { margin-top: 12px; }
/* long emails are one unbreakable token — let them wrap inside the panel */
#acct-signedin .body-text, #acct-who { overflow-wrap: anywhere; }

.signin-cta {
  display: block;
  width: 100%;
  margin-top: 26px;
  font-size: 9px;
  line-height: 1.8;
  white-space: normal;
  border-color: var(--gold-dk);
  box-shadow: 0 4px 0 #3d2e00;
}

.signin-cta:hover { border-color: var(--gold); color: var(--gold); }

.tb-searchrow { margin-bottom: 18px; padding: 6px 8px 6px 14px; }
.tb-searchrow input { min-height: 32px; }

/* ---------- PROFILE STAT CARD (screenshot bait) ---------- */
.statcard {
  text-align: center;
  border-color: var(--gold-dk);
  box-shadow: 0 0 0 5px var(--gold-dk), 0 6px 0 5px rgba(0, 0, 0, .5), inset 0 0 26px rgba(255, 210, 74, .06);
  margin-top: 26px;
}

.statcard-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 14px;
}

.statcard-shamrock { width: 30px; height: 30px; flex: 0 0 30px; animation: none; }

.statcard-word {
  font-family: var(--font-px);
  font-size: 12px;
  color: var(--green);
  letter-spacing: 2px;
  text-shadow: 2px 2px 0 #052a12;
}

/* avatar + name/rank side by side */
.statcard-id {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 6px 0 14px;
}

.statcard-idtext { text-align: center; min-width: 0; }

.statcard-namerow { display: flex; align-items: center; justify-content: center; gap: 8px; }

.statcard-name {
  font-family: var(--font-body);
  font-size: 34px;
  color: var(--gold);
  text-shadow: 2px 2px 0 #3d2e00;
  line-height: 1.1;
}

.statcard-rank {
  font-family: var(--font-px);
  font-size: 10px;
  color: var(--bright);
  margin-top: 8px;
  line-height: 1.8;
}

.statcard-grid {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 14px;
}

.statbox {
  background: rgba(0, 0, 0, .3);
  border: 2px solid var(--line);
  padding: 10px 14px;
  min-width: 84px;
}

.statnum {
  display: block;
  font-family: var(--font-body);
  font-size: 38px;
  color: var(--gold);
  line-height: 1;
}

.statlbl { font-family: var(--font-px); font-size: 8px; color: var(--dim); }

.statcard-types {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 7px;
  margin-bottom: 6px;
}

/* "buy me a pint" donation button (anchor styled as a button) */
.pint-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  margin: 20px 0 0;
}
.pint-note { text-align: left; margin: 8px 0 6px; }
/* native (App Store) builds hide the external Stripe donation link — Apple 3.1.1 */
body.native .pint-btn, body.native .pint-note { display: none !important; }

/* tiny inline pencil next to the profile name — quiet, not a full button */
.name-edit {
  background: none;
  border: none;
  color: var(--dim);
  font-size: 17px;
  padding: 6px 8px;
  cursor: pointer;
  line-height: 1;
}

.name-edit:hover, .name-edit:focus-visible { color: var(--gold); }

.statbox-hero { min-width: 150px; padding: 12px 22px; }
.statbox-hero .statnum { font-size: 46px; }

/* ---------- SAVED SETS ---------- */
.set-heart { align-self: center; margin: 4px auto 10px; min-width: 180px; }
.set-heart.saved { color: var(--gold); border-color: var(--gold); }

#saved-sets-list, #savedpage-list { display: flex; flex-direction: column; gap: 12px; }

.saved-panel-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.saved-panel-head .panel-label { margin: 0; }

.saved-sort-row { display: flex; gap: 8px; margin: 2px 0 14px; }

.saved-set {
  background: rgba(0, 0, 0, .25);
  border: 2px solid var(--line);
  padding: 12px 14px;
}

.saved-set-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 6px; }

.saved-set-name {
  font-family: var(--font-body);
  font-size: 22px;
  color: var(--gold);
}

.saved-set-lineup {
  font-family: var(--font-body);
  font-size: 17px;
  color: var(--bright);
  margin: 0 0 12px;
  line-height: 1.5;
}

.saved-set-lineup .tarrow { color: var(--dim); padding: 0 2px; }

.saved-set-actions { display: flex; gap: 8px; }
.saved-set-actions .btn { flex: 0 0 auto; }
.saved-set-actions [data-play] { flex: 1 1 auto; }

/* pixel avatar on the stat card + the WHAT'S YOUR WEAPON picker */
.avatar-btn {
  display: inline-flex;
  background: none;
  border: none;
  padding: 4px;
  cursor: pointer;
  line-height: 0;
  flex: 0 0 auto;
}

.avatar-btn:hover svg, .avatar-btn:focus-visible svg { filter: drop-shadow(0 0 4px var(--gold)); }

.avatar-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 10px;
}

.avatar-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 9px;
  background: rgba(0, 0, 0, .25);
  border: 3px solid var(--line);
  padding: 12px 4px 10px;
  cursor: pointer;
  min-height: 96px;
}

.avatar-cell:hover, .avatar-cell:focus-visible { border-color: var(--line-bright); background: var(--panel2); }

.avatar-cell.picked { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold-dk); }

.avatar-name {
  font-family: var(--font-px);
  font-size: 7px;
  color: var(--dim);
  line-height: 1.5;
  text-align: center;
}

.statcard-foot {
  font-family: var(--font-px);
  font-size: 8px;
  color: var(--dim);
  margin-top: 14px;
  border-top: 3px dashed var(--line);
  padding-top: 12px;
}

/* ---------- DATA EXPORT/IMPORT ROW ---------- */
.data-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
  padding-top: 18px;
  border-top: 3px dashed var(--line);
}
/* don't let these shrink below their label — wrap to a new line instead of overflowing */
.data-row .btn { flex: 0 0 auto; }

/* ---------- SESSION TAB ---------- */
.session-chiprow {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 18px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.setting-row .panel-label { margin: 12px 0; }

/* build-your-own set */
.setmode-row { display: flex; gap: 10px; margin-bottom: 16px; }
.setmode-row .btn { flex: 1; }
#build-results { display: flex; flex-direction: column; gap: 6px; }
.build-list { list-style: none; margin: 12px 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.build-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--panel2); border: 2px solid var(--line);
  cursor: grab;
}
.build-item.dragging { opacity: .4; }
.build-num { font-family: var(--font-px); font-size: 11px; color: var(--gold); min-width: 1.5em; text-align: center; }
.build-tname {
  flex: 1; min-width: 0;
  font-family: var(--font-body); font-size: 21px; color: var(--bright);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.build-ctl { display: flex; gap: 6px; flex-shrink: 0; }
.build-ctl .btn { padding: 8px 11px; font-size: 13px; }
#build-name { width: 100%; margin: 10px 0; text-align: left; font-size: 20px; letter-spacing: 0; padding: 10px 12px; color: var(--bright); }

.stepper { display: flex; align-items: center; gap: 12px; }

.stepper .btn { font-size: 16px; padding: 8px 16px; }

#len-val {
  font-family: var(--font-body);
  font-size: 36px;
  color: var(--gold);
  min-width: 44px;
  text-align: center;
}


#opener-results { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }

.opener-option {
  font-family: var(--font-body);
  font-size: 23px;
  text-align: left;
  padding: 11px 14px;
  background: #0a2010;
  color: var(--bright);
  border: 2px solid var(--line);
  cursor: pointer;
}

.opener-option:hover { border-color: var(--green); }

.opener-option .dim { font-size: 18px; }

#opener-pinned[hidden] { display: none; }

#opener-pinned {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px;
  border: 2px solid var(--gold-dk);
  background: rgba(255, 210, 74, .07);
}

#opener-name { color: var(--gold); font-size: 24px; }


/* ---------- SET PLAYER ---------- */
.setplayer {
  position: fixed;
  inset: 0;
  z-index: 90;
  overscroll-behavior: contain;
  background: var(--bg);
  overflow-y: auto;
}

.setplayer-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 18px 16px 56px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  min-height: 100%;
}

.setplayer-head { display: flex; justify-content: space-between; align-items: center; }

#sp-pos { color: var(--gold); font-size: 13px; }

.setplayer-now {
  text-align: center;
  padding: 26px 14px;
  border: 3px solid var(--line-bright);
  background: var(--panel2);
  box-shadow: 0 6px 0 rgba(0,0,0,.5);
}

#sp-tune {
  font-family: var(--font-body);
  font-size: 52px;
  line-height: 1.05;
  color: var(--gold);
  margin: 10px 0 14px;
  text-shadow: 3px 3px 0 #04200e;
  overflow-wrap: break-word;
}

.setplayer-now .detail-meta { justify-content: center; margin-bottom: 16px; }

.sp-progress {
  height: 12px;
  background: #051509;
  border: 2px solid var(--line);
  margin: 0 auto 18px;
  max-width: 360px;
  overflow: hidden;
}

#sp-progress-fill {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(to right, var(--gold) 0 6px, #d4a82f 6px 8px);
}


.sp-picker { display: flex; flex-direction: column; gap: 10px; }

.sp-picker[hidden] { display: none; }

#sp-options { display: flex; flex-direction: column; gap: 10px; }

.set-card-row .opt-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* full forged-set cards */
.set-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  text-align: left;
  padding: 14px;
  background: var(--panel);
  border: 3px solid var(--line-bright);
  box-shadow: 0 4px 0 rgba(0,0,0,.45);
  cursor: pointer;
  font-family: var(--font-body);
}

.set-card:hover { border-color: var(--gold); background: var(--panel2); }

.set-card:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(0,0,0,.45); }

.set-card-title {
  font-family: var(--font-px);
  font-size: 10px;
  color: var(--gold);
  margin-bottom: 2px;
}

.set-card-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-size: 24px;
  color: var(--bright);
  line-height: 1.2;
}

.set-card:hover .set-card-row { color: var(--gold); }

.sp-slot.tappable { cursor: pointer; }
.sp-slot.tappable:hover { border-color: var(--gold); color: var(--gold); }

#sp-reroll { align-self: center; }

.sp-lineup { display: flex; flex-direction: column; gap: 10px; }

.sp-slot {
  display: flex;
  align-items: center;
  gap: 12px;
  font-family: var(--font-body);
  font-size: 25px;
  padding: 12px 14px;
  border: 2px solid var(--line);
  background: var(--panel);
  color: var(--dim);
}

.sp-slot.current {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(255, 210, 74, .06);
}

.sp-slot.done { opacity: .55; }

.sp-slot .slot-num { font-family: var(--font-px); font-size: 10px; flex-shrink: 0; }

.sp-slot .slot-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.sp-slot .badge { font-size: 16px; }

.sp-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.sp-controls[hidden] { display: none; }

.sp-controls .btn { flex: 1; max-width: 170px; font-size: 11px; }

/* ---------- POST-SET SCORER ---------- */
.scorer {
  position: fixed;
  inset: 0;
  z-index: 95;
  overscroll-behavior: contain;
  background: var(--bg);
  overflow-y: auto;
}

.scorer-inner {
  max-width: 600px;
  margin: 0 auto;
  padding: 28px 16px 56px;
}

.scorer-title {
  font-family: var(--font-px);
  font-size: 14px;
  line-height: 1.8;
  color: var(--gold);
  text-shadow: 2px 2px 0 #04200e;
  margin: 0 0 6px;
}

.transition-card {
  margin: 18px 0;
  padding: 16px;
  border: 3px solid var(--line);
  background: var(--panel);
}

.transition-names {
  font-family: var(--font-body);
  font-size: 25px;
  color: var(--bright);
  margin-bottom: 14px;
  line-height: 1.3;
}

.transition-names .tarrow { color: var(--gold); }

.transition-keys { color: var(--dim); font-size: 19px; }

.rate-row { display: flex; gap: 10px; }

.rate-row .btn { flex: 1; }

.rate-btn.picked-great { background: var(--green); color: #04200e; border-color: var(--bright); }
.rate-btn.picked-ok { background: var(--gold); color: #2a1f00; border-color: #ffe9a0; }
.rate-btn.picked-nope { background: #7a2727; color: #fff; border-color: var(--red); }

/* ---------- DETAIL OVERLAY ---------- */
.detail {
  position: fixed;
  inset: 0;
  z-index: 100;
  overscroll-behavior: contain;
  background: var(--bg);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.detail-inner {
  max-width: 860px;
  margin: 0 auto;
  padding: 16px 14px 64px;
}

.detail-head {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  margin-bottom: 16px;
  padding-right: 64px; /* clear the floating close button */
}

/* always-reachable close for the scroll overlay */
.close-btn {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top, 0px));
  right: 12px;
  z-index: 5;
  width: 52px;
  height: 52px;
  padding: 0;
  font-size: 24px;
  font-weight: bold;
  line-height: 1;
  color: var(--bright);
  background: var(--panel2);
  border-color: var(--green);
  text-shadow: 2px 2px 0 #04200e;
  box-shadow: 0 4px 0 #04200e, 0 0 14px rgba(0, 0, 0, .55);
}

.close-btn:hover { background: #17472a; border-color: var(--bright); color: #fff; }

/* red close — used where the user asked for a clear red ✕ (friend view) */
.close-btn-red { color: #fff; background: #7a2727; border-color: var(--red); text-shadow: 2px 2px 0 #2a0808; }
.close-btn-red:hover { background: #963030; border-color: #e06a6a; color: #fff; }

/* devices with a keyboard learn the shortcut */
@media (hover: hover) and (pointer: fine) {
  .close-btn::after {
    content: 'ESC';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -20px;
    font-family: var(--font-px);
    font-size: 7px;
    color: var(--dim);
    text-shadow: none;
  }
}

.detail-titles h2 {
  font-family: var(--font-body);
  font-size: 34px;
  color: var(--gold);
  margin: 0 0 8px;
  line-height: 1.1;
  text-shadow: 2px 2px 0 #04200e;
}

.detail-meta { display: flex; gap: 7px; flex-wrap: wrap; }

.detail-controls {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
  align-items: center;
  padding: 14px;
  margin-bottom: 20px;
}

.ctl-group { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

.tempo-group { flex: 1; min-width: 200px; }

.tempo-group label { color: var(--dim); }

input[type="range"] {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 10px;
  background: #051509;
  border: 2px solid var(--line);
  outline: none;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 26px; height: 26px;
  background: var(--green);
  border: 3px solid var(--bright);
  cursor: pointer;
  border-radius: 0;
}

input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  background: var(--green);
  border: 3px solid var(--bright);
  cursor: pointer;
  border-radius: 0;
}

#tempo-val { color: var(--gold); min-width: 32px; text-align: right; }

.pix-select {
  font-family: var(--font-px);
  font-size: 9px;
  padding: 12px 8px;
  min-height: 48px;
  color: var(--bright);
  background: var(--panel2);
  border: 3px solid var(--line-bright);
  cursor: pointer;
}

/* ---------- SHEET MUSIC SCROLL ---------- */
.scroll-paper {
  background:
    url('icons/knot.png') 10px 26px / 24px 24px no-repeat,
    url('icons/knot.png') calc(100% - 10px) 26px / 24px 24px no-repeat,
    url('icons/knot.png') 10px calc(100% - 10px) / 24px 24px no-repeat,
    url('icons/knot.png') calc(100% - 10px) calc(100% - 10px) / 24px 24px no-repeat,
    radial-gradient(ellipse at 18% 12%, rgba(160, 120, 60, .10), transparent 42%),
    radial-gradient(ellipse at 84% 88%, rgba(160, 120, 60, .12), transparent 45%),
    radial-gradient(ellipse at 55% 45%, rgba(120, 90, 40, .05), transparent 55%),
    var(--cream);
  image-rendering: pixelated;
  border-color: #8a6f3c;
  outline-color: var(--bg);
  box-shadow:
    0 0 0 5px #8a6f3c,
    0 8px 0 5px rgba(0, 0, 0, .5),
    inset 0 0 34px rgba(110, 80, 30, .22);
  padding: 14px 10px 34px;
  margin-bottom: 0;
  overflow-x: auto;
}

/* the rolled wooden ends of the scroll */
.scroll-roll {
  height: 14px;
  margin: 0 -8px;
  background: linear-gradient(to bottom, #a8854a 0%, #8a6f3c 35%, #5c4824 75%, #3d2e14 100%);
  border: 3px solid #3d2e14;
  border-radius: 7px;
  box-shadow: 0 4px 0 rgba(0, 0, 0, .45);
  position: relative;
  z-index: 1;
}

.scroll-roll + .scroll-paper { margin-top: -7px; }

.scroll-paper + .scroll-roll { margin-top: -7px; margin-bottom: 22px; }

.scroll-paper::before {
  content: '✦ ── THE TUNE SCROLL ── ✦';
  display: block;
  text-align: center;
  font-family: var(--font-px);
  font-size: 8px;
  color: #8a6f3c;
  margin-bottom: 6px;
}

#paper { min-height: 120px; color: #2a1f0a; }

#paper svg { max-width: 100%; color: #2a1f0a; }

#paper .note-glow,
#paper .note-glow * { fill: #c0392b !important; }

/* notes inside a selected loop section */
#paper .loop-sel,
#paper .loop-sel * { fill: #b8860b !important; }

/* the note you tapped to "play from here" */
#paper .start-here,
#paper .start-here * { fill: #ffd24a !important; }

/* ⛶ BIGGER: fullscreen notation (vector SVG scales up crisply — best in landscape) */
.bignote-bar { display: none; }
body.bignote #paper-wrap {
  position: fixed; inset: 0; margin: 0; z-index: 200;
  border: none !important; outline: none !important; box-shadow: none !important; border-radius: 0;
  overflow: auto;
  padding: 10px 10px 78px;
}
body.bignote .bignote-bar {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 201;
  padding: 9px 12px calc(9px + env(safe-area-inset-bottom, 0px));
  background: rgba(7, 22, 13, .94);
  border-top: 3px solid var(--line);
}
.bignote-hint { font-family: var(--font-body); font-size: 16px; color: var(--dim); }
@media (orientation: landscape) { .bignote-hint { display: none; } }

.detail-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.learned-stamp {
  width: 100%;
  text-align: center;
  color: var(--gold);
  font-family: var(--font-px);
  font-size: 11px;
  line-height: 1.8;
  margin-bottom: 6px;
}

.gold-link { color: var(--gold); }

.help-credit { margin-top: 16px; }
.help-foot { margin-top: 14px; border-top: 3px dashed var(--line); padding-top: 14px; }

#fb-message { margin: 10px 0 4px; }

/* ---------- SAVE & SYNC SHEET ---------- */
.syncsheet {
  position: fixed;
  inset: 0;
  z-index: 115;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
}

/* ---------- ADD YOUR OWN TUNE ---------- */
.tuneform {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: var(--bg);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.tuneform-inner {
  max-width: 640px;
  margin: 0 auto;
  padding: 16px 14px 64px;
}

.tuneform .searchbox input { width: 100%; }

.tf-select {
  width: 100%;
  font-size: 11px;
  margin-bottom: 4px;
}

.tf-abc {
  width: 100%;
  font-family: var(--font-body);
  font-size: 20px;
  color: var(--bright);
  background: #0a2010;
  border: 3px solid var(--line);
  padding: 12px;
  resize: vertical;
  min-height: 110px;
}

.tf-abc:focus { border-color: var(--line-bright); outline: none; }

#tf-msg { min-height: 1.2em; }

.badge-mine { color: #7fd9ff; border-style: dashed; }

.no-scroll-note {
  text-align: center;
  padding: 40px 16px;
  font-family: var(--font-body);
  font-size: 23px;
  color: #6b5a2e;
}

/* ---------- BACK TO TOP ---------- */
.top-btn {
  position: fixed;
  right: 16px;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 60;
  font-size: 9px;
  padding: 12px 14px;
  border-color: var(--gold-dk);
  box-shadow: 0 4px 0 #3d2e00, 0 0 18px rgba(0, 0, 0, .6);
}

#well-top { z-index: 85; }

/* ---------- INVITE GATE ---------- */
.gate {
  position: fixed;
  inset: 0;
  z-index: 500;
  background: radial-gradient(ellipse at 50% 30%, #0e2f18 0%, var(--bg) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.gate[hidden] { display: none; }

.gate-box {
  text-align: center;
  padding: 34px 30px;
  max-width: 430px;
  width: 100%;
}

.gate-shamrock {
  width: 56px; height: 56px;
  flex: none;
  display: inline-block;
  margin-bottom: 14px;
}

.gate-title {
  font-family: var(--font-px);
  font-size: 20px;
  color: var(--green);
  margin: 0 0 10px;
  text-shadow: 3px 3px 0 #052a12;
}

.gate-sub {
  font-family: var(--font-px);
  font-size: 9px;
  color: var(--gold);
  margin: 0 0 18px;
}

.gate-input {
  display: block;
  width: 100%;
  font-family: var(--font-body);
  font-size: 36px;
  letter-spacing: 14px;
  text-align: center;
  color: var(--gold);
  background: #051509;
  border: 3px solid var(--line-bright);
  padding: 12px;
  margin: 8px 0 4px;
  outline: none;
}

.gate-input:focus { border-color: var(--bright); }

.gate-msg { min-height: 1.3em; }

.code-input { max-width: 320px; margin: 10px 0 12px; }

#acct-code-step { margin-top: 14px; }
#acct-code-step[hidden] { display: none; }

.gate-box.shake { animation: gateshake .3s steps(6); }

@keyframes gateshake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-10px); }
  75% { transform: translateX(10px); }
}

/* ---------- TOASTS ---------- */
.toasts {
  position: fixed;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
  width: max-content;
  max-width: 92vw;
}

.toast {
  font-family: var(--font-px);
  font-size: 10px;
  line-height: 1.7;
  padding: 13px 18px;
  color: var(--gold);
  background: #04200e;
  border: 3px solid var(--gold-dk);
  box-shadow: 0 4px 0 rgba(0,0,0,.6);
  animation: toastin 3.4s steps(6) forwards;
  text-align: center;
}

.toast.toast-green { color: var(--bright); border-color: var(--line-bright); }

@keyframes toastin {
  0% { opacity: 0; transform: translateY(12px); }
  10% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10px); }
}

/* ---------- LEVEL UP ---------- */
.levelup {
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(2, 12, 5, .85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.levelup[hidden] { display: none; }

.levelup-box {
  text-align: center;
  padding: 30px 34px;
  animation: lvlpop .3s steps(4);
}

@keyframes lvlpop { from { transform: scale(.6); } to { transform: scale(1); } }

.levelup-burst {
  color: var(--gold);
  font-family: var(--font-px);
  font-size: 16px;
  animation: bob .8s steps(2) infinite;
}

.levelup-title {
  font-family: var(--font-px);
  font-size: 20px;
  color: var(--gold);
  margin: 16px 0 12px;
  text-shadow: 3px 3px 0 #5c4500;
}

.levelup-rank { font-family: var(--font-px); font-size: 11px; color: var(--bright); margin-bottom: 22px; line-height: 1.8; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 600px) {
  .hud { padding: 8px 10px 10px; }
  .hud-top { flex-wrap: wrap; gap: 8px; margin-bottom: 0; }
  .hud-left { width: 100%; justify-content: space-between; }
  .player-panel { flex-basis: 100%; max-width: none; padding: 7px 10px; }
  .xpbar { height: 12px; margin: 5px 0 4px; }
  .logo-shamrock { width: 32px; height: 32px; flex: 0 0 32px; }
  .logo-text { font-size: 12px; }
  .hud-btns .btn { min-height: 40px; padding: 8px 9px; }
  .well-btn img { width: 24px; height: 24px; }
  .cloud-btn img { width: 22px; height: 22px; }

  /* tabs become a fixed bottom bar — thumb country */
  .tabs {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 70;
    max-width: none;
    margin: 0;
    gap: 8px;
    background: #061509;
    border-top: 4px solid var(--line-bright);
    box-shadow: 0 -2px 0 #04200e, 0 -8px 18px rgba(0, 0, 0, .6);
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .tab {
    top: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    min-height: 64px;
    padding: 6px 2px;
    background: var(--panel);
    border: 3px solid var(--line);
    box-shadow: 0 4px 0 rgba(0, 0, 0, .5);
    color: var(--dim);
    overflow: visible;
  }
  .tab .tab-ico {
    margin: 0;
    font-size: 22px;
    line-height: 1;
    filter: grayscale(1) opacity(.7);
  }
  .tab .tab-lbl { font-size: 8px; }
  .tab.active {
    top: 0;
    color: var(--gold);
    background: var(--panel2);
    border-color: var(--gold);
    box-shadow: 0 4px 0 #3d2e00, inset 0 0 14px rgba(255, 210, 74, .12);
    transform: translateY(-4px);
  }
  .tab.active .tab-ico { filter: none; }
  .tab .count {
    position: absolute;
    top: -10px;
    right: -6px;
    margin: 0;
    min-width: 22px;
    padding: 4px 4px 3px;
    border: 2px solid var(--bg);
    font-size: 9px;
  }
  .tab { position: relative; }
  /* clear the bar: content, floating buttons, toasts all sit above it */
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom, 0px)); }
  .top-btn { bottom: calc(86px + env(safe-area-inset-bottom, 0px)); }
  .toasts { bottom: calc(92px + env(safe-area-inset-bottom, 0px)); }
  .tab { font-size: 8px; padding-left: 1px; padding-right: 1px; }
  .tab .count { display: block; margin: 4px auto 0; width: max-content; }
  #sp-tune { font-size: 42px; }
  .sp-controls .btn { font-size: 9px; padding-left: 6px; padding-right: 6px; }
  .card-btns { flex-direction: column; }
  .card-play { display: none; } /* play button is desktop-only */
}

/* ---------- PATCH NOTES ---------- */
.patch-list { margin: 6px 0 10px; padding-left: 20px; }
.patch-list li {
  font-family: var(--font-body);
  font-size: 18px;
  color: var(--bright);
  margin-bottom: 9px;
  line-height: 1.4;
}
.patchnotes {
  position: fixed; inset: 0; z-index: 1000;
  background: rgba(4, 16, 8, .82);
  display: flex; align-items: center; justify-content: center;
  padding: 22px;
}
.patchnotes-card {
  max-width: 420px; width: 100%;
  padding: 22px 18px 20px;
  text-align: center;
  border-color: var(--gold-dk);
  box-shadow: 0 0 0 4px var(--gold-dk), 0 8px 0 4px rgba(0, 0, 0, .5);
}
.patchnotes-card .panel-label { margin-top: 0; }
.patchnotes-card .patch-list { text-align: left; }
.patchnotes-card .btn { margin-top: 10px; }

/* ---------- Connect: friend-code sharing ---------- */
.connect-panel { margin-top: 14px; }
.connect-title { font-family: var(--font-px); font-size: 13px; color: var(--gold); margin: 0 0 8px; }
.connect-rule { border: none; border-top: 2px dashed var(--line); margin: 16px 0 14px; }
#share-need-signin { margin-top: 10px; }

#share-on { margin-top: 10px; }
.share-code {
  font-family: var(--font-body); font-size: 40px; letter-spacing: 10px;
  text-align: center; color: var(--gold); background: #051509;
  border: 3px solid var(--line-bright); padding: 10px 6px 8px;
  margin: 6px 0 12px; word-break: break-all;
}
.share-qr {
  width: 180px; max-width: 70%; margin: 0 auto 12px;
  background: #fff; padding: 10px; border: 3px solid var(--line-bright);
}
.share-qr svg { display: block; width: 100%; height: auto; }
.share-url { overflow-wrap: anywhere; }

.friend-input {
  font-size: 30px; letter-spacing: 8px; text-transform: uppercase;
  max-width: 340px; margin: 8px auto 12px;
}
.friend-head { margin-bottom: 12px; }
/* friendsheet opens on top of the Save & Sync sheet (both .syncsheet, z 115);
   bump it clear so its fixed ✕ hit-tests correctly on iOS (equal z confuses taps) */
#friendsheet { z-index: 130; }

.friend-filter { display: flex; gap: 8px; margin-top: 12px; }
.ffbtn {
  flex: 1; font-family: var(--font-px); font-size: 9px; line-height: 1.45;
  padding: 11px 6px; min-height: 48px; text-align: center;
}
.ffboth { border-color: var(--gold-dk); }
.ffbtn.active {
  color: #2a1f00; background: var(--gold); border-color: var(--gold);
  box-shadow: 0 4px 0 var(--gold-dk);
}

.friend-list { display: flex; flex-direction: column; gap: 10px; }
.friend-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  flex-wrap: wrap; border: 3px solid var(--line); background: var(--panel);
  padding: 12px 14px;
}
.friend-item.is-known { opacity: .5; }
.friend-item.is-new { border-color: var(--gold-dk); background: var(--panel2); }
.friend-tinfo { flex: 1 1 60%; min-width: 0; }
.friend-tname { font-family: var(--font-body); font-size: 22px; color: var(--cream); }
.friend-item.is-new .friend-tname { color: var(--gold); }
.friend-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.friend-have { font-family: var(--font-px); font-size: 9px; color: var(--dim); white-space: nowrap; }
.friend-empty { text-align: center; padding: 18px 0; }

.invite-uses { text-align: center; margin: 6px 0 10px; }

/* manage-data drawer — keeps export/import/delete tucked away */
.data-drawer { margin-top: 14px; border: 3px solid var(--line); background: var(--panel); }
.data-summary {
  font-family: var(--font-px); font-size: 12px; color: var(--dim);
  padding: 16px 14px; cursor: pointer; list-style: none;
  display: flex; justify-content: space-between; align-items: center; min-height: 52px;
}
.data-summary::-webkit-details-marker { display: none; }
.data-summary::after { content: '▾'; font-size: 14px; }
.data-drawer[open] .data-summary::after { content: '▴'; }
.data-summary:hover { color: var(--green); }
.data-drawer .data-row { padding: 0 14px 16px; margin: 0; }

.friends-label { margin: 14px 0 6px; }
.friends-list { display: flex; flex-direction: column; gap: 8px; }
.friend-chip { display: flex; gap: 8px; align-items: stretch; }
.friend-chip .friend-open {
  flex: 1 1 auto; text-align: left; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.friend-chip .icon-btn { flex: 0 0 auto; }

/* ---------- Well: sort + tier controls ---------- */
.well-controls { display: flex; gap: 10px; margin: -6px 0 16px; }
.well-ctl {
  position: relative; flex: 1; display: flex; flex-direction: column; gap: 4px;
  font-family: var(--font-px); font-size: 9px; color: var(--dim); letter-spacing: 1px;
}
.well-select {
  width: 100%; font-family: var(--font-body); font-size: 19px; color: var(--cream);
  background: #051509; border: 3px solid var(--line-bright); border-radius: 0;
  padding: 8px 30px 8px 10px; min-height: 46px;
  -webkit-appearance: none; appearance: none;
}
.well-select:focus { outline: none; border-color: var(--bright); }
.well-ctl::after {
  content: '▾'; position: absolute; right: 11px; bottom: 13px;
  color: var(--green); font-size: 14px; pointer-events: none;
}
