/* THIS WEEK'S TOP 10: an arcade high-score screen laid over the game
   (public/js/scoreboard.js). Uses the site tokens, with fallbacks. */

.sb {
  --sb-ink: var(--ink, #070b1f);
  --sb-deep: var(--navy-deep, #0a1230);
  --sb-white: var(--white, #fffaf0);
  --sb-yellow: var(--yellow, #ffde17);
  --sb-pink: var(--pink, #ff5fb8);
  --sb-blue: var(--trans-blue, #5bcefa);
  --sb-gold: var(--gold, #ffcc33);
  --sb-rainbow: var(--rainbow, linear-gradient(90deg, #e8262c, #f7941d, #ffde17, #12a150, #2e6be6, #93268f));

  position: absolute;
  inset: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(10px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) max(10px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  background:
    repeating-linear-gradient(180deg, rgba(0, 0, 0, 0.22) 0 2px, transparent 2px 4px),
    rgba(7, 11, 31, 0.74);
  color: var(--sb-white);
  font-family: var(--font-pixel, "Press Start 2P", ui-monospace, monospace);
  line-height: 1.5;
  text-align: center;
  pointer-events: auto;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  animation: sb-in 0.18s steps(3);
}
.sb[hidden] { display: none; }
.sb.is-out { animation: sb-out 0.16s steps(3) forwards; }
@keyframes sb-in { from { opacity: 0; } }
@keyframes sb-out { to { opacity: 0; } }

.sb__panel {
  position: relative;
  width: min(352px, 100%);
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 12px 14px;
  background: var(--sb-deep);
  border: 3px solid var(--sb-ink);
  box-shadow: 0 0 0 2px var(--sb-white), 6px 6px 0 2px var(--sb-pink);
  outline: none;
  animation: sb-pop 0.22s steps(4);
}
.sb__panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 6px;
  background: var(--sb-rainbow);
}
@keyframes sb-pop { from { transform: scale(0.86); } }

:where(.sb) p { margin: 0; }
.sb__sr {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden; clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Header */
.sb__kicker {
  display: table;
  margin: 0 auto 6px;
  font-size: 8px;
  background: var(--sb-rainbow);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(1px 1px 0 var(--sb-ink));
}
.sb__title {
  margin: 0;
  font-family: inherit;
  font-weight: 400;
  font-size: 14px;
  line-height: 1.3;
  color: var(--sb-yellow);
  text-shadow: 2px 2px 0 var(--sb-ink), -1px -1px 0 var(--sb-ink), 1px -1px 0 var(--sb-ink), -1px 1px 0 var(--sb-ink);
}
.sb__when { margin-top: 6px; font-size: 7px; color: var(--sb-blue); letter-spacing: 0.02em; }

.sb__body { margin-top: 12px; }

/* Loading / napping */
.sb__status { padding: 18px 0 8px; font-size: 10px; color: var(--sb-yellow); }
.sb__zzz { padding-bottom: 14px; font-size: 14px; color: var(--sb-blue); animation: sb-float 1.2s steps(3) infinite; }
.sb__blink { animation: sb-blink 1s steps(2) infinite; }
@keyframes sb-blink { 50% { opacity: 0; } }
@keyframes sb-float { 50% { transform: translateY(-4px); } }

/* Little pixel icons */
.sb__flag, .sb__stamp {
  display: inline-block;
  vertical-align: -1px;
  background: center / contain no-repeat;
  filter: drop-shadow(1px 1px 0 var(--sb-ink));
}
.sb__flag {
  width: 12px;
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23fffaf0' d='M0 0h1v8H0z'/%3E%3Cpath fill='%23e8262c' d='M1 0h9v1H1z'/%3E%3Cpath fill='%23f7941d' d='M1 1h9v1H1z'/%3E%3Cpath fill='%23ffde17' d='M1 2h9v1H1z'/%3E%3Cpath fill='%2312a150' d='M1 3h9v1H1z'/%3E%3Cpath fill='%232e6be6' d='M1 4h9v1H1z'/%3E%3Cpath fill='%2393268f' d='M1 5h9v1H1z'/%3E%3C/svg%3E");
}
.sb__stamp {
  width: 11px;
  height: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 11 10' shape-rendering='crispEdges'%3E%3Cpath fill='%2312a150' d='M9 0h2v2H9zM8 2h2v2H8zM7 4h2v2H7zM6 6h2v2H6zM0 4h2v2H0zM1 6h2v2H1zM2 7h4v2H2zM3 9h2v1H3z'/%3E%3C/svg%3E");
}

/* Initials */
.sb__lead { font-size: 8px; color: var(--sb-blue); }
.sb__lead.is-win { color: var(--sb-gold); }
.sb__lead .sb__flag { margin-right: 6px; }
.sb__big { margin-top: 10px; font-size: 12px; color: var(--sb-pink); text-shadow: 2px 2px 0 var(--sb-ink); }
.sb__rankline { margin-top: 6px; font-size: 8px; color: var(--sb-yellow); }
.sb__stats {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  align-items: center;
  gap: 4px 12px;
  margin-top: 10px;
  font-size: 9px;
}
.sb__stats b { font-weight: 400; color: var(--sb-yellow); }
.sb__stamps, .sb__flagged { display: inline-flex; align-items: center; gap: 4px; }
.sb__flagged { color: var(--sb-gold); }
.sb__label { margin-top: 14px; font-size: 8px; color: var(--sb-white); opacity: 0.85; }

.sb__slots { display: flex; justify-content: center; gap: 12px; margin-top: 8px; }
.sb__slot { display: grid; justify-items: center; gap: 6px; }
.sb__arrow {
  appearance: none;
  display: grid;
  place-items: center;
  width: 58px;
  height: 44px;
  padding: 0;
  color: var(--sb-ink);
  background: var(--sb-white);
  border: 3px solid var(--sb-ink);
  box-shadow: 3px 3px 0 #000;
  cursor: pointer;
  touch-action: none;
  transition: transform 60ms steps(2), box-shadow 60ms steps(2);
}
.sb__arrow svg { width: 21px; height: 12px; fill: currentColor; shape-rendering: crispEdges; }
.sb__arrow:active { transform: translate(3px, 3px); box-shadow: 0 0 0 #000; }
.sb__slot.is-active .sb__arrow { background: var(--sb-yellow); }
.sb__char {
  appearance: none;
  -webkit-appearance: none;
  display: block;
  width: 58px;
  height: 62px;
  margin: 0;
  padding: 4px 0 0;
  font: inherit;
  font-size: 32px;
  line-height: 1;
  text-align: center;
  text-transform: uppercase;
  color: var(--sb-yellow);
  background: var(--sb-ink);
  border: 3px solid #3a4478;
  border-radius: 0;
  caret-color: transparent;
  outline: none;
  cursor: pointer;
  /* iOS Safari won't type into an input with user-select: none. */
  user-select: text;
  -webkit-user-select: text;
}
.sb__char::selection { background: transparent; }
.sb__slot.is-active .sb__char {
  border-color: var(--sb-pink);
  box-shadow: inset 0 -6px 0 var(--sb-pink);
  animation: sb-cursor 0.9s steps(2) infinite;
}
.sb__char:focus-visible { outline: 3px solid var(--sb-yellow); outline-offset: 2px; }
@keyframes sb-cursor { 50% { box-shadow: inset 0 0 0 var(--sb-pink); } }

.sb__msg { min-height: 2.6em; padding-top: 8px; font-size: 8px; line-height: 1.5; color: var(--sb-pink); }
.sb__msg.is-shake { animation: sb-shake 0.4s steps(4); }
@keyframes sb-shake { 25%, 75% { transform: translateX(-4px); } 50% { transform: translateX(4px); } }

.sb__actions { display: flex; justify-content: center; gap: 12px; margin-top: 6px; }
.sb .sb__btn { min-height: 48px; min-width: 112px; padding: 10px 14px; font-size: 12px; }
.sb .sb__btn:disabled { opacity: 0.6; cursor: wait; }
.sb.is-saving .sb__save { animation: sb-blink 0.6s steps(2) infinite; }

/* The board */
.sb__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
  font-size: 10px;
  line-height: 1;
  text-align: left;
}
.sb__row {
  display: grid;
  grid-template-columns: 2.8em 4em 2em 3.4em 1fr;
  align-items: center;
  min-height: 22px;
  padding: 0 6px;
  background: rgba(255, 255, 255, 0.04);
}
.sb__row:nth-child(odd) { background: rgba(255, 255, 255, 0.08); }
.sb__rank { color: var(--sb-blue); }
.sb__name { letter-spacing: 0.06em; }
.sb__mark { display: flex; padding-left: 1px; }
.sb__row .sb__stamps { gap: 3px; font-size: 8px; color: #b9c2e6; }
.sb__row .sb__stamp { width: 9px; height: 8px; }
.sb__pts { text-align: right; }
.sb__row.is-1 { color: var(--sb-gold); }
.sb__row.is-1 .sb__rank { color: var(--sb-gold); }
.sb__row.is-2 { color: #e4e9ff; }
.sb__row.is-3 { color: #ffb36b; }
.sb__row.is-empty { color: #4c5684; }
.sb__row.is-empty .sb__rank { color: #4c5684; }
.sb__row.is-mine { background: rgba(255, 95, 184, 0.28); box-shadow: inset 4px 0 0 var(--sb-pink); }
.sb__row.is-fresh { background: var(--sb-pink); color: var(--sb-ink); box-shadow: none; animation: sb-row 0.9s steps(2) infinite; }
.sb__row.is-fresh .sb__rank, .sb__row.is-fresh .sb__stamps { color: var(--sb-ink); }
@keyframes sb-row { 50% { background: var(--sb-yellow); } }

.sb__you { margin-top: 12px; font-size: 9px; line-height: 1.6; text-wrap: balance; }
.sb__you b { font-weight: 400; color: var(--sb-yellow); }
.sb__you.is-saved { color: var(--sb-pink); }
.sb__hint { margin-top: 4px; font-size: 7px; color: var(--sb-blue); }
.sb__legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 4px 12px;
  margin-top: 12px;
  font-size: 6px;
  color: #8a93b0;
}
.sb__legend span { display: inline-flex; align-items: center; gap: 4px; }
.sb__legend .sb__stamp { width: 9px; height: 8px; }
.sb__legend .sb__flag { width: 10px; height: 8px; }
.sb[data-view="board"] .sb__actions { margin-top: 12px; }

@media (min-width: 760px) {
  .sb__panel { width: 400px; padding: 22px 18px 18px; }
  .sb__title { font-size: 17px; }
  .sb__kicker { font-size: 9px; }
  .sb__when { font-size: 8px; }
  .sb__list { font-size: 12px; }
  .sb__row { min-height: 26px; }
  .sb__legend { font-size: 7px; }
}

/* Very narrow phones */
@media (max-width: 340px) {
  .sb__panel { padding-inline: 8px; }
  .sb__title { font-size: 12px; }
  .sb__list { font-size: 9px; }
  .sb__slots { gap: 8px; }
}

/* Short screens (phones on their side): the game is taller than the screen
   here, so hug the top and tighten everything to fit. */
@media (max-height: 560px) {
  .sb { align-items: flex-start; }
  .sb__panel { max-height: calc(100vh - 20px); max-height: calc(100svh - 20px); padding: 12px 12px 10px; }
  .sb__body { margin-top: 8px; }
  .sb__kicker, .sb__lead, .sb__legend { display: none; }
  .sb__title { font-size: 13px; }
  .sb__when { margin-top: 4px; }
  .sb__big { margin-top: 0; font-size: 10px; }
  .sb__rankline { margin-top: 4px; }
  .sb__stats { margin-top: 6px; }
  .sb__label { margin-top: 6px; }
  .sb__slots { margin-top: 4px; }
  .sb__slot { gap: 4px; }
  .sb__arrow { height: 36px; }
  .sb__char { height: 46px; font-size: 26px; }
  .sb__msg { min-height: 1.6em; padding-top: 4px; }
  .sb .sb__btn { min-height: 42px; }
  .sb__list { font-size: 10px; }
  .sb__row { min-height: 17px; }
  .sb__you { margin-top: 8px; }
  .sb[data-view="board"] .sb__actions { margin-top: 8px; }
}

@media (prefers-reduced-motion: reduce) {
  .sb, .sb.is-out, .sb__panel, .sb__zzz, .sb__blink, .sb__msg.is-shake,
  .sb__slot.is-active .sb__char, .sb.is-saving .sb__save, .sb__row.is-fresh { animation: none; }
  .sb__arrow { transition: none; }
}
