/* ===========================================================
   Reflexo BR — style.css
   Mobile-first, sem framework, uma fonte opcional (Rajdhani).
   =========================================================== */

:root {
  --bg: #0a0e14;
  --bg-2: #10161f;
  --card: #131a24;
  --card-border: #202836;
  --text: #f5f7fa;
  --text-muted: #9aa5b1;
  --red: #ff4747;
  --yellow: #ffcd3c;
  --green: #2eff8f;
  --green-deep: #16c96b;
  --blue: #4da3ff;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 24px;
  --font-display: "Rajdhani", "Arial Narrow", Arial, sans-serif;
  --font-body: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --shadow-1: 0 8px 24px rgba(0, 0, 0, 0.35);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #0a0e14;
    --bg-2: #10161f;
  }
}

* { box-sizing: border-box; }

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

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(1200px 800px at 80% -10%, #17202c 0%, var(--bg) 55%) fixed;
  color: var(--text);
  font-family: var(--font-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 {
  font-family: var(--font-display), var(--font-body);
  font-weight: 700;
  letter-spacing: 0.01em;
  margin: 0 0 0.5em;
}

p { margin: 0 0 1em; }

button {
  font-family: inherit;
  color: inherit;
}

a { color: var(--green); }

.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

/* ---------- layout shell ---------- */

.app-shell {
  max-width: 640px;
  margin: 0 auto;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: calc(14px + var(--safe-top)) 20px 14px;
  position: sticky;
  top: 0;
  z-index: 20;
  background: linear-gradient(to bottom, rgba(10,14,20,0.92), rgba(10,14,20,0.65));
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--text);
}

.brand-lights {
  display: inline-flex;
  flex-direction: column;
  gap: 3px;
  padding: 5px 6px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: 8px;
}

.dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}
.dot-red { background: var(--red); }
.dot-yellow { background: var(--yellow); }
.dot-green { background: var(--green); box-shadow: 0 0 8px rgba(46,255,143,0.8); }

.brand-name {
  font-family: var(--font-display), var(--font-body);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: 0.03em;
}
.brand-name strong { color: var(--green); }

.topbar-tag {
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

#main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
}

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

.screen {
  display: none;
  padding: 24px 20px calc(40px + var(--safe-bottom));
  animation: fade-in 0.25s ease;
}
.screen.is-active {
  display: flex;
  flex-direction: column;
  flex: 1;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.eyebrow {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--green);
  font-weight: 700;
  margin: 0 0 10px;
}

/* ---------- home ---------- */

.challenge-banner {
  background: linear-gradient(135deg, rgba(255,205,60,0.14), rgba(46,255,143,0.10));
  border: 1px solid rgba(255,205,60,0.35);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  margin-bottom: 18px;
  font-size: 0.92rem;
}
.challenge-banner p { margin: 0; }

.hero { padding-top: 4px; }

.hero h1 {
  font-size: 1.9rem;
  line-height: 1.18;
}
.hero h1 .or {
  color: var(--text-muted);
  font-weight: 500;
  font-style: italic;
}

.hero-sub {
  color: var(--text-muted);
  font-size: 1rem;
}
.hero-sub strong { color: var(--text); }

