:root {
  color-scheme: dark;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --bg: #050510;
  --panel: rgba(12, 12, 40, 0.7);
  --border: rgba(23, 255, 196, 0.25);
  --text-primary: #f4f8ff;
  --text-secondary: rgba(244, 248, 255, 0.7);
  --primary: #C200FB;
  --secondary: #17FFC4;
  --yellow: #FFFF00;
  --blue: #1AC8ED;
  --orange: #FF8811;
  background-color: var(--bg);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-primary);
  background: radial-gradient(circle at top left, rgba(194, 0, 251, 0.2), transparent 55%),
    radial-gradient(circle at bottom right, rgba(23, 255, 196, 0.2), transparent 55%),
    var(--bg);
}

main.app-shell {
  width: min(1100px, 92vw);
  padding: 1.5rem clamp(1.5rem, 4vw, 3rem) 2rem;
  border-radius: 24px;
  border: 1px solid var(--border);
  background: linear-gradient(135deg, rgba(21, 26, 54, 0.85), rgba(6, 10, 27, 0.9));
  box-shadow: 0 40px 80px rgba(3, 4, 17, 0.65);
  display: grid;
  grid-template-columns: minmax(300px, 1.5fr) minmax(220px, 1fr);
  grid-template-rows: auto 1fr;
  gap: clamp(1.5rem, 4vw, 2.5rem);
  align-items: start;
}

.header-wrapper {
  position: relative;
  grid-column: 2;
  grid-row: 1;
}

.app-header {
  text-align: left;
  padding-right: 3rem;
}

.timer-section {
  grid-column: 1;
  grid-row: 1 / -1;
}

.controls-wrapper {
  grid-column: 2;
  grid-row: 2;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.6rem, 3.5vw, 2.2rem);
  font-weight: 700;
}

.app-header p {
  margin: 0.4rem 0 0;
  color: var(--text-secondary);
  font-size: 0.9rem;
}

.timer-section {
  display: grid;
  justify-items: center;
  gap: 1rem;
  position: relative;
}

.timer-visual {
  position: relative;
  width: min(520px, 70vw);
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: rgba(5, 10, 24, 0.45);
  border: 1px solid rgba(23, 255, 196, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}



.rings-container {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 1;
}

.ring-separator {
  position: absolute;
  width: var(--separator-size);
  height: var(--separator-size);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.95);
  pointer-events: none;
}

.ring {
  position: absolute;
  width: var(--ring-size);
  height: var(--ring-size);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  --ring-progress: 1;
  border-radius: 50%;
}

