
:root{
  --purple:#6a1b6a;
  --purple-dark:#4A0F4A;
  --yellow:#F2B705;
  --cream:#FFF6E8;
}
*{box-sizing:border-box;-webkit-user-select:none;user-select:none}
body{
  margin:0;
  font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial,sans-serif;
  background:linear-gradient(180deg,var(--purple-dark),var(--purple));
  color:var(--cream);
}
.app{min-height:100vh;display:flex;flex-direction:column;}
.hidden{display:none !important}

.topbar{
  position:sticky;top:0;z-index:10;
  display:grid;
  grid-template-columns:60px 1fr 60px;
  align-items:center;
  padding:10px 12px 8px;
  background:linear-gradient(180deg,var(--purple-dark),var(--purple));
  border-bottom:1px solid rgba(255,255,255,.12);
}
.icon-btn{
  width:50px;height:50px;border:none;border-radius:999px;
  background:var(--yellow);color:var(--purple-dark);
  font-size:22px;font-weight:950;
  box-shadow:0 12px 22px rgba(0,0,0,.24);
}
#btnReset{justify-self:start}
#btnOverview{justify-self:end}

.brand-center{
  justify-self:center;
  display:flex;
  align-items:center;
  gap:10px;
}
.logo{
  width:64px;height:64px;border-radius:18px;object-fit:cover;
  border:2px solid rgba(255,255,255,.14);
  box-shadow:0 16px 30px rgba(0,0,0,.30);
}

/* Make the logo feel tappable */
.logo[role="button"]{ cursor:pointer; user-select:none; -webkit-tap-highlight-color: transparent; }
.logo[role="button"]:active{ transform: scale(0.98); }
.brand-text{line-height:1.05;text-align:left;min-width:0}
.brand-title{
  color:var(--yellow);
  font-weight:950;
  letter-spacing:.10em;
  font-size:14px;
  white-space:nowrap;
}
.brand-sub{
  font-weight:850;
  font-size:13px;
  white-space:nowrap;
}
.spotify-btn{
  border:none;background:transparent;padding:0;
  width:28px;height:28px;display:flex;align-items:center;justify-content:center;
  cursor:pointer;
}
.spotify-svg{width:28px;height:28px; filter: drop-shadow(0 6px 10px rgba(0,0,0,.25));}

main{flex:1;padding:12px}
.screen{max-width:920px;margin:0 auto;}

.add-row{display:flex;gap:12px;margin:6px 0 12px}
.input{
  flex:1;padding:14px 14px;border-radius:18px;border:none;font-size:17px;
}
.btn{border:none;border-radius:18px;padding:14px 18px;font-weight:950;font-size:16px;}
.btn-primary{
  background:var(--yellow);color:var(--purple-dark);
  box-shadow:0 12px 22px rgba(0,0,0,.18);
}

.grid{display:grid;gap:14px}
.grid-2{grid-template-columns:repeat(2, minmax(0, 1fr));}

/* Tiles */
.tile{
  position:relative;
  background:var(--yellow);
  border-radius:30px;
  padding:20px 14px 18px;
  color:var(--purple-dark);
  font-weight:950;
  text-align:center;
  box-shadow:0 14px 24px rgba(0,0,0,.20);
  /* IMPORTANT: no overflow hidden, otherwise the bubble gets clipped */
}
.tile::before{content:"";position:absolute;left:0;top:0;bottom:0;width:25%;}
.tile::after{content:"";position:absolute;left:25%;right:0;top:0;bottom:0;}
.drink-name{
  font-size:20px;line-height:1.08;
  display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;
  overflow:hidden;
}
/* Count bubble fully INSIDE, always readable */
.count-bubble{
  position:absolute;
  top:10px;
  right:10px;
  width:42px;height:42px;border-radius:50%;
  background:var(--purple-dark);
  border:4px solid var(--yellow);
  color:var(--yellow);
  display:flex;align-items:center;justify-content:center;
  font-size:20px;font-weight:950;
  box-shadow:0 10px 18px rgba(0,0,0,.22);
}
.bottom-spacer{height:10px}

