:root {
  --bg: #190134;
  --surface: #392551;
  --border: #5a496e;
  --text: #bdb6c5;
  --muted: #9c92a8;
  --primary: #aa356e;
  --secondary: #c33678;
  --accent: #8f6c97;
  --deep: #100021;
  --surface-deep: #2b173f;
  --text-bright: #eee9f0;
  --ring: #d1a5cc;
  --danger: #d6548f;
  --serif: Georgia, "Times New Roman", serif;
  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

html { min-width: 320px; background: var(--bg); }

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  background:
    radial-gradient(ellipse at 18% -8%, rgba(143, 108, 151, 0.2), transparent 38%),
    radial-gradient(ellipse at 88% 105%, rgba(170, 53, 110, 0.12), transparent 40%),
    linear-gradient(145deg, var(--bg) 0%, #21083c 52%, var(--bg) 100%);
  font-family: var(--sans);
  line-height: 1.5;
}

body::before {
  position: fixed;
  inset: 0;
  pointer-events: none;
  content: "";
  opacity: 0.24;
  background-image:
    repeating-linear-gradient(112deg, transparent 0 13px, rgba(238, 233, 240, 0.025) 14px, transparent 15px),
    repeating-linear-gradient(9deg, transparent 0 27px, rgba(195, 54, 120, 0.02) 28px, transparent 29px);
}

button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }

.page-glow {
  position: fixed;
  top: 12%;
  left: 50%;
  width: min(84vw, 920px);
  height: 55vh;
  transform: translateX(-50%);
  border-radius: 50%;
  background: rgba(143, 108, 151, 0.08);
  filter: blur(80px);
  pointer-events: none;
}

.site-header, .site-footer, .main-shell {
  position: relative;
  z-index: 1;
  width: min(100% - 40px, 880px);
  margin-inline: auto;
}

.site-header { padding: 30px 0 16px; }

.wordmark {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  color: var(--text-bright);
  font-family: var(--serif);
  font-size: 1.08rem;
  letter-spacing: 0.035em;
  text-decoration: none;
}

.wordmark-mark {
  width: 24px;
  height: 24px;
  margin-right: 10px;
  border: 1px solid var(--accent);
  border-radius: 50% 50% 45% 55%;
  box-shadow: inset 5px 4px 0 rgba(195, 54, 120, 0.22);
}

.main-shell {
  display: grid;
  min-height: calc(100vh - 180px);
  align-content: center;
  padding: 34px 0 70px;
}

.setup-panel {
  position: relative;
  width: min(100%, 660px);
  margin-inline: auto;
  padding: clamp(30px, 5vw, 54px);
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 4px 58px 4px 4px;
  background: linear-gradient(145deg, rgba(57, 37, 81, 0.96), rgba(43, 23, 63, 0.98));
  box-shadow: 0 34px 80px rgba(9, 0, 19, 0.38), inset 0 1px 0 rgba(238, 233, 240, 0.08);
  animation: reveal 420ms ease-out both;
}

.setup-panel::after {
  position: absolute;
  top: -72px;
  right: -62px;
  width: 180px;
  height: 180px;
  border: 1px solid rgba(143, 108, 151, 0.45);
  border-radius: 43% 57% 49% 51%;
  content: "";
  pointer-events: none;
}

.eyebrow, .card-brand {
  margin: 0 0 14px;
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.19em;
  text-transform: uppercase;
}

h1 { margin: 0; }

.setup-panel h1 {
  max-width: 520px;
  color: var(--text-bright);
  font-family: var(--serif);
  font-size: clamp(2.2rem, 7vw, 4.15rem);
  font-weight: 400;
  line-height: 0.98;
  letter-spacing: -0.035em;
}

.intro { margin: 20px 0 36px; color: var(--muted); }

.field { margin-top: 23px; }

label {
  display: block;
  margin-bottom: 9px;
  color: var(--text-bright);
  font-size: 0.86rem;
  font-weight: 650;
}

input {
  width: 100%;
  min-height: 52px;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: 3px;
  color: var(--text-bright);
  background: rgba(25, 1, 52, 0.68);
  outline: none;
}

input:hover { border-color: var(--accent); }
input:focus-visible, button:focus-visible, a:focus-visible {
  outline: 3px solid var(--ring);
  outline-offset: 3px;
}

input[aria-invalid="true"] { border-color: var(--danger); }
input::-webkit-calendar-picker-indicator { filter: invert(0.8) sepia(0.2) saturate(0.7); cursor: pointer; }

.field-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 7px;
  color: var(--muted);
  font-size: 0.74rem;
}

