:root {
  --bg: #000;
  --fg: #f5f5f7;
  --dim: rgba(235, 235, 245, 0.6);
  --faint: rgba(235, 235, 245, 0.35);
  --card: #1c1c1e;
  --panel: #111113;
  --control: #2c2c2e;
  --control-on: #545458;
  --accent: #6fd1b4;
  --accent-ink: #002a20;
  --cue: #c9f2e4;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  color-scheme: dark;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  overscroll-behavior: none;
}

body { position: fixed; inset: 0; }

#flower { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
button:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }

/* ---------- Képernyők ---------- */

.screen {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: calc(var(--safe-t) + 20px) calc(var(--safe-r) + 20px) calc(var(--safe-b) + 28px) calc(var(--safe-l) + 20px);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.6s ease, visibility 0s linear 0.6s;
}
.screen.active { opacity: 1; visibility: visible; transition: opacity 0.6s ease; }

.btn {
  appearance: none;
  border: 0;
  border-radius: 999px;
  padding: 15px 28px;
  font-size: 17px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}
.btn:active { transform: scale(0.97); }
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn.ghost { background: rgba(255, 255, 255, 0.12); color: var(--fg); }
.btn.big { width: min(300px, 100%); padding: 17px 32px; }

.link {
  background: none;
  border: 0;
  color: var(--dim);
  font-size: 15px;
  padding: 8px 12px;
  cursor: pointer;
}
.link.strong { color: var(--accent); font-weight: 600; font-size: 17px; }

.dim { color: var(--dim); font-size: 15px; margin-top: 4px; }

/* ---------- Kezdőképernyő ---------- */

.top { display: flex; justify-content: space-between; align-items: flex-start; gap: 12px; }
h1 { font-size: 32px; font-weight: 700; letter-spacing: -0.01em; }

.icon-btn {
  flex: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: rgba(255, 255, 255, 0.1);
  display: grid;
  place-items: center;
  cursor: pointer;
}

.bottom { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 16px; }

.config-pill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  max-width: 100%;
  padding: 9px 16px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  font-size: 15px;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.2s ease, transform 0.15s ease;
}
.config-pill:active { transform: scale(0.97); background: rgba(255, 255, 255, 0.12); }
.config-pill span { overflow: hidden; text-overflow: ellipsis; }
.config-pill .pi { flex: none; width: 17px; height: 17px; }
.config-pill .pi.accent { color: var(--accent); }
.config-pill .pi.dim { color: var(--dim); margin-left: -2px; }

/* Lassan pulzáló fény a beállítások gomb körül, amíg még senki nem nyitotta meg */
.icon-btn.glow { animation: hint-glow 4s ease-in-out infinite; }
@keyframes hint-glow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(111, 209, 180, 0.15), 0 0 6px 0 rgba(111, 209, 180, 0.2); color: var(--fg); }
  50% { box-shadow: 0 0 0 9px rgba(111, 209, 180, 0.4), 0 0 22px 8px rgba(111, 209, 180, 0.45); color: #b9f0df; }
}
@media (prefers-reduced-motion: reduce) {
  .icon-btn.glow { animation: none; box-shadow: 0 0 0 3px rgba(111, 209, 180, 0.45); }
}

/* ---------- Légzés ---------- */

#session { cursor: pointer; }

.hint {
  position: absolute;
  top: calc(var(--safe-t) + 22px);
  left: 0;
  right: 0;
  text-align: center;
  color: var(--faint);
  font-size: 14px;
  transition: opacity 1.2s ease;
}
.hint.hidden { opacity: 0; }

.cue-wrap {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--safe-b) + 11vh);
  height: 1.3em;
  font-size: clamp(24px, 6.5vw, 32px);
}
.cue {
  position: absolute;
  inset: 0;
  text-align: center;
  font-weight: 500;
  color: var(--cue);
  opacity: 0;
  transform: translateY(10px);
  filter: blur(6px);
  transition-property: opacity, transform, filter;
  transition-duration: var(--cue-dur, 0.9s);
  transition-timing-function: cubic-bezier(0.45, 0, 0.55, 1);
}
.cue.show { opacity: 1; transform: none; filter: none; }
.cue.leave { opacity: 0; transform: translateY(-10px); filter: blur(6px); }
@media (prefers-reduced-motion: reduce) {
  .cue, .cue.leave { transform: none; filter: none; }
}

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  cursor: default;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}
.overlay.active { opacity: 1; visibility: visible; transition: opacity 0.3s ease; }
.paused-title { font-size: 28px; font-weight: 600; }

.actions { display: flex; gap: 12px; margin-top: 24px; }
.actions .btn { flex: 1; }
.actions.vertical { flex-direction: column; width: min(300px, 100%); }

/* ---------- Összegzés ---------- */

#summary { justify-content: flex-end; align-items: center; }
.summary-inner { width: min(420px, 100%); display: flex; flex-direction: column; gap: 18px; }
.summary-inner h2 { font-size: 28px; font-weight: 700; text-align: center; }
.summary-inner .actions { margin-top: 4px; }

