/* Playnesta shell stylesheet for Reaction Time Test (Playnesta-original MIT).
   The whole game is a full-bleed tap pad that flips red -> green; no sprites,
   fonts or network assets. Layout is viewport-relative so the same page fits
   the two production stages (894x670 desktop and 348x261 phone) with no
   overflow in either axis. */

* { box-sizing: border-box; }

:root {
  --bg: #141a12;
  --panel: #1f2a1c;
  --ink: #eef3ea;
  --muted: #a9b8a4;
  --accent: #7fd14f;
  --go: #37c94a;
  --wait: #c0392b;
}

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  min-height: 0;
}

.topbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.title { font-weight: 700; font-size: 15px; }
.title small { font-weight: 500; color: var(--muted); font-size: 11px; }
.spacer { flex: 1; }
.hud {
  display: flex; align-items: baseline; gap: 6px; font-size: 13px;
  background: var(--panel); padding: 4px 10px; border-radius: 8px;
}
.hud b { font-size: 16px; color: var(--accent); }
.hud .opt { color: var(--muted); }

/* ---- results card (shown when a set completes) ---- */
#results { flex: 0 0 auto; display: flex; justify-content: center; }
.res-card {
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--panel); border: 1px solid rgba(127, 209, 79, 0.35);
  border-radius: 10px; padding: 10px 16px; width: 100%; max-width: 460px;
}
.res-label { color: var(--muted); font-size: 12px; text-transform: uppercase; letter-spacing: 0.05em; }
.res-line { font-size: 17px; }
.res-line b { color: var(--accent); font-size: 22px; }
.res-sep { color: var(--muted); margin: 0 6px; }
.res-sub { color: var(--muted); font-size: 12px; text-align: center; }

/* ---- the tap pad: ready / wait(red) / go(green) ---- */
#pad {
  flex: 1 1 auto;
  min-height: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.08s linear;
  text-align: center;
  padding: 8px;
}
#pad[data-state="ready"] { background: var(--panel); }
#pad[data-state="wait"] { background: var(--wait); }
#pad[data-state="go"]   { background: var(--go); }
#pad[data-state="result"] { background: var(--panel); align-items: flex-start; }
#pad[data-state="wrong"] { background: #5a3b12; }

#pad-msg {
  font-size: clamp(18px, 6vh, 40px);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
  line-height: 1.1;
}
#pad[data-state="result"] #pad-msg {
  font-size: clamp(20px, 7vh, 48px);
  font-weight: 800;
}
#pad[data-state="result"] #pad-msg small {
  display: block; font-size: clamp(11px, 2.4vh, 16px); font-weight: 600;
  color: var(--accent); margin-top: 4px;
}

#statusbar {
  flex: 0 0 auto;
  display: flex; align-items: center; gap: 8px; justify-content: space-between;
  flex-wrap: wrap;
}
#status { color: var(--muted); font-size: 12.5px; flex: 1 1 200px; min-width: 0; }
.actions { display: flex; gap: 6px; flex: 0 0 auto; }
.btn {
  font: inherit; font-size: 13px; font-weight: 600; color: var(--ink);
  background: var(--panel); border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px; padding: 6px 12px; cursor: pointer;
}
.btn.primary { background: var(--accent); color: #10230b; border-color: transparent; }
.btn:active { transform: translateY(1px); }

.hidden { display: none !important; }

/* Short stages (e.g. the 348x261 phone viewport): tighten vertical spend so the
   finished set — results card + result pad + bars — fits with no overflow and
   the pad never collapses under its own text. Desktop is unchanged. */
@media (max-height: 380px) {
  #app { gap: 3px; padding: 6px; }
  .topbar .title { font-size: 13px; }
  .topbar .title small { font-size: 10px; }
  .hud { padding: 2px 8px; }
  .hud b { font-size: 14px; }
  #pad[data-state="result"] #pad-msg { font-size: clamp(15px, 4.2vh, 24px); }
  #pad[data-state="result"] #pad-msg small { font-size: clamp(10px, 2vh, 13px); }
  .res-card { padding: 6px 12px; gap: 3px; }
  .res-line { font-size: 14px; }
  .res-line b { font-size: 18px; }
  .res-sub { font-size: 11px; }
  #status { font-size: 11px; }
  .btn { padding: 4px 10px; font-size: 12px; }
}

/* modal + toast (reused shell conventions) */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55);
  display: flex; align-items: center; justify-content: center; padding: 16px; z-index: 20;
}
.modal {
  background: var(--panel); border-radius: 12px; max-width: 460px; width: 100%;
  max-height: 86%; overflow: auto; padding: 16px 18px;
}
.modal h2 { margin: 0 0 8px; font-size: 17px; }
.rules-body { font-size: 13.5px; line-height: 1.5; color: var(--ink); }
.rules-body h3 { margin: 10px 0 4px; font-size: 14px; color: var(--accent); }
.rules-body ul { margin: 4px 0; padding-left: 20px; }
.modal-buttons { margin-top: 12px; display: flex; justify-content: flex-end; }

#toast {
  position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%) translateY(20px);
  background: #000; color: #fff; padding: 8px 14px; border-radius: 8px; font-size: 13px;
  opacity: 0; pointer-events: none; transition: opacity 0.15s ease, transform 0.15s ease; z-index: 30;
}
#toast.show { opacity: 0.92; transform: translateX(-50%) translateY(0); }
