* {
  box-sizing: border-box;
}

/* HARD-RULE: #site-footer / #logs-link must remain visible. */
#site-footer {
  padding: 1rem;
  text-align: center;
  font-size: 0.75rem;
  opacity: 0.6;
}
#site-footer a {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dotted currentColor;
}
#site-footer a:hover { opacity: 1; }

@keyframes sheepWalk {
  0% { transform: translateX(-100px) scaleX(1); }
  48% { transform: translateX(calc(100vw + 50px)) scaleX(1); }
  50% { transform: translateX(calc(100vw + 50px)) scaleX(-1); }
  98% { transform: translateX(-100px) scaleX(-1); }
  100% { transform: translateX(-100px) scaleX(1); }
}

@keyframes cosmicDrift {
  0% { background-position: 0% 0%; }
  100% { background-position: 100% 100%; }
}

@keyframes orbPulse {
  0%, 100% { opacity: 0.4; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.15); }
}

@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}

@keyframes fogDrift {
  0% { transform: translateX(0) translateY(0); opacity: 0.15; }
  50% { transform: translateX(30px) translateY(-20px); opacity: 0.25; }
  100% { transform: translateX(0) translateY(0); opacity: 0.15; }
}

@keyframes shadowPulse {
  0%, 100% { 
    text-shadow: 0 0 20px rgba(147, 51, 234, 0.6),
                 0 0 40px rgba(59, 130, 246, 0.4),
                 0 0 60px rgba(16, 185, 129, 0.3);
  }
  50% { 
    text-shadow: 0 0 30px rgba(147, 51, 234, 0.8),
                 0 0 60px rgba(59, 130, 246, 0.6),
                 0 0 90px rgba(16, 185, 129, 0.5);
  }
}

@keyframes noteBirth {
  0% { 
    transform: scale(0) rotate(-180deg); 
    opacity: 0; 
    filter: blur(10px);
  }
  70% { 
    transform: scale(1.12) rotate(10deg); 
    opacity: 1; 
    filter: blur(0px);
  }
  100% { 
    transform: scale(1) rotate(0); 
    opacity: 1; 
    filter: blur(0px);
  }
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif;
  background: #0a0a0f;
  color: #b8c5d6;
  overflow-x: hidden;
  position: relative;
}

.void-bg {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse at 20% 30%, rgba(88, 28, 135, 0.15) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 70%, rgba(29, 78, 216, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 50%, rgba(5, 150, 105, 0.08) 0%, transparent 50%),
    #0a0a0f;
  z-index: -3;
}

.cosmic-dust {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-image: 
    radial-gradient(2px 2px at 20% 30%, rgba(255, 255, 255, 0.15), transparent),
    radial-gradient(2px 2px at 60% 70%, rgba(147, 197, 253, 0.12), transparent),
    radial-gradient(1px 1px at 50% 50%, rgba(167, 139, 250, 0.1), transparent),
    radial-gradient(1px 1px at 80% 10%, rgba(110, 231, 183, 0.08), transparent),
    radial-gradient(2px 2px at 90% 60%, rgba(248, 113, 113, 0.1), transparent);
  background-size: 200px 200px, 180px 180px, 150px 150px, 220px 220px, 190px 190px;
  animation: cosmicDrift 120s linear infinite;
  pointer-events: none;
  z-index: -2;
}

.sheep-field {
  position: fixed;
  bottom: 100px;
  left: 0;
  width: 100%;
  height: 80px;
  pointer-events: none;
  z-index: 1;
  overflow: hidden;
}

.sheep {
  position: absolute;
  font-size: 48px;
  filter: drop-shadow(0 0 8px rgba(147, 51, 234, 0.4));
  will-change: transform;
}

header {
  padding: 2rem 1.5rem 1.5rem;
  background: rgba(10, 10, 15, 0.85);
  border-bottom: 1px solid rgba(147, 51, 234, 0.3);
  backdrop-filter: blur(12px);
  position: relative;
}

h1 {
  margin: 0;
  font-size: clamp(1.8rem, 5vw, 3.2rem);
  font-weight: 900;
  color: #e9d5ff;
  letter-spacing: 0.05em;
  text-align: center;
}

.shadow-pulse {
  animation: shadowPulse 3s ease-in-out infinite;
}

.subtitle {
  margin: 0.5rem 0 0;
  font-size: clamp(0.9rem, 2vw, 1.1rem);
  color: #a78bfa;
  text-align: center;
  font-weight: 300;
  letter-spacing: 0.08em;
}

