/* RUBIX 5S — brand tokens from the RUBIX 2026 design system. */

:root {
  --navy: #17479e;
  --navy-deep: #143f8c;
  --green: #00a890;
  --cyan: #08c0de;
  --lime: #c4d52e;
  --orange: #faa21b;
  --red: #ef3a4c;
  --purple: #ab4499;
  --pink: #f27fb2;

  --ink: #333333;
  --muted: #555555;
  --label: #6f7171;
  --hairline: #dde3eb;
  --panel: #f5f7fa;
  --white: #ffffff;

  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --radius: 4px;

  --head: "Poppins", system-ui, sans-serif;
  --body: "Inter", system-ui, -apple-system, sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }

/* Several of these elements are flex or grid, which otherwise beats [hidden]. */
[hidden] { display: none !important; }

html, body {
  height: 100%;
  margin: 0;
}

body {
  font-family: var(--body);
  color: var(--ink);
  background: var(--white);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: flex;
  flex-direction: column;
  height: 100dvh;
}

/* ------------------------------------------------------------------ header */

.bar {
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 14px 24px;
  border-bottom: 1px solid var(--hairline);
  flex: none;
}

.bar__brand { display: flex; line-height: 0; }
.bar__brand img { height: 30px; width: auto; }

.bar__status {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.bar__round {
  font-family: var(--head);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--label);
  white-space: nowrap;
}

.bar__stage {
  font-family: var(--head);
  font-weight: 700;
  font-size: 15px;
  color: var(--navy);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bar__timer {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 220px;
}

.bar__count {
  font-family: var(--head);
  font-weight: 700;
  font-size: 20px;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
  min-width: 28px;
  text-align: right;
}

.bar__timer.is-low .bar__count { color: var(--red); }
.bar__timer.is-low .track__fill { background: var(--red); }

.track {
  flex: 1;
  height: 6px;
  background: var(--hairline);
  border-radius: 999px;
  overflow: hidden;
}

.track__fill {
  height: 100%;
  width: 100%;
  background: var(--green);
  border-radius: 999px;
  transform-origin: left center;
}

/* ------------------------------------------------------------------- board */

.stage {
  flex: 1;
  min-height: 0;
  padding: 18px 24px 12px;
  display: flex;
  flex-direction: column;
}

.board {
  position: relative;
  flex: 1;
  min-height: 0;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--white);
  overflow: hidden;
}

.findnext {
  flex: none;
  margin: 10px 0 0;
  text-align: center;
  font-family: var(--head);
  font-weight: 600;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--label);
}
.findnext strong { color: var(--navy); font-size: 17px; }

/* Cards ------------------------------------------------------------------- */

.card {
  position: absolute;
  margin: 0;
  padding: 2px 5px;
  border: 0;
  background: none;
  font-family: var(--head);
  font-weight: 600;
  font-size: var(--size);
  line-height: 1.05;
  color: var(--tone);
  cursor: pointer;
  transform: rotate(var(--rot));
  transition: opacity 0.4s var(--ease), color 0.5s var(--ease),
              transform 0.5s var(--ease), font-size 0.5s var(--ease);
  -webkit-tap-highlight-color: transparent;
}

.card:hover { opacity: 0.65; }
.card:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.card.is-done {
  color: var(--green);
  opacity: 0.28;
  pointer-events: none;
  text-decoration: line-through;
}

.card.is-gone {
  opacity: 0;
  pointer-events: none;
  transform: rotate(var(--rot)) scale(0.4);
}

.card.is-wrong { animation: nudge 0.22s var(--ease); }

@keyframes nudge {
  0%, 100% { transform: rotate(var(--rot)) translateX(0); }
  33% { transform: rotate(var(--rot)) translateX(-4px); }
  66% { transform: rotate(var(--rot)) translateX(4px); }
}

/* Zone layouts ------------------------------------------------------------ */

.board.layout-zones,
.board.layout-zones-tidy {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  gap: 8px;
  padding: 8px;
}

.zone {
  position: relative;
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  background: var(--panel);
  min-height: 0;
  transition: background 0.25s var(--ease), border-color 0.25s var(--ease);
}

