/* SICk Arcade — site styles.
   Tokens come from docs/design-spec.md ("Visual style"). Change a color or
   size there first, then here. */

:root {
  --page: #E2E2E2;
  --panel: #3C3C3C;
  --card: #4A4A4A;
  --card-text: #FFFFFF;
  --card-stats: #C9C9C9;
  --brass-dark: #D4AB55;   /* brass on dark surfaces */
  --brass-light: #B8913F;  /* brass on white or light gray */
  --wordmark-brass: #8A6A22;
  --star-empty-dark: #6E6E6E;
  --star-empty-light: #C4C4C4;
  --ink: #171A21;
  --ink-soft: #3F444D;
  --muted: #555B66;
  --border: #CACACA;
  --input-border: #BDBDBD;
  --control: #F2F2F2;
  --tag: #CFCFCF;
  --white: #FFFFFF;
  --skeleton-a: #575757;
  --skeleton-b: #5E5E5E;

  --font: 'Libre Franklin', 'Helvetica Neue', Arial, sans-serif;
  --max: 1280px;
  --gutter: 32px;
  --tap: 44px; /* every button and link is at least this tall */
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--page);
  color: var(--ink);
  font-family: var(--font);
  font-size: 16px;
  line-height: 24px;
}

a { color: var(--ink); }
a:hover { color: var(--panel); }

button, input { font: inherit; color: inherit; }
button { cursor: pointer; }

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

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: var(--max);
  margin: 0 auto;
  padding-left: var(--gutter);
  padding-right: var(--gutter);
}

/* ---------- Header ---------- */

.site-header { border-bottom: 1px solid var(--border); background: var(--page); }

.site-header .wrap {
  min-height: 72px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0 24px;
}

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: var(--tap);
  text-decoration: none;
  color: var(--ink);
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.wordmark:hover { color: var(--ink); }
.wordmark span { color: var(--wordmark-brass); margin-left: 0.25em; }

.search { flex: 0 1 360px; position: relative; margin: 0; }

.search input {
  width: 100%;
  height: var(--tap);
  padding: 0 16px 0 42px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--white);
  font-size: 15px;
  color: var(--ink);
  -webkit-appearance: none;
  appearance: none;
}
.search input::placeholder { color: var(--muted); opacity: 1; }

.search svg {
  position: absolute;
  left: 14px;
  top: 13px;
  pointer-events: none;
}

.search-toggle {
  display: none;
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 6px;
  background: transparent;
  align-items: center;
  justify-content: center;
}

/* ---------- Page body ---------- */

main.wrap {
  flex: 1 0 auto;
  padding-top: 32px;
  padding-bottom: 48px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
main.game-main { padding-top: 24px; }

.site-footer { border-top: 1px solid var(--border); }
.site-footer .wrap {
  padding-top: 20px;
  padding-bottom: 24px;
  font-size: 13px;
  line-height: 18px;
  color: var(--muted);
}

/* ---------- Library controls ---------- */

.controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.control-group { display: flex; align-items: center; gap: 10px; min-width: 0; }
.control-label { font-size: 14px; color: var(--muted); white-space: nowrap; }

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

.chip {
  flex-shrink: 0;
  height: var(--tap);
  padding: 0 16px;
  border-radius: 22px;
  border: 1px solid var(--input-border);
  background: var(--control);
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}
.chip[aria-pressed="true"] {
  border-color: var(--panel);
  background: var(--panel);
  color: var(--white);
  font-weight: 600;
}

.sort {
  display: flex;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  overflow: hidden;
  background: var(--control);
}
.sort button {
  height: var(--tap);
  padding: 0 14px;
  border: 0;
  border-left: 1px solid var(--input-border);
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  white-space: nowrap;
}
.sort button:first-child { border-left: 0; }
.sort button[aria-pressed="true"] {
  background: var(--panel);
  color: var(--white);
  font-weight: 600;
}
.sort button:focus-visible, .chip:focus-visible { outline-offset: -4px; outline-color: var(--brass-dark); }
.chip:not([aria-pressed="true"]):focus-visible,
.sort button:not([aria-pressed="true"]):focus-visible { outline-color: var(--ink); }

/* ---------- Dark panel and grid ---------- */

.panel { background: var(--panel); border-radius: 8px; padding: 24px; }

.panel-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 16px;
}
.panel-head h1 {
  margin: 0;
  font-size: 20px;
  line-height: 28px;
  font-weight: 600;
  color: var(--white);
  overflow-wrap: anywhere;
}
.panel-head .count { font-size: 14px; color: var(--card-stats); white-space: nowrap; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}
@media (min-width: 1280px) {
  .grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .grid.grid-more { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

.empty {
  margin: 0;
  padding: 32px 8px;
  color: var(--white);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

/* ---------- Game card ---------- */

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--card);
  border-radius: 6px;
  overflow: hidden;
  text-decoration: none;
  color: var(--card-text);
  transition: transform .15s ease, box-shadow .15s ease;
}
.card:hover,
.card:focus-visible {
  color: var(--card-text);
  transform: translateY(-3px);
  box-shadow: 0 0 0 2px var(--brass-dark);
  outline: none;
}

.card-thumb {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  height: auto;
  object-fit: cover;
  background: var(--skeleton-a);
}

.card-body { padding: 12px 14px 14px; display: flex; flex-direction: column; gap: 6px; flex: 1 0 auto; }

.card-name { font-size: 16px; line-height: 22px; font-weight: 600; overflow-wrap: anywhere; }

.card-stats {
  margin-top: auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: center;
  gap: 0 8px;
  font-size: 13px;
  line-height: 18px;
  color: var(--card-stats);
}
.card-stats > span { white-space: nowrap; }

.stars { letter-spacing: 1px; }
.stars .on { color: var(--brass-dark); }
.stars .off { color: var(--star-empty-dark); }
.on-light .stars .on, .stars.on-light .on { color: var(--brass-light); }
.on-light .stars .off, .stars.on-light .off { color: var(--star-empty-light); }

.card.skeleton { pointer-events: none; }
.card.skeleton .card-thumb { background: var(--skeleton-a); }
.card.skeleton .bar-a { height: 14px; width: 70%; background: var(--skeleton-b); border-radius: 2px; margin: 4px 0; }
.card.skeleton .bar-b { height: 10px; width: 100%; background: var(--skeleton-a); border-radius: 2px; margin: 4px 0; }

/* ---------- Buttons ---------- */

.btn-brass {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  height: var(--tap);
  padding: 0 16px;
  border: 0;
  border-radius: 6px;
  background: var(--brass-dark);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
}
.btn-brass:focus-visible { outline-color: var(--white); }

.btn-plain {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: var(--tap);
  padding: 0 16px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--control);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
}