/* Overview: much bigger for distance */
.title{
  margin:10px 0 18px;
  text-align:center;
  color:var(--yellow);
  font-size:44px;
  font-weight:950;
  letter-spacing:.02em;
}
.summary-list{display:flex;flex-direction:column;gap:18px;}
.summary-row{
  display:flex;justify-content:space-between;align-items:center;gap:18px;
  padding:26px 22px;
  border-radius:22px;
  background:rgba(0,0,0,.22);
  border:1px solid rgba(255,255,255,.12);
}
.summary-row .left{
  font-weight:950;
  font-size:40px;
  overflow:hidden;text-overflow:ellipsis;white-space:nowrap;
}
.summary-row .right{
  font-weight:950;
  font-size:48px;
  color:var(--yellow);
  min-width:64px;
  text-align:right;
}

/* Spotify modal */
.modal{
  position:fixed;inset:0;z-index:9999;
  display:flex;align-items:center;justify-content:center;
  padding:18px;
}
.modal-backdrop{position:absolute;inset:0;background:rgba(0,0,0,.60);}
.modal-card{
  position:relative;z-index:10000;
  width:min(520px,100%);
  border-radius:22px;
  background:linear-gradient(180deg, rgba(255,255,255,.14), rgba(255,255,255,.10));
  border:1px solid rgba(255,255,255,.18);
  padding:14px;
  box-shadow:0 24px 46px rgba(0,0,0,.40);
  backdrop-filter: blur(10px);
}
.modal-head{display:flex;align-items:center;gap:12px;}
.modal-title-main{font-weight:950;color:var(--yellow);letter-spacing:.08em;}
.modal-title-sub{font-weight:850;opacity:.55;font-size:12px;}
.modal-x{
  margin-left:auto;
  width:48px;height:48px;border:none;border-radius:999px;
  background:rgba(255,255,255,.18);
  color:var(--cream);
  font-weight:950;font-size:20px;
  cursor:pointer;pointer-events:auto;
  position:relative;z-index:10001;
}
.qr-link{display:block;margin:12px auto 10px;width:fit-content;}
.qr-img{width:260px;height:260px;background:#fff;padding:10px;border-radius:18px;object-fit:contain;}
.open-spotify{
  display:block;text-align:center;
  padding:14px 14px;border-radius:18px;
  background:#1DB954;color:#fff;
  font-weight:950;text-decoration:none;
}

/* v8.4 modal robustness */
.modal *{ -webkit-user-select:none; user-select:none; }
.modal-x{ pointer-events:auto !important; }


/* v8.5: Summary must fit on one screen (no scroll) */
#screenSummary{
  height: calc(100vh - 86px); /* header approx */
  display: flex;
  flex-direction: column;
}
#summaryList{
  flex: 1;
  min-height: 0;
  overflow: hidden; /* prevent scrolling */
}
#summaryFooter{
  margin-top: 12px;
  padding: 14px 18px;
  border-radius: 22px;
  background: rgba(0,0,0,.26);
  border: 1px solid rgba(255,255,255,.12);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
#summaryFooter .left{
  font-weight: 950;
  font-size: clamp(18px, 4.2vw, 34px);
}
#summaryFooter .right{
  font-weight: 950;
  font-size: clamp(22px, 5vw, 42px);
  color: var(--yellow);
}

/* Make summary row sizes controllable via CSS vars set by JS */
.summary-row{
  padding: var(--sum-pad, 22px) var(--sum-pad-x, 22px) !important;
}
.summary-row .left{
  font-size: var(--sum-name, 36px) !important;
}
.summary-row .right{
  font-size: var(--sum-qty, 44px) !important;
}

/* Spotify icon should feel tappable */
.spotify-btn{
  width: 40px !important;
  height: 40px !important;
  border-radius: 999px;
  background: rgba(255,255,255,.10);
  box-shadow: 0 10px 18px rgba(0,0,0,.20);
}
.spotify-btn:active{
  transform: scale(0.96);
}
.spotify-svg{width: 28px !important; height: 28px !important;}

