/* ============================================================
   CUSS — The Elements of Naughty
   Palette lifted from the element-card artwork: fluorine green,
   uranium yellow, carbon bone, potassium purple, on pure black.
   ============================================================ */

:root {
  --bg:        #0a0a0a;
  --bg-soft:   #121212;
  --panel:     #171716;
  --line:      #2c2b29;
  --line-soft: #201f1e;

  --text:      #e8e4dc;
  --muted:     #8b8680;
  --faint:     #5d5954;

  --green:     #9ccc3f;
  --yellow:    #f2c119;
  --bone:      #ded9d0;
  --purple:    #b07ecc;
  --graphite:  #3b3a38;

  --correct:      var(--green);
  --correct-bg:   rgba(156, 204, 63, .14);
  --present:      var(--yellow);
  --present-bg:   rgba(242, 193, 25, .14);
  --absent:       var(--graphite);
  --absent-bg:    #191918;

  --radius: 10px;
  --tile: clamp(42px, min(15.5vw, 8.2vh), 64px);
  --font-display: 'Oswald', 'Haettenschweiler', 'Arial Narrow', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
}

/* Colour-blind / high-contrast: blue + orange instead of green + yellow */
body.hc {
  --correct:    #4d9fff;
  --correct-bg: rgba(77, 159, 255, .16);
  --present:    #f5811f;
  --present-bg: rgba(245, 129, 31, .16);
}

* { box-sizing: border-box; }

/* [hidden] must beat the display rules below */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- ambient background -------------------------------------------------
   A faint periodic-table lattice under three slow-drifting element glows.
   Both layers sit at z-index 0 and the app is lifted to 1 — a negative
   z-index would put them behind body's own background colour. */

