:root {
  --background-color: #00122e;
  --text-color: #dbf5ff;
  --gauge-color: #003d7a;
  --ball-color: #00c7ff;
  --button-fill: rgb(255 255 255 / 0.08);
  --button-border: rgb(255 255 255 / 0.34);
  --button-active: rgb(255 255 255 / 0.18);
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  min-height: 100vh;
  min-height: 100svh;
  overflow: hidden;
  background: var(--background-color);
  color: var(--text-color);
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  position: relative;
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--background-color);
}

.screen {
  width: 100%;
  min-height: 100vh;
  min-height: 100svh;
}

[hidden] {
  display: none !important;
}


.intro-screen {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: calc(28px + env(safe-area-inset-top)) calc(24px + env(safe-area-inset-right)) calc(28px + env(safe-area-inset-bottom)) calc(24px + env(safe-area-inset-left));
  background: var(--background-color);
  color: var(--text-color);
}

.intro-screen::before {
  content: "";
  position: absolute;
  inset: -20%;
  background: radial-gradient(circle at 50% 15%, rgb(255 255 255 / 0.14), transparent 46%);
  pointer-events: none;
}

.intro-card {
  position: relative;
  z-index: 1;
  width: min(100%, 430px);
  padding: clamp(28px, 7vw, 42px) clamp(22px, 6vw, 34px);
  border: 1px solid var(--button-border);
  border-radius: 32px;
  background: rgb(255 255 255 / 0.07);
  box-shadow: 0 24px 70px rgb(0 0 0 / 0.18);
  text-align: center;
}

.intro-logo {
  width: 78px;
  height: 78px;
  margin: 0 auto 22px;
  border: 1px solid var(--button-border);
  border-radius: 26px;
  background: var(--button-fill);
  display: flex;
  align-items: center;
  justify-content: center;
}

.intro-logo svg {
  width: 48px;
  height: 48px;
  opacity: 0.96;
}

.intro-logo rect {
  fill: var(--gauge-color);
}

.intro-logo circle {
  fill: var(--ball-color);
}

.intro-card h1 {
  margin: 0;
  font-size: clamp(2rem, 9vw, 2.8rem);
  line-height: 1.05;
  font-weight: 700;
  letter-spacing: -0.04em;
}

.intro-subtitle {
  margin: 14px 0 0;
  font-size: clamp(1.08rem, 4.6vw, 1.25rem);
  opacity: 0.88;
}

.intro-instructions {
  display: grid;
  gap: 14px;
  margin: 30px 0 32px;
  text-align: left;
  font-size: clamp(1rem, 4.2vw, 1.12rem);
  line-height: 1.42;
}

.intro-instructions p {
  margin: 0;
}