.ring::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: var(--ring-width, 48px) solid transparent;
  box-sizing: border-box;
  background: conic-gradient(from 0deg,
      var(--ring-color-a, #25ffe0) 0deg,
      var(--ring-color-b, #ff6af1) calc(var(--ring-angle-deg, var(--ring-max-angle, 360deg)) * 0.5),
      var(--ring-color-c, #1ac8ed) var(--ring-angle-deg, var(--ring-max-angle, 360deg)),
      rgba(0, 0, 0, 0.95) var(--ring-angle-deg, var(--ring-max-angle, 360deg)),
      rgba(0, 0, 0, 0.95) 360deg) border-box;
  -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
  mask-composite: exclude;
  pointer-events: none;
  animation: ringColorFlow 28s ease-in-out infinite alternate;
}

@keyframes ringColorFlow {
  0% {
    filter: hue-rotate(0deg) saturate(100%) brightness(1);
    opacity: 0.85;
  }
  50% {
    filter: hue-rotate(15deg) saturate(120%) brightness(1.1);
    opacity: 1;
  }
  100% {
    filter: hue-rotate(-10deg) saturate(110%) brightness(1.05);
    opacity: 0.9;
  }
}

@keyframes ringGlow {
  0% {
    filter: blur(0.6px) saturate(110%);
    opacity: 0.7;
  }
  50% {
    filter: blur(1.1px) saturate(130%);
    opacity: 0.95;
  }
  100% {
    filter: blur(0.7px) saturate(115%);
    opacity: 0.8;
  }
}

@keyframes ringSweep {
  0% {
    filter: hue-rotate(0deg);
  }
  50% {
    filter: hue-rotate(24deg);
  }
  100% {
    filter: hue-rotate(-16deg);
  }
}


.inner-circle {
  position: relative;
  width: 57%;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  overflow: hidden;
  background: #04050c;
  box-shadow: inset 0 0 60px rgba(0, 0, 0, 0.55);
  border: 8px solid rgba(0, 0, 0, 0.95);
  box-sizing: border-box;
  z-index: 10;
}

.inner-fill {
  position: absolute;
  inset: 0;
  background: linear-gradient(140deg, rgba(194, 0, 251, 0.85), rgba(26, 200, 237, 0.75), rgba(23, 255, 196, 0.65));
  animation: auroraFlow 28s ease-in-out infinite alternate;
  --mask-angle: 360deg;
  transform-origin: center;
  -webkit-mask-image: conic-gradient(from 0deg, rgba(0, 0, 0, 1) 0deg, rgba(0, 0, 0, 1) var(--mask-angle), rgba(0, 0, 0, 0) var(--mask-angle), rgba(0, 0, 0, 0) 360deg);
  mask-image: conic-gradient(from 0deg, rgba(0, 0, 0, 1) 0deg, rgba(0, 0, 0, 1) var(--mask-angle), rgba(0, 0, 0, 0) var(--mask-angle), rgba(0, 0, 0, 0) 360deg);
  transition: -webkit-mask-image 0.35s ease, mask-image 0.35s ease;
  will-change: mask-image;
}

.inner-fill.is-count-up {
  --mask-angle: 0deg;
}

.inner-overlay {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 35% 35%, rgba(255, 255, 255, 0.3), transparent 55%),
    radial-gradient(circle at 65% 70%, rgba(13, 30, 77, 0.35), transparent 60%);
  mix-blend-mode: screen;
  opacity: 0.45;
  pointer-events: none;
  animation: innerGlow 34s ease-in-out infinite alternate;
}

@keyframes auroraFlow {
  0% {
    transform: scale(1.1);
    filter: hue-rotate(0deg) saturate(110%);
  }
  50% {
    transform: scale(1.14);
    filter: hue-rotate(20deg) saturate(125%);
  }
  100% {
    transform: scale(1.09);
    filter: hue-rotate(-15deg) saturate(115%);
  }
}

@keyframes innerGlow {
  0% {
    opacity: 0.35;
    transform: scale(1);
  }
  50% {
    opacity: 0.55;
    transform: scale(1.02);
  }
  100% {
    opacity: 0.4;
    transform: scale(0.99);
  }
}

.inner-circle::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.25), transparent 55%);
  mix-blend-mode: screen;
}

.readout-wrapper {
  position: relative;
  display: flex;
  justify-content: center;
}

.timer-readout {
  border-radius: 18px;
  backdrop-filter: blur(16px);
  background: rgba(7, 9, 26, 0.55);
  border: 1px solid rgba(23, 255, 196, 0.2);
  padding: 1.15rem 3.5rem 1.15rem 1.8rem;
  text-align: center;
  display: grid;
  gap: 0.45rem;
  width: fit-content;
}

.time-display {
  font-variant-numeric: tabular-nums;
  font-size: clamp(1.8rem, 4vw, 2.2rem);
  letter-spacing: 0.08em;
}