body::before {
  content: '';
  position: fixed;
  inset: -12%;
  z-index: 0;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(90deg, rgba(222, 217, 208, .05) 0 1px, transparent 1px 66px),
    repeating-linear-gradient(0deg,  rgba(222, 217, 208, .05) 0 1px, transparent 1px 82px);
  -webkit-mask-image: radial-gradient(ellipse 70% 55% at 50% 46%, transparent 12%, #000 95%);
  mask-image: radial-gradient(ellipse 70% 55% at 50% 46%, transparent 12%, #000 95%);
}

body::after {
  content: '';
  position: fixed;
  inset: -6%;
  z-index: 0;
  pointer-events: none;
  background-image:
    radial-gradient(52vw 40vh at 16% 6%,  rgba(156, 204, 63, .15), transparent 62%),
    radial-gradient(46vw 38vh at 86% 20%, rgba(242, 193, 25, .10), transparent 62%),
    radial-gradient(58vw 46vh at 74% 98%, rgba(176, 126, 204, .16), transparent 64%);
  animation: drift 38s ease-in-out infinite alternate;
}

@keyframes drift {
  from { transform: translate3d(-1.6%, -1.2%, 0) scale(1.02); }
  to   { transform: translate3d(1.6%,  1.6%, 0) scale(1.09); }
}

button { font-family: inherit; color: inherit; cursor: pointer; }

/* ============================================================
   Wordmark — C U S S rendered as real element cards
   (Carbon 6, Uranium 92, Sulfur 16, Sulfur 16)
   ============================================================ */

.wordmark { display: flex; gap: 5px; justify-content: center; }

.el {
  --el: var(--bone);
  position: relative;
  width: 34px;
  height: 46px;
  border: 1.6px solid var(--el);
  border-radius: 5px;
  background: linear-gradient(180deg, rgba(255,255,255,.05), transparent 60%);
  box-shadow: 0 0 14px -4px var(--el), inset 0 0 18px -12px var(--el);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 24px;
  line-height: 1;
  color: var(--el);
  padding: 7px 0 9px;
}
.el::before {
  content: attr(data-n);
  position: absolute;
  top: 2px; left: 4px;
  font-family: var(--font-body);
  font-size: 8px;
  font-weight: 600;
  opacity: .85;
}
.el::after {
  content: attr(data-name);
  position: absolute;
  bottom: 3px; left: 0; right: 0;
  font-family: var(--font-body);
  font-size: 6.5px;
  font-weight: 600;
  letter-spacing: .04em;
  text-align: center;
  opacity: .8;
}
.el.c { --el: var(--bone); }
.el.u { --el: var(--yellow); }
.el.s { --el: var(--green); }
.el.s2 { --el: var(--purple); }

.wordmark--lg .el { width: 62px; height: 84px; font-size: 44px; border-radius: 8px; border-width: 2px; padding: 12px 0 15px; }
.wordmark--lg .el::before { font-size: 13px; top: 5px; left: 8px; }
.wordmark--lg .el::after { font-size: 10px; bottom: 6px; }

.tagline {
  margin: 14px 0 0;
  text-align: center;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--muted);
}
.tagline .c-w { color: var(--bone); }
.tagline .c-g { color: var(--green); text-shadow: 0 0 14px rgba(156,204,63,.35); }
.tagline .c-p { color: var(--purple); text-shadow: 0 0 14px rgba(176,126,204,.35); }
.tagline .c-y { color: var(--yellow); }
.tagline--sm { font-size: 8.5px; letter-spacing: .22em; margin-top: 6px; font-weight: 600; }
.tagline--sm .c-g,
.tagline--sm .c-p { text-shadow: none; }

.tagline-sub {
  margin: 10px 0 0;
  text-align: center;
  font-family: 'Caveat', 'Comic Sans MS', cursive;
  font-weight: 700;
  font-size: 22px;
  letter-spacing: .04em;
  text-transform: uppercase;
  line-height: 1;
  color: var(--yellow);
}
.tagline-sub .dash {
  display: inline-block;
  color: var(--bone);
  opacity: .55;
  margin: 0 .35em;
  transform: translateY(-3px);
  letter-spacing: -.15em;
}

/* ============================================================
   18+ gate
   ============================================================ */

.gate {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 24px;
  background: var(--bg);
  overflow-y: auto;
}
.gate-inner { max-width: 420px; text-align: center; }
.gate-copy {
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 14.5px;
  line-height: 1.6;
}
.gate-ask {
  margin: 26px 0 14px;
  font-family: var(--font-display);
  font-size: 19px;
  letter-spacing: .04em;
}
.gate-buttons { display: grid; gap: 10px; }
.gate-fine { margin: 22px 0 0; font-size: 11.5px; color: var(--faint); line-height: 1.6; }

.btn {
  display: block;
  width: 100%;
  padding: 14px 18px;
  border-radius: var(--radius);
  border: 1.5px solid var(--line);
  background: transparent;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  text-decoration: none;
  text-align: center;
  color: var(--text);
  transition: transform .12s, background .15s, border-color .15s;
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(0); }
.btn--primary {
  border-color: var(--green);
  color: var(--green);
  background: rgba(156, 204, 63, .08);
  box-shadow: 0 0 26px -12px var(--green);
}
.btn--primary:hover { background: rgba(156, 204, 63, .16); }
.btn--ghost { color: var(--faint); font-size: 12.5px; padding: 10px; border-color: transparent; }
.btn--ghost:hover { color: var(--muted); }

/* ============================================================
   Layout
   ============================================================ */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  max-height: 880px;
  max-width: 520px;
  margin: 0 auto;
  padding: 0 8px env(safe-area-inset-bottom);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px 4px 8px;
  border-bottom: 1px solid var(--line-soft);
}
.brand { flex: 1; min-width: 0; }
.topbar-right { display: flex; gap: 4px; }

.icon-btn {
  width: 36px; height: 36px;
  display: grid; place-items: center;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 18px;
  transition: background .15s, color .15s;
}
.icon-btn:hover { background: var(--panel); color: var(--text); }

.modebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 4px 3px;
}
.seg {
  display: flex;
  gap: 2px;
  padding: 2px;
  border: 1px solid var(--line-soft);
  border-radius: 8px;
  background: var(--bg-soft);
}
.seg-btn {
  border: none;
  background: transparent;
  color: var(--faint);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 5px 12px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.seg-btn.is-on { background: var(--panel); color: var(--text); }

.element-no {
  font-family: var(--font-body);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
}

.board-wrap {
  flex: 1;
  display: grid;
  place-items: center;
  min-height: 0;
  padding: 4px 0;
}

/* ============================================================
   Board — portrait element cards, not squares
   ============================================================ */

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(6, 1fr);
  gap: 6px;
  height: 100%;
  max-height: 520px;
  max-width: 100%;
  aspect-ratio: 5 / 7.5;
  container-type: size;
}

.tile {
  position: relative;
  display: grid;
  place-items: center;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: transparent;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: min(6.2vh, 8.4vw);
  font-size: 9.4cqh;
  line-height: 1;
  color: var(--text);
  user-select: none;
  transition: border-color .1s;
}
/* atomic-number corner mark, only once the tile has a letter */
.tile::before {
  content: attr(data-n);
  position: absolute;
  top: 3px; left: 5px;
  font-family: var(--font-body);
  font-size: min(1.7vh, 2.3vw);
  font-size: 2.6cqh;
  font-weight: 600;
  opacity: 0;
  transition: opacity .2s;
}
.tile[data-filled]::before { opacity: .55; }

