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

:root {
  /* Surrealist Exquisite Corpse Palette */
  --coral: #ff6b6b;  /* Life/flesh/warmth */
  --teal: #4ecdc4;   /* Dream/unconscious */
  --bone: #f8f4e3;    /* Skeleton/paper */
  --purple: #4a148c;  /* Mystery/surrealism */
  --orange: #ffe66d;  /* Energy/creativity */
  --cream: #fff8e7;   /* Aged paper background */
  --ink: #2d3436;     /* Dark ink for text */
  --blood: #c0392b;   /* Deep red accents */
  
  /* Functional colors */
  --primary-color: var(--coral);
  --primary-dark: #e55555;
  --secondary-color: var(--teal);
  --accent-color: var(--purple);
  --light-bg: var(--cream);
  --border-color: #d4c4a0;
  --text-muted: #7f8c8d;
  --shadow: 0 2px 4px rgba(74, 20, 140, 0.1);
  --shadow-lg: 0 4px 12px rgba(74, 20, 140, 0.15);
  --paper-shadow: 2px 2px 5px rgba(0,0,0,0.1), inset 1px 1px 3px rgba(255,255,255,0.5);
}

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Space+Grotesk:wght@400;700&family=Caveat:wght@400;700&family=Special+Elite&family=Creepster&display=swap');

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.7;
  font-weight: 400;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    repeating-linear-gradient(0deg, transparent, transparent 2px, rgba(74, 20, 140, 0.02) 2px, rgba(74, 20, 140, 0.02) 4px),
    repeating-linear-gradient(90deg, transparent, transparent 2px, rgba(74, 20, 140, 0.02) 2px, rgba(74, 20, 140, 0.02) 4px);
  background-size: 20px 20px;
  pointer-events: none;
  z-index: 0;
}

#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background: linear-gradient(135deg, var(--purple) 0%, var(--coral) 50%, var(--teal) 100%);
  color: white;
  padding: 1.5rem 1rem;
  text-align: center;
  box-shadow: var(--paper-shadow), 0 4px 12px rgba(74, 20, 140, 0.25);
  position: relative;
  overflow: hidden;
  border-bottom: 3px dashed var(--bone);
}

header::before {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(255,255,255,0.1) 1px, transparent 1px);
  background-size: 20px 20px;
  transform: rotate(45deg);
  pointer-events: none;
}

header h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  position: relative;
  z-index: 1;
  display: inline-block;
}

/* Mismatched typography for surrealist effect */
header h1 .word1 {
  font-family: 'Creepster', cursive;
  color: var(--bone);
  transform: rotate(-5deg);
  display: inline-block;
  text-shadow: 2px 2px 4px rgba(0,0,0,0.5);
}

header h1 .word2 {
  font-family: 'Space Grotesk', sans-serif;
  font-weight: 700;
  transform: rotate(3deg) translateY(-5px);
  display: inline-block;
  margin-left: 0.2em;
}

header h1 .word3 {
  font-family: 'Caveat', cursive;
  font-size: 2.8rem;
  color: var(--orange);
  transform: rotate(-2deg) translateY(3px);
  display: inline-block;
  margin-left: 0.2em;
}

#subtitle {
  font-size: 1rem;
  opacity: 0.9;
  font-weight: 300;
  letter-spacing: 0.02em;
}