/* v8.6: lock summary to one screen with grid layout */
#screenSummary{
  height: calc(100vh - 86px);
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  overflow: hidden;
}
#screenSummary .title{margin: 4px 0 0 !important;}
#summaryList{overflow: hidden !important;}
.summary-list{gap: var(--sum-gap, 12px) !important;}

/* v8.7: remove overview title spacing */
#screenSummary .title{display:none !important;}

/* v8.8: bigger Spotify button for tap-ability */
.spotify-btn{
  width: 54px !important;
  height: 54px !important;
  padding: 0 !important;
}
.spotify-svg{
  width: 36px !important;
  height: 36px !important;
}

/* =========================
   v9: SCOREBOARD OVERVIEW
   - ZERO SCROLL, EVER
   - iOS Safari safe height (uses --appH from JS = window.innerHeight)
   ========================= */
:root{
  --appH: 100vh;     /* JS will override to px */
  --headerH: 86px;   /* JS will update precisely */
  --sum-gap: 8px;
  --sum-name: 28px;
  --sum-qty: 34px;
  --sum-padY: 10px;
  --sum-padX: 14px;
  --footerH: 64px;
}

/* Prevent rubber-band scroll in overview */
body.overview-lock{ overflow: hidden !important; }

#screenSummary{
  /* use JS-measured innerHeight to avoid iOS 100vh issues */
  height: calc(var(--appH) - var(--headerH));
  display: grid;
  grid-template-rows: 1fr var(--footerH);
  gap: 10px;
  overflow: hidden;
  padding-top: 6px;
}

#summaryList{
  overflow: hidden !important;
  display: flex;
  flex-direction: column;
  gap: var(--sum-gap);
  min-height: 0;
}

/* Each row gets equal height so everything fits */
#summaryList .summary-row{
  flex: 1 1 0;
  min-height: 0;
  padding: var(--sum-padY) var(--sum-padX) !important;
  border-radius: 18px;
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.12);
  box-shadow: none; /* save space */
}

#summaryList .summary-row .left{
  font-size: var(--sum-name) !important;
  font-weight: 950;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#summaryList .summary-row .right{
  font-size: var(--sum-qty) !important;
  font-weight: 950;
  color: var(--yellow);
  min-width: 56px;
  text-align: right;
}

#summaryFooter{
  height: var(--footerH);
  padding: 10px 16px;
  border-radius: 18px;
  background: rgba(0,0,0,.30);
  border: 1px solid rgba(255,255,255,.14);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#summaryFooter .left{
  font-weight: 950;
  font-size: clamp(18px, 4.0vw, 30px);
}
#summaryFooter .right{
  font-weight: 950;
  font-size: clamp(22px, 5.0vw, 40px);
  color: var(--yellow);
}

/* Spotify button: bigger + clearer tap target */
.spotify-btn{
  width: 58px !important;
  height: 58px !important;
  border-radius: 999px;
  background: rgba(255,255,255,.12);
  box-shadow: 0 10px 18px rgba(0,0,0,.22);
}
.spotify-svg{ width: 40px !important; height: 40px !important; }
.spotify-btn:active{ transform: scale(0.96); }

/* v9.1 cross-platform UX */
button, .drink-btn, .spotify-btn, .icon-btn {
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  touch-action: manipulation;
}

/* iOS safe areas */
#screenSummary{
  padding-bottom: max(10px, env(safe-area-inset-bottom));
}
#summaryFooter{
  margin-bottom: env(safe-area-inset-bottom);
}

/* Make Spotify feel more like a button */
.spotify-btn{
  outline: 2px solid rgba(255,255,255,.14);
}
.spotify-btn::after{
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 999px;
}

/* v9.2: prevent center (logo/text/spotify) from overlapping the right icon button */
.topbar{ overflow:hidden; }
.brand-center{ max-width:100%; min-width:0; }
.brand-text{ max-width: 150px; min-width:0; }
@media (max-width: 420px){
  .logo{ width:56px; height:56px; border-radius:16px; }
  .brand-title{ font-size:13px; letter-spacing:.08em; }
  .brand-sub{ font-size:12px; }
  .spotify-btn{ width:52px !important; height:52px !important; }
  .spotify-svg{ width:36px !important; height:36px !important; }
}
/* ensure right button stays clickable above any overlap */
#btnOverview{ position:relative; z-index:20; }
#btnSpotify{ position:relative; z-index:10; }

