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

:root {
  --ocean-deep: #0077B6;
  --ocean-light: #00B4D8;
  --sand: #E9C46A;
  --sunset: #F4A261;
  --danger: #E76F51;
  --palm: #2A9D8F;
  --dark: #1a1a2e;
  --darker: #16162a;
  --parchment: #fef9f0;
  --parchment-dark: #f4efe5;
}

body {
  font-family: 'Bricolage Grotesque', sans-serif;
  background: linear-gradient(135deg, var(--dark) 0%, var(--darker) 50%, #0d0d1a 100%);
  min-height: 100vh;
  color: #fff;
  overflow-x: hidden;
}

.app-container {
  position: relative;
  min-height: 100vh;
  padding: 1rem;
}

/* Background waves animation */
.bg-waves {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 200px;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 119, 182, 0.1) 50%, rgba(0, 180, 216, 0.2) 100%);
  z-index: 0;
  animation: wave-pulse 4s ease-in-out infinite;
}

@keyframes wave-pulse {
  0%, 100% { opacity: 0.5; transform: translateY(0); }
  50% { opacity: 0.8; transform: translateY(-10px); }
}

/* Floating elements */
.floating-elements {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  overflow: hidden;
}

.float-item {
  position: absolute;
  font-size: 2rem;
  opacity: 0.15;
  animation: float 20s infinite ease-in-out;
}

.float-1 { top: 10%; left: 5%; animation-delay: 0s; }
.float-2 { top: 30%; right: 10%; animation-delay: -5s; }
.float-3 { bottom: 20%; left: 15%; animation-delay: -10s; }
.float-4 { bottom: 40%; right: 5%; animation-delay: -15s; }

@keyframes float {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  25% { transform: translate(20px, -30px) rotate(5deg); }
  50% { transform: translate(-10px, 20px) rotate(-5deg); }
  75% { transform: translate(15px, 10px) rotate(3deg); }
}

/* Toast notification */
.toast-notification {
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(135deg, var(--dark), var(--darker));
  border: 2px solid var(--sand);
  color: var(--sand);
  padding: 1rem 2rem;
  border-radius: 50px;
  font-weight: 700;
  z-index: 1000;
  animation: toast-in 0.3s ease-out, toast-out 0.3s ease-in 2.7s;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(-20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

@keyframes toast-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Header */
.header {
  text-align: center;
  padding: 2rem 1rem;
  position: relative;
  z-index: 1;
}

.title {
  font-size: clamp(1.8rem, 5vw, 3.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--sand) 0%, var(--sunset) 50%, var(--danger) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 60px rgba(233, 196, 106, 0.3);
  margin-bottom: 0.5rem;
}

.subtitle {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  font-size: 1.2rem;
  color: var(--ocean-light);
  opacity: 0.8;
}

/* Main content */
.main-content {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Generate section */
.generate-section {
  text-align: center;
  margin-bottom: 2rem;
}

.generate-btn {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1.4rem;
  font-weight: 800;
  padding: 1.2rem 3rem;
  border: none;
  border-radius: 50px;
  background: linear-gradient(135deg, var(--danger) 0%, var(--sunset) 100%);
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 10px 40px rgba(231, 111, 81, 0.4);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.generate-btn:hover:not(:disabled) {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 0 15px 50px rgba(231, 111, 81, 0.5);
}

.generate-btn:active:not(:disabled) {
  transform: translateY(0) scale(0.98);
}

.generate-btn.generating {
  animation: pulse-glow 1s infinite;
}

.generate-btn:disabled {
  cursor: not-allowed;
  opacity: 0.9;
}

@keyframes pulse-glow {
  0%, 100% { box-shadow: 0 10px 40px rgba(231, 111, 81, 0.4); }
  50% { box-shadow: 0 10px 60px rgba(231, 111, 81, 0.7); }
}

/* Scenario wrapper */
.scenario-wrapper {
  animation: fade-in 0.5s ease-out;
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Island Card */
.island-card {
  background: linear-gradient(145deg, var(--parchment) 0%, var(--parchment-dark) 100%);
  border-radius: 24px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  color: var(--dark);
  position: relative;
  overflow: hidden;
}

.island-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(0, 180, 216, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.island-header {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 2px dashed var(--sand);
}

.island-icon {
  font-size: 3rem;
  animation: gentle-bob 3s ease-in-out infinite;
}

@keyframes gentle-bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-5px); }
}

.island-name {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--dark);
  margin-bottom: 0.25rem;
}

.island-type {
  font-family: 'Crimson Pro', serif;
  font-style: italic;
  color: var(--ocean-deep);
  font-size: 1.1rem;
}

/* Scenario grid */
.scenario-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.scenario-item {
  background: rgba(0, 119, 182, 0.05);
  padding: 1rem;
  border-radius: 12px;
  border-left: 4px solid var(--ocean-deep);
}

.scenario-item h3 {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--ocean-deep);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.scenario-item p {
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  color: var(--dark);
  line-height: 1.4;
}

/* Twist section */
.twist-section {
  background: linear-gradient(135deg, rgba(231, 111, 81, 0.1) 0%, rgba(244, 162, 97, 0.1) 100%);
  border: 2px dashed var(--danger);
  border-radius: 12px;
  padding: 1rem;
  text-align: center;
}

.twist-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--danger);
  letter-spacing: 2px;
  margin-bottom: 0.5rem;
}

.twist-text {
  font-family: 'Crimson Pro', serif;
  font-size: 1.2rem;
  font-weight: 700;
  color: var(--dark);
}

