/* Smarter Than A Crow — black/white, deadpan, minimal. Mobile-first. */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #000;
  --fg: #fff;
  --muted: #888;
  --dim: #333;
}

html {
  height: 100%;
  /* Don't let mobile browsers auto-inflate our deliberately sized text. */
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  min-height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  line-height: 1.4;
  /* Subtle white flash on tap instead of the default blue box. */
  -webkit-tap-highlight-color: rgba(255, 255, 255, 0.12);
}

#app {
  width: 100%;
}

/* --- Screens --- */
.screen {
  position: relative; /* anchor the absolute top bars to the screen */
  min-height: 100vh;
  min-height: 100dvh; /* respects mobile browser chrome; falls back to vh */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  max-width: 640px;
  margin: 0 auto;
  text-align: center;
  /* Respect notches / rounded corners on the sides and bottom. */
  padding: 24px;
  padding-top: max(24px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
}

.screen[hidden] {
  display: none;
}

/* Content-heavy screens flow from the top and scroll, with room reserved for
   the absolutely-positioned back button so it never overlaps the title. */
#screen-opponents,
#screen-rewards {
  justify-content: flex-start;
  padding-top: calc(72px + env(safe-area-inset-top));
}

/* --- Typography (fluid sizes so nothing overflows a small phone) --- */
.title {
  font-size: clamp(1.4rem, 6vw, 1.8rem);
  font-weight: 700;
  margin-bottom: 20px;
  letter-spacing: -0.02em;
  overflow-wrap: break-word;
}

.subtitle {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin: 28px 0 12px;
  align-self: flex-start;
}

.question {
  font-size: clamp(1.2rem, 5.2vw, 1.5rem);
  font-weight: 700;
  margin: clamp(20px, 5vh, 32px) 0;
  min-height: 2.5em;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow-wrap: break-word;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
}

.big-score {
  font-size: clamp(3rem, 16vw, 4rem);
  font-weight: 700;
  margin: 12px 0;
  letter-spacing: -0.03em;
}

.verdict {
  font-size: clamp(1.15rem, 5vw, 1.4rem);
  font-weight: 700;
  margin-bottom: 12px;
  overflow-wrap: break-word;
}

/* --- Buttons --- */
.btn {
  background: var(--fg);
  color: var(--bg);
  border: 2px solid var(--fg);
  font-family: inherit;
  font-weight: 700;
  cursor: pointer;
  padding: 14px 24px;
  font-size: 1rem;
  min-height: 44px; /* comfortable touch target */
  transition: opacity 0.12s ease, background 0.12s ease, color 0.12s ease;
  touch-action: manipulation; /* kill the 300ms tap delay */
  overflow-wrap: break-word;
}

/* Hover only where it's a real pointer; avoids sticky :hover on touch. */
@media (hover: hover) {
  .btn:hover {
    opacity: 0.82;
  }
}

.btn:active {
  opacity: 0.65;
}

.btn:disabled {
  background: var(--bg);
  color: var(--dim);
  border-color: var(--dim);
  cursor: default;
}

.btn-big {
  font-size: clamp(1.1rem, 4.6vw, 1.3rem);
  padding: clamp(16px, 3.5vh, 20px) 24px;
  max-width: 480px;
  width: 100%;
}

.btn-small {
  font-size: 0.85rem;
  padding: 10px 14px;
  min-height: 40px;
  background: var(--bg);
  color: var(--fg);
}

@media (hover: hover) {
  .btn-small:hover {
    background: var(--fg);
    color: var(--bg);
    opacity: 1;
  }
}

/* --- Layout helpers --- */
.top-bar,
.test-header {
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-left: max(16px, env(safe-area-inset-left));
  padding-right: max(16px, env(safe-area-inset-right));
}

.center {
  width: 100%;
  display: flex;
  justify-content: center;
}

/* --- Lists --- */
.list {
  list-style: none;
  width: 100%;
}

