* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #000; touch-action: none; }
@supports (padding: env(safe-area-inset-bottom)) {
  #session-controls, #freestyle-controls { padding-bottom: env(safe-area-inset-bottom); }
  #freq-label { margin-bottom: env(safe-area-inset-bottom); }
  #session-name { padding-top: env(safe-area-inset-top); }
}
canvas { width: 100%; height: 100%; display: block; touch-action: none; }

/* ─── Shared ─── */
.font { font-family: 'Segoe UI', system-ui, -apple-system, sans-serif; }
.fade { transition: opacity 0.6s ease; }

/* ─── Menu Screen ─── */
#menu {
  position: fixed; inset: 0; z-index: 30;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: auto; overflow-y: auto; -webkit-overflow-scrolling: touch;
  padding: 24px 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.2) 0%, rgba(0,0,0,0.6) 100%);
}
#menu.hidden { opacity: 0; pointer-events: none; }
#menu h1 {
  font-size: 36px; font-weight: 200; letter-spacing: 8px; color: rgba(255,255,255,0.9);
  text-transform: uppercase; margin-bottom: 6px;
  text-shadow: 0 0 40px rgba(255,255,255,0.2);
}
#menu .subtitle {
  font-size: 13px; font-weight: 300; color: rgba(255,255,255,0.4);
  letter-spacing: 3px; margin-bottom: 40px; text-transform: uppercase;
}
#techniques {
  display: grid; grid-template-columns: 1fr 1fr; gap: 12px;
  max-width: 620px; width: 90%;
}
.tech-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px; padding: 16px 20px;
  cursor: pointer; transition: all 0.3s ease;
  text-align: left;
}
@media (hover: hover) {
  .tech-card:hover {
    background: rgba(255,255,255,0.1);
    border-color: rgba(255,255,255,0.25);
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
  }
}
.tech-card:active {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.25);
}
.tech-card .name {
  font-size: 15px; font-weight: 400; color: rgba(255,255,255,0.9);
  margin-bottom: 4px;
}
.tech-card .desc {
  font-size: 11px; font-weight: 300; color: rgba(255,255,255,0.4);
  line-height: 1.4;
}
.tech-card .timing {
  font-size: 10px; font-weight: 400; color: rgba(255,255,255,0.3);
  margin-top: 6px; letter-spacing: 1px; text-transform: uppercase;
}
.tech-card.freestyle {
  grid-column: 1 / -1;
  background: rgba(255,255,255,0.02);
  border-style: dashed;
  text-align: center;
}
.tech-card.freestyle .name { font-weight: 300; letter-spacing: 2px; }
#menu .hint {
  margin-top: 24px; font-size: 11px; color: rgba(255,255,255,0.25);
  letter-spacing: 1px;
}

/* ─── Breathing Session Overlay ─── */
#session {
  position: fixed; inset: 0; z-index: 25;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none;
  background: radial-gradient(circle at center, rgba(0,0,0,0.55) 0%, rgba(0,0,0,0.75) 40%, rgba(0,0,0,0.88) 100%);
}
#session.hidden { opacity: 0; pointer-events: none; }

#session-name {
  position: fixed; top: 24px; left: 0; right: 0; text-align: center;
  font-size: 12px; font-weight: 300; color: rgba(255,255,255,0.35);
  letter-spacing: 4px; text-transform: uppercase;
}

#breath-container {
  position: relative; width: min(420px, 85vw); height: min(420px, 85vw);
  display: flex; align-items: center; justify-content: center;
}

#cycle-svg {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  overflow: visible;
}
#cycle-svg .track {
  fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 2;
}
#cycle-svg .progress {
  fill: none; stroke: rgba(255,255,255,0.85); stroke-width: 4;
  stroke-linecap: round;
}
#cycle-svg .node {
  fill: rgba(255,255,255,0.15); transition: all 0.4s;
}
#cycle-svg .node.reached {
  fill: rgba(255,255,255,0.9);
}
#cycle-svg .node-label {
  fill: rgba(255,255,255,0.3); font-size: 9px;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  text-transform: uppercase; letter-spacing: 1px;
}

#breath-circle {
  position: absolute; width: 80px; height: 80px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255,255,255,0.5) 0%, rgba(255,255,255,0.1) 60%, transparent 100%);
  box-shadow: 0 0 60px 20px rgba(255,255,255,0.15);
}

#phase-info {
  position: absolute;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  pointer-events: none; user-select: none;
}

