/* Layout and styling for every screen. Colors, typefaces and sizes come
 * from settings.css. */

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--color-page);
  color-scheme: dark;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--color-page);
  color: var(--color-text);
  font-family: var(--font-body);
  font-size: 16px;
  line-height: 1.3;
  -webkit-font-smoothing: antialiased;
}

h1, h2, p, dl, dd { margin: 0; }

button {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: inherit;
  font: inherit;
  text-align: inherit;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  -webkit-appearance: none;
  appearance: none;
}

:focus { outline: none; }
:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 3px; }
h1:focus-visible, p:focus-visible { outline: none; }

[hidden] { display: none !important; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}

/* ---------- The page ---------- */

.app {
  width: 100%;
  max-width: var(--page-width);
  margin: 0 auto;
}

.screen {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(6px, env(safe-area-inset-top)) max(var(--page-side), env(safe-area-inset-right))
    max(20px, env(safe-area-inset-bottom)) max(var(--page-side), env(safe-area-inset-left));
}

/* ---------- Tiles ---------- */

.tiles {
  display: flex;
  gap: 3px;
  min-width: 0;
}

.tile {
  flex: 0 1 var(--tile-width);
  min-width: 0;
  height: var(--tile-height);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-tile);
  background: linear-gradient(var(--color-tile) 0 48%, var(--color-tile-split) 48% 52%, var(--color-tile) 52% 100%);
  font: 700 var(--tile-text)/1 var(--font-display);
  color: var(--color-text);
}

.tile-gap { flex-basis: 10px; background: none; }
.tiles-accent .tile { color: var(--color-accent); }
.tiles-right .tile { color: var(--color-right); }
.tiles-wrong .tile { color: var(--color-wrong); }

/* The big lettering tiles: the wordmark and STREAK OVER. */
.flap-row { display: flex; justify-content: center; gap: 6px; }
.flap-row-left { justify-content: flex-start; gap: 5px; }

.flap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 60px;
  border-radius: 4px;
  background: linear-gradient(var(--color-tile) 0 48.5%, var(--color-tile-split) 48.5% 51.5%, var(--color-tile) 51.5% 100%);
  font: 700 46px/1 var(--font-display);
  color: var(--color-text);
}

.flap-small { width: 34px; height: 42px; font-size: 30px; color: var(--color-accent); }
.flap-title { width: 44px; height: 58px; font-size: 42px; }
.flap-number { width: 72px; height: 94px; font-size: 72px; color: var(--color-accent); }

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

.button {
  display: block;
  width: 100%;
  border-radius: var(--radius-card);
  font: 700 22px/1 var(--font-display);
  letter-spacing: 1.5px;
  text-align: center;
  padding: 17px 0;
}

.button-primary { background: var(--color-accent); color: var(--color-page); }
.button-primary:active { filter: brightness(0.9); }

/* ---------- Top bar on play screens ---------- */

.topbar {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  font: 600 15px/16px var(--font-display);
  letter-spacing: 2px;
  color: var(--color-muted);
}

.topbar-count { justify-self: end; color: var(--color-accent); }

.home-link {
  justify-self: start;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 12px 14px 0;
  font: inherit;
  letter-spacing: inherit;
  color: var(--color-muted);
}

.home-link span, .home-link-plain { text-decoration: underline; }
.home-link-plain { justify-self: end; padding: 14px 0 14px 12px; }
@media (hover: hover) { .home-link:hover { color: var(--color-text); } }

.topbar-over { grid-template-columns: 1fr auto; }

/* ---------- Home ---------- */

.home { padding-left: 0; padding-right: 0; padding-bottom: 0; padding-top: max(26px, env(safe-area-inset-top)); }

.wordmark { display: flex; flex-direction: column; gap: 6px; }

.subhead {
  width: 276px;
  margin: 16px auto 0;
  font-size: 18px;
  line-height: 1.35;
  text-align: center;
  text-wrap: balance;
}

.modes { margin: 22px var(--page-side) 0; border-top: 2px solid var(--color-accent); }

.mode {
  display: grid;
  grid-template-columns: 44px 1fr 24px;
  align-items: center;
  width: 100%;
  padding: 13px 0;
  border-bottom: 1px solid var(--color-rule);
}