.zone__label {
  position: absolute;
  top: 6px;
  left: 8px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 9px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--label);
  pointer-events: none;
  z-index: 2;
}

.zone.is-hint {
  background: rgba(0, 168, 144, 0.1);
  border-color: var(--green);
}
.zone.is-hint .zone__label { color: var(--green); }

.zone__cards {
  position: absolute;
  inset: 22px 8px 8px;
}

/* Tidied zones lay their cards out in neat rows instead of scattering them. */
.layout-zones-tidy .zone__cards {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: 4px 10px;
}
.layout-zones-tidy .card { position: relative; left: auto !important; top: auto !important; }

/* Flow layout ------------------------------------------------------------- */

.board.layout-flow {
  display: flex;
  flex-wrap: wrap;
  align-content: center;
  gap: 18px 26px;
  padding: 24px 32px;
}
.layout-flow .card { position: relative; left: auto !important; top: auto !important; }

/* ------------------------------------------------------------------ sheets */

.sheet {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(3px);
  overflow-y: auto;
}

.sheet[hidden] { display: none; }

.sheet__inner {
  animation: rise 0.24s var(--ease);
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: none; }
}

.panel {
  width: min(620px, 100%);
  background: var(--white);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  box-shadow: 0 8px 24px rgba(23, 71, 158, 0.1);
  padding: 40px 44px;
}

.panel--wide { width: min(860px, 100%); }

.kicker {
  margin: 0 0 6px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--label);
  padding-left: 12px;
  border-left: 4px solid var(--green);
}

.fiveS {
  margin: 0 0 4px;
  padding-left: 16px;
  font-family: var(--head);
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--cyan);
}

.h1 {
  margin: 0 0 14px;
  font-family: var(--head);
  font-weight: 700;
  font-size: clamp(28px, 3.4vw, 42px);
  line-height: 1.08;
  letter-spacing: -0.01em;
  text-transform: uppercase;
  color: var(--navy);
}

.dot { color: var(--green); }

.lead {
  margin: 0 0 14px;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
  font-weight: 500;
}

.body {
  margin: 0 0 14px;
  font-size: 15px;
  line-height: 1.62;
  color: var(--muted);
}

.delta {
  display: flex;
  align-items: center;
  gap: 10px;
  margin: 20px 0 24px;
  padding: 12px 14px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-radius: var(--radius);
  font-family: var(--head);
  font-weight: 600;
  font-size: 13px;
  color: var(--navy);
}

.tick {
  flex: none;
  width: 4px;
  height: 16px;
  background: var(--orange);
}

.lastscore {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: -8px 0 24px;
}
.lastscore__num {
  font-family: var(--head);
  font-weight: 700;
  font-size: 34px;
  color: var(--navy);
  line-height: 1;
}
.lastscore__label {
  font-family: var(--head);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--label);
}

/* ------------------------------------------------------- round-length control */

.timeset {
  margin: 0 0 26px;
  padding: 16px 18px 14px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--cyan);
  border-radius: var(--radius);
}

.timeset__head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.timeset__label {
  font-family: var(--head);
  font-weight: 700;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--label);
}

.timeset__value {
  font-family: var(--head);
  font-weight: 700;
  font-size: 26px;
  line-height: 1;
  color: var(--navy);
  font-variant-numeric: tabular-nums;
}
.timeset__value::after {
  content: "s";
  font-size: 15px;
  color: var(--label);
  margin-left: 1px;
}

.timeset__range {
  -webkit-appearance: none;
  appearance: none;
  display: block;
  width: 100%;
  margin: 12px 0 4px;
  background: none;
  cursor: pointer;
}
.timeset__range:focus-visible { outline: 2px solid var(--navy); outline-offset: 4px; }

/* --pct is set by paintSeconds() so the track fills up to the thumb. */
.timeset__range {
  --pct: 100%;
  --fill: linear-gradient(to right, var(--navy) 0 var(--pct), var(--hairline) var(--pct) 100%);
}

.timeset__range::-webkit-slider-runnable-track {
  height: 6px;
  border-radius: 999px;
  background: var(--fill);
}
.timeset__range::-moz-range-track {
  height: 6px;
  border-radius: 999px;
  background: var(--fill);
}