.mode-display {
  font-size: 0.85rem;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.controls-wrapper {
  display: grid;
  gap: clamp(1.2rem, 3vw, 1.8rem);
  align-content: start;
  position: relative;
}

.controls-section {
  display: grid;
  gap: clamp(1.2rem, 3vw, 1.8rem);
  align-content: start;
}

.timer-form {
  display: grid;
  gap: 1.2rem;
  padding: 1.5rem;
  border-radius: 18px;
  border: 1px solid rgba(23, 255, 196, 0.25);
  background: rgba(11, 13, 33, 0.55);
}

.timer-form fieldset {
  border: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 0.75rem;
}

.timer-form legend {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  color: var(--text-primary);
  font-weight: 600;
}

.duration-fields {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.duration-fields label {
  display: grid;
  gap: 0.35rem;
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.duration-fields input {
  width: 100%;
  padding: 0.55rem 0.65rem;
  border-radius: 10px;
  border: 1px solid rgba(23, 255, 196, 0.35);
  background: rgba(8, 10, 21, 0.7);
  color: var(--text-primary);
  font-size: 1rem;
}

.mode-fields {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.radio-option {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.radio-option input[type="radio"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary);
}

.primary {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.65rem 1.8rem;
  border-radius: 999px;
  border: none;
  color: #050510;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  font-weight: 600;
  letter-spacing: 0.08em;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(20, 114, 179, 0.35);
  transition: transform 180ms ease, box-shadow 240ms ease;
}

.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 18px 32px rgba(20, 114, 179, 0.5);
}

.primary:active {
  transform: translateY(1px);
}

.ghost {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  padding: 0.65rem 1.8rem;
  border-radius: 999px;
  border: 1px solid rgba(23, 255, 196, 0.35);
  background: transparent;
  color: var(--text-secondary);
  font-weight: 500;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: border 180ms ease, color 180ms ease;
}

.ghost:hover {
  border-color: rgba(23, 255, 196, 0.6);
  color: var(--text-primary);
}

.action-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.footer-wrapper {
  position: relative;
  margin-top: 5rem;
}

.app-footer {
  padding: 1.5rem 1.2rem;
  border-radius: 18px;
  border: 1px solid rgba(23, 255, 196, 0.25);
  background: rgba(11, 13, 33, 0.55);
  display: grid;
  gap: 1.5rem;
}

.footer-connect h3 {
  margin: 0 0 0.75rem 0;
  font-size: 1.2rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding-right: 3rem;
}

.social-buttons {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.social-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 1.2rem;
  border-radius: 999px;
  border: 1px solid rgba(23, 255, 196, 0.35);
  background: transparent;
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 500;
  font-size: 0.9rem;
  transition: all 180ms ease;
}

.social-btn:hover {
  border-color: rgba(23, 255, 196, 0.6);
  color: var(--text-primary);
  background: rgba(23, 255, 196, 0.05);
}

.footer-story {
  display: grid;
  gap: 1rem;
}

.story-toggle {
  background: transparent;
  border: none;
  color: var(--secondary);
  font-size: 1rem;
  font-weight: 500;
  text-align: left;
  cursor: pointer;
  padding: 0.5rem 0;
  transition: color 180ms ease;
}

.story-toggle:hover {
  color: var(--primary);
}

.story-content {
  display: none;
  gap: 1rem;
  color: var(--text-secondary);
  line-height: 1.6;
  font-size: 0.95rem;
}

.story-content.visible {
  display: grid;
}

.story-content p {
  margin: 0;
}

.story-content strong {
  color: var(--text-primary);
}

@media (max-width: 1000px) {
  main.app-shell {
    grid-template-columns: 1fr;
  }

  .timer-visual {
    width: min(520px, 80vw);
    margin: 0 auto;
  }

  .footer-wrapper {
    margin-top: 1rem;
  }

  /* Reorder layout on mobile: header at top */
  main.app-shell {
    display: flex;
    flex-direction: column;
  }

  .header-wrapper {
    order: 1;
  }

  .timer-section {
    order: 2;
  }

  .controls-wrapper {
    order: 3;
  }

  .app-header {
    text-align: center;
  }
}

@media (max-width: 560px) {
  .duration-fields {
    grid-template-columns: 1fr;
  }

  .mode-fields {
    grid-template-columns: 1fr;
  }

  .action-buttons {
    justify-content: center;
  }
}
