/* Playnesta shell stylesheet for Click Sprint (Playnesta-original, MIT).
   No sprites, fonts, images or network assets: the pad, the ripples and the
   bar are plain elements. The layout has to fit both production stages
   (894x670 desktop and 348x261 phone) with no overflow in either axis, so the
   pad is the only element that grows and everything else is a fixed row. */

* { box-sizing: border-box; }

:root {
  --bg: #0e1220;
  --panel: #171d31;
  --panel2: #202840;
  --ink: #eef2ff;
  --muted: #8f9ab8;
  --accent: #5ef2c0;
  --accent-2: #35c9a3;
  --hot: #ffd166;
  --line: #2b3450;
}

html,
body {
  margin: 0;
  height: 100%;
  background:
    radial-gradient(120% 90% at 50% 0%, #18213a 0%, var(--bg) 62%);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

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

/* ---- top bar ---- */
.topbar { display: flex; align-items: center; gap: 8px; flex: 0 0 auto; }
.title { font-weight: 700; font-size: 14px; white-space: nowrap; letter-spacing: 0.2px; }
.title small { font-weight: 500; color: var(--muted); font-size: 10px; letter-spacing: 0.4px; text-transform: uppercase; }
.spacer { flex: 1 1 auto; min-width: 0; }
.hud {
  display: flex; align-items: baseline; gap: 4px; font-size: 11px;
  background: var(--panel); padding: 3px 8px; border-radius: 8px;
  white-space: nowrap; overflow: hidden;
}
.hud b { font-size: 13px; color: var(--accent); font-variant-numeric: tabular-nums; }
.hud .opt { color: var(--muted); }

/* ---- pad ---- */
#stage { position: relative; flex: 1 1 auto; min-height: 0; min-width: 0; }

#pad {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background:
    radial-gradient(90% 120% at 50% 0%, #1d2745 0%, #151b2d 70%);
  overflow: hidden;
  cursor: pointer;
  touch-action: none;
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
#pad:focus-visible { border-color: var(--accent); box-shadow: 0 0 0 2px rgba(94, 242, 192, 0.25); }
#pad[data-state="running"] { border-color: rgba(94, 242, 192, 0.55); }
#pad[data-state="done"] { border-color: rgba(255, 209, 102, 0.4); }
#pad[data-state="done"] #pad-main,
#pad[data-state="done"] #pad-live { visibility: hidden; }

#pad-main { display: flex; flex-direction: column; align-items: center; line-height: 1; pointer-events: none; }
#pad-count {
  font-size: clamp(34px, 13vh, 92px);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: -1px;
  color: var(--ink);
}
#pad[data-state="running"] #pad-count { color: var(--accent); }
#pad-unit { font-size: 11px; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); margin-top: 4px; }
#pad-msg { font-size: 12px; color: var(--muted); margin-top: 8px; min-height: 16px; }
#pad[data-state="running"] #pad-msg { color: transparent; }

#pad-live {
  position: absolute; top: 10px; right: 12px;
  display: flex; align-items: baseline; gap: 3px;
  font-variant-numeric: tabular-nums; color: var(--muted); font-size: 11px;
}
#pad-live b { font-size: 16px; color: var(--hot); }
#pad[data-state="idle"] #pad-live,
#pad[data-state="done"] #pad-live { opacity: 0.35; }

#pad-bar {
  position: absolute; left: 0; right: 0; bottom: 0; height: 6px;
  background: rgba(255, 255, 255, 0.06);
}
#pad-bar i {
  display: block; height: 100%; width: 0;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 60ms linear;
}

#ripples { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.ripple {
  position: absolute;
  width: 14px; height: 14px;
  margin: -7px 0 0 -7px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  opacity: 0.85;
  animation: ripple 380ms ease-out forwards;
}
@keyframes ripple {
  from { transform: scale(0.4); opacity: 0.9; }
  to { transform: scale(6.5); opacity: 0; }
}
.spark {
  position: absolute;
  width: 5px; height: 5px;
  margin: -2.5px 0 0 -2.5px;
  border-radius: 50%;
  background: var(--hot);
  animation: spark 460ms ease-out forwards;
}
@keyframes spark {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}

/* ---- result card ---- */
#results {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  border-radius: 14px;
  background: rgba(14, 18, 32, 0.92);
  backdrop-filter: blur(2px);
  pointer-events: none;
  text-align: center;
  padding: 6px 10px;
  animation: fade 160ms ease-out;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