#phase-text {
  color: rgba(255,255,255,0.95); font-size: 22px; font-weight: 300;
  letter-spacing: 6px; text-transform: uppercase;
  text-shadow: 0 0 30px rgba(255,255,255,0.5), 0 0 60px rgba(255,255,255,0.2);
  line-height: 1;
}

#phase-timer {
  color: rgba(255,255,255,0.5); font-size: 40px; font-weight: 200;
  text-shadow: 0 0 15px rgba(255,255,255,0.3);
  margin-top: 4px; line-height: 1;
}

#cycle-count {
  color: rgba(255,255,255,0.25); font-size: 10px; font-weight: 300;
  letter-spacing: 2px; text-transform: uppercase;
  margin-top: 6px;
}

#freq-label {
  position: fixed; bottom: 96px; left: 0; right: 0; text-align: center;
  font-size: 10px; color: rgba(255,255,255,0.2);
  letter-spacing: 2px; text-transform: uppercase;
}

#session-controls {
  position: fixed; bottom: 20px; left: 0; right: 0;
  display: flex; justify-content: center; gap: 24px;
  pointer-events: auto;
}
#session-controls button {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 10px 24px;
  color: rgba(255,255,255,0.6); font-size: 13px; font-weight: 300;
  letter-spacing: 2px; text-transform: uppercase; cursor: pointer;
  transition: all 0.3s; -webkit-tap-highlight-color: transparent;
  min-height: 44px;
}
@media (hover: hover) {
  #session-controls button:hover {
    background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.9);
  }
}

/* ─── Freestyle HUD ─── */
#freestyle-hud {
  position: fixed; top: 16px; left: 16px; z-index: 25;
  color: rgba(255,255,255,0.6); font-size: 12px; font-weight: 300;
  pointer-events: none; user-select: none;
  text-shadow: 0 1px 4px rgba(0,0,0,0.8); line-height: 1.6;
}
#freestyle-hud.hidden { opacity: 0; pointer-events: none; }
#freestyle-hud h2 {
  font-size: 16px; font-weight: 300; letter-spacing: 3px; color: rgba(255,255,255,0.8);
  margin-bottom: 4px; text-transform: uppercase;
}
#freestyle-hud .key {
  display: inline-block; border: 1px solid rgba(255,255,255,0.25);
  border-radius: 3px; padding: 0 5px; font-size: 10px; margin: 0 1px;
}

/* Freestyle mobile controls */
#freestyle-controls {
  display: none; /* shown via media query on mobile */
  position: fixed; bottom: 20px; left: 0; right: 0;
  justify-content: center; gap: 16px;
  pointer-events: auto;
}
.fs-btn {
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; padding: 10px 18px;
  color: rgba(255,255,255,0.6); font-size: 12px; font-weight: 300;
  letter-spacing: 2px; text-transform: uppercase; cursor: pointer;
  transition: all 0.3s; -webkit-tap-highlight-color: transparent;
}
.fs-btn:active {
  background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.35);
  color: rgba(255,255,255,0.95);
}

/* ─── Start Modal ─── */
#start-modal {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.4) 0%, rgba(0,0,0,0.8) 100%);
  pointer-events: auto;
}
#start-modal.hidden { opacity: 0; pointer-events: none; }
.modal-content {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  width: 280px;
}
#modal-name {
  font-size: 16px; font-weight: 300; color: rgba(255,255,255,0.8);
  letter-spacing: 3px; text-transform: uppercase; margin-bottom: 8px;
  text-align: center;
}
.modal-btn {
  width: 100%;
  background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px; padding: 14px 20px;
  color: rgba(255,255,255,0.7); font-size: 14px; font-weight: 300;
  letter-spacing: 2px; text-transform: uppercase; cursor: pointer;
  transition: all 0.3s; -webkit-tap-highlight-color: transparent;
}
@media (hover: hover) {
  .modal-btn:hover {
    background: rgba(255,255,255,0.12); border-color: rgba(255,255,255,0.3);
    color: rgba(255,255,255,0.95);
  }
}
.modal-btn:active {
  background: rgba(255,255,255,0.15); border-color: rgba(255,255,255,0.35);
}
.modal-cancel {
  background: none; border-color: rgba(255,255,255,0.08);
  color: rgba(255,255,255,0.3); font-size: 12px; margin-top: 4px;
}

