/* Temat väljs med <html data-theme="…"> (js/theme.js). Standard = "massa" (mörk spelhall).
   Varje tema sätter samma variabler; layouten nedan är gemensam. */
:root, [data-theme="massa"] {
  color-scheme: dark;
  --ink: #f9f4e3;          /* text */
  --muted: #b9c8b1;        /* sekundär text */
  --green: #bff16e;        /* accent: knappar, markeringar */
  --btn-ink: #15270d;      /* text på accentknapp */
  --gold: #f8cc76;         /* bonus/placering */
  --dark: #10261f;         /* spelytans bakgrund */
  --line: #ffffff24;
  --page: #091a15;         /* utanför spelytan */
  --page-glow: #203e30;
  --start-bg: radial-gradient(ellipse at 82% 36%, #2a503b 0%, transparent 61%), #10261f;
  --shade: #091b16da;      /* bakom paneler */
  --panel: #183329;
  --field: #0b2118;        /* inmatning, små knappar */
  --placeholder: #a9baa5;
  --body-font: system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
  --display-font: system-ui, sans-serif;
  --radius: 6px;
  font-family: var(--body-font);
  color: var(--ink);
  background: var(--page);
}

/* NovoBins grafiska profil: mörkgrön + grön på ljus krämgrön, Archivo Narrow för rubriker och siffror.
   Samma färger finns i js/themes/profil.js för canvas-grafiken. */
[data-theme="profil"] {
  color-scheme: light;
  --ink: #000;
  --muted: #1C5439cc;
  --green: #2B8B43;
  --btn-ink: #fff;
  --gold: #D9A21B;
  --dark: #1C5439;
  --line: #1C543926;
  --page: #E2EBDF;
  --page-glow: #F3F7F1;
  --start-bg: linear-gradient(#F3F7F1, #E2EBDF);
  --shade: #1C5439b8;
  --panel: #fff;
  --field: #fff;
  --placeholder: #1C543980;
  --body-font: "Archivo", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display-font: "Archivo Narrow", "Arial Narrow", system-ui, sans-serif;
  --radius: 14px;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  min-height: 100dvh;
  display: grid;
  justify-items: center;
  background: radial-gradient(ellipse at center, var(--page-glow), var(--page) 70%);
  overscroll-behavior: none;
}
button, input { font: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:focus-visible, input:focus-visible { outline: 3px solid var(--gold); outline-offset: 3px; }
.hide { display: none !important; }

.machine {
  isolation: isolate;
  position: relative;
  width: min(100%, 520px);
  height: 100dvh;
  overflow: hidden;
  background: var(--dark);
}
#c { width: 100%; height: 100%; display: block; touch-action: none; }
.ov {
  position: absolute;
  z-index: 2;
  inset: 0;
  display: grid;
  justify-items: center;
  align-items: safe center;
  padding: max(14px, env(safe-area-inset-top)) 20px max(12px, env(safe-area-inset-bottom));
  overscroll-behavior: contain;
  overflow: auto;
}
#start { background: var(--start-bg); }
.shade { background: var(--shade); }
.card { width: 100%; max-width: 420px; }
.start-card { display: grid; gap: clamp(10px, 2dvh, 22px); }
.brand-bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.bar-buttons { display: flex; gap: 6px; }
.brand-logo { display: none; height: 34px; width: auto; }
.brand { display: inline-flex; align-items: center; gap: 7px; font-weight: 900; letter-spacing: .07em; font-size: .85rem; }
.brand span:last-child { color: var(--green); }
.brand-mark {
  width: 13px;
  height: 15px;
  border-radius: 2px 2px 4px 4px;
  border: 1.5px solid var(--green);
  transform: skew(-9deg);
  background: repeating-linear-gradient(90deg, transparent 0 2px, #bff16e66 2px 3px);
}
.sound-button {
  border: 1px solid var(--line);
  border-radius: 100px;
  color: var(--ink);
  background: var(--field);
  font-size: .75rem;
  min-height: 44px;
  padding: 0 12px;
}
.hero {
  min-height: clamp(218px, 39dvh, 331px);
  isolation: isolate;
  display: flex;
  align-items: center;
  position: relative;
}
.hero::before {
  content: "";
  position: absolute;
  z-index: -2;
  width: 64%;
  aspect-ratio: 1;
  right: 1%;
  border: 1px solid #d8ff9e35;
  border-radius: 50%;
  box-shadow: 0 0 0 16px #d8ff9e0b, 0 0 0 33px #d8ff9e09;
}
#heroBin {
  position: absolute;
  z-index: -1;
  inset: 0 0 0 auto;
  width: min(44%, 180px);
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(7px 14px 15px #08161194);
}
.hero-copy { width: 59%; }
h1, h2, p { margin: 0; }
h1 {
  color: var(--ink);
  font: 1000 clamp(36px, 11vw, 61px)/.87 var(--display-font);
  letter-spacing: -.085em;
  max-width: 275px;
  text-wrap: balance;
}
.hero p { max-width: 190px; margin-top: 13px; color: var(--muted); font-size: .87rem; line-height: 1.4; }
.prize {
  display: flex;
  align-items: center;
  padding: 9px 12px;
  gap: 11px;
  border-block: 1px solid #eec16b54;
  background: linear-gradient(90deg, #f8cc7613, transparent 88%);
  color: var(--gold);
}
.prize-mark {
  width: 29px;
  height: 29px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid #f8cc7680;
  font-weight: 850;
  font-size: .8rem;
}
.prize strong, .prize small { display: block; }
.prize small { color: var(--muted); font-size: .73rem; margin-top: 2px; }
label { display: block; margin: 0 0 5px 1px; color: var(--muted); font-size: .75rem; font-weight: 700; }
input {
  display: block;
  width: 100%;
  min-height: 46px;
  padding: 8px 13px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  color: var(--ink);
  background: var(--field);
  font-size: 16px;
}
input::placeholder { color: var(--placeholder); }
.btn {
  width: 100%;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  font-weight: 850;
  color: var(--btn-ink);
  background: var(--green);
}
.btn:active { filter: brightness(.88); }
.btn span { float: right; }
form .btn, .panel > .btn { margin-top: 10px; }
.form-msg { margin-top: 8px; color: var(--gold); font-size: .85rem; line-height: 1.4; }
.form-note { margin-top: 8px; color: var(--muted); font-size: .72rem; line-height: 1.4; }
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.ghost { background: transparent; color: var(--ink); border-color: var(--line); font-size: .83rem; }
.panel {
  padding: 21px;
  border: 1px solid var(--line);
  border-top: 3px solid var(--green);
  border-radius: 8px;
  background: var(--panel);
}
.panel h2 { letter-spacing: -.05em; font-size: 2rem; line-height: 1; margin-bottom: 12px; }
.panel .menu-row { margin-top: 9px; }
.rules { padding-left: 1.25em; color: var(--muted); font-size: .9rem; line-height: 1.5; }
.rules li + li { margin-top: .65em; }
.rules strong { color: var(--ink); }
.muted { color: var(--muted); font-size: .82rem; line-height: 1.4; margin: 5px 0; }
.big { font-size: clamp(40px, 12vw, 68px); color: var(--green); font-weight: 900; line-height: 1; letter-spacing: -.08em; overflow-wrap: anywhere; }
.score-label { color: var(--muted); font-size: .68rem; font-weight: 800; letter-spacing: .17em; margin: 4px 0 10px; }
.pb { color: var(--gold); font-weight: 760; font-size: .85rem; margin-bottom: 8px; }
.lb { list-style: none; padding: 0; margin: 9px 0; font-variant-numeric: tabular-nums; }
.lb li { display: flex; gap: 10px; align-items: baseline; padding: 8px 5px; border-bottom: 1px solid var(--line); font-size: .84rem; }
.lb li:first-child .r, .lb li.me { color: var(--gold); }
.lb .r { width: 22px; }
.lb .n { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lb .s { font-weight: 800; }
.lb .l { color: var(--muted); white-space: nowrap; font-size: .72rem; }
.game-controls { position: absolute; z-index: 1; right: 10px; top: max(12px, env(safe-area-inset-top)); pointer-events: none; }
.icon-button { display: grid; place-items: center; pointer-events: auto; width: 44px; height: 44px; border: 1px solid var(--line); border-radius: 9px; background: var(--dark); color: var(--ink); }
.pause-icon { display: block; width: 12px; height: 14px; border-inline: 3px solid currentColor; }
.dump-button { position: absolute; width: auto; z-index: 1; left: 50%; bottom: max(13px, env(safe-area-inset-bottom)); transform: translateX(-50%); white-space: nowrap; }

@media (max-width: 360px) {
  .ov { padding-inline: 14px; }
  h1 { font-size: 10.8vw; }
}
@media (max-height: 630px) {
  .start-card { gap: 8px; }
  .hero { min-height: 178px; }
  #heroBin { width: 38%; }
  .hero::before { width: 48%; }
}
@media (min-width: 560px) {
  .machine { box-shadow: 0 0 80px #0007; }
}

/* --- Temat "NovoBin": egna detaljer utöver variablerna --- */
[data-theme="profil"] .brand { display: none; }
[data-theme="profil"] .brand-logo { display: block; }
[data-theme="profil"] .hero::before { border-color: #2B8B4333; box-shadow: 0 0 0 16px #2B8B430d, 0 0 0 33px #2B8B4309; }
[data-theme="profil"] #heroBin { filter: drop-shadow(7px 14px 15px #1C543933); }
[data-theme="profil"] h1 { color: var(--dark); font-weight: 700; letter-spacing: -.01em; line-height: .95; }
[data-theme="profil"] .panel h2, [data-theme="profil"] .big { font-family: var(--display-font); font-weight: 700; letter-spacing: -.01em; }
[data-theme="profil"] .panel h2 { color: var(--dark); }
[data-theme="profil"] .panel { border: 0; border-radius: 22px; box-shadow: 0 16px 48px #0004; }
[data-theme="profil"] .prize { border-color: #D9A21B66; background: linear-gradient(90deg, #D9A21B1a, transparent 88%); color: #8a6408; }
[data-theme="profil"] .btn { font-family: var(--display-font); font-weight: 700; font-size: 1.15rem; box-shadow: 0 4px 0 var(--dark); }
[data-theme="profil"] .btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--dark); filter: none; }
[data-theme="profil"] .ghost { box-shadow: none; color: var(--dark); border: 2px solid var(--line); font-size: 1rem; }
[data-theme="profil"] .ghost:active { transform: none; }
[data-theme="profil"] .dump-button { width: auto; }
[data-theme="profil"] input { border-width: 2px; }
[data-theme="profil"] .form-msg { color: #B3261E; font-weight: 600; }
[data-theme="profil"] .lb li:nth-child(odd) { background: var(--page); }
[data-theme="profil"] .lb li.me { color: var(--green); font-weight: 700; }
[data-theme="profil"] .icon-button { background: #fff; color: var(--dark); border: 2px solid var(--line); }
