/* Native app presentation and safe-area refinements. */
:root {
  color-scheme: light;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
}

html,
body,
#app {
  min-height: 100%;
}

html {
  background: #dcebfb;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  touch-action: manipulation;
  overscroll-behavior: none;
}

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

button:focus-visible,
textarea:focus-visible {
  outline: 3px solid color-mix(in oklch, var(--accent) 55%, white);
  outline-offset: 2px;
}

.phone {
  isolation: isolate;
}

.content {
  min-height: 0;
  scrollbar-width: none;
  overscroll-behavior-y: contain;
  touch-action: pan-y;
}

.content::-webkit-scrollbar {
  display: none;
}

.nav-bar {
  padding-right: max(8px, var(--safe-right));
  padding-bottom: max(12px, var(--safe-bottom));
  padding-left: max(8px, var(--safe-left));
}

.nav-item,
.icon-btn,
.home-return,
.cat-mini,
.cat-card,
.method-choice,
.option,
.dur-chip,
.btn-primary,
.btn-secondary,
.btn-danger,
.btn-mini {
  min-height: 44px;
}

.btn-primary {
  min-height: 54px;
  font-size: 16px;
}

.card,
.practice-card,
.library-intro,
.practice-hero,
.timer-card {
  -webkit-backdrop-filter: blur(18px) saturate(120%);
  backdrop-filter: blur(18px) saturate(120%);
}

/* Keep the richer category illustrations crisp at both shortcut and card sizes. */
.cat-mini .icon-badge svg {
  width: 24px !important;
  height: 24px !important;
  stroke-width: 1.9;
}

.cat-mini .icon-badge,
.cat-card .icon-badge,
.practice-hero .icon-badge {
  box-shadow: inset 0 0 0 1px rgb(255 255 255 / 42%), 0 5px 14px rgb(41 77 116 / 10%);
}

