/* latin-ext */
@font-face {
  font-family: 'Bebas Neue';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./fonts/bebas-0.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'Bebas Neue';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./fonts/bebas-1.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(./fonts/dm-mono-2.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 300;
  font-display: swap;
  src: url(./fonts/dm-mono-3.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./fonts/dm-mono-4.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url(./fonts/dm-mono-5.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
/* latin-ext */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./fonts/dm-mono-6.woff2) format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
/* latin */
@font-face {
  font-family: 'DM Mono';
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url(./fonts/dm-mono-7.woff2) format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  /* High-contrast backgrounds for readability */
  --bg-app:   #131212;   /* Near-Black (Reduces screen glare) */
  --bg-card:  #161618;   /* Subtle Elevation */

  /* The 2001 Moby Accents */
  --up:       #00b9b9;   /* Electric Cyan (Maximum peripheral visibility) */
  --down:     #ffb000;   /* Safety Amber (Distinct from Cyan in peripheral vision) */
  --hold:     #b01d1d;   /* must sustain the position */
  --dead:     #c800e7;   /* Dead-Stop: coming to a full rest (not death/give-up) */
  --death:    #ff003c;   /* Tapped Out: giving up on the challenge */
  --start:    #00d400;   /* Moby Go: Vivid Phosphor Green for primary actions */
  --rest:     #444446;   /* Dimmed Slate (Visual 'Quiet' time) */

  --bg:      var(--bg-app);
  --surface: var(--bg-card);
  --border:  #2a2a2c;
  --text:    #ffffff;
  --muted:   #8a8a8c;
  --muted2:  #555557;

  /* Difficulty colors */
  --diff-easy-bg: rgba(0, 255, 255, 0.15);
  --diff-easy-fg: var(--up);
  --diff-med-bg:  rgba(255, 176, 0, 0.15);
  --diff-med-fg:  var(--down);
  --diff-hard-bg: rgba(255, 0, 60, 0.15);
  --diff-hard-fg: var(--dead);
}

/* Enforce the new high-contrast palette everywhere */
:root[data-theme="dark"],
:root[data-theme="light"] {
  --bg: var(--bg-app);
  --surface: var(--bg-card);
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: var(--bg-app);
    --surface: var(--bg-card);
  }
}

/* Theme Toggle Button */
.theme-toggle {
  display: none !important;
  position: absolute;
  top: 16px;
  right: 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  color: var(--text);
  transition: background 0.15s, border-color 0.15s;
  z-index: 100;
}
.theme-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--muted);
}

/* Info Toggle Button */
.info-toggle {
  position: absolute;
  top: 16px;
  left: 16px;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-family: sans-serif;
  cursor: pointer;
  color: var(--muted);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  z-index: 100;
}
.info-toggle:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: var(--muted);
  color: var(--text);
}

/* Accessibility Skip Link */
.skip-link {
  position: absolute;
  top: -40px;
  left: 0;
  background: var(--surface);
  color: var(--text);
  padding: 8px;
  z-index: 1000;
  transition: top 0.2s;
}
.skip-link:focus {
  top: 0;
}