/* ---------- Game page ---------- */

.back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tap);
  font-size: 15px;
  font-weight: 600;
  text-decoration: none;
  color: var(--ink);
}

.title-block { display: flex; flex-direction: column; gap: 6px; }
.title-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.title-row h1 {
  margin: 0;
  font-size: 34px;
  line-height: 40px;
  font-weight: 700;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
}
.tag {
  font-size: 13px;
  line-height: 18px;
  font-weight: 600;
  padding: 4px 10px;
  border-radius: 12px;
  background: var(--tag);
  color: var(--ink);
}
.how-to { margin: 0; font-size: 16px; color: var(--ink-soft); }

.game-panel { padding: 16px; display: flex; flex-direction: column; gap: 12px; }

.game-stage {
  position: relative;
  width: 100%;
  max-width: calc(640px * 16 / 9); /* keeps the area a true 16:9, at most 640px tall */
  margin: 0 auto;
  aspect-ratio: 16 / 9;
  background: #2B2B2B;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}
.game-stage iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #2B2B2B;
}
.game-error {
  position: absolute;
  inset: 0;
  padding: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  color: var(--white);
  background: #2B2B2B;
}
.game-error p { margin: 0; max-width: 420px; }

.game-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.game-hint { font-size: 13px; color: var(--card-stats); }

/* Fullscreen: the stage fills the screen and the game keeps its 16:9 shape. */
.game-stage:fullscreen,
.game-stage.is-max {
  max-width: none;
  aspect-ratio: auto;
  border-radius: 0;
  background: #000;
}
.game-stage.is-max { position: fixed; inset: 0; z-index: 1000; width: 100vw; height: 100vh; height: 100dvh; }
.game-stage:fullscreen iframe,
.game-stage.is-max iframe {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  flex: none;
}
.exit-max {
  display: none;
  position: absolute;
  top: 8px;
  right: 8px;
  z-index: 2;
}
.game-stage:fullscreen .exit-max,
.game-stage.is-max .exit-max { display: inline-flex; }

.stats {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 20px 32px;
}
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-label { font-size: 13px; line-height: 18px; color: var(--muted); }
.stat-value { font-size: 24px; line-height: 30px; font-weight: 700; white-space: nowrap; }
.stat-value .stars { font-size: 20px; }
.stat-value.is-text { font-size: 16px; font-weight: 400; color: var(--muted); }

.rate { margin-left: auto; display: flex; flex-direction: column; gap: 4px; }
.rate-label { font-size: 14px; font-weight: 600; }
.rate-stars { display: flex; align-items: center; gap: 2px; margin-left: -8px; }
.rate-stars button {
  width: var(--tap);
  height: var(--tap);
  border: 0;
  border-radius: 6px;
  background: transparent;
  padding: 0;
  font-size: 30px;
  line-height: 44px;
  color: var(--star-empty-light);
}
.rate-stars button.on { color: var(--brass-light); }
.rate-stars button:disabled { cursor: default; }
.rate-note { margin: 0; font-size: 13px; line-height: 18px; color: var(--muted); min-height: 18px; }

