@font-face {
  font-family: "Montserrat";
  src: url("fonts/Montserrat-Regular.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Noto Sans";
  src: url("fonts/NotoSans-Regular.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "OpenDyslexic";
  src: url("fonts/OpenDyslexic-Regular.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Space Mono";
  src: url("fonts/SpaceMono-Regular.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Atkinson Hyperlegible";
  src: url("fonts/Atkinson-Hyperlegible-Regular.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

.modal input,
.modal textarea {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
}

.modal,
.modalRow,
.modal * {
  min-width: 0;
}


:root {
  --bg: #000;
  --fg: #fff;
  --red: #ff2a2a;
  --panel: rgba(0,0,0,0.55);
  --border: rgba(255,255,255,0.18);
  --accent: rgba(255,255,255,0.85);
  --track: rgba(255,255,255,0.20);
}

[data-theme="light"] {
  --bg: #fff;
  --fg: #000;
  --red: #ff2a2a;
  --panel: rgba(255,255,255,0.70);
  --border: rgba(0,0,0,0.18);
  --accent: rgba(0,0,0,0.85);
  --track: rgba(0,0,0,0.18);
}

/* Theme modal inputs */
.themeGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

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

.themeRow label {
  font-size: 13px;
  font-weight: 650;
  opacity: 0.9;
}

.themeRow input[type="color"] {
  width: 56px;
  height: 44px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: transparent;
  padding: 0;
}

.themeRow input[type="text"] {
  width: 140px;
  max-width: 100%;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
}

@media (max-width: 520px) {
  .themeRow input[type="text"] { width: 100%; }
}


html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow: hidden;
}

body[data-theme="dark"] { color-scheme: dark; }
body[data-theme="light"] { color-scheme: light; }

canvas {
  width: 100vw;
  height: 100vh;
  display: block;
}

/* ===== Progress (TOP) ===== */
.progressWrap {
  position: fixed;
  top: calc(8px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  width: min(1100px, calc(100vw - 18px));
  padding: 8px 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  backdrop-filter: blur(10px);
  z-index: 10;
}

.progressTopRow {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  font-weight: 650;
}

.progressBar {
  height: 6px;
  margin-top: 6px;
  background: var(--track);
  border-radius: 999px;
  overflow: hidden;
  cursor: pointer;
}

.progressBar:focus {
  outline: 2px solid var(--border);
  outline-offset: 3px;
}

.progressFill {
  height: 100%;
  width: 0%;
  background: var(--accent);
}

/* ===== One-time tip bubble (progress scrub discoverability) ===== */
/* TIP: remove this section after the first week if you want */
.tipBubble {
  position: absolute;
  top: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: min(520px, calc(100vw - 26px));
  backdrop-filter: blur(10px);
  z-index: 30;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

.tipBubble::before {
  content: "";
  position: absolute;
  top: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-bottom: 8px solid var(--panel);
}

.tipBubble::after {
  content: "";
  position: absolute;
  top: -9px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 9px solid transparent;
  border-right: 9px solid transparent;
  border-bottom: 9px solid var(--border);
  z-index: -1;
}

.tipText {
  font-size: 13px;
  font-weight: 750;
  line-height: 1.2;
  color: var(--fg);
}

.tipClose {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  border-radius: 10px;
  padding: 6px 8px;
  min-height: unset;
  font-weight: 850;
  cursor: pointer;
}

.tipClose:hover { opacity: 0.9; }
.tipClose:focus { outline: 2px solid var(--border); outline-offset: 2px; }

@media (max-width: 520px) {
  .tipBubble { left: 50%; transform: translateX(-50%); }
}
/* /TIP */

/* ===== Controls (BOTTOM) ===== */
.controls {
  position: fixed;
  bottom: calc(12px + env(safe-area-inset-bottom));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  width: fit-content;
  max-width: calc(100vw - 18px);
  justify-content: center;

}

.playbackRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.playBtn {
  min-width: unset;
}

button, select {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 650;
  cursor: pointer;
  min-height: 44px;
}

button:disabled { opacity: .5; cursor: not-allowed; }

.wpm {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  justify-content: center;
  flex-wrap: wrap;
}

.utilityRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  flex-wrap: wrap;
}

.wpmCore {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}

#wpmLabel { cursor: pointer; font-weight: 750; }

#wpmInput {
  display: none;
  width: 90px;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
}

input[type="range"] { width: 160px; }

/* ===== Modal ===== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 18px;
}

.modal {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 14px;
  width: min(720px, 96vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

textarea {
  width: 100%;
  min-height: 220px;
  resize: vertical;
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
}

.modalRow {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  flex-wrap: wrap;
}

#statusLine, #feedbackStatus {
  font-size: 12px;
  opacity: .8;
}

#feedbackLink {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 20;

  color: var(--fg);
  opacity: 0.72;
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;

  padding: 8px 10px;
  border-radius: 12px;
  background: transparent;
}

#supportLink {
  position: fixed;
  left: calc(12px + env(safe-area-inset-left));
  bottom: calc(10px + env(safe-area-inset-bottom));
  z-index: 20;

  color: var(--fg);
  opacity: 0.72;
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;

  padding: 8px 10px;
  border-radius: 12px;
  background: transparent;
}

#supportLink:hover { opacity: 0.95; }

#supportLink:focus {
  outline: 2px solid var(--border);
  outline-offset: 2px;
}

/* Anchor styled like a button (used in the Support modal) */
.buttonLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  padding: 10px 12px;
  border-radius: 12px;
  font-weight: 650;
  min-height: 44px;
  text-decoration: none;
}

.buttonLink:hover { opacity: 0.95; }
.buttonLink:focus { outline: 2px solid var(--border); outline-offset: 2px; }

#feedbackLink:hover {
  opacity: 0.95;
}

#feedbackLink:focus {
  outline: 2px solid var(--border);
  outline-offset: 2px;
}


/* Ensure hidden attribute always hides elements */
[hidden]{display:none !important;}


/* Icon-style buttons */
/* Icon-only button (play / pause) */
.icon-btn {
  padding: 0.35rem;
  width: auto;
  min-width: unset;
  height: auto;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  
}
/* External SVG images inside icon buttons */
.icon-btn .icon-img {
  width: 1.25em;
  height: 1.25em;
  display: block;
  object-fit: contain;
}
.icon-btn span{display:inline-block;width:1.2em;text-align:center;}
.settings-btn {
  font-size: 1.5rem;
}
.modal {
  position: relative; /* IMPORTANT: makes the X anchor to the modal box */
}

.modalCloseX {
  position: absolute;
  top: 12px;
  right: 12px;

  background: none;
  border: none;
  padding: 0;

  font-size: 22px;
  line-height: 1;

  cursor: pointer;
}

.modalRowCenter {
  display: flex;
  justify-content: center;
  margin-top: 16px;
}

/* Ensures the "Support" link sizes nicely like a button */
#supportAction.buttonLink {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: auto;
  line-height: normal;
}
.mask-back-icon,
.mask-forward-icon {
  position: relative;
  width: 44px;
  height: 44px;
  padding: 0;
}

/* Icon layer */
.mask-back-icon::before,
.mask-forward-icon::before {
  content: "";
  position: absolute;
  inset: 0;

  background-color: var(--fg);

  -webkit-mask-repeat: no-repeat;
  -webkit-mask-position: center;
  -webkit-mask-size: 60%;
  mask-repeat: no-repeat;
  mask-position: center;
  mask-size: 60%;
}

/* Individual icons */
.mask-back-icon::before {
  -webkit-mask-image: url("icons/back30.svg");
  mask-image: url("icons/back30.svg");
}

.mask-forward-icon::before {
  -webkit-mask-image: url("icons/forward30.svg");
  mask-image: url("icons/forward30.svg");
}

.progressBottomRow {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

#helpLink {
  color: var(--fg);
  opacity: 0.72;
  font-size: 12px;
  font-weight: 650;
  text-decoration: underline;
  cursor: pointer;

  padding: 6px 8px;
  border-radius: 12px;
  background: transparent;
}

#helpLink:hover { opacity: 0.95; }

#helpLink:focus {
  outline: 2px solid var(--border);
  outline-offset: 2px;
}
/* Mobile control re-ordering */
@media (max-width: 520px) {
  .controls {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 10px 8px;
    width: calc(100vw - 18px);
    justify-items: center;
    align-items: center;
  }

  /* Let children participate directly in the .controls grid */
  .playbackRow,
  .wpm {
    display: contents;
  }

  /* Row 1: -30 | back one | play/pause | forward one | +30 */
  #back30Btn { grid-row: 1; grid-column: 1; }
  #backBtn   { grid-row: 1; grid-column: 2; }
  #playBtn   { grid-row: 1; grid-column: 3; }
  #fwdBtn    { grid-row: 1; grid-column: 4; }
  #fwd30Btn  { grid-row: 1; grid-column: 5; }

  /* Row 2: reset | set text | settings */
#resetBtn {
  grid-row: 2;
  grid-column: 2;
}

#textBtn {
  grid-row: 2;
  grid-column: 3; /* exact middle */
  justify-self: center;
}

#settingsBtn {
  grid-row: 2;
  grid-column: 4;
}

/* Row 3: centered WPM label + slider on one line */
.wpmCore {
  grid-row: 3;
  grid-column: 1 / 6;

  display: flex;
  flex-direction: row;      /* same row */
  align-items: center;      /* vertical alignment */
  justify-content: center;  /* center as a group */
  gap: 10px;

  width: 100%;
  min-width: 0;
  padding-bottom: 16px;
}

/* Slider width tuned for mobile */
.wpmCore input[type="range"] {
  width: min(260px, 75%);
}

}
