/* Arena Pomodoro — la interfaz flota sobre el canvas, que ocupa la pantalla
   entera. Sin fuentes remotas: la app (WebView sin red) y la web tienen que
   verse exactamente igual. */

:root {
  --ink: #4a3a2c;
  --ink-soft: rgba(74, 58, 44, 0.66);
  --accent: #e8577f;
  --glass: rgba(255, 255, 255, 0.58);
  --glass-strong: rgba(255, 255, 255, 0.86);
  --stroke: rgba(255, 255, 255, 0.75);
  --shadow: 0 8px 26px rgba(31, 84, 96, 0.18);
  --radius: 22px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: var(--font);
  color: var(--ink);
  background: linear-gradient(160deg, #a9e0c6 0%, #8fd6d6 45%, #6fbfe8 100%);
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#glass {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 0;
}

.app {
  position: fixed;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  pointer-events: none;
}

.spacer {
  flex: 1 1 auto;
  min-height: 0;
}

.bar {
  pointer-events: auto;
  flex: 0 0 auto;
}

/* ---------------- Cabecera ---------------- */

.bar--top {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: calc(var(--safe-top) + 12px) 16px 10px;
}

.phase {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 15px;
  border-radius: 999px;
  background: var(--glass);
  border: 1px solid var(--stroke);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: var(--shadow);
  font-weight: 650;
  font-size: 15px;
  letter-spacing: 0.01em;
}

.phase__dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 26%, transparent);
  transition: background 0.35s ease;
}

.cycles {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1 1 auto;
}

.cycles i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(255, 255, 255, 0.85);
  transition: background 0.3s ease, transform 0.3s ease;
}

.cycles i.is-done {
  background: var(--accent);
  border-color: transparent;
}

.cycles i.is-current {
  transform: scale(1.45);
  background: var(--glass-strong);
  border-color: var(--accent);
}

.icon-btn {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, background 0.2s ease;
}

.icon-btn:active {
  transform: scale(0.92);
}

.icon-btn svg {
  width: 21px;
  height: 21px;
  fill: currentColor;
}

.icon-btn--dark {
  background: rgba(74, 58, 44, 0.07);
  border-color: rgba(74, 58, 44, 0.12);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

/* ---------------- Pie: lectura + controles ---------------- */

.bar--bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 6px 16px calc(var(--safe-bottom) + 18px);
}

.readout {
  text-align: center;
  line-height: 1;
}

.readout__time {
  font-size: clamp(44px, 13vw, 68px);
  font-weight: 700;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  text-shadow: 0 2px 14px rgba(255, 255, 255, 0.7);
}

.readout__hint {
  margin-top: 7px;
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  min-height: 1.2em;
}

.controls {
  display: flex;
  align-items: center;
  gap: 22px;
}

.round-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid var(--stroke);
  background: var(--glass);
  backdrop-filter: blur(10px) saturate(1.3);
  -webkit-backdrop-filter: blur(10px) saturate(1.3);
  box-shadow: var(--shadow);
  color: var(--ink);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.round-btn svg {
  width: 24px;
  height: 24px;
  fill: currentColor;
}

.round-btn:active {
  transform: scale(0.9);
}

.round-btn--primary {
  width: 76px;
  height: 76px;
  background: var(--accent);
  border-color: rgba(255, 255, 255, 0.5);
  color: #fff;
  box-shadow: 0 10px 28px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: background 0.35s ease, transform 0.15s ease, box-shadow 0.35s ease;
}

.round-btn--primary svg {
  width: 32px;
  height: 32px;
}

/* Sólo se ve el icono que corresponde al estado. */
.ic-pause {
  display: none;
}

.is-running .ic-play {
  display: none;
}

.is-running .ic-pause {
  display: block;
}

/* ---------------- Capa modal ---------------- */

.scrim {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  background: rgba(28, 62, 72, 0.34);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade 0.22s ease;
}

.scrim[hidden] {
  display: none;
}

@keyframes fade {
  from {
    opacity: 0;
  }
}

/* --- Aviso de fin de fase --- */

#alert-scrim {
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  width: min(400px, 100%);
  background: var(--glass-strong);
  border: 1px solid rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(20px) saturate(1.4);
  -webkit-backdrop-filter: blur(20px) saturate(1.4);
  border-radius: 26px;
  padding: 26px 24px 20px;
  text-align: center;
  box-shadow: 0 22px 60px rgba(24, 62, 74, 0.28);
  animation: pop 0.28s cubic-bezier(0.18, 0.9, 0.3, 1.1);
}

@keyframes pop {
  from {
    opacity: 0;
    transform: translateY(14px) scale(0.94);
  }
}

.card__glyph {
  width: 52px;
  height: 52px;
  display: block;
  margin: 0 auto 12px;
}

.glyph-frame {
  fill: #c9a575;
}

.glyph-sand {
  fill: var(--accent);
}