.list li {
  border: 2px solid var(--fg);
  margin-bottom: 12px;
}

/* Opponent rows */
.opponent-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  border: none;
  font-family: inherit;
  padding: 16px 18px;
  min-height: 60px;
  cursor: pointer;
  text-align: left;
  touch-action: manipulation;
}

@media (hover: hover) {
  .opponent-row:hover:not(:disabled) {
    background: var(--fg);
    color: var(--bg);
  }
}

.opponent-row:disabled {
  color: var(--dim);
  cursor: default;
}

.opponent-row .op-name {
  font-size: clamp(1.05rem, 4.5vw, 1.2rem);
  font-weight: 700;
  overflow-wrap: break-word;
}

.opponent-row .op-meta {
  text-align: right;
  font-size: 0.85rem;
  white-space: nowrap;
  flex-shrink: 0;
}

.opponent-row .op-locked {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* Static info rows (streaks / trophies) */
.info-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
}

.info-row .label {
  font-weight: 700;
  overflow-wrap: break-word;
}

.empty-note {
  color: var(--muted);
  padding: 8px 0;
  align-self: flex-start;
}

/* --- Test choices --- */
.choices {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 480px;
}

.choice {
  background: var(--bg);
  color: var(--fg);
  border: 2px solid var(--fg);
  font-family: inherit;
  font-size: clamp(0.95rem, 4vw, 1.05rem);
  font-weight: 600;
  padding: 16px 18px;
  min-height: 52px;
  cursor: pointer;
  text-align: left;
  overflow-wrap: break-word;
  touch-action: manipulation;
  transition: background 0.12s ease, color 0.12s ease;
}

@media (hover: hover) {
  .choice:hover {
    background: var(--fg);
    color: var(--bg);
  }
}

.choice:active {
  background: var(--fg);
  color: var(--bg);
}

/* --- Trophy banner --- */
.trophy-banner {
  border: 2px solid var(--fg);
  padding: 16px 18px;
  margin: 20px 0;
  width: 100%;
  max-width: 480px;
}

.trophy-banner[hidden] {
  display: none;
}

.trophy-banner .trophy-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  margin-bottom: 6px;
  color: var(--muted);
}

.trophy-banner .trophy-name {
  font-size: 1.2rem;
  font-weight: 700;
  overflow-wrap: break-word;
}

/* --- Result review ("what you got wrong") --- */
.review {
  width: 100%;
  max-width: 480px;
  margin: 12px 0 24px;
  text-align: left;
}

.review[hidden] {
  display: none;
}

.review-title {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 12px;
  text-align: center;
}

.review-item {
  border: 2px solid var(--fg);
  padding: 14px 16px;
  margin-bottom: 12px;
}

.review-q {
  font-weight: 700;
  margin-bottom: 10px;
  overflow-wrap: break-word;
}

.review-line {
  font-size: 0.95rem;
  overflow-wrap: break-word;
}

.review-line.wrong {
  color: var(--muted);
  text-decoration: line-through;
  margin-bottom: 4px;
}

.review-line.right {
  color: var(--fg);
  font-weight: 700;
}

/* A long review can exceed the viewport, so a reviewed result top-aligns and
   scrolls instead of vertically centering (which would clip the top). */
#screen-result.has-review {
  justify-content: flex-start;
  padding-top: max(28px, env(safe-area-inset-top));
}

/* --- Short / landscape screens: stop vertically centering so tall content
       can't tuck under the top bar or get clipped — let it scroll instead. --- */
@media (max-height: 560px) {
  .screen {
    justify-content: flex-start;
  }
  #screen-test,
  #screen-result {
    padding-top: calc(64px + env(safe-area-inset-top));
  }
}

/* Tighter gutters on very narrow phones. */
@media (max-width: 360px) {
  .screen {
    padding-left: max(14px, env(safe-area-inset-left));
    padding-right: max(14px, env(safe-area-inset-right));
  }
}