.hero-meta {
  margin-top: 12px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.hero-meta strong { color: var(--yellow); }

.mini-steps {
  list-style: none;
  padding: 0;
  margin: 26px 0 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.mini-steps li {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.9rem;
  color: var(--text-muted);
}
.mini-steps .dot { flex-shrink: 0; }

.info-block {
  margin-top: 34px;
  padding-top: 22px;
  border-top: 1px solid var(--card-border);
}
.info-block h2 {
  font-size: 1.15rem;
}
.info-block p {
  color: var(--text-muted);
  font-size: 0.92rem;
}
.info-block strong { color: var(--text); }

.disclaimer-inline {
  font-size: 0.82rem;
  color: var(--text-muted);
  background: rgba(255,255,255,0.03);
  border: 1px dashed var(--card-border);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
}

.site-footer {
  margin-top: 30px;
  padding-top: 18px;
  border-top: 1px solid var(--card-border);
  font-size: 0.78rem;
  color: var(--text-muted);
}
.site-footer p { margin: 0 0 4px; }
.site-footer-disclaimer { opacity: 0.8; }

/* ---------- buttons ---------- */

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  font-weight: 700;
  font-size: 1rem;
  padding: 14px 24px;
  transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
  touch-action: manipulation;
}
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

.btn-primary {
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: #06170e;
  box-shadow: 0 6px 20px rgba(46,255,143,0.28);
}
.btn-primary:hover { box-shadow: 0 8px 26px rgba(46,255,143,0.4); }

.btn-secondary {
  background: var(--card);
  color: var(--text);
  border: 1px solid var(--card-border);
}

.btn-text {
  background: transparent;
  color: var(--text-muted);
  padding: 10px 12px;
  font-weight: 600;
}

.btn-lg {
  width: 100%;
  padding: 17px 24px;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-arrow { transition: transform 0.15s ease; }
.btn-primary:hover .btn-arrow { transform: translateX(3px); }

#btn-start { margin-top: 22px; }

/* ---------- transition screen ---------- */

.screen-transition {
  align-items: center;
  justify-content: center;
  text-align: center;
}
.transition-box {
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}
.transition-box h2 {
  font-size: 2.1rem;
  margin-bottom: 10px;
}
.transition-box p:not(.eyebrow) {
  color: var(--text-muted);
  margin-bottom: 26px;
}

/* ---------- game screens ---------- */

.screen-game { align-items: stretch; }

.game-header { margin-bottom: 18px; }
.game-header h2 {
  font-size: 1.3rem;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.game-round {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: var(--font-body);
  font-weight: 600;
}
.game-instructions {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-bottom: 0;
}
.game-instructions strong { color: var(--text); }

/* reaction pad */

.reaction-pad {
  flex: 1;
  min-height: 300px;
  border: none;
  border-radius: var(--radius-lg);
  background: var(--card);
  border: 1px solid var(--card-border);
  color: var(--text);
  font-size: 1.4rem;
  font-weight: 700;
  font-family: var(--font-display), var(--font-body);
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  cursor: pointer;
  transition: background-color 0.08s linear;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: manipulation;
}
.reaction-pad.state-waiting { background: var(--card); }
.reaction-pad.state-armed { background: #241417; color: var(--red); }
.reaction-pad.state-go {
  background: linear-gradient(135deg, var(--green), var(--green-deep));
  color: #06170e;
}
.reaction-pad.state-early { background: #2a1518; color: var(--red); }
.reaction-pad.state-result { background: var(--card); }

.reaction-history {
  margin-top: 14px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.88rem;
  min-height: 1.2em;
}

/* memory */

.memory-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 10px 0 22px;
  flex: 1;
}
.memory-tile {
  border-radius: var(--radius-md);
  border: 1px solid var(--card-border);
  min-height: 120px;
  cursor: pointer;
  transition: filter 0.1s ease, transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.memory-tile:active { transform: scale(0.97); }
.memory-tile[data-tile="0"] { background: #3a1414; }
.memory-tile[data-tile="1"] { background: #3a3014; }
.memory-tile[data-tile="2"] { background: #143a24; }
.memory-tile[data-tile="3"] { background: #142a3a; }
.memory-tile.lit[data-tile="0"] { background: var(--red); box-shadow: 0 0 26px rgba(255,71,71,0.7); }
.memory-tile.lit[data-tile="1"] { background: var(--yellow); box-shadow: 0 0 26px rgba(255,205,60,0.7); }
.memory-tile.lit[data-tile="2"] { background: var(--green); box-shadow: 0 0 26px rgba(46,255,143,0.7); }
.memory-tile.lit[data-tile="3"] { background: var(--blue); box-shadow: 0 0 26px rgba(77,163,255,0.7); }
.memory-tile.wrong { background: var(--red) !important; }
.memory-tile:disabled { cursor: default; }

/* math */

.math-status {
  display: flex;
  justify-content: space-between;
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 8px;
}
.math-timer { font-weight: 700; color: var(--yellow); font-variant-numeric: tabular-nums; }
.math-score { font-weight: 700; }

.math-problem {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-display), var(--font-body);
  font-size: 3rem;
  font-weight: 700;
  min-height: 140px;
  text-align: center;
}

.math-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}
.math-option {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 18px 10px;
  font-size: 1.3rem;
  font-weight: 700;
  cursor: pointer;
  transition: background-color 0.1s ease, border-color 0.1s ease, transform 0.08s ease;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.math-option:active { transform: scale(0.97); }
.math-option.correct { background: rgba(46,255,143,0.18); border-color: var(--green); }
.math-option.wrong { background: rgba(255,71,71,0.18); border-color: var(--red); }
.math-option:disabled { cursor: default; }

/* ---------- results ---------- */

.screen-results { text-align: center; }

.results-score {
  font-size: 3.4rem;
  margin: 4px 0 0;
  line-height: 1;
}
.results-score-max {
  font-size: 1.4rem;
  color: var(--text-muted);
  font-weight: 600;
  margin-left: 4px;
}

.results-rank {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--green);
  margin-top: 6px;
}

.results-newbest {
  color: var(--yellow);
  font-weight: 700;
  font-size: 0.9rem;
}

.results-bars {
  margin-top: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  text-align: left;
}
.results-bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 90px;
  align-items: center;
  gap: 10px;
}
.results-bar-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  color: var(--text-muted);
}
.results-bar-track {
  height: 10px;
  border-radius: 999px;
  background: var(--card);
  border: 1px solid var(--card-border);
  overflow: hidden;
}
.results-bar-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  transition: width 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
.fill-red { background: linear-gradient(90deg, #ff4747, #ff8a47); }
.fill-yellow { background: linear-gradient(90deg, #ffcd3c, #ffe98a); }
.fill-green { background: linear-gradient(90deg, #2eff8f, #16c96b); }
.results-bar-value {
  font-size: 0.82rem;
  color: var(--text-muted);
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.results-f1-compare {
  margin-top: 20px;
  font-size: 0.88rem;
  color: var(--text-muted);
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  text-align: left;
}

.results-challenge {
  margin-top: 14px;
  font-size: 0.9rem;
  background: rgba(255,205,60,0.08);
  border: 1px solid rgba(255,205,60,0.3);
  border-radius: var(--radius-md);
  padding: 12px 14px;
  text-align: left;
}

.results-actions {
  margin-top: 22px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.results-disclaimer { margin-top: 20px; text-align: left; }

/* ---------- share card screen ---------- */

.screen-card { align-items: center; text-align: center; }

.card-canvas-wrap {
  width: 100%;
  max-width: 320px;
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: var(--shadow-1);
}
#result-canvas {
  width: 100%;
  height: auto;
  display: block;
}

.card-actions {
  margin-top: 20px;
  width: 100%;
  max-width: 320px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.card-toast {
  margin-top: 14px;
  font-size: 0.85rem;
  color: var(--green);
  background: rgba(46,255,143,0.1);
  border: 1px solid rgba(46,255,143,0.3);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

#btn-card-back { margin-top: 16px; }

/* ---------- responsive tweaks ---------- */

@media (min-width: 480px) {
  .hero h1 { font-size: 2.2rem; }
  .reaction-pad { min-height: 340px; }
}

@media (min-width: 640px) {
  .app-shell { border-left: 1px solid var(--card-border); border-right: 1px solid var(--card-border); }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.001ms !important; transition-duration: 0.001ms !important; }
}

/* focus visibility for keyboard users */
a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
