* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --bg-primary: #1a1625;
  --bg-secondary: #2d2640;
  --accent-lavender: #b794f4;
  --accent-mint: #68d391;
  --accent-pink: #f687b3;
  --accent-coral: #fc8181;
  --accent-gold: #ffd93d;
  --text-primary: #f7fafc;
  --text-secondary: #a0aec0;
}

body {
  font-family: 'Bricolage Grotesque', sans-serif;
  background: linear-gradient(135deg, var(--bg-primary) 0%, #2a1f3d 50%, var(--bg-secondary) 100%);
  min-height: 100vh;
  color: var(--text-primary);
  overflow-x: hidden;
}

.app {
  min-height: 100vh;
  padding: 1rem;
  max-width: 600px;
  margin: 0 auto;
  position: relative;
}

.header {
  text-align: center;
  padding: 2rem 0;
  animation: fadeInDown 0.8s ease-out;
}

@keyframes fadeInDown {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.main-title {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-lavender), var(--accent-pink), var(--accent-coral));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  margin-bottom: 0.5rem;
}

.subtitle {
  font-size: 0.95rem;
  color: var(--text-secondary);
  font-style: italic;
}

.main-content {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.meter-section {
  display: flex;
  justify-content: center;
  animation: fadeIn 1s ease-out 0.2s both;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.patience-meter-container {
  position: relative;
  width: 280px;
  height: 280px;
}

.patience-meter {
  width: 100%;
  height: 100%;
  filter: drop-shadow(0 0 20px rgba(183, 148, 244, 0.3));
}

.meter-fill {
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}

.meter-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
}

.meter-percentage {
  font-size: 3.5rem;
  font-weight: 800;
  font-family: 'Space Mono', monospace;
  background: linear-gradient(135deg, var(--accent-mint), var(--accent-lavender));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.meter-title {
  font-size: 1rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.counter-section {
  text-align: center;
  animation: fadeIn 1s ease-out 0.4s both;
}

.iteration-display {
  margin-bottom: 1.5rem;
}

.iteration-count {
  display: block;
  font-size: 4rem;
  font-weight: 800;
  font-family: 'Space Mono', monospace;
  color: var(--accent-gold);
  text-shadow: 0 0 30px rgba(255, 217, 61, 0.4);
}

.iteration-label {
  font-size: 1rem;
  color: var(--text-secondary);
}

.add-button {
  background: linear-gradient(135deg, var(--accent-lavender), var(--accent-pink));
  border: none;
  padding: 1.25rem 3rem;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 10px 40px rgba(183, 148, 244, 0.4);
  font-family: 'Bricolage Grotesque', sans-serif;
}

.add-button:hover {
  transform: scale(1.05);
  box-shadow: 0 15px 50px rgba(183, 148, 244, 0.5);
}

.add-button:active {
  transform: scale(0.95);
}

.sound-toggle {
  display: block;
  margin: 1rem auto 0;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  color: var(--text-secondary);
  border-radius: 25px;
  cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.sound-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

.mascot-section {
  animation: fadeIn 1s ease-out 0.6s both;
}

.berry-mascot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
}

.speech-bubble {
  background: linear-gradient(135deg, rgba(183, 148, 244, 0.2), rgba(246, 135, 179, 0.2));
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 1rem 1.5rem;
  border-radius: 20px;
  position: relative;
  max-width: 300px;
  text-align: center;
  color: var(--text-primary);
  font-size: 0.95rem;
  animation: pulse 2s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.02); }
}

.speech-bubble::after {
  content: '';
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid rgba(183, 148, 244, 0.2);
}

.berry-character {
  font-size: 3rem;
  animation: bounce 2s ease-in-out infinite;
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

.black-screen-section {
  animation: fadeIn 1s ease-out 0.8s both;
}

.black-screen-toggle {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, #2d2640, #1a1625);
  border: 2px solid var(--accent-coral);
  padding: 1rem 2rem;
  color: var(--accent-coral);
  border-radius: 15px;
  cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  transition: all 0.3s ease;
}

.black-screen-toggle:hover {
  background: var(--accent-coral);
  color: white;
  box-shadow: 0 10px 30px rgba(252, 129, 129, 0.3);
}

.black-screen-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.3s ease-out;
}

.black-screen-content {
  width: 100%;
  max-width: 500px;
}

.code-window {
  background: #0d0d0d;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #333;
}

.code-header {
  background: #1a1a1a;
  padding: 0.75rem 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
}

.dot.red { background: #ff5f56; }
.dot.yellow { background: #ffbd2e; }
.dot.green { background: #27ca40; }

.code-title {
  margin-left: 0.5rem;
  color: #666;
  font-family: 'Space Mono', monospace;
  font-size: 0.8rem;
}

.code-body {
  padding: 1rem;
  max-height: 300px;
  overflow-y: auto;
  font-family: 'Space Mono', monospace;
  font-size: 0.75rem;
  color: #4ade80;
  line-height: 1.6;
}

.code-line {
  animation: typeIn 0.1s ease-out;
}

@keyframes typeIn {
  from { opacity: 0; transform: translateX(-10px); }
  to { opacity: 1; transform: translateX(0); }
}

.survival-message {
  text-align: center;
  padding: 1.5rem;
  color: white;
}

.survival-message p {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
}

.sub-message {
  color: var(--text-secondary);
  font-size: 0.9rem !important;
}

.survive-button {
  display: block;
  width: 100%;
  background: linear-gradient(135deg, var(--accent-mint), #38a169);
  border: none;
  padding: 1rem 2rem;
  color: white;
  border-radius: 50px;
  cursor: pointer;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.1rem;
  font-weight: 700;
  transition: all 0.2s ease;
}

.survive-button:hover {
  transform: scale(1.05);
  box-shadow: 0 10px 30px rgba(104, 211, 145, 0.4);
}

.stats-section, .achievements-section {
  animation: fadeIn 1s ease-out 1s both;
}

.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1rem;
}

.stat-card {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.02));
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 15px;
  padding: 1.25rem;
  text-align: center;
  transition: transform 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-3px);
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  font-family: 'Space Mono', monospace;
  color: var(--accent-lavender);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-secondary);
  margin-top: 0.25rem;
}