/* Gold theme v10.5 */
:root{
  --gold:#f7c948;
  --gold-2:#ffde7a;
  --spark:rgba(255, 222, 122, .22);
  --spark-2:rgba(255, 222, 122, .10);
  --glass:rgba(255,255,255,.08);
  --glass-2:rgba(255,255,255,.12);
}

body::before{
  content:"";
  position:fixed; inset:-20vh -20vw;
  pointer-events:none;
  background:
    radial-gradient(circle at 20% 10%, var(--spark) 0 18%, transparent 19%),
    radial-gradient(circle at 80% 15%, var(--spark-2) 0 14%, transparent 15%),
    radial-gradient(circle at 70% 80%, var(--spark) 0 16%, transparent 17%),
    radial-gradient(circle at 25% 75%, var(--spark-2) 0 12%, transparent 13%);
  filter: blur(0.2px);
  opacity:.55;
}

.icon-btn, .spotify-btn, .btn, .drink-btn{
  box-shadow: 0 10px 22px rgba(0,0,0,.25);
}

.icon-btn:active, .spotify-btn:active, .btn:active, .drink-btn:active{
  transform: translateY(1px);
}

.primary-btn{
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  color:#2a102a;
  font-weight:900;
  border:none;
  border-radius: 16px;
  padding: 12px 16px;
  box-shadow: 0 0 0 2px rgba(0,0,0,.08), 0 0 18px rgba(247,201,72,.35);
}

.primary-btn:hover{ filter: brightness(1.03); }
.primary-btn:active{ transform: translateY(1px); }

/* Help modal */
.help-modal .help-card{
  width:min(680px, 92vw);
  max-height: 90vh;
  overflow:auto;
  position: relative;
}

.help-close{
  position:absolute;
  top:14px;
  right:14px;
  width:44px;
  height:44px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.22);
  color: #fff;
  font-size: 20px;
  font-weight: 800;
  cursor:pointer;
}
.help-close:hover{ background: rgba(0,0,0,.36); }
.help-close:active{ transform: scale(0.98); }

.help-hero{
  position:relative;
  padding: 18px 18px 14px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(247,201,72,.18), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 0 28px rgba(247,201,72,.20);
  margin: 14px;
}

.help-hero-badge{
  display:inline-block;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.18);
  font-weight: 800;
  letter-spacing: .2px;
}

.help-hero-title{
  margin-top: 10px;
  font-size: 34px;
  font-weight: 900;
  letter-spacing: .3px;
}

.help-hero-sub{
  margin-top: 6px;
  opacity: .95;
  font-size: 16px;
  line-height: 1.3;
}

.help-steps{ padding: 0 14px 10px; }

.help-step{
  display:flex;
  gap:14px;
  align-items: stretch;
  margin: 12px 0;
  padding: 14px;
  border-radius: 18px;
  background: var(--glass);
  border: 1px solid rgba(255,255,255,.14);
}

.help-step-left{ flex: 1.3; min-width: 0; }
.help-step-right{ flex: 1; display:flex; align-items:center; justify-content:center; }

.help-step-title{ font-weight: 900; font-size: 18px; margin-bottom: 6px; }
.help-step-text{ opacity: .95; line-height: 1.35; }

.help-plusminus{
  margin-top: 10px;
  display: grid;
  gap: 6px;
  max-width: 280px;
}

.pm-row{
  display:grid;
  grid-template-columns: 1fr 64px;
  align-items:center;
  gap: 10px;
  padding: 10px 10px;
  border-radius: 14px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.14);
}
.pm-side{ opacity:.95; font-weight:700; }
.pm-val{
  text-align:center;
  font-weight: 900;
  color: #2a102a;
  background: linear-gradient(135deg, var(--gold), var(--gold-2));
  border-radius: 12px;
  padding: 6px 0;
  box-shadow: 0 0 16px rgba(247,201,72,.25);
}