#generation-attraction {
  margin: 1.5rem auto 0.8rem;
  padding: 1rem 1.2rem;
  background: rgba(88, 28, 135, 0.15);
  border: 1px solid rgba(147, 51, 234, 0.4);
  border-radius: 50px;
  max-width: 600px;
  text-align: center;
}

.attraction-label {
  margin: 0;
  font-weight: 600;
  color: #c4b5fd;
  font-size: 0.9rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.countdown {
  margin: 0.5rem 0 0;
  font-size: clamp(2.5rem, 8vw, 4.5rem);
  line-height: 1;
  font-weight: 900;
  color: #e9d5ff;
  font-family: "Courier New", monospace;
  letter-spacing: 0.05em;
}

.clock-container {
  position: relative;
  display: inline-block;
  margin-top: 0.3rem;
}

.big-clock {
  margin: 0;
  font-size: clamp(1.2rem, 4vw, 2rem);
  font-weight: 700;
  color: #a78bfa;
  font-family: "Courier New", monospace;
  position: relative;
  z-index: 1;
}

.clock-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 120%;
  height: 120%;
  background: radial-gradient(circle, rgba(147, 51, 234, 0.3) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  animation: orbPulse 2s ease-in-out infinite;
  z-index: 0;
  pointer-events: none;
}

.last-summary {
  margin: 0.8rem 0 0;
  font-size: 0.95rem;
  color: #93c5fd;
  font-style: italic;
  line-height: 1.5;
}

.button-row {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.2rem;
  flex-wrap: wrap;
}

button {
  border: 1px solid rgba(147, 51, 234, 0.5);
  border-radius: 50px;
  background: rgba(88, 28, 135, 0.3);
  color: #e9d5ff;
  padding: 0.7rem 1.5rem;
  font-weight: 600;
  cursor: pointer;
  font-size: 0.95rem;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  letter-spacing: 0.05em;
  text-transform: lowercase;
  backdrop-filter: blur(8px);
}

button:hover:not(:disabled) {
  background: rgba(147, 51, 234, 0.5);
  border-color: rgba(167, 139, 250, 0.8);
  box-shadow: 0 0 20px rgba(147, 51, 234, 0.4);
  transform: translateY(-2px);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary .btn-icon {
  font-size: 1.2rem;
  line-height: 1;
}

#trigger-cycle-btn {
  background: rgba(29, 78, 216, 0.2);
  border-color: rgba(59, 130, 246, 0.4);
  color: #bfdbfe;
  font-size: 0.85rem;
}

#trigger-cycle-btn:hover:not(:disabled) {
  background: rgba(59, 130, 246, 0.4);
  border-color: rgba(96, 165, 250, 0.7);
  box-shadow: 0 0 20px rgba(59, 130, 246, 0.4);
}

#canvas {
  position: relative;
  min-height: calc(100vh - 200px);
  padding: 2rem 1rem;
  overflow: visible;
}

.pasture-fog {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: 
    radial-gradient(ellipse 600px 400px at 30% 40%, rgba(88, 28, 135, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 500px 350px at 70% 60%, rgba(29, 78, 216, 0.06) 0%, transparent 50%);
  animation: fogDrift 20s ease-in-out infinite;
  pointer-events: none;
}

.note {
  position: absolute;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle at 30% 30%, rgba(147, 51, 234, 0.25), rgba(29, 78, 216, 0.15));
  border: 2px solid rgba(167, 139, 250, 0.4);
  border-radius: 50%;
  box-shadow: 
    0 0 30px rgba(147, 51, 234, 0.3),
    inset 0 0 40px rgba(88, 28, 135, 0.2);
  padding: 1.5rem;
  cursor: grab;
  transition: all 0.3s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.note:hover {
  transform: scale(1.05) rotate(3deg);
  box-shadow: 
    0 0 50px rgba(147, 51, 234, 0.5),
    inset 0 0 60px rgba(88, 28, 135, 0.3);
  border-color: rgba(167, 139, 250, 0.6);
}

.note:active {
  cursor: grabbing;
}

.orb-glow {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle, rgba(147, 51, 234, 0.15) 0%, transparent 70%);
  transform: translate(-50%, -50%);
  animation: orbPulse 3s ease-in-out infinite;
  pointer-events: none;
  border-radius: 50%;
}