.field-hint, .field-error { margin: 7px 0 0; font-size: 0.76rem; }
.field-hint { color: var(--muted); }
.field-error { min-height: 1.15em; color: #e2a2c2; }

.form-actions, .result-actions, .reset-confirm > div {
  display: flex;
  flex-wrap: wrap;
  gap: 11px;
  margin-top: 30px;
}

.button {
  min-height: 46px;
  padding: 11px 19px;
  border: 1px solid transparent;
  border-radius: 2px 16px 2px 2px;
  cursor: pointer;
  font-weight: 700;
  transition: transform 150ms ease, border-color 150ms ease, background-color 150ms ease;
}

.button:hover { transform: translateY(-1px); }
.button:active { transform: translateY(0); }
.button-primary { color: var(--deep); background: var(--secondary); }
.button-primary:hover { background: #d34b8c; }
.button-secondary { color: var(--text-bright); border-color: var(--border); background: var(--surface); }
.button-secondary:hover { border-color: var(--accent); background: #452d60; }
.button-quiet { color: var(--text); border-color: transparent; background: transparent; }
.button-quiet:hover { border-color: var(--border); }
.button-danger { color: var(--deep); background: var(--danger); }

.result-panel { width: 100%; animation: reveal 420ms ease-out both; }

.countdown-card {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: clamp(28px, 6vw, 62px);
  border: 1px solid var(--border);
  border-radius: 4px 72px 4px 4px;
  background:
    linear-gradient(118deg, rgba(238, 233, 240, 0.04), transparent 23%),
    linear-gradient(150deg, var(--surface), var(--surface-deep));
  box-shadow: 0 40px 90px rgba(9, 0, 19, 0.44), inset 0 1px 0 rgba(238, 233, 240, 0.09);
}

.card-curve {
  position: absolute;
  z-index: -1;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(143, 108, 151, 0.42);
  pointer-events: none;
}

.card-curve-top { top: -132px; right: -62px; border-radius: 45% 55% 65% 35%; transform: rotate(18deg); }
.card-curve-bottom { bottom: -184px; left: -74px; border-radius: 64% 36% 48% 52%; transform: rotate(-30deg); }

.card-brand { color: var(--accent); }

.countdown-title {
  max-width: 760px;
  overflow-wrap: anywhere;
  color: var(--text-bright);
  font-family: var(--serif);
  font-size: clamp(2rem, 6vw, 4.8rem);
  font-weight: 400;
  line-height: 1;
  letter-spacing: -0.035em;
}

.completed-label {
  margin: 13px 0 0;
  color: var(--text);
  font-family: var(--serif);
  font-size: clamp(1.1rem, 3vw, 1.55rem);
  overflow-wrap: anywhere;
}

.time-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-top: clamp(30px, 6vw, 58px);
}

.time-cell {
  min-width: 0;
  padding: 17px 12px 14px;
  border-top: 1px solid var(--border);
  background: rgba(25, 1, 52, 0.26);
  text-align: center;
}

.time-value {
  display: block;
  overflow: hidden;
  color: var(--text-bright);
  font-family: var(--serif);
  font-size: clamp(2.25rem, 8vw, 5rem);
  font-variant-numeric: tabular-nums lining-nums;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.time-unit {
  display: block;
  margin-top: 9px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.deadline-rule { width: 44px; margin: 28px 0 13px; border-top: 2px solid var(--primary); }
.deadline { margin: 0; color: var(--muted); font-size: 0.82rem; }

.result-actions { justify-content: center; margin-top: 21px; }

.reset-confirm {
  width: fit-content;
  margin: 18px auto 0;
  padding: 18px 20px;
  border: 1px solid var(--border);
  background: var(--surface-deep);
  text-align: center;
}

.reset-confirm p { margin: 0; color: var(--text-bright); }
.reset-confirm > div { justify-content: center; margin-top: 12px; }

.notice {
  min-height: 1.5em;
  margin: 18px auto 0;
  color: var(--muted);
  font-size: 0.8rem;
  text-align: center;
}

.site-footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 20px 0 28px;
  border-top: 1px solid rgba(90, 73, 110, 0.55);
  color: var(--muted);
  font-size: 0.72rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

[hidden] { display: none !important; }

@keyframes reveal {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@media (max-width: 640px) {
  .site-header, .site-footer, .main-shell { width: min(100% - 28px, 880px); }
  .site-header { padding-top: 18px; }
  .main-shell { padding-top: 18px; }
  .setup-panel { border-radius: 3px 42px 3px 3px; }
  .countdown-card { border-radius: 3px 48px 3px 3px; }
  .time-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .button { flex: 1 1 180px; }
  .result-actions .button { flex: 0 1 auto; }
}

@media (max-width: 380px) {
  .setup-panel, .countdown-card { padding: 25px 20px; }
  .time-value { font-size: clamp(2.15rem, 15vw, 3.4rem); }
  .result-actions { align-items: stretch; flex-direction: column; }
}

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