.tile[data-filled] { border-color: #56534e; animation: pop .1s ease-out; }

.tile[data-state] { color: #fff; }
.tile[data-state="correct"] {
  border-color: var(--correct);
  background: var(--correct-bg);
  color: var(--correct);
  box-shadow: 0 0 22px -8px var(--correct), inset 0 0 24px -16px var(--correct);
}
.tile[data-state="present"] {
  border-color: var(--present);
  background: var(--present-bg);
  color: var(--present);
  box-shadow: 0 0 22px -10px var(--present);
}
.tile[data-state="absent"] {
  border-color: var(--absent);
  background: var(--absent-bg);
  color: #6f6b66;
}

.tile.flip { animation: flip .5s ease forwards; }
.row-shake { animation: shake .5s; }
.tile.win { animation: winbounce .6s ease; }

@keyframes pop { 0% { transform: scale(.9); } 100% { transform: scale(1); } }
@keyframes flip {
  0%   { transform: rotateX(0); }
  49%  { transform: rotateX(90deg); }
  50%  { transform: rotateX(90deg); }
  100% { transform: rotateX(0); }
}
@keyframes shake {
  10%, 90% { transform: translateX(-2px); }
  20%, 80% { transform: translateX(4px); }
  30%, 50%, 70% { transform: translateX(-7px); }
  40%, 60% { transform: translateX(7px); }
}
@keyframes winbounce {
  0% { transform: translateY(0); }
  30% { transform: translateY(-22px); }
  55% { transform: translateY(4px); }
  75% { transform: translateY(-6px); }
  100% { transform: translateY(0); }
}

/* ============================================================
   Keyboard
   ============================================================ */

.keyboard {
  display: grid;
  gap: 6px;
  padding: 8px 2px 12px;
}
.krow { display: flex; gap: 5px; justify-content: center; }
.key {
  flex: 1 1 0;
  min-width: 0;
  height: 52px;
  border: 1px solid var(--line-soft);
  border-radius: 7px;
  background: #232220;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 600;
  letter-spacing: .03em;
  transition: background .12s, transform .06s, color .2s, border-color .2s;
}
.key:active { transform: scale(.94); }
.key--wide { flex: 1.6 1 0; font-size: 11px; letter-spacing: .1em; }
.key[data-state="correct"] { background: var(--correct); border-color: var(--correct); color: #0a0a0a; }
.key[data-state="present"] { background: var(--present); border-color: var(--present); color: #0a0a0a; }
.key[data-state="absent"]  { background: #141413; border-color: #191918; color: #4a4744; }

/* ============================================================
   Toast
   ============================================================ */

.toast {
  position: fixed;
  top: 96px; left: 50%;
  transform: translateX(-50%) translateY(-8px);
  z-index: 40;
  padding: 11px 18px;
  border-radius: 8px;
  background: var(--bone);
  color: #111;
  font-size: 13.5px;
  font-weight: 600;
  letter-spacing: .01em;
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s, transform .18s;
  white-space: nowrap;
  box-shadow: 0 10px 40px -14px #000;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ============================================================
   Modal
   ============================================================ */

.modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 4, 4, .82);
  backdrop-filter: blur(6px);
  animation: fade .2s ease;
  overflow-y: auto;
}
.modal-card {
  position: relative;
  width: 100%;
  max-width: 430px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  padding: 26px 24px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--panel);
  box-shadow: 0 30px 80px -30px #000;
  animation: rise .26s cubic-bezier(.2, .9, .3, 1);
}
@keyframes fade { from { opacity: 0; } }
@keyframes rise { from { opacity: 0; transform: translateY(16px); } }

.modal-close {
  position: absolute;
  top: 10px; right: 12px;
  width: 32px; height: 32px;
  border: none;
  background: transparent;
  color: var(--faint);
  font-size: 26px;
  line-height: 1;
  border-radius: 8px;
}
.modal-close:hover { color: var(--text); background: #201f1e; }

.m-title {
  margin: 0 0 4px;
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-align: center;
}
.m-sub {
  margin: 0 0 20px;
  text-align: center;
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}
.m-body { font-size: 14px; line-height: 1.65; color: #c9c4bc; }
.m-body p { margin: 0 0 12px; }
.m-body strong { color: var(--text); }
.m-rule { border: 0; border-top: 1px solid var(--line-soft); margin: 20px 0; }

/* how-to-play example row */
.demo { display: flex; gap: 5px; margin: 6px 0 10px; }
.demo .tile {
  width: 40px; height: 48px;
  font-size: 22px;
  border-width: 2px;
}
.demo .tile::before { font-size: 7px; opacity: .55; }

/* ============================================================
   Result — the answer as a full element card
   ============================================================ */

.reveal { text-align: center; }
.card-el {
  --el: var(--green);
  position: relative;
  width: 190px;
  margin: 4px auto 18px;
  padding: 22px 12px 16px;
  border: 2.5px solid var(--el);
  border-radius: 12px;
  background: linear-gradient(180deg, rgba(255,255,255,.055), transparent 55%);
  box-shadow: 0 0 46px -14px var(--el), inset 0 0 40px -26px var(--el);
  animation: rise .4s cubic-bezier(.2,.9,.3,1);
}
.card-el .num {
  position: absolute; top: 8px; left: 12px;
  font-size: 15px; font-weight: 700; color: var(--el);
}
.card-el .sym {
  font-family: var(--font-display);
  font-size: 68px; font-weight: 700; line-height: 1;
  color: var(--el);
}
.card-el .name {
  margin-top: 10px;
  font-size: 17px; font-weight: 700;
  letter-spacing: .08em; text-transform: uppercase;
  color: var(--el);
}
.card-el .mass { margin-top: 5px; font-size: 12.5px; color: var(--el); opacity: .75; }

.blurb {
  margin: 0 auto 20px;
  max-width: 330px;
  font-size: 14px;
  line-height: 1.68;
  color: #bdb8b0;
}
.blurb i { color: var(--purple); font-style: italic; }

.verdict {
  font-family: var(--font-display);
  font-size: 17px;
  letter-spacing: .1em;
  text-transform: uppercase;
  margin: 0 0 14px;
  color: var(--text);
}

/* ============================================================
   Stats
   ============================================================ */

.stats { display: flex; justify-content: center; gap: 6px; margin: 4px 0 20px; }
.stat { flex: 1; text-align: center; }
.stat b {
  display: block;
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  line-height: 1.1;
}
.stat span {
  display: block;
  margin-top: 3px;
  font-size: 9.5px;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--faint);
  line-height: 1.3;
}

.dist { display: grid; gap: 5px; margin-bottom: 4px; }
.dist-row { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.dist-row > i {
  width: 10px;
  font-style: normal;
  color: var(--faint);
  font-weight: 600;
}
.dist-bar {
  min-width: 22px;
  padding: 3px 7px;
  border-radius: 4px;
  background: var(--graphite);
  color: var(--text);
  text-align: right;
  font-weight: 700;
  font-size: 11.5px;
  transition: width .5s cubic-bezier(.2,.9,.3,1);
}
.dist-row.is-now .dist-bar { background: var(--correct); color: #0a0a0a; }

.next {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--line-soft);
}
.next-label { font-size: 9.5px; letter-spacing: .12em; text-transform: uppercase; color: var(--faint); }
.next-time {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 600;
  letter-spacing: .04em;
  font-variant-numeric: tabular-nums;
}
.btn-share {
  flex: 1;
  padding: 14px 16px;
  border: none;
  border-radius: 9px;
  background: var(--correct);
  color: #0a0a0a;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
  box-shadow: 0 0 30px -12px var(--correct);
  transition: transform .12s, filter .15s;
}
.btn-share:hover { transform: translateY(-1px); filter: brightness(1.08); }

/* ============================================================
   Settings
   ============================================================ */

.setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 15px 0;
  border-bottom: 1px solid var(--line-soft);
}
.setting:last-of-type { border-bottom: 0; }
.setting h4 { margin: 0 0 3px; font-size: 14.5px; font-weight: 600; }
.setting p { margin: 0; font-size: 11.5px; line-height: 1.5; color: var(--faint); }

.switch {
  flex: 0 0 auto;
  width: 46px; height: 27px;
  border: none;
  border-radius: 99px;
  background: var(--graphite);
  position: relative;
  transition: background .18s;
}
.switch::after {
  content: '';
  position: absolute;
  top: 3px; left: 3px;
  width: 21px; height: 21px;
  border-radius: 50%;
  background: var(--text);
  transition: transform .18s;
}
.switch[aria-checked="true"] { background: var(--correct); }
.switch[aria-checked="true"]::after { transform: translateX(19px); background: #0a0a0a; }

.footnote {
  margin-top: 18px;
  font-size: 10.5px;
  line-height: 1.6;
  color: var(--faint);
  text-align: center;
}

@media (max-width: 360px) {
  .key { height: 46px; font-size: 14px; }
  .el { width: 30px; height: 40px; font-size: 21px; }
}
@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ============================================================
   "Download as an app" strip
   ============================================================ */

.appbar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 0;
  padding: 7px 12px;
  border: 1px solid rgba(156, 204, 63, .22);
  border-radius: 8px;
  background: rgba(156, 204, 63, .06);
  color: var(--green);
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .13em;
  text-transform: uppercase;
  text-decoration: none;
  transition: background .15s, border-color .15s;
}
.appbar:hover { background: rgba(156, 204, 63, .13); border-color: rgba(156, 204, 63, .45); }
.appbar .tag {
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--purple);
  color: #0a0a0a;
  font-size: 8.5px;
  letter-spacing: .12em;
}
.appbar .arr { font-size: 13px; line-height: 1; }

/* ============================================================
   Score table
   ============================================================ */

.tabs {
  display: flex;
  gap: 3px;
  margin: 0 auto 20px;
  padding: 3px;
  width: fit-content;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: var(--bg-soft);
}
.tab {
  border: none;
  background: transparent;
  color: var(--faint);
  font-family: var(--font-display);
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 7px 18px;
  border-radius: 6px;
  transition: background .15s, color .15s;
}
.tab.is-on { background: var(--panel); color: var(--text); }

.points {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}
.points b {
  font-family: var(--font-display);
  font-size: 46px;
  font-weight: 700;
  line-height: 1;
  color: var(--correct);
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px rgba(156, 204, 63, .3);
}
.points span {
  font-size: 10px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}

.score-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}
.score-table th {
  padding: 0 0 8px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--faint);
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
}
.score-table th:first-child,
.score-table td:first-child { text-align: left; }
.score-table th:nth-child(2),
.score-table td:nth-child(2) { text-align: left; }
.score-table td {
  padding: 9px 0;
  text-align: right;
  border-bottom: 1px solid var(--line-soft);
  color: #c3beb6;
}
.score-table tr:last-child td { border-bottom: 0; }
.score-table .el-no { color: var(--faint); font-size: 11.5px; }
.score-table .wd {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: .08em;
  color: var(--text);
}
.score-table .pts { color: var(--correct); font-weight: 700; }
.score-table .lost .wd,
.score-table .lost .pts { color: var(--faint); }
.score-scroll { max-height: 290px; overflow-y: auto; margin-top: 14px; }

.empty {
  padding: 30px 10px;
  text-align: center;
  font-size: 13px;
  line-height: 1.6;
  color: var(--faint);
}

/* points awarded on the result card */
.earned {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  margin: 0 0 16px;
  padding: 7px 15px;
  border: 1px solid rgba(156, 204, 63, .3);
  border-radius: 99px;
  background: rgba(156, 204, 63, .08);
}
.earned b {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--correct);
  font-variant-numeric: tabular-nums;
}
.earned span {
  font-size: 9.5px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ============================================================
   Install / download page
   ============================================================ */

.page {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 620px;
  margin: 0 auto;
  padding: 34px 20px 60px;
  overflow-y: auto;
  max-height: 100%;
}
.page-head { text-align: center; margin-bottom: 34px; }
.page-head .tagline { margin-top: 14px; }

.back {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 26px;
  color: var(--faint);
  font-size: 12px;
  letter-spacing: .1em;
  text-transform: uppercase;
  text-decoration: none;
  font-family: var(--font-display);
  font-weight: 600;
}
.back:hover { color: var(--text); }

.beta-note {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  margin: 0 0 30px;
  padding: 14px 16px;
  border: 1px solid rgba(176, 126, 204, .3);
  border-left-width: 3px;
  border-radius: 8px;
  background: rgba(176, 126, 204, .07);
  font-size: 13px;
  line-height: 1.6;
  color: #c3beb6;
}
.beta-note b { color: var(--purple); }

.plat {
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--panel);
  overflow: hidden;
}
.plat-head {
  display: flex;
  align-items: center;
  gap: 13px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.plat-head svg { flex: 0 0 auto; }
.plat-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 17px;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
}
.plat-head p { margin: 3px 0 0; font-size: 11.5px; color: var(--faint); }
.plat-body { padding: 18px 20px 20px; }