.mode-number { font: 700 26px/1 var(--font-display); color: var(--color-accent); }
.mode-text { display: flex; flex-direction: column; gap: 3px; }
.mode-name { font: 700 30px/1 var(--font-display); letter-spacing: 1px; }
.mode-name-long { letter-spacing: 0.5px; }
.mode-note { font-size: 15px; line-height: 1.3; color: var(--color-muted); }
.mode:active .mode-name { color: var(--color-accent); }
@media (hover: hover) { .mode:hover .mode-name { color: var(--color-accent); } }

.home-art { margin-top: auto; padding-top: 16px; }
.home-art img { display: block; width: 100%; height: auto; }

.copyright {
  background: var(--color-water);
  padding: 0 0 max(10px, env(safe-area-inset-bottom));
  font-size: 12px;
  line-height: 16px;
  color: var(--color-muted);
  text-align: center;
}

/* ---------- The matchup ---------- */

.category {
  margin-top: 24px;
  font: 600 14px/1.3 var(--font-display);
  letter-spacing: 1.5px;
  color: var(--color-accent);
}

.question {
  margin-top: 6px;
  font: 700 34px/1.05 var(--font-display);
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.measured { margin-top: 6px; min-height: 20px; font-size: 15px; line-height: 20px; color: var(--color-muted); }

.cards { flex: 1 0 auto; margin-top: 16px; display: flex; flex-direction: column; }

.card {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: flex-start;
  width: 100%;
  min-width: 0;
  background: var(--color-panel);
  border: 1px solid var(--color-rule);
  border-radius: var(--radius-card);
  padding: 16px 18px;
}

.card-pick:active { border-color: var(--color-accent); background: #1E2126; }
@media (hover: hover) { .card-pick:hover { border-color: var(--color-accent); } }

.card-name {
  max-width: 100%;
  font: 700 var(--name-1)/1 var(--font-display);
  letter-spacing: 1px;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.name-2 { font-size: var(--name-2); }
.name-3 { font-size: var(--name-3); letter-spacing: 0.5px; }
.name-4 { font-size: var(--name-4); letter-spacing: 0.5px; }

.card-label { margin-top: 8px; font-size: 17px; line-height: 1.3; color: var(--color-muted); }
.card .tiles { margin-top: 16px; width: 100%; }

.versus {
  position: relative;
  z-index: 1;
  align-self: center;
  margin: -10px 0;
  display: flex;
  gap: 3px;
  padding: 4px;
  background: var(--color-page);
  border-radius: 5px;
}

.versus .tile { flex: 0 0 var(--tile-width); color: var(--color-accent); }

.hint { margin-top: 16px; font-size: 16px; color: var(--color-muted); text-align: center; }

/* ---------- The reveal ---------- */

.verdict { margin-top: 20px; display: flex; align-items: center; gap: 10px; }
.verdict-icon { flex: none; }
.verdict .tiles { flex: 1 1 0; }

.cards-reveal { gap: 12px; }
.card-result { padding: 12px 18px; }
.card-result .card-name { font-size: calc(var(--name-1) * 0.77); }
.card-result .name-2 { font-size: calc(var(--name-2) * 0.8); }
.card-result .name-3 { font-size: calc(var(--name-3) * 0.85); }
.card-result .name-4 { font-size: calc(var(--name-4) * 0.9); }
.card-result .card-label { margin-top: 6px; font-size: 16px; }
.card-result .tiles { margin-top: 14px; }
.card-unit { margin-top: 8px; font-size: 14px; color: var(--color-muted); }
.card-source { margin-top: 4px; font-size: 13px; color: var(--color-muted); }

.card-tag {
  margin-bottom: 8px;
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-tile);
  color: var(--color-accent);
  font: 700 13px/1 var(--font-display);
  letter-spacing: 1.5px;
  padding: 4px 7px;
}

.card-picked-right { border: 2px solid var(--color-accent); }
.card-picked-right .card-tag { background: var(--color-accent); color: var(--color-page); }
.card-picked-wrong { border: 2px solid var(--color-wrong); }
.card-picked-wrong .card-tag { background: var(--color-wrong); border-color: var(--color-wrong); color: var(--color-page); }

.source { margin-top: 14px; font-size: 13px; color: var(--color-muted); }
.reveal .button { margin-top: 14px; }

/* ---------- Streak over ---------- */

.over { padding-bottom: max(22px, env(safe-area-inset-bottom)); }
.over-title { margin-top: 18px; display: flex; flex-direction: column; gap: 6px; }
.over-result { margin-top: 26px; display: flex; flex-direction: column; gap: 12px; align-items: flex-start; }
.over-line { font-size: 22px; font-weight: 500; line-height: 1.25; }

.badge {
  border: 1px solid var(--color-accent);
  border-radius: var(--radius-tile);
  color: var(--color-accent);
  font-size: 16px;
  line-height: 1.2;
  padding: 6px 9px;
}

.over-actions { margin-top: 30px; display: flex; flex-direction: column; gap: 12px; }

.stats { margin-top: auto; padding-top: 30px; }

.stats-title {
  padding-bottom: 8px;
  border-bottom: 2px solid var(--color-accent);
  font: 600 13px/16px var(--font-display);
  letter-spacing: 2px;
  color: var(--color-muted);
}

.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 9px 0;
  border-bottom: 1px solid var(--color-rule);
  font-size: 16px;
}

.stats-row dd { font: 700 26px/1 var(--font-display); color: var(--color-accent); }

/* ---------- Something went wrong ---------- */

.error { justify-content: center; gap: 24px; }
.error-line { font-size: 20px; font-weight: 500; line-height: 1.3; text-align: center; }

.noscript { padding: 40px var(--page-side); font-size: 18px; text-align: center; }

/* ---------- Short screens ---------- */

@media (max-height: 720px) {
  .verdict { margin-top: 10px; }
  .cards-reveal { gap: 10px; }
  .card-result { padding: 10px 18px; }
  .card-result .tiles { margin-top: 10px; }
}

@media (max-height: 620px) {
  .home { padding-top: max(16px, env(safe-area-inset-top)); }
  .flap { width: 40px; height: 50px; font-size: 38px; }
  .flap-small { width: 28px; height: 35px; font-size: 25px; }
  .flap-title { width: 38px; height: 50px; font-size: 36px; }
  .flap-number { width: 56px; height: 74px; font-size: 56px; }
  .subhead { margin-top: 12px; }
  .modes { margin-top: 16px; }
  .home-art { padding-top: 10px; }

  .home-link { padding-top: 10px; padding-bottom: 10px; }
  .category { margin-top: 10px; }
  .question { font-size: 28px; }
  .measured { margin-top: 4px; }
  .cards { margin-top: 12px; }
  .card { padding: 10px 14px; }
  .card-label { margin-top: 4px; font-size: 15px; }
  .card .tiles { margin-top: 10px; }
  .hint { margin-top: 10px; font-size: 15px; }

  .verdict { margin-top: 6px; }
  .cards-reveal { gap: 8px; }
  .card-result { padding: 8px 14px; }
  .card-result .card-label { margin-top: 3px; font-size: 15px; }
  .card-result .tiles { margin-top: 8px; }
  .card-tag { margin-bottom: 5px; }
  .card-unit { margin-top: 5px; font-size: 13px; }
  .card-source { margin-top: 2px; font-size: 12px; }
  .source { margin-top: 8px; font-size: 12px; }
  .reveal .button { margin-top: 10px; }
  .button { padding: 14px 0; }
  .screen { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .home { padding-bottom: 0; }

  .over-title { margin-top: 8px; }
  .over-result { margin-top: 16px; gap: 10px; }
  .over-line { font-size: 20px; }
  .over-actions { margin-top: 20px; }
  .stats { padding-top: 16px; }
}

/* ---------- Narrow phones ---------- */

@media (max-width: 359px) {
  :root { --page-side: 18px; }
  .card { padding-left: 14px; padding-right: 14px; }
  .question { font-size: 30px; }
  .flap-title { width: 38px; height: 50px; font-size: 36px; }
}