.card__title {
  margin: 0 0 8px;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.card__body {
  margin: 0;
  font-size: 15px;
  color: var(--ink-soft);
  line-height: 1.45;
}

.card__flip {
  margin: 12px 0 0;
  font-size: 13.5px;
  font-weight: 550;
  color: var(--accent);
}

.card__actions {
  display: flex;
  gap: 10px;
  margin-top: 20px;
}

.btn {
  flex: 1 1 0;
  padding: 13px 18px;
  border-radius: 14px;
  font: inherit;
  font-weight: 650;
  font-size: 15px;
  cursor: pointer;
  border: 1px solid transparent;
  transition: transform 0.14s ease, filter 0.2s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn--solid {
  background: var(--accent);
  color: #fff;
  box-shadow: 0 8px 20px color-mix(in srgb, var(--accent) 38%, transparent);
}

.btn--ghost {
  background: rgba(74, 58, 44, 0.07);
  color: var(--ink);
  border-color: rgba(74, 58, 44, 0.12);
}

.btn--wide {
  width: 100%;
  flex: none;
}

/* --- Hoja de ajustes --- */

#sheet-scrim {
  align-items: flex-end;
  justify-content: center;
}

.sheet {
  width: min(560px, 100%);
  max-height: min(88vh, 760px);
  display: flex;
  flex-direction: column;
  background: rgba(252, 250, 245, 0.96);
  backdrop-filter: blur(22px) saturate(1.3);
  -webkit-backdrop-filter: blur(22px) saturate(1.3);
  border-radius: 26px 26px 0 0;
  box-shadow: 0 -14px 50px rgba(24, 62, 74, 0.3);
  animation: rise 0.3s cubic-bezier(0.2, 0.9, 0.3, 1);
  padding-bottom: var(--safe-bottom);
}

@media (min-width: 620px) {
  #sheet-scrim {
    align-items: center;
  }

  .sheet {
    border-radius: 26px;
    max-height: 84vh;
  }
}

@keyframes rise {
  from {
    transform: translateY(26px);
    opacity: 0;
  }
}

.sheet__grip {
  width: 42px;
  height: 4px;
  border-radius: 999px;
  background: rgba(74, 58, 44, 0.18);
  margin: 10px auto 2px;
}

.sheet__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px 12px;
  border-bottom: 1px solid rgba(74, 58, 44, 0.09);
}

.sheet__head h2 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

.sheet__scroll {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 4px 20px 24px;
  overscroll-behavior: contain;
}

.group {
  padding: 18px 0 6px;
  border-bottom: 1px solid rgba(74, 58, 44, 0.09);
}

.group--last {
  border-bottom: none;
  padding-top: 20px;
}

.group__title {
  margin: 0 0 12px;
  font-size: 12.5px;
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.presets {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.chip {
  padding: 8px 13px;
  border-radius: 999px;
  border: 1px solid rgba(74, 58, 44, 0.15);
  background: rgba(255, 255, 255, 0.7);
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
  cursor: pointer;
  transition: background 0.18s ease, border-color 0.18s ease;
}

.chip.is-active {
  background: var(--accent);
  border-color: transparent;
  color: #fff;
}

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 11px 0;
  min-height: 48px;
}

.row label {
  font-size: 15px;
  font-weight: 550;
  flex: 1 1 auto;
}

.row--slider {
  padding-top: 2px;
  padding-bottom: 14px;
}

.row--slider label {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--ink-soft);
  flex: 0 0 auto;
}

.note {
  margin: -6px 0 10px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--ink-soft);
}

.note--center {
  text-align: center;
  margin-top: 16px;
}

/* Steppers numéricos: los botones evitan tener que abrir el teclado. */

.stepper {
  display: flex;
  align-items: center;
  gap: 2px;
  flex: 0 0 auto;
}

.step {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  border: 1px solid rgba(74, 58, 44, 0.15);
  background: rgba(255, 255, 255, 0.8);
  font: inherit;
  font-size: 19px;
  font-weight: 600;
  line-height: 1;
  color: var(--ink);
  cursor: pointer;
}

.step:active {
  background: rgba(74, 58, 44, 0.08);
}

.stepper input[type="number"] {
  width: 54px;
  height: 36px;
  text-align: center;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 17px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  -moz-appearance: textfield;
  appearance: textfield;
}

.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.unit {
  font-size: 12.5px;
  color: var(--ink-soft);
  width: 34px;
  margin-left: 3px;
}

/* Interruptores */

.switch {
  appearance: none;
  -webkit-appearance: none;
  flex: 0 0 auto;
  width: 50px;
  height: 30px;
  border-radius: 999px;
  background: rgba(74, 58, 44, 0.18);
  position: relative;
  cursor: pointer;
  transition: background 0.22s ease;
  margin: 0;
}

.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
  transition: transform 0.22s cubic-bezier(0.3, 0.9, 0.3, 1.2);
}

.switch:checked {
  background: var(--accent);
}

.switch:checked::after {
  transform: translateX(20px);
}

.switch:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Sliders */

input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  flex: 1 1 auto;
  height: 26px;
  background: transparent;
  cursor: pointer;
  margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(74, 58, 44, 0.16);
}

input[type="range"]::-moz-range-track {
  height: 5px;
  border-radius: 999px;
  background: rgba(74, 58, 44, 0.16);
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 20px;
  height: 20px;
  margin-top: -7.5px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

input[type="range"]::-moz-range-thumb {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.row.is-muted {
  opacity: 0.42;
  pointer-events: none;
}

/* Accesibilidad de foco */

button:focus-visible,
input:focus-visible {
  outline: 3px solid rgba(232, 87, 127, 0.55);
  outline-offset: 2px;
}

/* Pantallas bajas (móvil apaisado): se comprime el pie para no comerse el reloj */

@media (max-height: 560px) {
  .readout__time {
    font-size: 38px;
  }

  .readout__hint {
    display: none;
  }

  .round-btn {
    width: 46px;
    height: 46px;
  }

  .round-btn--primary {
    width: 60px;
    height: 60px;
  }

  .bar--bottom {
    gap: 8px;
    padding-bottom: calc(var(--safe-bottom) + 10px);
  }
}

@media (prefers-reduced-motion: reduce) {

  .scrim,
  .card,
  .sheet {
    animation: none;
  }

  * {
    transition-duration: 0.01ms !important;
  }
}