main {
  flex: 1;
  padding: 1rem;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* Floating Body Parts */
.floating-parts {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.floating-parts .part {
  position: absolute;
  font-size: 2rem;
  opacity: 0.3;
  animation: floatPart 20s infinite ease-in-out;
  filter: blur(0.5px);
}

.floating-parts .eye {
  top: 20%;
  left: 10%;
  animation-delay: 0s;
  animation-duration: 15s;
}

.floating-parts .hand {
  top: 60%;
  right: 15%;
  animation-delay: 3s;
  animation-duration: 18s;
  transform: rotate(45deg);
}

.floating-parts .skull {
  bottom: 20%;
  left: 20%;
  animation-delay: 6s;
  animation-duration: 22s;
}

.floating-parts .bone {
  top: 40%;
  right: 25%;
  animation-delay: 9s;
  animation-duration: 17s;
  transform: rotate(-30deg);
}

.floating-parts .brain {
  bottom: 30%;
  right: 10%;
  animation-delay: 12s;
  animation-duration: 19s;
}

/* Animations */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

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

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

@keyframes floatPart {
  0%, 100% { 
    transform: translateX(0) translateY(0) rotate(0deg);
    opacity: 0.2;
  }
  25% { 
    transform: translateX(30px) translateY(-20px) rotate(90deg);
    opacity: 0.4;
  }
  50% { 
    transform: translateX(-20px) translateY(30px) rotate(180deg);
    opacity: 0.3;
  }
  75% { 
    transform: translateX(40px) translateY(10px) rotate(270deg);
    opacity: 0.5;
  }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

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

/* Add folded paper effect to sections */
.screen {
  position: relative;
}

.screen::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 0;
  right: 0;
  height: 10px;
  background: linear-gradient(to bottom, rgba(0,0,0,0.1) 0%, transparent 100%);
  transform: scaleY(0.5);
  pointer-events: none;
}

/* Room code styling */
.code {
  font-family: 'Special Elite', monospace;
  font-size: 1.4rem;
  letter-spacing: 0.2em;
  color: var(--purple);
  background: var(--bone);
  padding: 8px 16px;
  border-radius: 4px;
  border: 2px dashed var(--purple);
  display: inline-block;
  transform: rotate(-1deg);
}

/* Example text with typewriter effect */
.example-text {
  font-family: 'Special Elite', monospace;
  line-height: 2;
  color: var(--ink);
  position: relative;
  padding: 20px;
  background: 
    repeating-linear-gradient(
      0deg,
      var(--cream),
      var(--cream) 28px,
      rgba(74, 20, 140, 0.1) 28px,
      rgba(74, 20, 140, 0.1) 29px
    );
  border-radius: 4px;
}


/* Loading States */
.loading {
  position: relative;
  pointer-events: none;
}

.loading::after {
  content: '';
  position: absolute;
  width: 20px;
  height: 20px;
  top: 50%;
  left: 50%;
  margin-left: -10px;
  margin-top: -10px;
  border: 2px solid white;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

button.loading {
  color: transparent !important;
}

.skeleton {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

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

.screen {
  display: none;
}

.screen.active {
  display: block;
  animation: fadeIn 0.3s ease-out;
}

.card {
  background: linear-gradient(135deg, var(--bone) 0%, var(--cream) 100%);
  border-radius: 4px 12px 8px 16px; /* Irregular corners */
  padding: 1.5rem 1rem;
  box-shadow: var(--paper-shadow), 2px 4px 8px rgba(74, 20, 140, 0.15);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  position: relative;
  transform: rotate(-0.5deg);
  border: 2px dashed rgba(74, 20, 140, 0.1);
}

.card::before {
  content: '';
  position: absolute;
  top: -5px;
  left: 20%;
  right: 20%;
  height: 10px;
  background-image: repeating-linear-gradient(
    90deg,
    transparent,
    transparent 3px,
    var(--purple) 3px,
    var(--purple) 6px
  );
  opacity: 0.3;
  transform: rotate(-1deg);
}

.card::after {
  content: '🧷';
  position: absolute;
  top: -10px;
  right: 30px;
  font-size: 1.5rem;
  transform: rotate(15deg);
  opacity: 0.7;
}

.card:hover {
  transform: rotate(0deg) scale(1.02);
  box-shadow: var(--paper-shadow), 4px 6px 12px rgba(74, 20, 140, 0.2);
}

@media (min-width: 400px) {
  .card {
    padding: 2rem 1.5rem;
  }
}

.card:hover {
  box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

h2 {
  margin-bottom: 1.5rem;
  color: var(--secondary-color);
  font-size: 1.75rem;
  font-weight: 600;
  letter-spacing: -0.01em;
}

h3 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--secondary-color);
  margin-bottom: 0.75rem;
}

.form-group {
  margin-bottom: 1rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.95rem;
  color: var(--secondary-color);
}

input, select, textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

input:read-only {
  background-color: var(--light-bg);
  color: var(--secondary-color);
  cursor: not-allowed;
}

textarea {
  resize: vertical;
  min-height: 100px;
}

.button-group {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
  flex-direction: column;
}

@media (min-width: 400px) {
  .button-group {
    flex-direction: row;
  }
}

button {
  flex: 1;
  padding: 0.875rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  overflow: hidden;
}

button.primary {
  background: linear-gradient(135deg, var(--coral) 0%, var(--purple) 100%);
  color: white;
  box-shadow: 0 4px 15px rgba(255, 107, 107, 0.3);
  font-weight: 600;
  letter-spacing: 0.5px;
  position: relative;
  overflow: visible;
}

button.primary::before {
  content: '✂️';
  position: absolute;
  left: -20px;
  top: 50%;
  transform: translateY(-50%) rotate(-45deg);
  opacity: 0;
  transition: opacity 0.3s ease, left 0.3s ease;
}

button.primary::after {
  content: '🧵';
  position: absolute;
  right: -20px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity 0.3s ease, right 0.3s ease;
}

button.primary:hover:not(:disabled) {
  background: linear-gradient(135deg, var(--purple) 0%, var(--teal) 100%);
  transform: translateY(-2px) rotate(1deg);
  box-shadow: 0 6px 20px rgba(74, 20, 140, 0.4);
}

button.primary:hover::before {
  opacity: 0.7;
  left: 10px;
}

button.primary:hover::after {
  opacity: 0.7;
  right: 10px;
}

button.primary:active:not(:disabled) {
  transform: translateY(0) rotate(0deg);
  box-shadow: 0 2px 10px rgba(74, 20, 140, 0.3);
}

button.secondary {
  background: var(--light-bg);
  color: var(--secondary-color);
  border: 2px solid var(--border-color);
}

button.secondary:hover {
  background: #e9ecef;
  border-color: #adb5bd;
}

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

.info-box {
  background: #ecf0f1;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
}

.code {
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: bold;
  color: #3498db;
}

.player-list ul {
  list-style: none;
  margin-top: 0.5rem;
}

.player-list li {
  padding: 0.5rem;
  background: #f8f9fa;
  margin-bottom: 0.25rem;
  border-radius: 4px;
}

.timer {
  background: #e74c3c;
  color: white;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  font-weight: bold;
  display: inline-block;
}

.context-box {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 4px;
  margin-bottom: 1rem;
  border-left: 4px solid #3498db;
}

.word-count {
  text-align: right;
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
  font-weight: 500;
  transition: color 0.2s ease;
}

.word-count.warning {
  color: var(--warning-color);
}

.word-count.danger {
  color: var(--danger-color);
  font-weight: 600;
}

.word-limit-error {
  font-size: 0.85rem;
  color: var(--danger-color);
  font-weight: normal;
}

/* Disabled submit button */
button[type="submit"]:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Textarea error state */
textarea.error {
  border-color: var(--danger-color) !important;
  box-shadow: 0 0 0 1px var(--danger-color);
}

.status-message {
  text-align: center;
  padding: 1rem;
  color: #666;
  font-style: italic;
}

.reveal-container {
  display: grid;
  gap: 1rem;
  margin-bottom: 1rem;
}

.reveal-section {
  background: #f8f9fa;
  padding: 1rem;
  border-radius: 4px;
}

.reveal-section h3 {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: #2c3e50;
}

.submission-item {
  padding: 10px;
  margin-bottom: 10px;
  background: rgba(52, 152, 219, 0.05);
  border-radius: 5px;
  border-left: 3px solid #3498db;
}

.submission-item strong {
  color: #2c3e50;
  display: block;
  margin-bottom: 5px;
  font-weight: 600;
}

.error-message {
  position: fixed;
  bottom: 1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #e74c3c;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 4px;
  display: none;
  max-width: 90%;
  cursor: pointer;
  user-select: none;
  text-align: center;
  z-index: 10000;
  box-shadow: 0 4px 6px rgba(0,0,0,0.3);
  font-weight: 500;
}

.error-message.show {
  display: block;
  animation: slideIn 0.3s ease-out;
}

.error-message:hover {
  background: #c0392b;
  transform: translateX(-50%) scale(1.02);
}

.error-message::after {
  content: ' (click to dismiss)';
  font-size: 0.85em;
  opacity: 0.8;
}

/* Success states */
.success {
  color: var(--success-color);
}

.form-group.has-success input,
.form-group.has-success textarea {
  border-color: var(--success-color);
}

/* Helper text */
.helper-text {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-top: 0.25rem;
}

/* Progress indicators */
.progress-bar {
  height: 4px;
  background: var(--light-bg);
  border-radius: 2px;
  overflow: hidden;
  margin: 1rem 0;
}

.progress-bar-fill {
  height: 100%;
  background: var(--primary-color);
  transition: width 0.3s ease;
}

/* Info sections */
.info-section {
  background: var(--light-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  border-left: 4px solid var(--primary-color);
}

.info-section h3 {
  margin-top: 0;
  margin-bottom: 0.75rem;
  color: var(--secondary-color);
  font-size: 1.1rem;
}

.info-section p {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.info-section p:last-child {
  margin-bottom: 0;
}

/* Name explanation dropdown */
.name-explanation {
  margin-top: 1rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  border: 1px solid rgba(52, 152, 219, 0.2);
  overflow: hidden;
}

.name-explanation summary {
  padding: 0.75rem 1rem;
  cursor: pointer;
  font-weight: 500;
  color: var(--primary-color);
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  user-select: none;
  transition: background-color 0.2s;
}

.name-explanation summary::-webkit-details-marker {
  display: none;
}

.name-explanation summary:hover {
  background: rgba(52, 152, 219, 0.05);
}

.name-explanation[open] summary {
  background: rgba(52, 152, 219, 0.1);
  border-bottom: 1px solid rgba(52, 152, 219, 0.2);
}

.explanation-content {
  padding: 1rem;
  font-size: 0.9rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.explanation-content p {
  margin-bottom: 0.75rem;
}

.explanation-content p:last-child {
  margin-bottom: 0;
}

/* Step items for How to Play */
.step-item {
  display: flex;
  align-items: flex-start;
  margin-bottom: 1rem;
  gap: 1rem;
}

.step-number {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1.1rem;
  box-shadow: 0 2px 8px rgba(52, 152, 219, 0.3);
}

.step-content {
  flex: 1;
  padding-top: 3px;
}

.step-content strong {
  display: block;
  color: var(--secondary-color);
  margin-bottom: 0.25rem;
}

.step-content span {
  color: var(--text-muted);
  font-size: 0.95rem;
}

/* Mode showcase */
.mode-showcase {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
  margin: 1rem 0;
}

@media (min-width: 576px) {
  .mode-showcase {
    grid-template-columns: 1fr 1fr;
  }
}

.mode-card {
  background: white;
  padding: 1.25rem;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  transition: transform 0.2s, box-shadow 0.2s;
}

.mode-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.mode-card h4 {
  margin: 0 0 0.75rem 0;
  color: var(--primary-color);
  font-size: 1.1rem;
}

.mode-card p {
  font-size: 0.9rem;
  color: var(--secondary-color);
  margin-bottom: 0.75rem;
  line-height: 1.5;
}

.mode-card ul {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 0.85rem;
}

.mode-card li {
  padding: 0.25rem 0 0.25rem 1.25rem;
  position: relative;
  color: var(--text-muted);
}

.mode-card li:before {
  content: '•';
  position: absolute;
  left: 0;
  color: var(--primary-color);
  font-weight: bold;
}

/* Example box */
.example-box {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  border-radius: 12px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  border: 2px dashed #dee2e6;
  position: relative;
}

.example-box h4 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--secondary-color);
  font-size: 1.1rem;
}

.example-text {
  font-size: 0.9rem;
  line-height: 1.8;
  color: #495057;
  font-style: italic;
}

.player-label {
  font-weight: 600;
  color: var(--primary-color);
  font-style: normal;
}

.ai-label {
  font-weight: 600;
  color: var(--success-color);
  font-style: normal;
}

/* Player Status Bubbles - Jackbox style */
.player-status-container {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
  padding: 1rem;
  background: rgba(248, 249, 250, 0.5);
  border-radius: 12px;
}

.player-bubble {
  position: relative;
  text-align: center;
  transition: all 0.3s ease;
}

.player-avatar {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 600;
  color: white;
  position: relative;
  transition: all 0.3s ease;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

@media (min-width: 400px) {
  .player-avatar {
    width: 80px;
    height: 80px;
    font-size: 2rem;
  }
}

.player-avatar.writing {
  background: var(--warning-color);
  animation: pulse 2s infinite;
}

.player-avatar.submitted {
  background: var(--success-color);
  transform: scale(1.1);
}

.player-avatar.waiting {
  background: #95a5a6;
}

.player-name {
  margin-top: 0.5rem;
  font-weight: 500;
  color: var(--secondary-color);
  font-size: 0.95rem;
}

.player-status-icon {
  position: absolute;
  bottom: -5px;
  right: -5px;
  width: 30px;
  height: 30px;
  background: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  font-size: 1.2rem;
}

.player-status-icon.check {
  color: var(--success-color);
}

.writing-indicator {
  position: absolute;
  bottom: -10px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 4px;
}

.writing-dot {
  width: 6px;
  height: 6px;
  background: var(--warning-color);
  border-radius: 50%;
  animation: writingBounce 1.4s infinite ease-in-out;
}

.writing-dot:nth-child(1) { animation-delay: -0.32s; }
.writing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes writingBounce {
  0%, 80%, 100% {
    transform: scale(0);
    opacity: 0.5;
  }
  40% {
    transform: scale(1);
    opacity: 1;
  }
}

/* Updated waiting message */
.dynamic-waiting {
  text-align: center;
  padding: 2rem;
}

.waiting-progress {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

.waiting-message {
  color: var(--text-muted);
  font-style: italic;
}

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

/* Settings Section */
.settings-section {
  background: var(--light-bg);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
}

.settings-section h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--secondary-color);
  font-size: 1.1rem;
}

.settings-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 768px) {
  .settings-grid {
    grid-template-columns: 1fr 1fr;
  }
  
  .settings-grid .setting-item:first-child {
    grid-column: 1 / -1;
  }
}

.setting-item label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
  color: var(--secondary-color);
}

.setting-control {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  font-size: 1rem;
  background: white;
  cursor: pointer;
  transition: border-color 0.2s;
}

.setting-control:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.1);
}