.steps { margin: 0; padding: 0; list-style: none; counter-reset: s; display: grid; gap: 13px; }
/* The marker is absolutely positioned rather than a grid cell: these list
   items contain inline <b> and <kbd>, and a grid container would promote
   each of them to its own cell and break the sentence apart. */
.steps li {
  counter-increment: s;
  position: relative;
  padding-left: 36px;
  min-height: 24px;
  font-size: 13.5px;
  line-height: 1.55;
  color: #c3beb6;
}
.steps li::before {
  content: counter(s);
  position: absolute;
  left: 0;
  top: 0;
  display: grid;
  place-items: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: var(--graphite);
  color: var(--text);
  font-size: 11px;
  font-weight: 700;
  font-family: var(--font-body);
}
.steps b { color: var(--text); }
.steps kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #222120;
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--text);
}

.install-btn {
  width: 100%;
  margin-bottom: 16px;
  padding: 15px;
  border: none;
  border-radius: 9px;
  background: var(--green);
  color: #0a0a0a;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  box-shadow: 0 0 34px -12px var(--green);
  transition: transform .12s, filter .15s;
}
.install-btn:hover { transform: translateY(-1px); filter: brightness(1.08); }
.install-btn[disabled] {
  background: var(--graphite);
  color: var(--faint);
  box-shadow: none;
  cursor: default;
  transform: none;
}