/* ─── About Link on Menu ─── */
.about-link {
  margin-top: 12px; background: none; border: none;
  color: rgba(255,255,255,0.25); font-size: 11px; font-weight: 300;
  letter-spacing: 2px; text-transform: uppercase; cursor: pointer;
  transition: color 0.3s;
}
.about-link:hover { color: rgba(255,255,255,0.6); }

/* ─── About Page ─── */
#about {
  position: fixed; inset: 0; z-index: 35;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(0,0,0,0.3) 0%, rgba(0,0,0,0.75) 100%);
  pointer-events: auto;
}
#about.hidden { opacity: 0; pointer-events: none; }
.about-content {
  max-width: 440px; width: 88%; text-align: center;
}
.about-content h2 {
  font-size: 30px; font-weight: 200; letter-spacing: 6px;
  color: rgba(255,255,255,0.9); text-transform: uppercase;
  margin-bottom: 4px;
}
.about-tagline {
  font-size: 12px; font-weight: 300; color: rgba(255,255,255,0.35);
  letter-spacing: 3px; text-transform: uppercase; margin-bottom: 32px;
}
.about-body {
  margin-bottom: 32px;
}
.about-body p {
  font-size: 13px; font-weight: 300; color: rgba(255,255,255,0.55);
  line-height: 1.7; margin-bottom: 12px;
}
.about-body strong { font-weight: 500; color: rgba(255,255,255,0.75); }

#bmc-link {
  display: inline-flex; align-items: center; gap: 8px;
  background: rgba(255,221,0,0.12); border: 1px solid rgba(255,221,0,0.3);
  border-radius: 10px; padding: 12px 28px;
  color: rgba(255,221,0,0.9); font-size: 14px; font-weight: 400;
  letter-spacing: 1px; text-decoration: none;
  transition: all 0.3s;
}
#bmc-link:hover {
  background: rgba(255,221,0,0.22); border-color: rgba(255,221,0,0.5);
  transform: translateY(-1px);
  box-shadow: 0 6px 24px rgba(255,221,0,0.1);
}
.bmc-icon { font-size: 18px; }

#about-back { margin-top: 24px; }
.about-version {
  margin-top: 16px; font-size: 10px; font-weight: 300;
  color: rgba(255,255,255,0.15); letter-spacing: 2px;
}

/* ─── Mobile Responsive ─── */
@media (max-width: 600px) {
  #menu h1 { font-size: 26px; letter-spacing: 5px; }
  #menu .subtitle { font-size: 11px; letter-spacing: 2px; margin-bottom: 24px; }
  #techniques { grid-template-columns: 1fr; gap: 10px; width: 92%; }
  .tech-card { padding: 14px 16px; }
  .tech-card .name { font-size: 14px; }
  .tech-card .desc { font-size: 10px; }
  #menu .hint { font-size: 10px; margin-top: 16px; }

  #session-name { top: 16px; font-size: 10px; letter-spacing: 3px; }
  #phase-text { font-size: 16px; letter-spacing: 4px; }
  #phase-timer { font-size: 32px; }
  #cycle-count { font-size: 9px; }

  #freq-label { bottom: 82px; font-size: 9px; }
  #session-controls { bottom: 16px; gap: 12px; }
  #session-controls button { padding: 10px 18px; font-size: 12px; min-height: 44px; }

  #cycle-svg .node-label { font-size: 7px; }

  #freestyle-hud { top: 10px; left: 10px; font-size: 11px; }
  #freestyle-hud h2 { font-size: 14px; }
  #freestyle-hud .desktop-hints { display: none; }
  #freestyle-controls { display: flex; }

  .modal-content { width: 260px; }
  .modal-btn { padding: 12px 16px; font-size: 13px; }
  #modal-name { font-size: 14px; letter-spacing: 2px; }

  .about-content h2 { font-size: 24px; letter-spacing: 4px; }
  .about-tagline { font-size: 11px; margin-bottom: 24px; }
  .about-body p { font-size: 12px; }
  #bmc-link { padding: 10px 22px; font-size: 13px; }
}

@media (max-height: 500px) {
  #breath-container { width: min(300px, 60vw); height: min(300px, 60vw); }
  #session-name { top: 8px; }
  #freq-label { display: none; }
  #session-controls { bottom: 6px; }
}

/* Prevent text selection and callouts on mobile */
#session, #menu, #freestyle-hud, #about, #start-modal {
  -webkit-touch-callout: none;
  -webkit-user-select: none; user-select: none;
}