@media (max-width: 576px) {
  .settings-grid {
    grid-template-columns: 1fr;
  }
}

/* Turn order notification */
.turn-order-notification {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.3);
  z-index: 1000;
  text-align: center;
  animation: fadeIn 0.3s ease-out;
}

.turn-order-notification h3 {
  margin-top: 0;
  margin-bottom: 1rem;
  color: var(--secondary-color);
}

.turn-order-notification ol {
  list-style: none;
  padding: 0;
  margin: 0;
  font-size: 1.1rem;
}

.turn-order-notification li {
  padding: 0.5rem 0;
  color: var(--secondary-color);
}

.turn-order-notification li.you {
  font-weight: 700;
  color: var(--primary-color);
}

/* Quick settings preview */
.quick-settings-preview {
  background: var(--light-bg);
  border-radius: 8px;
  padding: 1.25rem;
  margin: 1.5rem 0;
  border: 1px solid var(--border-color);
}

.quick-settings-preview h4 {
  margin: 0 0 1rem 0;
  color: var(--secondary-color);
  font-size: 1rem;
}

.quick-settings-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.quick-setting label {
  display: block;
  margin-bottom: 0.25rem;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--text-muted);
}

.quick-setting select {
  width: 100%;
  padding: 0.5rem;
  font-size: 0.9rem;
}