.page-foot {
  margin-top: 34px;
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
  color: var(--faint);
}
.page-foot a { color: var(--muted); }

:where(a, button, [role="switch"], .tab, .seg-btn):focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ============================================================
   Full-width Submit — the second, more obvious Enter
   ============================================================ */

.submit-btn {
  flex: 0 0 auto;
  width: 100%;
  margin: 0 0 12px;
  padding: 15px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: #232220;
  color: var(--faint);
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  transition: background .18s, color .18s, border-color .18s, box-shadow .18s, transform .06s;
}
.submit-btn:active { transform: scale(.99); }

/* lights up only once the row is actually submittable */
.submit-btn.ready {
  border-color: var(--correct);
  background: var(--correct);
  color: #0a0a0a;
  box-shadow: 0 0 30px -10px var(--correct);
}
.submit-btn.ready:hover { filter: brightness(1.08); }

@media (max-width: 380px) {
  .submit-btn { padding: 13px; font-size: 14px; margin-bottom: 10px; }
  .keyboard { padding-bottom: 8px; }
}

/* ============================================================
   Reveal card — two sides, one fixed height
   ============================================================ */

.flip { position: relative; }
.face { width: 100%; }
.face--front { animation: faceIn .28s ease; }
.face--back {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  text-align: left;
  animation: faceIn .28s ease;
}
@keyframes faceIn { from { opacity: 0; transform: translateY(6px); } }