#results.hidden { display: none; }
.res-head { font-size: 10px; letter-spacing: 1px; text-transform: uppercase; color: var(--muted); }
.res-big { display: flex; align-items: baseline; gap: 5px; line-height: 1; }
.res-big b { font-size: clamp(30px, 11vh, 72px); font-weight: 800; color: var(--accent); font-variant-numeric: tabular-nums; }
.res-big span { font-size: 12px; color: var(--muted); }
.res-big em {
  display: none;
  font-style: normal; font-size: 10px; font-weight: 700;
  color: #1a1200; background: var(--hot);
  padding: 2px 6px; border-radius: 999px; letter-spacing: 0.4px; text-transform: uppercase;
}
.res-big em.on { display: inline-block; }
.res-line { display: flex; flex-wrap: wrap; gap: 4px 12px; justify-content: center; font-size: 11px; color: var(--muted); }
.res-line b { color: var(--ink); font-variant-numeric: tabular-nums; }
.res-sub { font-size: 10px; color: var(--muted); min-height: 13px; }
#btn-again { pointer-events: auto; margin-top: 4px; }

/* ---- readout ---- */
#readout {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  flex: 0 0 auto;
}
.stat {
  background: var(--panel);
  border-radius: 8px;
  padding: 3px 6px;
  display: flex;
  align-items: baseline;
  gap: 4px;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.stat span { font-size: 9px; letter-spacing: 0.6px; text-transform: uppercase; color: var(--muted); }
.stat b { font-size: 12px; color: var(--ink); font-variant-numeric: tabular-nums; margin-left: auto; }

/* ---- modes ---- */
#modes { display: flex; flex-wrap: wrap; gap: 4px; flex: 0 0 auto; }
.group { display: flex; gap: 3px; background: var(--panel); border-radius: 9px; padding: 2px; }
.chip {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 11px;
  padding: 3px 7px;
  min-height: 24px;
  border-radius: 7px;
  cursor: pointer;
  white-space: nowrap;
}
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent); color: #06150f; font-weight: 700; }
.chip:disabled { opacity: 0.45; cursor: default; }

/* ---- status bar ---- */
#statusbar { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
#status { flex: 1 1 auto; min-width: 0; font-size: 10px; color: var(--muted); line-height: 1.25; }
.actions { display: flex; gap: 3px; flex: 0 0 auto; }
.btn {
  appearance: none;
  border: 1px solid var(--line);
  background: var(--panel2);
  color: var(--ink);
  font: inherit;
  font-size: 11px;
  padding: 4px 8px;
  min-height: 26px;
  border-radius: 8px;
  cursor: pointer;
  white-space: nowrap;
}
.btn:hover { border-color: var(--accent-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #06150f; font-weight: 700; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---- modal / toast ---- */
#modal-root:empty { display: none; }
.modal-back {
  position: fixed; inset: 0; background: rgba(6, 9, 17, 0.72);
  display: flex; align-items: center; justify-content: center; padding: 10px; z-index: 20;
}
.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  max-width: 520px;
  width: 100%;
  max-height: 100%;
  overflow: auto;
  font-size: 12px;
  line-height: 1.45;
}
.modal h2 { margin: 0 0 6px; font-size: 14px; }
.modal p { margin: 0 0 7px; color: #cfd7ee; }
.modal ul { margin: 0 0 8px; padding-left: 16px; color: #cfd7ee; }
.modal li { margin-bottom: 4px; }
.modal .modal-actions { display: flex; justify-content: flex-end; }
#toast {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%) translateY(8px);
  background: var(--panel2); border: 1px solid var(--line); color: var(--ink);
  font-size: 11px; padding: 6px 10px; border-radius: 999px;
  opacity: 0; pointer-events: none; transition: opacity 160ms ease, transform 160ms ease; z-index: 30;
  max-width: 92vw; text-align: center;
}
#toast.on { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---- small stage (phone iframe, 348x261) ---- */
@media (max-height: 420px) {
  #app { gap: 4px; padding: 5px; }
  .title { font-size: 12px; }
  .title small { font-size: 9px; }
  .hud { padding: 2px 6px; font-size: 10px; }
  .hud b { font-size: 11px; }
  #pad-count { font-size: clamp(26px, 15vh, 58px); }
  #pad-unit { font-size: 9px; margin-top: 2px; }
  #pad-msg { font-size: 10px; margin-top: 4px; min-height: 12px; }
  #pad-live { top: 6px; right: 8px; }
  #pad-live b { font-size: 13px; }
  .stat { padding: 2px 5px; }
  .stat span { font-size: 8px; }
  .stat b { font-size: 11px; }
  .chip { font-size: 10px; min-height: 21px; padding: 2px 6px; }
  .btn { font-size: 10px; min-height: 23px; padding: 3px 7px; }
  #status { font-size: 9px; }
  .res-head { font-size: 9px; }
  .res-line { font-size: 10px; }
  .res-sub { font-size: 9px; min-height: 11px; }
}

@media (max-height: 300px) {
  #readout { display: none; }
  #status { display: none; }
  #pad-count { font-size: clamp(24px, 16vh, 48px); }
}

@media (min-width: 620px) {
  .title { font-size: 16px; }
  .title small { font-size: 11px; }
  #pad-count { font-size: clamp(48px, 14vh, 104px); }
  .stat b { font-size: 14px; }
  .chip { font-size: 12px; min-height: 27px; padding: 4px 10px; }
  .btn { font-size: 12px; min-height: 28px; }
  #status { font-size: 11px; }
}