/* Verdict section */
.verdict-section {
  background: linear-gradient(145deg, var(--dark) 0%, var(--darker) 100%);
  border: 2px solid var(--sand);
  border-radius: 24px;
  padding: 2rem;
  text-align: center;
  margin-bottom: 1.5rem;
}

.verdict-title {
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--sand);
  margin-bottom: 1rem;
}

.survival-time {
  margin-bottom: 1.5rem;
}

.time-value {
  font-size: clamp(2rem, 8vw, 3.5rem);
  font-weight: 800;
  background: linear-gradient(135deg, var(--sand) 0%, var(--sunset) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.chance-bar-container {
  margin-bottom: 1.5rem;
}

.chance-bar {
  height: 12px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.chance-fill {
  height: 100%;
  border-radius: 6px;
  transition: width 1s ease-out;
  box-shadow: 0 0 20px currentColor;
}

.chance-text {
  font-weight: 700;
  font-size: 1.2rem;
}

.death-prediction {
  background: rgba(231, 111, 81, 0.1);
  border-radius: 12px;
  padding: 1rem;
}

.death-label {
  display: block;
  font-size: 0.8rem;
  color: var(--sunset);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.death-cause {
  font-family: 'Crimson Pro', serif;
  font-size: 1.3rem;
  font-style: italic;
  color: var(--danger);
}

/* Action buttons */
.action-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.action-btn {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  padding: 0.8rem 1.5rem;
  border: 2px solid;
  border-radius: 50px;
  cursor: pointer;
  transition: all 0.3s ease;
  flex: 1;
  min-width: 180px;
  max-width: 250px;
}

.share-btn {
  background: transparent;
  border-color: var(--ocean-light);
  color: var(--ocean-light);
}

.share-btn:hover {
  background: var(--ocean-light);
  color: var(--dark);
}

.optimism-btn {
  background: transparent;
  border-color: var(--palm);
  color: var(--palm);
}

.optimism-btn:hover {
  background: var(--palm);
  color: white;
}

/* Tips section */
.tips-section {
  background: rgba(255, 255, 255, 0.05);
  border-radius: 16px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.tips-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.tips-header h3 {
  font-size: 1.1rem;
  color: var(--sand);
}

.tips-toggle {
  font-family: 'Bricolage Grotesque', sans-serif;
  font-size: 0.8rem;
  background: transparent;
  border: 1px solid var(--ocean-light);
  color: var(--ocean-light);
  padding: 0.4rem 0.8rem;
  border-radius: 20px;
  cursor: pointer;
  transition: all 0.3s ease;
}

.tips-toggle:hover {
  background: var(--ocean-light);
  color: var(--dark);
}

.tips-list {
  list-style: none;
}

.tips-list li {
  font-family: 'Crimson Pro', serif;
  font-size: 1rem;
  color: rgba(255, 255, 255, 0.8);
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tips-list li:last-child {
  border-bottom: none;
}

/* Stats section */
.stats-section {
  background: linear-gradient(145deg, rgba(0, 119, 182, 0.1) 0%, rgba(0, 180, 216, 0.1) 100%);
  border: 1px solid rgba(0, 180, 216, 0.3);
  border-radius: 20px;
  padding: 1.5rem;
  margin-bottom: 2rem;
}

.stats-title {
  font-size: 1.1rem;
  color: var(--ocean-light);
  margin-bottom: 1rem;
  text-align: center;
}

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

.stat-item {
  text-align: center;
  padding: 0.75rem;
  background: rgba(0, 0, 0, 0.2);
  border-radius: 12px;
}

.stat-value {
  display: block;
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--sand);
}

.stat-label {
  font-size: 0.75rem;
  color: rgba(255, 255, 255, 0.6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Achievements */
.achievements-section {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.achievements-section h4 {
  font-size: 0.9rem;
  color: var(--sand);
  margin-bottom: 0.75rem;
  text-align: center;
}

.achievements-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  justify-content: center;
}

.achievement {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  background: rgba(233, 196, 106, 0.1);
  border: 1px solid rgba(233, 196, 106, 0.3);
  padding: 0.3rem 0.6rem;
  border-radius: 20px;
  cursor: help;
}

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

.achievement-name {
  font-size: 0.7rem;
  color: var(--sand);
  font-weight: 600;
}

/* Footer */
.footer {
  text-align: center;
  padding: 2rem 1rem;
  position: relative;
  z-index: 1;
}

.footer p {
  font-family: 'Crimson Pro', serif;
  font-size: 0.9rem;
  color: rgba(255, 255, 255, 0.5);
  margin-bottom: 0.5rem;
}

.footer-link {
  display: inline-block;
  color: var(--sunset);
  text-decoration: none;
  font-weight: 600;
  transition: all 0.3s ease;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  border: 1px solid transparent;
}

.footer-link:hover {
  color: var(--sand);
  border-color: var(--sand);
  background: rgba(233, 196, 106, 0.1);
}

/* Responsive */
@media (max-width: 600px) {
  .app-container {
    padding: 0.5rem;
  }
  
  .island-card, .verdict-section, .stats-section {
    padding: 1.25rem;
    border-radius: 16px;
  }
  
  .scenario-grid {
    grid-template-columns: 1fr;
  }
  
  .action-buttons {
    flex-direction: column;
    align-items: center;
  }
  
  .action-btn {
    max-width: 100%;
  }
  
  .generate-btn {
    padding: 1rem 2rem;
    font-size: 1.2rem;
  }
  
  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
  }
  
  .stat-item {
    padding: 0.5rem;
  }
  
  .stat-value {
    font-size: 1rem;
  }
}