/* the element card is now a button */
button.card-el {
  display: block;
  width: 190px;
  margin: 4px auto 18px;
  padding: 22px 12px 26px;
  font: inherit;
  text-align: center;
  cursor: pointer;
  transition: transform .18s, box-shadow .18s;
}
button.card-el:hover { transform: translateY(-2px); box-shadow: 0 0 56px -12px var(--el); }
button.card-el:active { transform: translateY(0) scale(.985); }
.card-el .num,
.card-el .sym,
.card-el .name,
.card-el .mass { display: block; }
.card-el .hint {
  display: block;
  margin-top: 12px;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--el);
  opacity: .55;
}
button.card-el:hover .hint { opacity: .9; }

/* back of the card */
.origin-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding-bottom: 14px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--line-soft);
}
.origin-sym {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 54px; height: 66px;
  border: 2px solid var(--el);
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--el);
  box-shadow: 0 0 24px -10px var(--el);
}
.origin-head h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 600;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.origin-head p {
  margin: 2px 0 0;
  font-size: 9.5px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--faint);
}
.origin-body p {
  margin: 0;
  font-size: 14px;
  line-height: 1.72;
  color: #c3beb6;
}
.origin-body i { color: var(--purple); font-style: italic; }

.more-btn {
  width: 100%;
  margin-top: 18px;
  padding: 13px;
  border: 1.5px solid var(--line);
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: .14em;
  text-transform: uppercase;
  transition: background .15s, color .15s, border-color .15s;
}
.more-btn:hover {
  background: var(--panel);
  color: var(--text);
  border-color: var(--graphite);
}

/* scrollbar inside the origin panel, so long entries stay contained */
.face--back::-webkit-scrollbar { width: 5px; }
.face--back::-webkit-scrollbar-thumb { background: var(--graphite); border-radius: 3px; }

/* ============================================================
   Already installed? Then stop advertising the install.
   ============================================================ */

@media (display-mode: standalone), (display-mode: fullscreen), (display-mode: minimal-ui) {
  .appbar { display: none; }
}
body.installed .appbar { display: none; }