.mini-screen{
  width: min(240px, 36vw);
  border-radius: 18px;
  background: rgba(0,0,0,.18);
  border: 1px solid rgba(255,255,255,.14);
  padding: 10px;
  box-shadow: 0 0 20px rgba(0,0,0,.22);
}
.mini-top{
  font-weight: 900;
  letter-spacing: .2px;
  font-size: 13px;
  opacity:.95;
  margin-bottom: 8px;
}
.mini-grid{
  display:grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.mini-btn{
  background: linear-gradient(135deg, rgba(247,201,72,.95), rgba(255,222,122,.95));
  color:#2a102a;
  font-weight: 900;
  font-size: 12px;
  padding: 10px 8px;
  border-radius: 999px;
  text-align:center;
  box-shadow: 0 0 16px rgba(247,201,72,.22);
}
.mini-hint{
  margin-top: 8px;
  font-size: 12px;
  opacity: .92;
}

.mini-list{ display:grid; gap: 8px; }
.mini-row{
  display:flex; justify-content:space-between; align-items:center;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  font-weight: 800;
  font-size: 12px;
}
.mini-total{
  margin-top: 8px;
  padding: 8px 10px;
  border-radius: 14px;
  background: rgba(247,201,72,.18);
  border: 1px solid rgba(255,255,255,.14);
  font-weight: 900;
  font-size: 12px;
  text-align:center;
}

.mini-toast{
  width: min(240px, 36vw);
  text-align:center;
  padding: 18px 12px;
  border-radius: 18px;
  background: linear-gradient(135deg, rgba(247,201,72,.22), rgba(255,255,255,.06));
  border: 1px solid rgba(255,255,255,.16);
  font-size: 34px;
  box-shadow: 0 0 28px rgba(247,201,72,.18);
}

.help-qr{
  margin: 4px 14px 0;
  padding: 14px 14px 12px;
  border-radius: 18px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.14);
  text-align: center;
}
.help-qr-title{ font-weight: 900; margin-bottom: 10px; }
.help-qr-link{ display:inline-block; text-decoration:none; color:inherit; }
.help-qr-img{
  width: min(220px, 70vw);
  height: auto;
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(0,0,0,.30), 0 0 22px rgba(247,201,72,.18);
  display:block;
  margin: 0 auto 8px;
}
.help-qr-url{ font-weight: 900; opacity:.95; }
.help-qr-hint{ margin-top: 6px; font-size: .95em; opacity:.55; }

.help-actions{
  display:flex; justify-content:center;
  padding: 14px 14px 18px;
}

@media (max-width: 520px){
  .help-step{ flex-direction: column; }
  .help-hero-title{ font-size: 30px; }
  .mini-screen, .mini-toast{ width: 100%; }
}

.no-scroll{ overflow:hidden; }

/* Polish v10.7 */
.help-modal{
  display:none;
}
.help-modal[data-open="1"]{
  display:block;
}
.help-modal .help-card{
  transform: translateY(10px);
  opacity: 0;
  transition: transform 180ms ease, opacity 180ms ease;
}
.help-modal.is-open .help-card{
  transform: translateY(0);
  opacity: 1;
}
.modal-backdrop{
  opacity: 0;
  transition: opacity 180ms ease;
}
.modal-backdrop.is-open{
  opacity: 1;
}
/* Slightly calmer gold glow */
.primary-btn{
  box-shadow: 0 0 0 2px rgba(0,0,0,.08), 0 0 14px rgba(247,201,72,.28);
}
.mini-btn{
  box-shadow: 0 0 12px rgba(247,201,72,.18);
}
.help-hero{
  box-shadow: 0 0 22px rgba(247,201,72,.16);
}
.help-qr-img{
  box-shadow: 0 12px 26px rgba(0,0,0,.28), 0 0 18px rgba(247,201,72,.14);
}
/* Accessibility */
@media (prefers-reduced-motion: reduce){
  .help-modal .help-card, .modal-backdrop, .primary-btn, .mini-btn{
    transition: none !important;
  }
  .icon-btn:active, .spotify-btn:active, .btn:active, .drink-btn:active, .primary-btn:active{
    transform:none !important;
  }
}
