:root {
  --bg: #090c11;
  --panel: #0b1016;
  --ring: #10f1dd;
  --ring-soft: rgba(16, 241, 221, 0.18);
  --text: #1ff3d4;
  --text-dim: rgba(184, 247, 237, 0.72);
  --muted: rgba(143, 235, 224, 0.45);
  --button-dark: #0e131b;
  --button-border: rgba(103, 121, 156, 0.34);
  --button-accent: #35f0cf;
  --button-accent-text: #051013;
  --shadow-glow: 0 0 24px rgba(16, 241, 221, 0.24);
  --shadow-strong: 0 0 42px rgba(16, 241, 221, 0.14);
  --ring-ambient-opacity: 0.6;
  --ring-ambient-scale: 1;
  --ring-run-opacity: 0;
  --ring-run-scale: 0.94;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  font-family: "Rajdhani", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(12, 37, 37, 0.36), transparent 28%),
    radial-gradient(circle at bottom, rgba(7, 16, 23, 0.84), transparent 42%),
    linear-gradient(180deg, #070a0f 0%, #090c11 45%, #06080d 100%);
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.015), transparent 28%, transparent 72%, rgba(255, 255, 255, 0.015));
}

.particles {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.grid-field {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  opacity: 0.7;
}

.app-shell {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.timer-panel {
  position: relative;
  width: min(100%, 520px);
  padding: 8px 0 28px;
  background: transparent;
}

.panel-noise {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.04;
  background-image:
    radial-gradient(circle at 24% 32%, rgba(255, 255, 255, 0.9) 0.5px, transparent 1px),
    radial-gradient(circle at 74% 64%, rgba(255, 255, 255, 0.7) 0.5px, transparent 1px);
  background-size: 28px 28px, 24px 24px;
}

.timer-layout {
  position: relative;
  z-index: 1;
  display: grid;
  justify-items: center;
  gap: 28px;
}

.ring-wrapper {
  position: relative;
  width: min(100%, 404px);
  aspect-ratio: 1 / 1.08;
  display: grid;
  place-items: center;
}

.finish-flash,
.finish-wave {
  position: absolute;
  inset: 12%;
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}

.finish-flash {
  background: radial-gradient(circle, rgba(255, 255, 255, 0.46) 0%, rgba(16, 241, 221, 0.2) 28%, transparent 62%);
  filter: blur(12px);
}

.finish-wave {
  border: 1px solid rgba(99, 255, 235, 0.58);
  box-shadow: 0 0 18px rgba(16, 241, 221, 0.24);
  transform: scale(0.72);
}

.ring-wrapper::before,
.ring-wrapper::after {
  content: "";
  position: absolute;
  inset: 10%;
  border-radius: 50%;
  pointer-events: none;
}

.ring-wrapper::before {
  background: radial-gradient(circle, rgba(16, 241, 221, 0.12) 0%, rgba(16, 241, 221, 0.06) 34%, transparent 68%);
  opacity: var(--ring-ambient-opacity);
  transform: scale(var(--ring-ambient-scale));
  filter: blur(22px);
  transition: opacity 0.8s ease, transform 0.8s ease, filter 0.8s ease;
}

.ring-wrapper::after {
  inset: 7%;
  background: radial-gradient(circle, rgba(16, 241, 221, 0.2) 0%, rgba(16, 241, 221, 0.08) 28%, transparent 62%);
  opacity: var(--ring-run-opacity);
  transform: scale(var(--ring-run-scale));
  filter: blur(28px);
  transition: opacity 0.95s ease, transform 0.95s ease, filter 0.95s ease;
}

.ring-visual {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  transform-origin: center;
  transition: filter 0.35s ease, opacity 0.35s ease;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 0 12px rgba(16, 241, 221, 0.3)) drop-shadow(0 0 24px rgba(16, 241, 221, 0.16));
  transition: filter 0.35s ease, opacity 0.35s ease;
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 6;
}

.ring-track {
  stroke: rgba(16, 241, 221, 0.09);
}

.ring-progress {
  stroke: url(#ringGradient);
  stroke-linecap: round;
  transition: stroke-dashoffset 0.08s linear, filter 0.35s ease, opacity 0.35s ease;
}

.time-display {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 14px;
  pointer-events: none;
  transition: opacity 0.35s ease, filter 0.35s ease;
}

.time-display.is-hidden {
  opacity: 0;
  transform: scale(0.96);
}

.time-display.is-finishing {
  opacity: 1;
  filter: saturate(1.08);
}

.time-core {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  transform: scale(0.9);
  transform-origin: center;
}

.digit-group {
  display: block;
}

.digit-pair {
  display: flex;
  align-items: center;
}

.digit-stack {
  position: relative;
  width: 60px;
  height: 76px;
  overflow: hidden;
}

.digit-stack span {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(3rem, 6.4vw, 3.9rem);
  font-weight: 800;
  line-height: 1;
  color: var(--text);
  text-shadow: 0 0 12px rgba(16, 241, 221, 0.45), 0 0 34px rgba(16, 241, 221, 0.18);
  transform: translateY(100%);
  opacity: 0;
  filter: blur(0);
  transition: text-shadow 0.5s ease, opacity 0.35s ease, filter 0.35s ease;
}

.digit-stack:not(.is-animating) span:first-child {
  transform: translateY(0%);
  opacity: 1;
}

.digit-stack:not(.is-animating) span:last-child {
  transform: translateY(100%);
  opacity: 0;
}

.digit-stack.is-animating span:first-child.is-sliding-out {
}

.digit-stack.is-animating span:last-child.is-sliding-in {
}

.digit-stack[data-direction="up"].is-animating span:first-child.is-sliding-out {
  animation: digitOutDown 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.digit-stack[data-direction="up"].is-animating span:last-child.is-sliding-in {
  animation: digitInFromTop 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.digit-stack[data-direction="down"].is-animating span:first-child.is-sliding-out {
  animation: digitOutUp 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.digit-stack[data-direction="down"].is-animating span:last-child.is-sliding-in {
  animation: digitInFromBottom 0.42s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.separator {
  width: 22px;
  display: grid;
  place-items: center;
  font-family: "Orbitron", sans-serif;
  font-size: clamp(2.5rem, 5vw, 3.2rem);
  font-weight: 800;
  color: var(--text);
  transform: translateY(-3px);
  text-shadow: 0 0 12px rgba(16, 241, 221, 0.42), 0 0 26px rgba(16, 241, 221, 0.18);
}

.mode-label {
  font-size: 0.66rem;
  letter-spacing: 0.45em;
  text-transform: uppercase;
  color: var(--text-dim);
}

.control-panel {
  width: min(100%, 324px);
  display: grid;
  gap: 18px;
}

.actions {
  display: grid;
  gap: 14px;
}

.secondary-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
}

.action-button {
  position: relative;
  width: 100%;
  border: 1px solid var(--button-border);
  border-radius: 10px;
  padding: 14px 18px;
  background: var(--button-dark);
  color: rgba(230, 250, 247, 0.92);
  font: 700 0.96rem "Rajdhani", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease, background 0.2s ease;
}

.action-button:hover,
.action-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(81, 233, 214, 0.62);
  box-shadow: 0 0 0 1px rgba(81, 233, 214, 0.14) inset, 0 0 20px rgba(16, 241, 221, 0.12);
}

.action-button--primary {
  background: linear-gradient(180deg, #44f4d4 0%, #2ce9c6 100%);
  color: var(--button-accent-text);
  border-color: transparent;
  box-shadow: 0 0 18px rgba(44, 233, 198, 0.22);
}

.action-button--primary:hover,
.action-button--primary:focus-visible {
  box-shadow: 0 0 28px rgba(44, 233, 198, 0.3);
}

.preset-card {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  opacity: 0.82;
}

.field {
  display: grid;
  gap: 8px;
}

.field span {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--muted);
}

.field input {
  width: 100%;
  border: 1px solid rgba(84, 103, 136, 0.32);
  border-radius: 10px;
  padding: 12px 46px 12px 14px;
  background: rgba(11, 16, 22, 0.94);
  color: rgba(233, 255, 252, 0.92);
  font: inherit;
  font-size: 1rem;
  outline: none;
  appearance: textfield;
  -moz-appearance: textfield;
}

.field input:focus {
  border-color: rgba(66, 231, 209, 0.6);
  box-shadow: 0 0 16px rgba(16, 241, 221, 0.12);
}

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

.input-shell {
  position: relative;
}

.stepper {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: grid;
  gap: 4px;
}

.stepper-button {
  width: 24px;
  height: 18px;
  border: 1px solid rgba(84, 103, 136, 0.38);
  border-radius: 6px;
  padding: 0;
  background: linear-gradient(180deg, rgba(20, 30, 38, 0.98), rgba(12, 19, 26, 0.98));
  color: rgba(224, 252, 247, 0.88);
  font: 700 0.82rem/1 "Rajdhani", sans-serif;
  cursor: pointer;
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.stepper-button:hover,
.stepper-button:focus-visible {
  border-color: rgba(81, 233, 214, 0.56);
  box-shadow: 0 0 14px rgba(16, 241, 221, 0.1);
  transform: translateY(-1px);
}

.finish-overlay {
  position: absolute;
  left: 50%;
  bottom: 42px;
  transform: translateX(-50%) translateY(14px);
  padding: 10px 16px;
  border: 1px solid rgba(90, 110, 141, 0.34);
  border-radius: 999px;
  background: rgba(11, 16, 22, 0.9);
  color: rgba(222, 250, 245, 0.84);
  font: 700 0.8rem "Rajdhani", sans-serif;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.timer-panel.is-finished .finish-overlay {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(-50%) translateY(0);
}

.timer-panel.is-running .ring-wrapper {
  --ring-ambient-opacity: 0.76;
  --ring-ambient-scale: 1;
  --ring-run-opacity: 0.88;
  --ring-run-scale: 1;
}

.timer-panel.is-running .progress-ring {
  filter: drop-shadow(0 0 16px rgba(16, 241, 221, 0.42)) drop-shadow(0 0 32px rgba(16, 241, 221, 0.24));
}

.timer-panel.is-running .ring-progress {
  animation: none;
  opacity: 1;
  filter: drop-shadow(0 0 12px rgba(16, 241, 221, 0.34)) drop-shadow(0 0 24px rgba(16, 241, 221, 0.16));
}

.timer-panel.is-paused .ring-visual {
  animation: none;
}

.timer-panel.is-paused .ring-wrapper {
  --ring-ambient-opacity: 0.48;
  --ring-ambient-scale: 0.995;
  --ring-run-opacity: 0.16;
  --ring-run-scale: 0.985;
}

.timer-panel.is-paused .progress-ring {
  filter: drop-shadow(0 0 8px rgba(16, 241, 221, 0.14)) drop-shadow(0 0 14px rgba(16, 241, 221, 0.06));
}

.timer-panel.is-paused .ring-progress {
  animation: none;
  opacity: 0.72;
  filter: drop-shadow(0 0 6px rgba(16, 241, 221, 0.16)) drop-shadow(0 0 12px rgba(16, 241, 221, 0.07));
}

.timer-panel.is-paused .time-display {
  filter: saturate(0.92);
}

.timer-panel.is-paused .digit-stack span,
.timer-panel.is-paused .separator {
  text-shadow: 0 0 8px rgba(16, 241, 221, 0.26), 0 0 18px rgba(16, 241, 221, 0.1);
}

.timer-panel.is-danger .ring-wrapper {
  --ring-ambient-opacity: 0.9;
  --ring-run-opacity: 1;
}

.timer-panel.is-danger .ring-progress {
  filter: drop-shadow(0 0 16px rgba(16, 241, 221, 0.52)) drop-shadow(0 0 34px rgba(16, 241, 221, 0.3));
}

.timer-panel.is-finished .ring-progress {
  opacity: 0.4;
}

.timer-panel.is-finished .finish-flash {
  animation: finishFlash 0.8s ease-out forwards;
}

.timer-panel.is-finished .finish-wave {
  animation: finishWave 1.1s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.timer-panel.is-finished .time-display {
  animation: finishHold 0.9s ease-out forwards;
}

.timer-panel.is-refilling .time-display {
  animation: refillIn 1s cubic-bezier(0.22, 1, 0.36, 1);
}

.timer-panel.is-refilling .ring-wrapper {
  --ring-ambient-opacity: 0.88;
  --ring-ambient-scale: 1.01;
  --ring-run-opacity: 0.96;
  --ring-run-scale: 1.01;
}

.timer-panel.is-refilling .progress-ring {
  filter: drop-shadow(0 0 18px rgba(16, 241, 221, 0.46)) drop-shadow(0 0 34px rgba(16, 241, 221, 0.24));
}

.timer-panel.is-refilling .ring-progress {
  transition: stroke-dashoffset 1s cubic-bezier(0.22, 1, 0.36, 1), filter 0.35s ease, opacity 0.35s ease;
  opacity: 1;
  filter: drop-shadow(0 0 16px rgba(16, 241, 221, 0.42)) drop-shadow(0 0 28px rgba(16, 241, 221, 0.2));
}

@keyframes refillIn {
  0% {
    opacity: 0.55;
    transform: translateY(-10px);
    filter: blur(6px);
  }

  100% {
    opacity: 1;
    transform: translateY(0);
    filter: blur(0);
  }
}

@keyframes finishFlash {
  0% {
    opacity: 0;
    transform: scale(0.8);
  }

  20% {
    opacity: 1;
    transform: scale(1.02);
  }

  100% {
    opacity: 0;
    transform: scale(1.18);
  }
}

@keyframes finishWave {
  0% {
    opacity: 0.92;
    transform: scale(0.72);
  }

  100% {
    opacity: 0;
    transform: scale(1.28);
  }
}

@keyframes finishHold {
  0% {
    filter: saturate(1) brightness(1);
  }

  25% {
    filter: saturate(1.18) brightness(1.08);
  }

  100% {
    filter: saturate(1.04) brightness(1);
  }
}

@keyframes digitOutUp {
  from {
    transform: translateY(0%);
    opacity: 1;
    filter: blur(0);
  }

  to {
    transform: translateY(-100%);
    opacity: 0;
    filter: blur(7px);
  }
}

@keyframes digitInFromBottom {
  from {
    transform: translateY(100%);
    opacity: 0;
    filter: blur(7px);
  }

  to {
    transform: translateY(0%);
    opacity: 1;
    filter: blur(0);
  }
}

@keyframes digitOutDown {
  from {
    transform: translateY(0%);
    opacity: 1;
    filter: blur(0);
  }

  to {
    transform: translateY(100%);
    opacity: 0;
    filter: blur(7px);
  }
}

@keyframes digitInFromTop {
  from {
    transform: translateY(-100%);
    opacity: 0;
    filter: blur(7px);
  }

  to {
    transform: translateY(0%);
    opacity: 1;
    filter: blur(0);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 14px 12px 18px;
  }

  .timer-panel {
    width: 100%;
    padding-bottom: 18px;
  }

  .ring-wrapper {
    width: min(100%, 312px);
  }

  .timer-layout {
    gap: 18px;
  }

  .time-display {
    gap: 10px;
  }

  .time-core {
    transform: scale(0.84);
  }

  .digit-stack {
    width: 44px;
    height: 58px;
  }

  .separator {
    width: 14px;
    font-size: 2.2rem;
  }

  .mode-label {
    font-size: 0.56rem;
    letter-spacing: 0.34em;
  }

  .control-panel {
    width: min(100%, 296px);
    gap: 14px;
  }

  .actions {
    gap: 10px;
  }

  .action-button {
    padding: 12px 14px;
    font-size: 0.88rem;
    letter-spacing: 0.14em;
  }

  .preset-card {
    gap: 8px;
  }

  .field span {
    font-size: 0.64rem;
  }

  .field input {
    padding: 11px 42px 11px 12px;
    font-size: 0.94rem;
  }

  .stepper {
    right: 6px;
    gap: 3px;
  }

  .stepper-button {
    width: 22px;
    height: 16px;
    font-size: 0.74rem;
  }

  .finish-overlay {
    bottom: 28px;
    padding: 9px 14px;
    font-size: 0.72rem;
  }
}

@media (max-width: 400px) {
  .ring-wrapper {
    width: min(100%, 286px);
  }

  .time-core {
    transform: scale(0.77);
  }

  .control-panel {
    width: min(100%, 272px);
  }

  .field input {
    font-size: 0.9rem;
  }
}

@media (max-height: 760px) {
  .app-shell {
    padding-top: 10px;
    padding-bottom: 14px;
  }

  .timer-layout {
    gap: 14px;
  }

  .ring-wrapper {
    width: min(100%, 300px);
  }

  .time-core {
    transform: scale(0.8);
  }

  .control-panel {
    gap: 12px;
  }

  .action-button {
    padding: 11px 14px;
  }

  .preset-card {
    gap: 8px;
  }
}

@media (max-height: 680px) {
  .ring-wrapper {
    width: min(100%, 268px);
  }

  .time-display {
    gap: 8px;
  }

  .time-core {
    transform: scale(0.72);
  }

  .mode-label {
    font-size: 0.52rem;
    letter-spacing: 0.28em;
  }
}