@media (max-width: 576px) {
  .quick-settings-grid {
    grid-template-columns: 1fr;
  }
}

/* Story Document Styles */
.final-story-container {
  margin: 1.5rem 0;
}

.story-document {
  background: white;
  border-radius: 8px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  margin: 0 auto;
  max-width: 800px;
  font-family: 'Georgia', 'Times New Roman', serif;
}

.document-header {
  background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
  color: white;
  padding: 3rem 2rem;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.document-header::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><text x="50" y="50" font-size="40" fill="white" opacity="0.05" text-anchor="middle">✍️</text></svg>') center/contain no-repeat;
}

.document-title {
  font-size: 2.5rem;
  margin: 0 0 0.5rem 0;
  font-weight: 400;
  letter-spacing: 0.02em;
  position: relative;
  z-index: 1;
}

.document-subtitle {
  font-size: 1.1rem;
  margin: 0 0 1.5rem 0;
  opacity: 0.9;
  font-style: italic;
  font-weight: 300;
  position: relative;
  z-index: 1;
}

.document-meta {
  display: flex;
  justify-content: center;
  gap: 2rem;
  font-size: 0.9rem;
  opacity: 0.8;
  position: relative;
  z-index: 1;
}

.document-date {
  font-style: italic;
}

.document-body {
  padding: 3rem;
  background: #fafafa;
  position: relative;
}