.cat-mini .icon-badge svg,
.cat-card .icon-badge svg,
.practice-hero .icon-badge svg {
  overflow: visible;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.timer-active-content {
  padding-top: 14px;
  scroll-padding-top: 14px;
}

.timer-active-content .timer-card {
  min-height: 300px;
}

.timer-progress {
  transition: stroke-dashoffset 0.45s linear;
}

.timer-steps-card {
  margin-top: 16px;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: rgb(255 255 255 / 76%);
  box-shadow: var(--shadow);
}

/* Slightly larger typography on iPhone without changing Android layout. */
html.ios-app {
  -webkit-text-size-adjust: 108%;
}

html.ios-app .nav-item,
html.ios-app .cat-mini > span {
  font-size: 12px !important;
}

html.ios-app .cat-methods,
html.ios-app .practice-kicker,
html.ios-app .section-label {
  font-size: 12px;
}

html.ios-app .cat-state,
html.ios-app .selected-method-pill {
  font-size: 11.5px;
}

html.ios-app .method-choice,
html.ios-app textarea {
  font-size: 14.5px;
}

html.ios-app .dur-chip {
  font-size: 14px;
}

html.ios-app .step > span {
  font-size: 14.5px !important;
}

html.ios-app .btn-primary {
  font-size: 17px;
}

/* Android System WebView compatibility for devices without OKLCH/color-mix. */
@supports not (color: oklch(50% 0 0)) {
  :root {
    --bg: #eaf4ff;
    --surface: rgba(255, 255, 255, 0.88);
    --surface-2: rgba(236, 246, 255, 0.92);
    --surface-warm: #fff8e9;
    --surface-green: #ddf5ec;
    --surface-gold: #fff0c9;
    --surface-rose: #fdebea;
    --text: #17324d;
    --text-muted: #587087;
    --border: rgba(115, 157, 194, 0.34);
    --accent: #34a4d8;
    --accent-soft: #d8f1fb;
    --accent-deep: #126f9f;
    --accent2: #e8b74a;
    --accent2-soft: #ffefc3;
    --danger: #be4652;
    --danger-soft: #fde7e8;
    --shadow: 0 8px 28px rgba(30, 75, 116, 0.14), 0 2px 6px rgba(30, 75, 116, 0.07);
  }

  html,
  body {
    background: #dcebfb;
  }

  .phone {
    background:
      linear-gradient(180deg, rgba(249, 253, 255, 0.48), rgba(238, 248, 255, 0.36)),
      url("image_background.png") center center / cover no-repeat;
    border-color: rgba(126, 166, 202, 0.42);
    box-shadow: 0 28px 72px rgba(25, 65, 105, 0.22);
  }

  .phone::before {
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.10), rgba(255, 255, 255, 0.22) 28%, rgba(255, 255, 255, 0.12) 62%, rgba(210, 230, 249, 0.14));
  }

  .header {
    background: linear-gradient(180deg, rgba(252, 254, 255, 0.78), rgba(250, 253, 255, 0.42));
  }

  .card,
  .practice-card,
  .library-intro,
  .practice-hero,
  .timer-card,
  .timer-steps-card {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.88), rgba(239, 248, 255, 0.76));
    border-color: rgba(141, 177, 207, 0.46);
    box-shadow: 0 12px 30px rgba(30, 73, 112, 0.14);
  }

  .cat-card {
    border-color: rgba(141, 177, 207, 0.48);
    box-shadow: 0 12px 28px rgba(30, 73, 112, 0.13);
  }

  .cat-card[data-accent="0"] {
    background: linear-gradient(150deg, rgba(239, 253, 255, 0.92), rgba(200, 239, 246, 0.84));
  }

  .cat-card[data-accent="1"] {
    background: linear-gradient(150deg, rgba(255, 253, 246, 0.94), rgba(226, 237, 255, 0.84));
  }

  .icon-badge {
    border-color: rgba(255, 255, 255, 0.74);
    box-shadow: 0 8px 18px rgba(30, 74, 112, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.38);
  }

  .cat-card[data-accent="0"] .icon-badge,
  .quick-icon-blue {
    background: linear-gradient(145deg, #ccefe4, #eafaf4) !important;
    color: #176c58 !important;
  }

  .cat-card[data-accent="1"] .icon-badge,
  .quick-icon-gold {
    background: linear-gradient(145deg, #ffe4a1, #fff6d8) !important;
    color: #6a4a12 !important;
  }

  .btn-primary {
    background: linear-gradient(135deg, #167eae, #246fbb);
    color: #fff;
    box-shadow: 0 12px 28px rgba(23, 89, 147, 0.28);
  }

  .btn-secondary,
  .method-choice {
    background: linear-gradient(145deg, rgba(255, 255, 255, 0.92), rgba(238, 247, 255, 0.82));
    border-color: rgba(126, 166, 202, 0.42);
  }

  .method-choice.selected {
    background: linear-gradient(135deg, #167eae, #246fbb);
    border-color: #115f8d;
    color: #fff;
    box-shadow: 0 8px 20px rgba(23, 89, 147, 0.24);
  }

  .method-choice.selected .choice-mark {
    background: rgba(255, 255, 255, 0.20);
    border-color: rgba(255, 255, 255, 0.72);
    color: #fff;
  }

  .method-choice.selected .featured-pill {
    background: #fff;
    border-color: #fff;
    color: #126f9f;
  }

  .dur-chip.active {
    background: linear-gradient(135deg, #167eae, #246fbb) !important;
    border-color: #115f8d !important;
    color: #fff !important;
    box-shadow: 0 7px 18px rgba(23, 89, 147, 0.22);
  }

  .nav-bar {
    background: rgba(250, 253, 255, 0.88);
    border-top-color: rgba(126, 166, 202, 0.38);
  }

  .nav-item {
    color: #4f667c;
  }

  .nav-item.active {
    color: #176f9e;
    background: rgba(199, 235, 247, 0.90);
  }

  .home-return {
    background: linear-gradient(145deg, #ddf5ec, #eefaf5);
    color: #176f5c;
    box-shadow: 0 6px 18px rgba(38, 117, 91, 0.14);
  }

  .featured-pill,
  .cat-state {
    border-color: rgba(126, 166, 202, 0.38);
  }
}

/* A selected practice or duration must remain unmistakable on every WebView. */
.method-choice.selected {
  background: linear-gradient(135deg, #167eae, #246fbb) !important;
  border-color: #115f8d !important;
  color: #fff !important;
  box-shadow: 0 8px 20px rgba(23, 89, 147, 0.24) !important;
}

.method-choice.selected .choice-mark {
  background: rgba(255, 255, 255, 0.20) !important;
  border-color: rgba(255, 255, 255, 0.72) !important;
  color: #fff !important;
}

.method-choice.selected .featured-pill {
  background: #fff !important;
  border-color: #fff !important;
  color: #126f9f !important;
}

.dur-chip.active {
  background: linear-gradient(135deg, #167eae, #246fbb) !important;
  border-color: #115f8d !important;
  color: #fff !important;
  box-shadow: 0 7px 18px rgba(23, 89, 147, 0.22) !important;
}

@media (max-width: 460px) {
  body {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  #app,
  .phone {
    width: 100%;
    height: 100vh;
    height: 100dvh;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .phone {
    border: 0;
    background-position: center center;
  }

  .header {
    padding-top: max(20px, calc(var(--safe-top) + 12px));
    padding-right: max(20px, calc(var(--safe-right) + 20px));
    padding-left: max(20px, calc(var(--safe-left) + 20px));
  }

  .content {
    min-height: 0;
    overflow-y: auto;
    touch-action: pan-y;
    padding-right: max(20px, calc(var(--safe-right) + 20px));
    padding-left: max(20px, calc(var(--safe-left) + 20px));
  }

  .nav-bar {
    flex-shrink: 0;
  }
}

@media (min-width: 461px) {
  .phone {
    width: 426px;
    min-height: 926px;
  }
}

/* The public web build is the game surface itself, not a simulated phone. */
@media (max-width: 460px) {
  body {
    padding: 0;
  }

  .phone {
    max-width: none;
    border-radius: 0;
    box-shadow: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
  }
}