.note-grip {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2rem;
  color: rgba(233, 213, 255, 0.3);
  cursor: grab;
  user-select: none;
  pointer-events: none;
  z-index: 1;
}

.note textarea {
  width: 100%;
  height: 100%;
  border: 0;
  resize: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.9rem;
  color: #e9d5ff;
  text-align: center;
  cursor: text;
  position: relative;
  z-index: 2;
  line-height: 1.4;
}

.note textarea::placeholder {
  color: rgba(167, 139, 250, 0.4);
}

.note textarea:focus {
  outline: none;
  color: #f3e8ff;
}

.note-author {
  position: absolute;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.7rem;
  font-style: italic;
  color: rgba(196, 181, 253, 0.6);
  text-align: center;
  user-select: none;
  z-index: 2;
  white-space: nowrap;
}

.note-delete {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.2rem;
  line-height: 2rem;
  text-align: center;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: 50%;
  cursor: pointer;
  display: none;
  font-weight: 700;
  z-index: 3;
  transition: all 0.2s ease;
}

.note-delete:hover {
  background: rgba(239, 68, 68, 0.5);
  color: #fee2e2;
  box-shadow: 0 0 15px rgba(239, 68, 68, 0.5);
  transform: scale(1.1);
}

.shimmer-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(233, 213, 255, 0.1) 50%,
    transparent 100%
  );
  background-size: 200% 100%;
  animation: shimmer 3s linear infinite;
  pointer-events: none;
  border-radius: 50%;
  opacity: 0.5;
}

.note textarea[readonly] {
  cursor: default;
  opacity: 0.8;
}

.note.just-added {
  animation: noteBirth 1s cubic-bezier(0.34, 1.56, 0.64, 1);
  outline: 2px solid rgba(167, 139, 250, 0.8);
  outline-offset: 4px;
}

#history {
  padding: 2rem 1.5rem 4rem;
  background: rgba(10, 10, 15, 0.85);
  border-top: 1px solid rgba(147, 51, 234, 0.3);
  backdrop-filter: blur(12px);
}

.history-title {
  margin: 0 0 1.2rem;
  font-size: 1.3rem;
  color: #c4b5fd;
  text-align: center;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-weight: 700;
}

.history-icon {
  color: rgba(167, 139, 250, 0.6);
  margin: 0 0.5rem;
}

#history-list {
  margin: 0 auto;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 0.6rem;
  max-width: 800px;
}

#history-list li {
  padding: 0.8rem 1rem;
  background: rgba(88, 28, 135, 0.15);
  border-left: 3px solid rgba(147, 51, 234, 0.6);
  border-radius: 20px;
  font-size: 0.9rem;
  line-height: 1.5;
  transition: all 0.3s ease;
}

#history-list li:hover {
  background: rgba(88, 28, 135, 0.25);
  border-left-color: rgba(167, 139, 250, 0.8);
  transform: translateX(5px);
}

#history-list .history-empty {
  border-left-color: rgba(107, 114, 128, 0.4);
  color: rgba(156, 163, 175, 0.7);
  font-style: italic;
  text-align: center;
}

#history-list .history-sha {
  display: inline-block;
  font-family: "Courier New", monospace;
  font-size: 0.75rem;
  color: rgba(167, 139, 250, 0.7);
  margin-right: 0.6rem;
  background: rgba(88, 28, 135, 0.2);
  padding: 0.2rem 0.5rem;
  border-radius: 10px;
}

.history-title-text {
  color: #e9d5ff;
}

#history-list .history-date {
  display: inline-block;
  font-size: 0.75rem;
  color: rgba(147, 197, 253, 0.6);
  margin-left: 0.6rem;
  font-family: "Courier New", monospace;
}

#history-list a {
  color: inherit;
  text-decoration: none;
  display: block;
}

#history-list a:hover .history-title-text {
  color: #f3e8ff;
  text-decoration: underline;
  text-decoration-color: rgba(167, 139, 250, 0.5);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 2rem;
  transform: translateX(-50%);
  background: rgba(88, 28, 135, 0.95);
  border: 1px solid rgba(167, 139, 250, 0.5);
  color: #e9d5ff;
  padding: 0.8rem 1.5rem;
  border-radius: 50px;
  font-size: 0.9rem;
  box-shadow: 0 0 40px rgba(147, 51, 234, 0.4);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 1000;
  backdrop-filter: blur(12px);
  letter-spacing: 0.03em;
}

.toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(-8px);
}