.document-body::before {
  content: '"';
  position: absolute;
  top: 1rem;
  left: 1rem;
  font-size: 4rem;
  color: rgba(52, 152, 219, 0.1);
  font-family: Georgia, serif;
}

.story-text {
  font-size: 1.2rem;
  line-height: 2;
  text-align: justify;
  margin: 0;
  color: #2c3e50;
  text-indent: 2rem;
  position: relative;
  z-index: 1;
}

.document-footer {
  background: #f8f9fa;
  padding: 1.5rem;
  border-top: 1px solid #e9ecef;
}

.story-breakdown {
  background: white;
  border-radius: 8px;
  padding: 1rem;
  border: 1px solid #e9ecef;
}

.story-breakdown summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--primary-color);
  padding: 0.5rem;
  user-select: none;
  font-family: 'Inter', sans-serif;
}

.story-breakdown summary:hover {
  color: var(--primary-dark);
}

.breakdown-content {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid #e9ecef;
  font-family: 'Inter', sans-serif;
}

.breakdown-round {
  margin-bottom: 1.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid #f0f0f0;
}

.breakdown-round:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.breakdown-round h4 {
  color: var(--primary-color);
  margin: 0 0 1rem 0;
  font-size: 1rem;
}

.breakdown-section {
  margin-bottom: 1rem;
}