.timeset__range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 1px 3px rgba(23, 71, 158, 0.35);
  transition: transform 0.09s var(--ease);
}
.timeset__range::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border: 3px solid var(--white);
  border-radius: 50%;
  background: var(--navy);
  box-shadow: 0 1px 3px rgba(23, 71, 158, 0.35);
}
.timeset__range:active::-webkit-slider-thumb { transform: scale(1.12); }

.timeset__scale {
  display: flex;
  justify-content: space-between;
  font-family: var(--head);
  font-weight: 600;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--label);
}

.timeset__note {
  margin: 10px 0 0;
  font-size: 12.5px;
  line-height: 1.55;
  color: var(--muted);
}

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

.btn {
  display: inline-block;
  font-family: var(--head);
  font-weight: 600;
  font-size: 15px;
  padding: 13px 26px;
  border: 1px solid var(--navy);
  border-radius: var(--radius);
  background: var(--navy);
  color: var(--white);
  text-decoration: none;
  cursor: pointer;
  transition: background 0.18s var(--ease), transform 0.09s var(--ease);
}
.btn:hover { background: #143f8c; }
.btn:active { transform: scale(0.98); }
.btn:focus-visible { outline: 2px solid var(--navy); outline-offset: 2px; }

.btn--ghost { background: var(--white); color: var(--navy); }
.btn--ghost:hover { background: var(--panel); }

.hint {
  margin: 12px 0 0;
  font-size: 13px;
  color: var(--label);
}

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

.chart {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  height: 190px;
  margin: 26px 0 10px;
  padding-bottom: 4px;
}

.col {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  height: 100%;
  gap: 6px;
}

.col__num {
  font-family: var(--head);
  font-weight: 700;
  font-size: 17px;
  color: var(--navy);
  line-height: 1;
}

.col__bar {
  width: 100%;
  background: var(--navy);
  border-radius: 3px 3px 0 0;
  min-height: 3px;
  transition: height 0.7s var(--ease);
}

.col--peak .col__bar { background: var(--green); }
.col--peak .col__num { color: var(--green); }
.col--drop .col__bar { background: var(--red); }
.col--drop .col__num { color: var(--red); }

.col__label {
  font-family: var(--head);
  font-weight: 700;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--label);
  text-align: center;
  line-height: 1.3;
  min-height: 26px;
}

.takeaways {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin: 22px 0 26px;
}

.takeaway {
  padding: 16px 18px;
  background: var(--panel);
  border: 1px solid var(--hairline);
  border-left: 4px solid var(--green);
  border-radius: var(--radius);
}
.takeaway--warn { border-left-color: var(--red); }

.takeaway__num {
  margin: 0 0 4px;
  font-family: var(--head);
  font-weight: 700;
  font-size: 32px;
  line-height: 1;
  color: var(--navy);
}
.takeaway--warn .takeaway__num { color: var(--red); }

.takeaway__label {
  margin: 0;
  font-family: var(--head);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--label);
  line-height: 1.4;
}

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 26px 0 0;
}

.credit {
  margin: 26px 0 0;
  padding-top: 18px;
  border-top: 1px solid var(--hairline);
  font-size: 12px;
  line-height: 1.6;
  color: var(--label);
}

/* ------------------------------------------------------------ small screen */

.smallscreen {
  display: none;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 60;
  margin: 0;
  padding: 10px 16px;
  background: var(--navy);
  color: var(--white);
  font-size: 12.5px;
  text-align: center;
}

@media (max-width: 760px) {
  .smallscreen { display: block; }
  .bar { padding: 10px 14px; gap: 12px; }
  .bar__status { display: none; }
  .bar__timer { min-width: 130px; }
  .stage { padding: 10px 12px 8px; }
  .panel { padding: 26px 22px; }
  .takeaways { grid-template-columns: 1fr; }
  .chart { height: 140px; gap: 5px; }
  .col__label { font-size: 8px; letter-spacing: 0.04em; }
}

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

.btn[disabled] { opacity: 0.55; cursor: default; }