html, body {
  overflow-x: hidden;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: max(24px, env(safe-area-inset-top)) max(24px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(24px, env(safe-area-inset-left));
  transition: background 0.3s, color 0.3s;
}

h1 {
  font-family: 'Teko', sans-serif;
  font-size: clamp(2.5rem, 8vw, 4rem);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  text-align: center;
  line-height: 0.9;
  margin-bottom: 10px;
}
.subtitle {
  font-size: 0.8rem;
  color: var(--text);
  letter-spacing: 0.15em;
  text-align: center;
  margin-bottom: 24px;
  text-transform: uppercase;
  padding: 0 16px;
}

.app-wrap {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  flex-grow: 1;
  position: relative;
  z-index: 10; /* Above atmosphere, below fixed overlays like fin-overlay */
}
.app-wrap > * {
  min-width: 0;
}
main {
  width: 100%;
  min-width: 0;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

/* TAB NAV */
.tab-nav {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 24px;
  width: 100%;
}
.tab-btn {
  flex: 1;
  padding: 14px 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: transparent;
  color: var(--muted);
  border: none;
  border-right: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.15s;
  font-weight: 600;
}
.tab-btn:last-child { border-right: none; }
.tab-btn[aria-selected="true"] { background: rgba(255, 255, 255, 0.08); color: var(--text); }

/* PANELS */
.panel { display: none; width: 100%; flex-direction: column; align-items: stretch; flex-grow: 1; }
.panel.active { display: flex; }

/* LAYOUT SECTIONS */
.bottom-section {
  position: relative;
  z-index: 11;
  background: var(--bg);
  /* Expand full width outside wrapping 540px constraint */
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  padding-left: calc(50vw - 50%);
  padding-right: calc(50vw - 50%);
  /* Stretch to bottom padding */
  margin-bottom: calc(-1 * max(32px, env(safe-area-inset-bottom)));
  padding-bottom: max(32px, env(safe-area-inset-bottom));
  padding-top: 16px;
  flex-grow: 1;
  transition: background 0.3s, color 0.3s;
}

/* COMMAND BOX */
.cmd-box {
  width: 100%;
  min-height: 140px;
  padding: 16px;
  border-radius: 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(22, 22, 24, 0.85); /* Slightly translucent to show background effects */
  border: 2px solid var(--border);
  margin-bottom: 16px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.15);
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, background 0.3s;
}
.cmd-box::before {
  content: '';
  position: absolute;
  inset: 0;
  opacity: 0.1;
  transition: background 0.2s;
  pointer-events: none;
}
.cmd-label {
  font-family: 'Teko', sans-serif;
  font-size: clamp(3rem, 15vw, 5.5rem);
  line-height: 0.8;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--muted);
  transition: all 0.2s;
  text-align: center;
  width: 100%;
  padding: 0 10px;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cmd-sub {
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text);
  margin-top: 10px;
  text-align: center;
  padding: 0 20px;
}

/* State theming without !important by increasing specificity */
.cmd-box.s-up    { border-color: var(--up);   box-shadow: inset 0 0 15px rgba(0, 255, 255, 0.1); }
.cmd-box.s-down  { border-color: var(--down); box-shadow: inset 0 0 15px rgba(255, 176, 0, 0.1); }
.cmd-box.s-hold  { border-color: var(--hold); box-shadow: inset 0 0 15px rgba(255, 255, 255, 0.1); }
.cmd-box.s-dead  { border-color: var(--dead); box-shadow: inset 0 0 15px rgba(255, 0, 60, 0.1); }
.cmd-box.s-rest  { border-color: var(--rest); }

.cmd-box.s-up    .cmd-label { color: var(--up);   text-shadow: 0 0 15px rgba(0, 255, 255, 0.6); }
.cmd-box.s-down  .cmd-label { color: var(--down); text-shadow: 0 0 15px rgba(255, 176, 0, 0.6); }
.cmd-box.s-hold  .cmd-label { color: var(--hold); text-shadow: 0 0 15px rgba(255, 255, 255, 0.6); }
.cmd-box.s-dead  .cmd-label { color: var(--dead); text-shadow: 0 0 15px rgba(255, 0, 60, 0.6); }
.cmd-box.s-rest  .cmd-label { color: var(--rest); }
.cmd-box.s-up::before    { background: var(--up);   }
.cmd-box.s-down::before  { background: var(--down); }
.cmd-box.s-hold::before  { background: var(--hold); }
.cmd-box.s-dead::before  { background: var(--dead); }
.cmd-box.s-rest::before  { background: var(--rest); }

/* COUNTDOWN BAR */
.cdown-wrap { width: 100%; margin-bottom: 5px; }
.cdown-track {
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
}
.cdown-fill {
  height: 100%;
  width: 100%;
  border-radius: 2px;
  transform-origin: left;
  background: var(--muted);
  transition: transform 0.1s linear, background 0.2s;
}
.next-lbl {
  font-size: 0.75rem;
  color: var(--text);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-align: right;
  margin-top: 4px;
  height: 14px;
}