.breakdown-label {
  display: block;
  font-size: 0.85rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.25rem;
}

.breakdown-text {
  margin: 0;
  font-size: 0.95rem;
  color: #495057;
  font-style: italic;
  padding-left: 1rem;
  border-left: 3px solid #e9ecef;
}

/* Responsive adjustments for document */
@media (max-width: 768px) {
  .document-header {
    padding: 2rem 1.5rem;
  }
  
  .document-title {
    font-size: 2rem;
  }
  
  .document-body {
    padding: 2rem 1.5rem;
  }
  
  .story-text {
    font-size: 1.1rem;
    text-align: left;
  }
  
  .document-meta {
    flex-direction: column;
    gap: 0.5rem;
  }
}

/* Mobile first approach - base styles work for mobile */

/* Small tablets and large phones (576px+) */
@media (min-width: 576px) {
  .button-group {
    flex-direction: row;
  }
  
  .player-status-container {
    gap: 2rem;
  }
}

/* Tablets (768px+) */
@media (min-width: 768px) {
  header h1 {
    font-size: 2rem;
  }
  
  main {
    padding: 2rem;
    max-width: 720px;
  }
  
  .card {
    padding: 2rem;
  }
  
  .reveal-container {
    grid-template-columns: 1fr 1fr;
  }
  
  .player-avatar {
    width: 90px;
    height: 90px;
    font-size: 2.25rem;
  }
}

/* Desktop (992px+) */
@media (min-width: 992px) {
  main {
    max-width: 800px;
  }
  
  header h1 {
    font-size: 2.5rem;
  }
  
  .info-section {
    padding: 2rem;
  }
}

/* Large desktop (1200px+) */
@media (min-width: 1200px) {
  main {
    max-width: 900px;
  }
}
/* AI Connector Styling - Stitching Effect */
.ai-connector {
  color: var(--purple);
  font-style: italic;
  font-size: 0.95em;
  padding: 12px 20px;
  margin: 20px 0;
  display: block;
  position: relative;
  background: linear-gradient(90deg, transparent 0%, rgba(74, 20, 140, 0.05) 50%, transparent 100%);
  border-left: 3px dashed var(--purple);
  border-right: 3px dashed var(--purple);
  opacity: 0.9;
}