.intro-inline-icon {
  width: 34px;
  height: 34px;
  margin: 0 0.18em;
  border: 1px solid var(--button-border);
  border-radius: 12px;
  background: var(--button-fill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  transform: translateY(-0.08em);
}

.intro-inline-icon svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

.intro-start-button {
  width: min(100%, 260px);
  min-height: 54px;
  border: 1px solid var(--button-border);
  border-radius: 18px;
  background: var(--button-fill);
  color: var(--text-color);
  box-shadow: 0 12px 34px rgb(0 0 0 / 0.16);
  font-size: 1.08rem;
  font-weight: 650;
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease;
}

.intro-start-button:active {
  transform: scale(0.97);
  background: var(--button-active);
}

.main-screen {
  position: relative;
  display: grid;
  grid-template-rows: minmax(96px, 14svh) minmax(0, 1fr) minmax(104px, 15svh);
  padding: calc(14px + env(safe-area-inset-top)) calc(18px + env(safe-area-inset-right)) calc(14px + env(safe-area-inset-bottom)) calc(18px + env(safe-area-inset-left));
  background: var(--background-color);
  color: var(--text-color);
}

.icon-button,
.control-button {
  border: 1px solid var(--button-border);
  background: var(--button-fill);
  color: var(--text-color);
  box-shadow: 0 10px 30px rgb(0 0 0 / 0.14);
  cursor: pointer;
  transition: transform 160ms ease, background-color 160ms ease, border-color 160ms ease;
}

.icon-button:active,
.control-button:active {
  transform: scale(0.96);
  background: var(--button-active);
}

.settings-button {
  position: absolute;
  z-index: 2;
  top: calc(14px + env(safe-area-inset-top));
  left: calc(18px + env(safe-area-inset-left));
  width: 48px;
  height: 48px;
  padding: 0;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-button svg {
  width: 28px;
  height: 28px;
  fill: currentColor;
  stroke: none;
}

.pause-panel {
  grid-row: 1;
  z-index: 1;
  align-self: end;
  justify-self: center;
  width: min(76vw, 360px);
  text-align: center;
  padding-bottom: 8px;
}

.pause-progress-label {
  margin-bottom: 10px;
  font-size: clamp(1.35rem, 5vw, 1.5rem);
  letter-spacing: 0.02em;
}

.session-progress {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.24);
}

.session-progress-fill {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: currentColor;
  transition: width 160ms linear;
}

.gauge-area {
  grid-row: 2;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transform: translateY(-23px);
}

.breathing-gauge {
  width: clamp(44px, 16.5vw, 76px);
  height: auto;
  overflow: visible;
}

.gauge-capsule {
  fill: var(--gauge-color);
}

.breathing-ball {
  fill: var(--ball-color);
  transform-box: fill-box;
  transform-origin: center;
  filter: drop-shadow(0 10px 16px rgb(0 0 0 / 0.16));
}

.bottom-controls {
  grid-row: 3;
  z-index: 3;
  --control-size: 64px;
  display: grid;
  grid-template-columns: var(--control-size) var(--control-size) var(--control-size);
  column-gap: 16px;
  align-items: start;
  justify-content: center;
  min-height: 86px;
}

.control-button {
  width: var(--control-size);
  height: var(--control-size);
  border-radius: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.control-button svg {
  width: 42px;
  height: 42px;
  fill: currentColor;
}

.stop-button {
  grid-column: 1;
}

.start-button {
  grid-column: 2;
}

.start-button:active,
.stop-button:active {
  transform: scale(0.96);
}

.running-touch-area {
  position: absolute;
  z-index: 2;
  inset: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
}

.settings-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: calc(18px + env(safe-area-inset-top)) calc(20px + env(safe-area-inset-right)) calc(32px + env(safe-area-inset-bottom)) calc(20px + env(safe-area-inset-left));
  background: #000;
  color: #fff;
}

.settings-header {
  display: grid;
  grid-template-columns: 48px 1fr;
  gap: 12px;
  align-items: center;
  width: min(100%, 430px);
  max-width: 430px;
  margin: 0 0 34px;
}

.settings-header h1 {
  margin: 0;
  font-size: clamp(1.65rem, 7vw, 2.25rem);
  font-weight: 650;
}

.settings-icon-button,
.stepper button,
.theme-picker button {
  border: 1px solid rgb(255 255 255 / 0.76);
  background: rgb(255 255 255 / 0.07);
  color: #fff;
  cursor: pointer;
}

.settings-icon-button {
  width: 48px;
  height: 48px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.settings-icon-button svg {
  width: 32px;
  height: 32px;
  fill: none;
  stroke: currentColor;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.settings-content {
  width: min(100%, 430px);
  max-width: 430px;
  margin: 0;
}

.settings-content h2 {
  margin: 30px 0 18px;
  font-size: clamp(1.15rem, 4.8vw, 1.35rem);
  font-weight: 650;
}

.setting-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  min-height: 60px;
  margin-bottom: 12px;
}

.setting-row label,
.slider-header label,
.stepper output,
.slider-header output {
  font-size: clamp(1rem, 4.2vw, 1.12rem);
}

.stepper {
  display: grid;
  grid-template-columns: clamp(54px, 12vw, 96px) 64px clamp(54px, 12vw, 96px);
  gap: clamp(8px, 1.8vw, 14px);
  align-items: center;
}

.stepper button,
.theme-picker button {
  min-height: 48px;
  border-radius: 14px;
  line-height: 1;
}

.stepper button {
  font-size: 1.9rem;
  font-weight: 700;
}

.theme-picker button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}

.theme-arrow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 14px;
  height: 14px;
  border-color: currentColor;
  border-style: solid;
  border-width: 0 4px 4px 0;
}

.theme-arrow-left {
  transform: translate(-42%, -50%) rotate(135deg);
}

.theme-arrow-right {
  transform: translate(-58%, -50%) rotate(-45deg);
}

.stepper output,
.theme-picker output,
.slider-header output {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.slider-block {
  margin-top: 24px;
}

.slider-header {
  display: flex;
  gap: 16px;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 12px;
}

#session-duration-slider {
  width: 100%;
  accent-color: #fff;
}

.theme-picker {
  display: grid;
  grid-template-columns: clamp(74px, 18vw, 104px) minmax(0, 1fr) clamp(74px, 18vw, 104px);
  gap: 14px;
  align-items: center;
}

.theme-picker output {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 16px;
  background: rgb(255 255 255 / 0.05);
  font-size: clamp(1.08rem, 4.7vw, 1.22rem);
}

.completion-overlay {
  position: fixed;
  z-index: 20;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  background: var(--background-color);
  color: var(--text-color);
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
  transition: opacity 450ms ease, visibility 0s linear 450ms;
}

.completion-overlay.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 450ms ease;
}

.completion-message {
  opacity: 0;
  text-align: center;
  font-size: clamp(1.75rem, 8vw, 2.5rem);
  font-weight: 650;
  transition: opacity 350ms ease;
}

.completion-overlay.show-message .completion-message {
  opacity: 1;
}

@media (min-width: 720px) {
  .main-screen {
    grid-template-rows: minmax(110px, 16svh) 1fr minmax(118px, 16svh);
  }

  .settings-button {
    width: 54px;
    height: 54px;
  }

  .bottom-controls {
    --control-size: 70px;
  }
}


@media (max-width: 420px) {
  .setting-row {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 10px;
  }

  .stepper {
    grid-template-columns: 52px 58px 52px;
    gap: 6px;
  }

  .stepper button,
  .theme-picker button {
    min-height: 46px;
  }
}