.stats { background: var(--card); border-radius: 16px; overflow: hidden; }
.stats div {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}
.stats div:last-child { border-bottom: 0; }
.stats dt { color: var(--dim); }
.stats dd { font-weight: 600; font-variant-numeric: tabular-nums; text-align: right; }

/* ---------- Beállítások (alsó panel) ---------- */

.sheet { position: fixed; inset: 0; z-index: 10; visibility: hidden; transition: visibility 0s linear 0.35s; }
.sheet.open { visibility: visible; transition: none; }

.sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); opacity: 0; transition: opacity 0.35s ease; }
.sheet.open .sheet-backdrop { opacity: 1; }

.sheet-panel {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  margin: 0 auto;
  max-width: 520px;
  max-height: 88dvh;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: var(--panel);
  border-radius: 22px 22px 0 0;
  padding: 6px calc(var(--safe-r) + 18px) calc(var(--safe-b) + 24px) calc(var(--safe-l) + 18px);
  transform: translateY(100%);
  transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1);
}
.sheet.open .sheet-panel { transform: none; }

.sheet-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0 6px;
  background: var(--panel);
}
.sheet-head h2 { font-size: 20px; font-weight: 700; }

.credit { margin-top: 18px; text-align: center; font-size: 12px; letter-spacing: 0.02em; color: rgba(235, 235, 245, 0.38); }

/* A beállítások "Kész" gombja pontosan a Kezdés gomb helyén ül: azonos szélesség, azonos alsó távolság */
#sheet .sheet-panel { padding-bottom: 0; }
.sheet-foot {
  position: sticky;
  bottom: 0;
  display: flex;
  justify-content: center;
  margin: 14px calc(-18px - var(--safe-r)) 0 calc(-18px - var(--safe-l));
  padding: 20px 0 calc(var(--safe-b) + 28px);
  background: linear-gradient(to bottom, rgba(17, 17, 19, 0), var(--panel) 20px);
}
.sheet-foot .btn { width: min(300px, calc(100vw - 40px - var(--safe-l) - var(--safe-r))); }

.group { background: var(--card); border-radius: 14px; padding: 12px 14px 14px; margin-top: 14px; }
.row { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 0; }
.label { font-size: 15px; margin: 2px 0 10px; }
.note { color: var(--dim); font-size: 13px; line-height: 1.4; margin-top: 10px; }

.stepper { display: flex; align-items: center; gap: 8px; }
.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 0;
  background: var(--control);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}
.stepper button:disabled { opacity: 0.3; cursor: default; }
.stepper output { min-width: 82px; text-align: center; font-weight: 600; font-variant-numeric: tabular-nums; }

.seg {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 3px;
  padding: 3px;
  border-radius: 10px;
  background: var(--control);
}
.seg button {
  border: 0;
  border-radius: 8px;
  background: transparent;
  padding: 8px 4px;
  font-size: 14px;
  cursor: pointer;
  transition: background 0.2s ease;
}
.seg button[aria-pressed="true"] { background: var(--control-on); font-weight: 600; }

.volume { display: flex; align-items: center; gap: 14px; margin-top: 14px; transition: opacity 0.2s ease; }
.volume.off { opacity: 0.35; pointer-events: none; }

.range {
  --fill: 50%;
  flex: 1;
  height: 28px;
  background: transparent;
  -webkit-appearance: none;
  appearance: none;
  cursor: pointer;
}
.range::-webkit-slider-runnable-track {
  height: 4px;
  border-radius: 2px;
  background: linear-gradient(to right, var(--accent) var(--fill), var(--control-on) var(--fill));
}
.range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 24px;
  height: 24px;
  margin-top: -10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
}
.range::-moz-range-track { height: 4px; border-radius: 2px; background: var(--control-on); }
.range::-moz-range-progress { height: 4px; border-radius: 2px; background: var(--accent); }
.range::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: #fff; }

/* ---------- Kezdőképernyőhöz adás ---------- */

.btn.small { padding: 9px 18px; font-size: 15px; }

.install-card {
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  gap: 10px 14px;
  padding: 14px 16px;
  border-radius: 16px;
  background: var(--card);
}
.install-card img { border-radius: 10px; }
.install-card p { font-size: 15px; line-height: 1.35; }
.install-card-actions { grid-column: 1 / -1; display: flex; justify-content: flex-end; align-items: center; gap: 6px; }

.row-btn {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  border: 0;
  background: none;
  color: var(--accent);
  font-size: 16px;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
}

.steps { list-style: none; counter-reset: step; margin-top: 8px; }
.steps li {
  counter-increment: step;
  display: grid;
  grid-template-columns: 30px 1fr;
  gap: 14px;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 16px;
  line-height: 1.4;
}
.steps li:last-child { border-bottom: 0; }
.steps li::before {
  content: counter(step);
  width: 30px;
  height: 30px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--control);
  font-weight: 600;
  font-size: 14px;
}
.steps .ico {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  margin: 0 2px;
  vertical-align: middle;
  border-radius: 7px;
  background: var(--control);
  color: #5aa9ff;
}
.steps .ico svg { width: 18px; height: 18px; }
.steps b { font-weight: 600; }