.ai-connector::before {
  content: "🧵 ";
  position: absolute;
  left: -15px;
  color: var(--coral);
  font-size: 1em;
  animation: pulse 2s infinite;
}

.ai-connector::after {
  content: " 🧵";
  position: absolute;
  right: -15px;
  color: var(--coral);
  font-size: 1em;
  animation: pulse 2s infinite;
  animation-delay: 1s;
}

/* Player Fragment Styling - Body Segments */
.player-fragment {
  color: var(--ink);
  display: block;
  margin: 15px 0;
  padding: 12px;
  font-weight: 500;
  background: linear-gradient(135deg, var(--cream) 0%, var(--bone) 100%);
  border-radius: 8px 4px 12px 6px;
  position: relative;
  border: 1px solid rgba(74, 20, 140, 0.1);
  transform: rotate(-0.5deg);
  transition: transform 0.2s ease;
}

.player-fragment:hover {
  transform: rotate(0deg) scale(1.02);
}

.player-fragment::before {
  content: '';
  position: absolute;
  top: 50%;
  left: -10px;
  width: 20px;
  height: 2px;
  background: repeating-linear-gradient(
    90deg,
    var(--purple),
    var(--purple) 2px,
    transparent 2px,
    transparent 4px
  );
  opacity: 0.5;
}

.player-fragment strong {
  color: var(--coral);
  font-weight: 600;
  margin-right: 8px;
  font-family: 'Caveat', cursive;
  font-size: 1.2em;
}

/* Refined content area */
#refined-content {
  line-height: 1.8;
  font-size: 1.05rem;
  text-align: justify;
}

/* AI Processing Animation */
.ai-processing {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 248, 231, 0.98); /* Semi-transparent cream */
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  border-radius: 12px;
}

.ai-animation {
  text-align: center;
  padding: 2rem;
}

.stitching-machine {
  position: relative;
  width: 200px;
  height: 120px;
  margin: 0 auto 2rem;
}

.needle {
  position: absolute;
  font-size: 3rem;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  animation: sewing 2s ease-in-out infinite;
  z-index: 3;
}

.thread {
  position: absolute;
  top: 40px;
  left: 50%;
  width: 2px;
  height: 60px;
  background: linear-gradient(to bottom, var(--purple), var(--coral));
  transform: translateX(-50%);
  transform-origin: top;
  animation: threadWave 2s ease-in-out infinite;
}

.fabric-pieces {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 10px;
  padding: 10px;
}

.piece {
  font-size: 2rem;
  animation: float 3s ease-in-out infinite;
  opacity: 0.8;
}

.piece-1 { animation-delay: 0s; }
.piece-2 { animation-delay: 0.5s; }
.piece-3 { animation-delay: 1s; }

.ai-message {
  font-family: 'Caveat', cursive;
  font-size: 1.5rem;
  color: var(--purple);
  margin-bottom: 1rem;
  animation: pulse 2s ease-in-out infinite;
}

.loading-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.loading-dots span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--coral);
  animation: bounce 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes sewing {
  0%, 100% { transform: translateX(-50%) translateY(0) rotate(0deg); }
  25% { transform: translateX(-30%) translateY(10px) rotate(-10deg); }
  50% { transform: translateX(-50%) translateY(20px) rotate(0deg); }
  75% { transform: translateX(-70%) translateY(10px) rotate(10deg); }
}

@keyframes threadWave {
  0%, 100% { transform: translateX(-50%) scaleY(1); }
  50% { transform: translateX(-50%) scaleY(1.3); }
}

@keyframes bounce {
  0%, 80%, 100% {
    transform: translateY(0);
    opacity: 1;
  }
  40% {
    transform: translateY(-20px);
    opacity: 0.8;
  }
}

/* Final Story Display Styles */
#final-story-container {
  width: 100%;
}

