:root {
  --bg: #0a0a0a;
  --fg: #ffffff;
  --accent: #7dd3fc;
  --muted: #9ca3af;
  --danger: #ef4444;
}
[data-theme="light"] {
  --bg: #ffffff;
  --fg: #000000;
  --accent: #2563eb;
  --muted: #6b7280;
  --danger: #dc2626;
}
html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Apple Color Emoji","Segoe UI Emoji", "Segoe UI Symbol";
}
.wrap {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100%;
}
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  gap: 10px;
  user-select: none;
}
footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 10px 14px;
  gap: 8px;
  user-select: none;
}
.footer-logo {
  height: 1em;
  max-height: 40px;
  width: auto;
  vertical-align: middle;
  margin-left: 6px;
}
[data-theme="dark"] [data-theme-logo="light"] { display: none; }
[data-theme="light"] [data-theme-logo="dark"] { display: none; }

.hud {
  display: flex;
  gap: 14px;
  align-items: center;
  flex-wrap: wrap;
}
.pill {
  padding: 6px 10px;
  border: 1px solid color-mix(in oklab, var(--fg) 18%, transparent);
  border-radius: 999px;
  font-weight: 600;
  font-size: 14px;
}
.btn {
  border: 1px solid color-mix(in oklab, var(--fg) 18%, transparent);
  background: color-mix(in oklab, var(--fg) 6%, transparent);
  color: var(--fg);
  border-radius: 10px;
  padding: 8px 12px;
  font-weight: 700;
  cursor: pointer;
  font-size: 14px;
  transition: transform .08s ease, background .2s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn.primary {
  border-radius: 12px;
  background: linear-gradient(135deg, #8AA9FF, #B583FF);
  color: #0a0d13;
  border: none;
}
.btn.ghost { background: transparent; }
.btn.selected {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--accent);
}
.btn.pause {
  background: transparent;
  /* color: #ff6666;
  border-color: #ff6666; */
}
.btn.resume {
  background: transparent;
  /* color: #16a34a; -->
  border-color: #16a34a; */
}
.btn.reset {
  color: #ff6666;
  border: 1px solid #ff6666;
}
.btn:disabled {
  background: color-mix(in oklab, var(--fg) 10%, transparent);
  color: var(--muted);
  border-color: color-mix(in oklab, var(--fg) 10%, transparent);
  cursor: not-allowed;
  opacity: 0.6;
}
.btn.home {
  background: transparent;
  border: 1px solid #8AA9FF;
  color: #8AA9FF;
}
.canvas-wrap {
  position: relative;
  overflow: hidden;
}
canvas {
  display: block;
  width: 100%;
  height: 100%;
  max-width: 1200px;
  max-height: 800px;
  margin: 0 auto;
  touch-action: none; /* we handle taps */
  cursor: crosshair;
  background: var(--bg);
}
.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in oklab, var(--bg) 60%, transparent);
  backdrop-filter: blur(2px);
}

.card {
  background: color-mix(in oklab, var(--bg) 85%, var(--fg) 8%);
  border: 1px solid color-mix(in oklab, var(--fg) 14%, transparent);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 8px 32px color-mix(in oklab, black 35%, transparent);
}
.row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
small.muted { color: var(--muted); }

#playBtn {
  font-size: 1.25rem;   /* bigger text */
  padding: 14px 28px;  /* more button padding */
}

#stats {
  font-size: 0.95em;
  margin: 8px 0 18px; /* add bottom space before difficulty buttons */
  line-height: 1.35;
  text-align: center;
}
.overlay .card #stats { margin-bottom: 18px; }

.pill.time-warning { 
  color: var(--danger, #ff4d4f);
  /* optional, if your pill has a border/background: */
  /* border-color: var(--danger, #ff4d4f); */
}

@media (max-width: 480px) {
  .btn { padding: 10px 14px; font-size: 15px; }
}
[hidden] { display: none !important; }

/* --- Help modal --- */
.modal[hidden] { display: none !important; }

.modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,0.25);           /* subtle backdrop */
  z-index: 1000;
}

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  padding: 14px 16px;
  border-radius: 12px;
  background: rgba(20,24,33,0.6);         /* translucent panel */
  border: 1px solid rgba(255,255,255,0.12);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  box-sizing: border-box;
}

/* close (X) button */
.icon-btn.close {
  position: absolute;
  top: 8px;
  right: 8px;
  border: none;
  background: transparent;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #fff;
  opacity: 0.8;
}
.icon-btn.close:hover { opacity: 1; }

/* tidy list */
.help-list {
  margin: 0 0 10px;
  padding-left: 18px;
}
.help-list li {
  line-height: 1.6;
  margin-bottom: 6px; /* adds extra gap between list items */
}

/* === Responsive HUD layout improvements === */
.hud { display: flex; gap: 8px; align-items: center; justify-content: center; }
.hud .pill { white-space: nowrap; }
.hud .pill span { font-variant-numeric: tabular-nums; font-feature-settings: "tnum"; }

/* Add the seconds label via CSS so JS can keep writing just the number */
#time::after { content: 's'; }

/* Mobile: split into two rows to reduce clutter */
@media (max-width: 480px) {
  .hud { display: flex; flex-direction: column; align-items: flex-start; row-gap: 8px; }
  .hud .pill + .pill { margin-top: 0px; }
  .hud-row.primary { margin-bottom: 6px; }
  .hud-row.primary .pill-full { width: 100%; text-align: center; }
  .hud-row.secondary { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  .hud-row.secondary .pill { text-align: center; }

  header { display: grid; grid-template-columns: 1fr auto; align-items: start; gap: 12px; }
  header .row {
    display: grid;
    grid-template-columns: auto auto;
    grid-template-areas:
      "info exit"
      "pause reset";
    gap: 10px;
    justify-content: end;
  }

  .modal { padding: 10px; }
  .modal-panel { width: auto; max-width: calc(100% - 10px); }

  .btn.home { grid-area: exit; }
  #helpBtn, .btn.info { grid-area: info; }
  #pauseBtn { grid-area: pause; }
  #resetBtn { grid-area: reset; }
}

/* Ensure the countdown warning colors both number and the trailing 's' */
#time.time-warning { color: var(--danger, #ef4444); }