.board {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.board-head { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 4px 16px; }
.board-head h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.board-rule { font-size: 13px; line-height: 18px; color: var(--muted); }
.board-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-rows: repeat(5, auto);
  grid-auto-flow: column;
  grid-auto-columns: minmax(0, 1fr);
  gap: 0 32px;
}
.board-list:empty { display: none; }
.board-list li {
  display: flex;
  align-items: baseline;
  gap: 12px;
  padding: 8px 8px;
  border-bottom: 1px solid #E6E6E6;
  font-size: 16px;
  line-height: 24px;
}
.board-list li.you { background: var(--control); box-shadow: inset 3px 0 0 var(--brass-light); }
.board-rank { flex: none; width: 22px; text-align: right; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.board-name { flex: 1 1 auto; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.board-score { flex: none; font-variant-numeric: tabular-nums; white-space: nowrap; }
.board-note { margin: 0; font-size: 14px; line-height: 20px; color: var(--muted); }

/* Name entry for a score that makes the board. It sits inside the game area
   so it also shows when the game is fullscreen. */
.score-entry {
  position: fixed;
  inset: 0;
  z-index: 2000;
  padding: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(23, 26, 33, 0.72);
  overflow: auto;
}
.score-entry-card {
  width: 100%;
  max-width: 380px;
  margin: auto;
  background: var(--white);
  color: var(--ink);
  border-radius: 8px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.score-entry-card h2 { margin: 0; font-size: 24px; line-height: 30px; font-weight: 700; }
.score-entry-card p { margin: 0; color: var(--ink-soft); }
.score-entry-card label { margin-top: 8px; font-size: 14px; line-height: 20px; font-weight: 600; }
.score-entry-card input {
  width: 100%;
  height: var(--tap);
  padding: 0 14px;
  border: 1px solid var(--input-border);
  border-radius: 6px;
  background: var(--white);
  font-size: 18px;
  font-weight: 600;
  color: var(--ink);
}
.score-entry-actions { display: flex; gap: 8px; margin-top: 8px; }
.score-entry-actions .btn-brass { flex: 1 1 auto; justify-content: center; }
.score-entry-actions .btn-brass:focus-visible { outline-color: var(--ink); }
.score-entry-actions .btn-brass:disabled { opacity: 0.6; cursor: default; }
.score-entry-card .score-entry-note { font-size: 13px; line-height: 18px; color: var(--muted); min-height: 18px; }

.about { display: flex; flex-direction: column; gap: 8px; }
.about h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.about p { margin: 0; max-width: 72ch; color: var(--ink-soft); }

.more { display: flex; flex-direction: column; gap: 12px; }
.more h2 { margin: 0; font-size: 20px; line-height: 28px; font-weight: 700; }
.more .panel { padding: 20px; }

.notfound { display: flex; flex-direction: column; gap: 16px; align-items: flex-start; }
.notfound h1 { margin: 0; font-size: 34px; line-height: 40px; font-weight: 700; }
.notfound p { margin: 0; color: var(--ink-soft); }

/* ---------- Phone (under 640px) ---------- */

@media (max-width: 639.98px) {
  :root { --gutter: 16px; }

  body { font-size: 15px; line-height: 22px; }

  .site-header .wrap { min-height: 60px; padding-right: 8px; }
  .wordmark { font-size: 22px; }

  /* Search collapses to an icon; tapping it opens a full-width box. */
  .search-toggle { display: inline-flex; }
  .search { display: none; flex: 1 0 100%; order: 3; margin: 0 8px 12px 0; }
  .site-header.search-open .search { display: block; }

  main.wrap { padding-top: 16px; padding-bottom: 32px; gap: 16px; }

  /* Sort becomes a full-width 3-way toggle, above the chips. */
  .controls { flex-direction: column; flex-wrap: nowrap; align-items: stretch; gap: 12px; }
  .control-label { display: none; }
  .control-group.sort-group { order: 1; }
  .control-group.chip-group { order: 2; margin-right: calc(var(--gutter) * -1); }
  .sort { width: 100%; }
  .sort button { flex: 1 1 0; padding: 0 4px; }

  /* Category chips scroll sideways. */
  .chips {
    flex: 1 1 auto;
    min-width: 0;
    flex-wrap: nowrap;
    overflow-x: auto;
    padding-right: var(--gutter);
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }
  .chips::-webkit-scrollbar { display: none; }

  .panel { padding: 12px; }
  .panel-head { margin: 2px 2px 12px; }
  .panel-head h1 { font-size: 17px; line-height: 24px; }
  .panel-head .count { font-size: 13px; }

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

  .card-body { padding: 10px 10px 12px; gap: 4px; }
  .card-name { font-size: 14px; line-height: 20px; }
  .card-stats { flex-direction: column; align-items: flex-start; font-size: 12px; line-height: 16px; }
  .stars { letter-spacing: 0; }

  .title-row h1 { font-size: 28px; line-height: 34px; }
  .game-panel { padding: 8px; gap: 8px; }
  .game-bar { padding: 0 4px 4px; }
  .stats { padding: 16px; gap: 16px 24px; }
  .board { padding: 16px; }
  .board-list { display: block; }
  .score-entry-card { padding: 20px; }
  .score-entry-card h2 { font-size: 20px; line-height: 26px; }
  .rate { margin-left: 0; flex-basis: 100%; }
  .more .panel { padding: 12px; }
  .notfound h1 { font-size: 28px; line-height: 34px; }
}

@media (prefers-reduced-motion: reduce) {
  .card { transition: none; }
}