/* PROGRESS BAR & MAIN TEXT */
.pct-wrap {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  margin: 10px 0 12px 0;
  width: 100%;
}
.main-pct {
  grid-column: 2;
  font-family: 'Teko', sans-serif;
  font-size: clamp(4rem, 15vw, 6rem);
  color: var(--text);
  line-height: 0.85;
  text-align: center;
  letter-spacing: 2px;
  text-transform: uppercase;
  padding: 0 10px;
}
.pct-highscore-wrap {
  grid-column: 3;
  display: flex;
  align-items: center;
  padding-left: 15px;
  padding-bottom: 22px;
  gap: 8px;
}
.pct-highscore {
  font-size: 1.1rem;
  color: var(--up);
  letter-spacing: 0.1em;
  font-weight: 700;
  opacity: 0.9;
}
.btn-hs-reset {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s;
  font-size: 1rem;
  line-height: 1;
}
.btn-hs-reset:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  border-color: var(--muted);
}
.prog-track {
  width: calc(100% - 10px);
  margin: 0 auto 16px auto;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
  position: relative;
}
.prog-fill {
  height: 100%;
  width: 0%;
  background: var(--up);
  border-radius: 2px;
  transition: width 0.4s linear;
}

/* TIMER ROW */
.timer-row {
  display: flex;
  justify-content: space-between;
  width: 100%;
  margin-bottom: 10px;
}
.t-block { display: flex; flex-direction: column; align-items: center; position: relative; }
.t-val {
  font-family: 'Teko', sans-serif;
  font-size: clamp(2rem, 10vw, 2.8rem);
  letter-spacing: 1px;
  line-height: 0.8;
  color: var(--text);
  text-transform: uppercase;
}
.t-lbl {
  font-size: 0.7rem;
  color: var(--muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  margin-top: 5px;
  padding: 0 4px;
}

/* REP DOTS */
.rep-row {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: center;
  margin-bottom: 12px;
  width: 100%;
}
.rdot {
  width: 13px; height: 13px;
  border-radius: 50%;
  background: var(--border);
  transition: background 0.2s, transform 0.15s;
}
.rdot.done    { background: var(--up); }
.rdot.current { background: var(--hold); transform: scale(1.4); }

/* SEQUENCE TRACK */
.seq-wrap { width: 100%; margin-bottom: 12px; position: relative;}
.seq-title {
  font-size: 0.7rem;
  letter-spacing: 0.15em;
  color: var(--text);
  text-transform: uppercase;
  margin-bottom: 10px;
  padding: 0 4px;
}
.seq-track {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  padding: 12px 10px;
  scroll-behavior: smooth;
}
.seq-track::-webkit-scrollbar { height: 3px; }
.seq-track::-webkit-scrollbar-thumb { background: var(--muted2); border-radius: 2px; }
.sblk {
  height: 26px;
  border-radius: 3px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.62rem;
  letter-spacing: 0.04em;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.35;
  transition: opacity 0.25s, transform 0.2s;
  color: #000;
  padding: 0 4px;
  min-width: 24px;
  overflow: hidden;
}
.sblk.t-up   { background: var(--up); }
.sblk.t-down { background: var(--down); }
.sblk.t-hold { background: var(--hold); }
.sblk.t-dead { background: var(--dead); color: #ffffff; }
.sblk.t-rest { background: var(--rest); }
.sblk.active { opacity: 1; transform: scaleY(1.25); box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text); }
.sblk.passed { opacity: 0.25; }

/* BUTTONS */
.btn-row { display: flex; gap: 10px; margin-top: 4px; margin-bottom: 4px; flex-wrap: wrap; justify-content: center;}
.btn {
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.82rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  padding: 13px 28px;
  border-radius: 4px;
  border: 1px solid;
  cursor: pointer;
  transition: opacity 0.15s, border-color 0.15s, color 0.15s, background 0.15s;
}
.btn-go   { 
  background: var(--start); 
  color: #000; 
  border-color: var(--start); 
  width: 100%;
  max-width: 440px;
  font-size: 1.1rem;
  padding: 18px 24px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(0, 212, 0, 0.2);
}
.btn-go:hover { background: #00b000; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0, 212, 0, 0.4); }
.btn-go:active { transform: translateY(0); }
.btn-go:disabled { opacity: 0.3; cursor: default; transform: none; box-shadow: none; }

.btn-pause { background: var(--rest); color: #fff; border-color: var(--border); }
.btn-pause:hover { background: var(--muted2); }
.btn-pause:disabled { opacity: 0.3; cursor: default; }

.death-row, .go-row { 
  width: 100%; 
  margin-bottom: 12px; 
  display: flex;
  justify-content: center;
}
.btn-death { 
  background: var(--death); 
  color: #fff; 
  border-color: var(--death); 
  width: 100%;
  max-width: 440px;
  font-size: 1.1rem;
  padding: 18px 24px;
  font-weight: 700;
  box-shadow: 0 4px 15px rgba(255, 0, 60, 0.2);
}
.btn-death:hover { background: #d70032; transform: translateY(-2px); box-shadow: 0 6px 20px rgba(255, 0, 60, 0.4); }
.btn-death:active { transform: translateY(0); }

.btn-off  { background: transparent; color: var(--text); border-color: var(--border); font-weight: 600; }
.btn-off:hover { border-color: var(--muted); color: var(--text); }

/* DRILL GRID */
.drill-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  margin-bottom: 24px;
}
.dcard {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 16px;
  cursor: pointer;
  background: rgba(22, 22, 24, 0.9);
  transition: border-color 0.15s, background 0.3s;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.dcard:hover { border-color: var(--muted); }
.dcard.sel { border-color: var(--up); background: rgba(0, 255, 255, 0.05); }
@media (prefers-color-scheme: light) {
  .dcard.sel { background: #fffbeb; }
}
.dcard.sel .dcard-title { color: inherit; }
.dcard.sel .dcard-desc { opacity: 0.8; }
.dcard-title {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.25rem;
  letter-spacing: 0.06em;
  margin-bottom: 5px;
}
.dcard-desc { font-size: 0.7rem; color: var(--text); letter-spacing: 0.05em; line-height: 1.6; }
.diff {
  display: inline-block;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  padding: 2px 7px;
  border-radius: 2px;
  text-transform: uppercase;
  margin-top: 5px;
}
.diff-1 { background: var(--diff-easy-bg); color: var(--diff-easy-fg); }
.diff-2 { background: var(--diff-med-bg); color: var(--diff-med-fg); }
.diff-3 { background: var(--diff-hard-bg); color: var(--diff-hard-fg); }

/* CONFIG PANEL */
.cfg-panel {
  width: 100%;
  background: rgba(22, 22, 24, 0.9);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 16px 20px;
  margin-bottom: 14px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
  transition: background 0.3s;
}
.cfg-title {
  font-size: 0.74rem;
  letter-spacing: 0.14em;
  color: var(--text);
  text-transform: uppercase;
  margin-bottom: 13px;
}
.cfg-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 9px;
}
.cfg-row:last-child { margin-bottom: 0; }
.cfg-lbl { font-size: 0.8rem; color: var(--text); letter-spacing: 0.05em; font-weight: 500; }
.cfg-val { font-family: 'Teko', sans-serif; font-size: 2.5rem; color: var(--up); min-width: 45px; text-align: center; line-height: 1; }
.stepper { display: flex; align-items: center; gap: 8px; }
.step-btn {
  width: 34px; height: 34px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--border);
  color: var(--text);
  font-weight: 700;
  font-size: 1.2rem;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: border-color 0.15s, background 0.3s;
  font-family: 'Share Tech Mono', monospace;
}
.step-btn:hover { border-color: var(--muted); }

/* SET PIPS */
.pip-row {
  display: flex; gap: 6px; flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 14px;
  width: 100%;
}
.pip {
  width: 32px; height: 7px;
  border-radius: 4px;
  background: var(--border);
  transition: background 0.2s;
}
.pip.done   { background: var(--up); }
.pip.active { background: var(--hold); }

/* LEGEND */
.legend {
  display: flex; gap: 12px; flex-wrap: wrap;
  justify-content: center;
  margin-bottom: 14px;
  width: 100%;
}
.leg-item { display: flex; align-items: center; gap: 5px; font-size: 0.72rem; color: var(--text); letter-spacing: 0.07em; text-transform: uppercase; }
.leg-dot { width: 11px; height: 11px; border-radius: 50%; flex-shrink: 0; }

.pause-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 2; /* Atmospheric layer, above flash but below UI */
  background: repeating-linear-gradient(
    -45deg,
    transparent,
    transparent 80px,
    rgba(255, 255, 255, 0.15) 80px,
    rgba(255, 255, 255, 0.2) 160px
  );
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.pause-overlay.show {
  display: block;
  opacity: 1;
}

/* FLASH — full-screen brutal cue visible across a noisy gym */
.flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 1;         /* Background atmosphere layer */
  mix-blend-mode: normal;
}

/* Punch hard on cue change, then vanish so the UI stays crisp */
@keyframes flashOut {
  0%   { opacity: 0.85; }
  30%  { opacity: 0.60; }   /* stays punchy for ~150ms */
  100% { opacity: 0; }      /* vanishes to let the body BG shine through clearly */
}

/* SHIFT FLASH — hard, white, short flash over the UI */
.shift-flash {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 3; /* Just above pause-overlay, but below app-wrap (z-index 10) so the bottom section covers it */
  background: #ffffff;
}

@keyframes shiftFlashOut {
  0%   { opacity: 1; }
  100% { opacity: 0; }
}

/* Ensure UI elements remain highly legible when the background is intensely coloured */
body[class*="flash-"] {
  --text: #ffffff;
  --muted: rgba(255, 255, 255, 0.85);
  --muted2: rgba(255, 255, 255, 0.6);
  --border: rgba(255, 255, 255, 0.25);
  --surface: rgba(0, 0, 0, 0.25); 
  --surface2: rgba(0, 0, 0, 0.15);
}

/* Revert text and background styling specifically for the visually isolated bottom UI section */
body[class*="flash-"] .bottom-section {
  --text: var(--base-text);
  --muted: var(--base-muted);
  --muted2: var(--base-muted2);
  --border: var(--base-border);
  --surface: var(--base-surface);
  --surface2: var(--base-surface2);
}

/* Body-level background flash using theme variables instead of hardcoded colours */
body.flash-up   { background: var(--up) !important; transition: background 0s !important; }
body.flash-down { background: var(--down) !important; transition: background 0s !important; }
body.flash-hold { background: var(--hold) !important; transition: background 0s !important; }
body.flash-dead { background: var(--dead) !important; transition: background 0s !important; }
body.flash-rest { background: var(--rest) !important; transition: background 0s !important; }

/* In flash mode, force monochromatic stark white/translucent accents for highest possible contrast */
body[class*="flash-"] .cmd-box[class*="s-"] { border-color: var(--border); }
body[class*="flash-"] .cmd-box[class*="s-"]::before { background: var(--text); opacity: 0.05; }
body[class*="flash-"] .cmd-box[class*="s-"] .cmd-label { color: var(--text); }
body[class*="flash-"] .prog-fill { background: var(--text); box-shadow: 0 0 8px rgba(255,255,255,0.4); }
body[class*="flash-"] .pct-highscore { color: var(--text); }

body[class*="flash-"] .rdot.done,
body[class*="flash-"] .rdot.current {
    background: var(--text);
    box-shadow: 0 0 6px rgba(255,255,255,0.4);
}

/* FINISH OVERLAY */
.fin-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.98);
  z-index: 200;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
}
.fin-overlay.show { display: flex; }
.fin-title {
  font-family: 'Teko', sans-serif;
  font-size: clamp(4rem, 12vw, 8rem);
  letter-spacing: 2px;
  line-height: 0.9;
  text-transform: uppercase;
  margin-bottom: 8px;
}
.fin-sub { font-size: 0.85rem; color: var(--muted); letter-spacing: 0.12em; margin-bottom: 24px; text-transform: uppercase;}
.fin-stats { display: flex; gap: 24px; margin-bottom: 24px; flex-wrap: wrap; justify-content: center; }
.fin-stat { display: flex; flex-direction: column; align-items: center; }
.fin-stat-val { font-family: 'Teko', sans-serif; font-size: 4rem; color: var(--up); line-height: 1; }
.fin-stat-lbl { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.1em; text-transform: uppercase;}

/* UPDATE TOAST */
.update-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--surface);
  border: 1px solid var(--up);
  padding: 16px 20px;
  border-radius: 8px;
  z-index: 2000;
  display: flex;
  align-items: center;
  gap: 20px;
  box-shadow: 0 4px 20px rgba(0, 185, 185, 0.2);
}
.update-toast-txt {
  font-family: 'Share Tech Mono', monospace;
  color: var(--up);
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  white-space: nowrap;
}
.update-btn {
  padding: 10px 16px;
  font-size: 1rem;
  min-width: 100px;
}