.story-document {
  background: linear-gradient(135deg, var(--bone) 0%, var(--cream) 100%);
  border-radius: 8px;
  padding: 2rem;
  box-shadow: var(--paper-shadow);
  position: relative;
  transform: rotate(-0.3deg);
}

.story-document::before {
  content: '📖';
  position: absolute;
  top: -15px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 2rem;
  opacity: 0.8;
}

.document-header {
  text-align: center;
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 3px dashed var(--purple);
}

.document-title {
  font-family: 'Creepster', cursive;
  font-size: 2.2rem;
  color: var(--purple);
  margin-bottom: 0.5rem;
  text-shadow: 2px 2px 4px rgba(74, 20, 140, 0.2);
}

.document-subtitle {
  font-family: 'Caveat', cursive;
  font-size: 1.3rem;
  color: var(--coral);
  margin-bottom: 1rem;
}

.document-meta {
  font-size: 0.9rem;
  color: var(--text-muted);
  display: flex;
  justify-content: center;
  gap: 2rem;
  flex-wrap: wrap;
}

.document-body {
  padding: 2rem 0;
  min-height: 200px;
}

.final-story-text h3 {
  font-family: 'Space Grotesk', sans-serif;
  color: var(--purple);
  margin-bottom: 1.5rem;
  font-size: 1.3rem;
  text-align: center;
}

.story-text {
  font-family: 'Special Elite', monospace;
  line-height: 2.2;
  font-size: 1.1rem;
  color: var(--ink);
  padding: 1.5rem;
  text-align: justify;
  background: 
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 32px,
      rgba(74, 20, 140, 0.05) 32px,
      rgba(74, 20, 140, 0.05) 33px
    );
  border-radius: 4px;
  margin: 0;
}

/* Inline text styling for final story */
.story-text .player-text {
  color: var(--ink);
  font-weight: 500;
}

/* Different colors for different players */
.story-text .player-text[data-player*="Host"],
.story-text .player-text:nth-of-type(odd) {
  color: var(--coral);
}

.story-text .player-text:nth-of-type(even) {
  color: var(--teal);
}

/* AI connector text inline */
.story-text .ai-connector-inline {
  color: var(--purple);
  font-style: italic;
  font-weight: 400;
  opacity: 0.9;
  padding: 0 2px;
}

.story-breakdown {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 3px dashed var(--purple);
}

.story-breakdown summary {
  font-family: 'Caveat', cursive;
  font-size: 1.3rem;
  color: var(--coral);
  cursor: pointer;
  padding: 0.5rem;
  transition: color 0.3s ease;
  list-style: none;
}

.story-breakdown summary::-webkit-details-marker {
  display: none;
}

.story-breakdown summary:hover {
  color: var(--purple);
}

.breakdown-content {
  margin-top: 1.5rem;
  padding: 1rem;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 8px;
}

.breakdown-round {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px dashed rgba(74, 20, 140, 0.2);
}

.breakdown-round:last-child {
  border-bottom: none;
  margin-bottom: 0;
  padding-bottom: 0;
}

.breakdown-round h4 {
  color: var(--purple);
  font-family: 'Space Grotesk', sans-serif;
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.breakdown-section {
  margin-bottom: 1rem;
}

.breakdown-label {
  display: block;
  font-weight: 600;
  color: var(--coral);
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  font-family: 'Caveat', cursive;
  font-size: 1.1rem;
}

.breakdown-fragments,
.breakdown-text {
  padding: 0.75rem;
  background: var(--cream);
  border-radius: 4px;
  font-size: 0.95rem;
  line-height: 1.6;
  border: 1px solid rgba(74, 20, 140, 0.1);
}

.refined-text {
  font-style: italic;
  color: var(--purple);
  background: linear-gradient(90deg, transparent, rgba(78, 205, 196, 0.1), transparent);
}

.player-fragment-breakdown {
  margin-bottom: 0.5rem;
  padding-bottom: 0.5rem;
  border-bottom: 1px dashed rgba(74, 20, 140, 0.1);
}

.player-fragment-breakdown:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.player-fragment-breakdown strong {
  color: var(--coral);
  font-family: 'Caveat', cursive;
  font-size: 1.1em;
  margin-right: 0.5rem;
}