.achievements-grid {
  display: grid;
  gap: 0.75rem;
}

.achievement {
  display: flex;
  align-items: center;
  gap: 1rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  padding: 1rem;
  transition: all 0.2s ease;
}

.achievement.unlocked {
  background: linear-gradient(135deg, rgba(183, 148, 244, 0.15), rgba(104, 211, 145, 0.1));
  border-color: rgba(183, 148, 244, 0.3);
}

.achievement.locked {
  opacity: 0.5;
}

.achievement-icon {
  font-size: 2rem;
}

.achievement-name {
  font-weight: 700;
  font-size: 0.95rem;
}

.achievement-desc {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.actions-section {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  animation: fadeIn 1s ease-out 1.2s both;
}

.share-button, .reset-button {
  width: 100%;
  padding: 1rem;
  border-radius: 12px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.share-button {
  background: linear-gradient(135deg, var(--accent-mint), #38a169);
  border: none;
  color: white;
}

.share-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(104, 211, 145, 0.3);
}

.reset-button {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-secondary);
}

.reset-button:hover {
  border-color: var(--accent-coral);
  color: var(--accent-coral);
}

.reset-modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
  animation: fadeIn 0.2s ease-out;
}

.reset-modal-content {
  background: var(--bg-secondary);
  border-radius: 20px;
  padding: 2rem;
  text-align: center;
  max-width: 350px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.reset-modal-content h3 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.reset-modal-content p {
  color: var(--text-secondary);
  margin-bottom: 1.5rem;
}

.reset-buttons {
  display: flex;
  gap: 1rem;
}

.confirm-reset, .cancel-reset {
  flex: 1;
  padding: 0.75rem;
  border-radius: 10px;
  font-family: 'Bricolage Grotesque', sans-serif;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.confirm-reset {
  background: var(--accent-coral);
  border: none;
  color: white;
}

.cancel-reset {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-primary);
}

.footer {
  text-align: center;
  padding: 2rem 0;
  color: var(--text-secondary);
  font-size: 0.85rem;
}

.footer a {
  color: var(--accent-lavender);
  text-decoration: none;
}

.footer a:hover {
  text-decoration: underline;
}

.particle {
  z-index: 100;
}

@media (min-width: 640px) {
  .main-title {
    font-size: 2.5rem;
  }
  
  .iteration-count {
    font-size: 5rem;
  }
  
  .add-button {
    font-size: 1.75rem;
    padding: 1.5rem 4rem;
  }
}