:root {
  --green:  #18d96b;
  --red:    #ee1414;
  --blue:   #2a6bff;
  --orange: #ff9020;
  --yellow: #ffe11a;
  --bg:     #111111;
  --panel:  #1c1c1c;
  --fg:     #f0f0f0;
  --dim:    #6e6e6e;
  --border: rgba(255, 255, 255, 0.08);
  --focus:  #ffd700;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-text-size-adjust: 100%;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

main {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 10px;
  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));
  max-width: 760px;
  margin: 0 auto;
}

/* ------------------------------------------------------------------ stats */

#stats {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px;
  background: var(--panel);
  border-radius: 10px;
}

.overall {
  display: flex;
  align-items: baseline;
  gap: 14px;
  line-height: 1;
}

.overall .accuracy {
  font-size: 30px;
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}

.overall .avgTime {
  font-size: 20px;
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.per-color {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.per-color li {
  display: flex;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.per-color .swatch {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.per-color li[data-color="green"]  .swatch { background: var(--green); }
.per-color li[data-color="red"]    .swatch { background: var(--red); }
.per-color li[data-color="blue"]   .swatch { background: var(--blue); }
.per-color li[data-color="orange"] .swatch { background: var(--orange); }

.per-color .acc { color: var(--fg); }
.per-color .t   { color: var(--dim); }

/* ------------------------------------------------------------------ quiz */

#quiz {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 14px;
  min-height: 0;
}

.row {
  display: flex;
  gap: 10px;
  padding: 8px;
  border: 3px solid transparent;
  background: var(--panel);
  border-radius: 14px;
  cursor: pointer;
  min-height: 88px;
  flex: 1 1 0;
  max-height: 220px;
  align-items: stretch;
  transition: border-color 120ms ease, transform 60ms ease;
  appearance: none;
  font: inherit;
  color: inherit;
}

.row:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.row:active        { transform: scale(0.985); }

@media (hover: hover) {
  .row:hover { border-color: rgba(255, 255, 255, 0.18); }
}

.box {
  flex: 1 1 0;
  border-radius: 10px;
  border: 1px solid rgba(0, 0, 0, 0.25);
  min-width: 0;
}

.box[data-color="green"]  { background: var(--green); }
.box[data-color="red"]    { background: var(--red); }
.box[data-color="blue"]   { background: var(--blue); }
.box[data-color="orange"] { background: var(--orange); }

/* feedback */

.row.correct-flash {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(0, 181, 74, 0.5);
}
.row.correct-target {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.6);
}

/* during feedback nothing is tappable */
body.state-feedback .row { cursor: default; pointer-events: none; }

/* before any question paints */
body.state-empty .row .box { background: transparent; border-color: transparent; }

@media (min-width: 600px) {
  main { gap: 14px; padding: 14px; }
  #quiz { gap: 18px; }
  .row { min-height: 140px; padding: 12px; gap: 14px; }
  .overall .accuracy { font-size: 36px; }
  .overall .avgTime  { font-size: 22px; }
  .per-color { font-size: 15px; gap: 10px; }
  .per-color .swatch { width: 14px; height: 14px; }
}
