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

:root {
  --brown-dark: #5C4033;
  --brown-medium: #8B6F47;
  --brown-light: #C4A77D;
  --grey-dark: #4A4A4A;
  --grey-medium: #7A7A7A;
  --grey-light: #D3D3D3;
  --grey-lighter: #F5F5F5;
  --white: #FFFFFF;
  --paper: #FFF8E7;
  --shadow: rgba(92, 64, 51, 0.15);
  --success: #6B8E23;
  --error: #CD5C5C;
}

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

body {
  font-family: 'Inter', sans-serif;
  background: linear-gradient(135deg, var(--grey-lighter) 0%, var(--grey-light) 100%);
  min-height: 100vh;
  overflow-x: hidden;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 20px;
}

/* Logo Animation */
.logo-container {
  text-align: center;
  padding: 40px 0;
  margin-bottom: 40px;
}

.logo {
  font-family: 'Caveat', cursive;
  font-size: 72px;
  font-weight: 700;
  color: var(--brown-dark);
  display: inline-block;
  position: relative;
}

.logo-letter {
  display: inline-block;
  animation: jumpLetter 2s ease-in-out infinite;
}

.logo-letter:nth-child(1) { animation-delay: 0s; }
.logo-letter:nth-child(2) { animation-delay: 0.1s; }
.logo-letter:nth-child(3) { animation-delay: 0.2s; }
.logo-letter:nth-child(4) { animation-delay: 0.3s; }
.logo-letter:nth-child(5) { animation-delay: 0.4s; }
.logo-letter:nth-child(6) { animation-delay: 0.5s; }
.logo-letter:nth-child(7) { animation-delay: 0.6s; }

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

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

.typing-letter {
  opacity: 0;
  animation: typeWriter 0.3s ease forwards;
}

/* Cards */
.card {
  background: var(--white);
  border-radius: 24px;
  padding: 40px;
  box-shadow: 0 8px 24px var(--shadow);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 32px var(--shadow);
}

/* Buttons */
.btn {
  font-family: 'Inter', sans-serif;
  font-size: 18px;
  font-weight: 600;
  padding: 16px 40px;
  border: none;
  border-radius: 16px;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  position: relative;
  overflow: hidden;
}

.btn:active {
  transform: scale(0.95);
}

.btn-primary {
  background: var(--brown-dark);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--brown-medium);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px var(--shadow);
}

.btn-secondary {
  background: var(--grey-medium);
  color: var(--white);
}

.btn-secondary:hover {
  background: var(--grey-dark);
  transform: translateY(-2px);
  box-shadow: 0 8px 16px var(--shadow);
}

.btn-crumble {
  background: var(--brown-medium);
  color: var(--white);
  font-size: 24px;
  padding: 20px 60px;
  border-radius: 20px;
  animation: pulse 2s ease-in-out infinite;
}

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

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

.btn:disabled:hover {
  transform: none;
  box-shadow: none;
}

/* Input Fields */
.input-group {
  margin-bottom: 24px;
}

.input-label {
  display: block;
  font-size: 14px;
  font-weight: 600;
  color: var(--grey-dark);
  margin-bottom: 8px;
  text-align: center;
}

.input-field {
  width: 100%;
  padding: 16px;
  border: 2px solid var(--grey-light);
  border-radius: 12px;
  font-size: 16px;
  font-family: 'Inter', sans-serif;
  transition: border-color 0.3s ease;
  background: var(--white);
}

.input-field:focus {
  outline: none;
  border-color: var(--brown-medium);
}

/* Code Input */
.code-input-container {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 24px 0;
}

.code-digit {
  width: 60px;
  height: 70px;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
  border: 3px solid var(--grey-light);
  border-radius: 12px;
  color: var(--brown-dark);
  transition: all 0.3s ease;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.code-digit:focus {
  outline: none;
  border-color: var(--brown-medium);
  transform: scale(1.05);
}

/* Emoji Selector */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 12px;
  margin: 24px 0;
  max-height: 300px;
  overflow-y: auto;
  padding: 12px;
  background: var(--grey-lighter);
  border-radius: 12px;
}

.emoji-option {
  font-size: 36px;
  width: 60px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 3px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--white);
}

.emoji-option:hover {
  transform: scale(1.2);
  border-color: var(--brown-light);
}

.emoji-option.selected {
  border-color: var(--brown-dark);
  background: var(--brown-light);
  transform: scale(1.1);
}

/* QR Code */
.qr-container {
  text-align: center;
  margin: 24px 0;
}

.qr-code {
  width: 200px;
  height: 200px;
  margin: 0 auto;
  border-radius: 16px;
  padding: 16px;
  background: var(--white);
  box-shadow: 0 4px 12px var(--shadow);
}

.session-code {
  font-size: 36px;
  font-weight: 700;
  color: var(--brown-dark);
  letter-spacing: 4px;
  margin: 16px 0;
  font-family: 'Courier New', monospace;
}

/* Participants */
.participants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 20px;
  margin: 32px 0;
}

.participant-card {
  background: var(--white);
  border-radius: 16px;
  padding: 20px;
  text-align: center;
  box-shadow: 0 4px 12px var(--shadow);
  transition: transform 0.3s ease;
}

.participant-card:hover {
  transform: translateY(-4px);
}

.participant-emoji {
  font-size: 48px;
  margin-bottom: 12px;
}

.participant-name {
  font-size: 16px;
  font-weight: 600;
  color: var(--grey-dark);
}

.participant-completed {
  opacity: 0.6;
  border: 3px solid var(--success);
}

/* Clean Article Style Writing Area */
.container-clean {
  max-width: 800px;
  width: 100%;
  margin: 0 auto;
  padding: 40px 20px;
  background: var(--white);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

.article-container {
  max-width: 700px;
  width: 100%;
  margin: 0 auto;
  font-family: 'Georgia', 'Times New Roman', serif;
  line-height: 1.8;
  color: #1a1a1a;
  flex: 1;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
}

/* Title Section */
.title-section {
  position: relative;
  padding-bottom: 24px;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
}

/* Directly Editable Title and Subtitle */
.article-title-input {
  width: 100%;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: clamp(24px, 4.5vw, 34px);
  font-weight: 700;
  color: #1a1a1a;
  border: none;
  outline: none;
  padding: 8px 60px 8px 0;
  margin: 0 0 12px 0;
  line-height: 1.3;
  background: transparent;
  transition: all 0.2s ease;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  min-height: 38px;
  height: auto;
  max-height: 200px;
  overflow-y: auto;
  overflow-x: hidden;
  resize: none;
  display: block;
}

.article-title-input::placeholder {
  color: #ccc;
  font-style: italic;
}

.article-title-input:focus {
  color: var(--brown-dark);
}

.btn-add-subtitle {
  display: inline-block;
  padding: 4px 12px;
  font-size: 13px;
  font-family: 'Inter', sans-serif;
  color: #999;
  background: transparent;
  border: 1px solid #e0e0e0;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-bottom: 16px;
  height: 29px;
}

.btn-add-subtitle:hover {
  color: #666;
  border-color: #ccc;
  background: #f8f8f8;
}

.article-subtitle-input {
  width: 100%;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: clamp(13px, 2.8vw, 16px);
  font-weight: 400;
  color: #888;
  border: none;
  outline: none;
  padding: 4px 0 4px 2px;
  margin: 0 0 16px 0;
  line-height: 1.4;
  background: transparent;
  font-style: italic;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  min-height: 22px;
  height: auto;
  max-height: 150px;
  overflow-y: auto;
  overflow-x: hidden;
  resize: none;
  display: block;
}

.article-subtitle-input::placeholder {
  color: #999;
  font-style: italic;
}

.article-subtitle-input:focus {
  color: #666;
}

.shuffle-icon {
  position: absolute;
  top: 0;
  right: 0;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  padding: 8px;
  opacity: 0.5;
  transition: opacity 0.2s ease;
}

.shuffle-icon:hover {
  opacity: 1;
}

.title-editor-buttons {
  display: flex;
  gap: 12px;
}

.btn-small {
  padding: 8px 16px;
  font-size: 14px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
}

/* Existing Content - Article Style */
.existing-content {
  margin-bottom: 24px;
  padding-top: 8px;
  flex-shrink: 0;
}

.existing-content p {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.8;
  color: #1a1a1a;
  margin: 0 0 24px 0;
  text-indent: 2em;
}

.existing-content p:first-child {
  text-indent: 0;
}

/* Pull Quote Callout */
.pull-quote {
  float: right;
  width: 45%;
  margin: 8px 0 24px 32px;
  padding: 24px;
  border-left: 4px solid var(--brown-dark);
  background: #f8f8f8;
}

.pull-quote-text {
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 22px;
  line-height: 1.6;
  font-style: italic;
  color: var(--brown-dark);
  margin: 0;
}

@media (max-width: 768px) {
  .pull-quote {
    float: none;
    width: 100%;
    margin: 24px 0;
  }
}

/* Speculation Button */
.btn-speculate {
  padding: 14px 28px;
  background: var(--brown-light);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-speculate:hover:not(:disabled) {
  background: var(--brown-dark);
  transform: translateY(-2px);
}

.btn-speculate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.speculate-content {
  background: #f8f8f8;
  padding: 24px;
  border-radius: 8px;
  margin-bottom: 32px;
  font-family: 'Georgia', serif;
  font-size: 18px;
  line-height: 1.8;
  color: #1a1a1a;
  font-style: italic;
}

.speculate-participants {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 16px;
  margin-top: 24px;
}

.speculate-participant-card {
  background: var(--white);
  border: 3px solid #e0e0e0;
  border-radius: 12px;
  padding: 20px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.speculate-participant-card:hover {
  border-color: var(--brown-medium);
  transform: translateY(-4px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.speculate-participant-card.selected {
  border-color: var(--brown-dark);
  background: var(--brown-light);
  color: var(--white);
}

.speculate-participant-emoji {
  font-size: 48px;
  margin-bottom: 8px;
}

.speculate-participant-name {
  font-size: 16px;
  font-weight: 600;
}

/* Your Turn Section */
.your-turn-section {
  margin-bottom: 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.section-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--brown-dark);
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: 1px;
  text-align: left;
}

/* Formatting Toolbar */
.formatting-toolbar {
  display: flex;
  gap: 8px;
  margin-top: 12px;
  padding: 8px;
  background: #f8f8f8;
  border-radius: 4px;
  justify-content: flex-start;
  flex-shrink: 0;
}

.format-btn {
  width: 32px;
  height: 32px;
  border: 1px solid #ddd;
  background: var(--white);
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #333;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.format-btn:hover {
  background: var(--brown-light);
  color: var(--white);
  border-color: var(--brown-medium);
}

.format-btn:active {
  transform: scale(0.95);
}

.format-btn.active {
  background: var(--brown-dark);
  color: var(--white);
  border-color: var(--brown-dark);
}

.format-btn strong,
.format-btn em {
  font-style: normal;
  font-weight: 600;
}

/* Article Textarea - Clean, No Borders */
.article-textarea {
  width: 100%;
  min-height: 300px;
  padding: 24px 0;
  font-family: 'Georgia', 'Times New Roman', serif;
  font-size: 18px;
  line-height: 1.8;
  color: #1a1a1a;
  border: none;
  outline: none;
  resize: vertical;
  background: transparent;
  flex: 1;
}

.article-textarea::placeholder {
  color: #ccc;
  font-style: italic;
}

/* Placeholder for contenteditable */
.article-textarea[contenteditable]:empty:before {
  content: attr(data-placeholder);
  color: #ccc;
  font-style: italic;
}

/* Formatting styles for contenteditable */
.article-textarea strong {
  font-weight: 700;
}

.article-textarea em {
  font-style: italic;
}

.article-textarea .quote,
.article-textarea blockquote.quote {
  display: block;
  font-style: italic;
  padding: 12px 20px 12px 24px;
  border-left: 4px solid var(--brown-medium);
  margin: 20px 0;
  color: #4a4a4a;
  background: linear-gradient(to right, rgba(196, 167, 125, 0.08), transparent);
  border-radius: 0 4px 4px 0;
  position: relative;
}

.article-textarea .quote::before,
.article-textarea blockquote.quote::before {
  content: '\201C';
  position: absolute;
  left: 8px;
  top: 8px;
  font-size: 32px;
  color: var(--brown-light);
  font-family: Georgia, serif;
  line-height: 1;
}

/* Writing Toolbar */
.writing-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 0;
  border-top: 1px solid #e0e0e0;
  position: sticky;
  bottom: 0;
  background: var(--white);
  z-index: 10;
  margin-top: auto;
  flex-shrink: 0;
}

.toolbar-buttons {
  display: flex;
  gap: 12px;
  align-items: center;
}

.word-counter-clean {
  font-size: 16px;
  font-weight: 600;
  color: #666;
}

.word-counter-clean.valid {
  color: var(--success);
}

.word-counter-clean.invalid {
  color: var(--error);
}

.btn-crumble-clean {
  padding: 14px 32px;
  background: var(--brown-dark);
  color: var(--white);
  border: none;
  border-radius: 4px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-crumble-clean:hover:not(:disabled) {
  background: var(--brown-medium);
  transform: translateX(4px);
}

.btn-crumble-clean:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Floating Timer */
.timer-floating {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--white);
  padding: 16px 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 8px;
  z-index: 1000;
}

.timer-icon {
  font-size: 20px;
}

.timer-display {
  font-family: 'Courier New', monospace;
  font-size: 20px;
  font-weight: 700;
  color: var(--brown-dark);
}

.timer-floating.timer-warning {
  background: var(--error);
  color: var(--white);
  animation: pulse 1s ease-in-out infinite;
}

.timer-floating.timer-warning .timer-display {
  color: var(--white);
}

/* Submission Status Floating */
.submission-floating {
  position: fixed;
  top: 100px;
  right: 24px;
  background: var(--white);
  padding: 16px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-width: 250px;
  z-index: 1000;
}

.submission-floating h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-dark);
  margin: 0 0 12px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.submission-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.submission-item:last-child {
  border-bottom: none;
}

.submission-item.submitted {
  color: var(--success);
}

.submission-item.typing {
  color: var(--brown-medium);
  font-weight: 600;
}

.submission-item.pending {
  color: #666;
}

.submission-item .char-count {
  font-size: 11px;
  color: #999;
  margin-left: 4px;
}

/* Old styles for compatibility */
.writing-container {
  position: relative;
  margin: 32px 0;
}

.paper-background {
  background-image: url('data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTAwJSIgaGVpZ2h0PSIxMDAlIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxkZWZzPjxwYXR0ZXJuIGlkPSJwYXBlciIgcGF0dGVyblVuaXRzPSJ1c2VyU3BhY2VPblVzZSIgd2lkdGg9IjEwMCIgaGVpZ2h0PSIxMDAiPjxyZWN0IGZpbGw9IiNGRkY4RTciIHdpZHRoPSIxMDAiIGhlaWdodD0iMTAwIi8+PC9wYXR0ZXJuPjwvZGVmcz48cmVjdCBmaWxsPSJ1cmwoI3BhcGVyKSIgd2lkdGg9IjEwMCUiIGhlaWdodD0iMTAwJSIvPjwvc3ZnPg==');
  background-color: var(--paper);
  border-radius: 16px;
  padding: 40px;
  box-shadow: 0 8px 24px var(--shadow);
}

.paper-title {
  font-family: 'Caveat', cursive;
  font-size: 36px;
  font-weight: 700;
  color: var(--brown-dark);
  margin-bottom: 24px;
  text-align: center;
}

.paper-title-input {
  width: 100%;
  font-family: 'Caveat', cursive;
  font-size: 36px;
  font-weight: 700;
  color: var(--brown-dark);
  background: transparent;
  border: 2px solid transparent;
  border-radius: 8px;
  padding: 8px 16px;
  text-align: center;
  transition: all 0.3s ease;
}

.paper-title-input:focus {
  outline: none;
  border-color: var(--brown-light);
  background: rgba(255, 255, 255, 0.5);
}

.paper-title-input:hover {
  border-color: var(--brown-light);
}

.writing-area {
  width: 100%;
  min-height: 400px;
  padding: 24px;
  border: 2px solid var(--brown-light);
  border-radius: 12px;
  font-size: 24px;
  font-family: 'Caveat', cursive;
  line-height: 1.8;
  background: transparent;
  resize: vertical;
}

.writing-area:focus {
  outline: none;
  border-color: var(--brown-dark);
}

.word-counter {
  text-align: right;
  margin-top: 12px;
  font-size: 16px;
  font-weight: 600;
  color: var(--grey-medium);
}

.word-counter.valid {
  color: var(--success);
}

.word-counter.invalid {
  color: var(--error);
}

/* Timer */
.timer-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--brown-dark);
  color: var(--white);
  padding: 16px 24px;
  border-radius: 16px;
  box-shadow: 0 8px 24px var(--shadow);
  z-index: 1000;
}

.timer-display {
  font-size: 32px;
  font-weight: 700;
  font-family: 'Courier New', monospace;
}

.timer-warning {
  animation: timerBlink 1s ease-in-out infinite;
}

@keyframes timerBlink {
  0%, 100% { background: var(--brown-dark); }
  50% { background: var(--error); }
}

/* Enterprise-Grade Crumble Animation */
@keyframes crumbleAnimation {
  0% {
    transform: scale(1) rotate(0deg) translateY(0);
    opacity: 1;
    filter: blur(0px);
  }
  15% {
    transform: scale(0.98) rotate(-2deg) translateY(0);
    opacity: 1;
  }
  30% {
    transform: scale(0.92) rotate(3deg) translateY(10px);
    opacity: 0.95;
    filter: blur(0.5px);
  }
  50% {
    transform: scale(0.75) rotate(-8deg) translateY(40px);
    opacity: 0.8;
    filter: blur(1px);
  }
  70% {
    transform: scale(0.5) rotate(25deg) translateY(80px);
    opacity: 0.5;
    filter: blur(2px);
  }
  85% {
    transform: scale(0.3) rotate(90deg) translateY(120px);
    opacity: 0.25;
    filter: blur(3px);
  }
  100% {
    transform: scale(0.1) rotate(180deg) translateY(200px);
    opacity: 0;
    filter: blur(5px);
  }
}

@keyframes crumbleParticles {
  0% {
    background-position: 0% 0%;
    opacity: 0;
  }
  30% {
    opacity: 1;
  }
  100% {
    background-position: 100% 100%;
    opacity: 0;
  }
}

.crumbling {
  animation: crumbleAnimation 1.2s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
  transform-origin: center center;
  position: relative;
  z-index: 100;
}

.crumbling::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: radial-gradient(circle, rgba(196, 167, 125, 0.3) 2px, transparent 2px),
              radial-gradient(circle, rgba(139, 111, 71, 0.3) 2px, transparent 2px);
  background-size: 30px 30px, 40px 40px;
  background-position: 0 0, 15px 15px;
  animation: crumbleParticles 1.2s ease-out forwards;
  pointer-events: none;
  border-radius: inherit;
}

/* Crumble container preparation */
.article-container.preparing-crumble {
  position: relative;
  overflow: visible;
}

/* Slide Transitions */
@keyframes slideOutLeft {
  from {
    transform: translateX(0);
    opacity: 1;
  }
  to {
    transform: translateX(-100%) scale(0.8);
    opacity: 0;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100%) scale(0.8);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.slide-out-left {
  animation: slideOutLeft 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

.slide-in-right {
  animation: slideInRight 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* Grand Reveal */
.reveal-container {
  max-width: 900px;
  margin: 0 auto;
}

.reveal-paper {
  background: var(--paper);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 32px;
  box-shadow: 0 8px 24px var(--shadow);
}

.reveal-segment {
  margin: 24px 0;
  padding: 20px;
  background: rgba(255, 255, 255, 0.5);
  border-radius: 12px;
  border-left: 4px solid var(--brown-medium);
}

.segment-author {
  font-weight: 600;
  color: var(--brown-dark);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Responsive */
@media (max-width: 768px) {
  .logo {
    font-size: 48px;
  }

  .card {
    padding: 24px;
  }

  .emoji-grid {
    grid-template-columns: repeat(6, 1fr);
  }

  .code-digit {
    width: 50px;
    height: 60px;
    font-size: 24px;
  }

  .participants-grid {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }

  .timer-container {
    bottom: 16px;
    right: 16px;
    padding: 12px 16px;
  }

  .timer-display {
    font-size: 24px;
  }

  /* Text wrapping improvements for mobile */
  .article-title-input {
    font-size: clamp(20px, 5vw, 28px);
    padding-right: 50px;
    max-height: 250px;
  }

  .article-subtitle-input {
    font-size: clamp(12px, 3.5vw, 15px);
    max-height: 180px;
  }

  .article-card-title {
    font-size: clamp(18px, 4vw, 20px);
  }

  .article-title {
    font-size: clamp(22px, 5vw, 30px);
  }

  .modal-article {
    padding: 24px;
  }
}

/* Loading Spinner */
.spinner {
  width: 50px;
  height: 50px;
  margin: 40px auto;
  border: 4px solid var(--grey-light);
  border-top-color: var(--brown-medium);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Submission Status */
.submission-status {
  position: fixed;
  top: 24px;
  right: 24px;
  background: var(--white);
  padding: 20px;
  border-radius: 16px;
  box-shadow: 0 8px 24px var(--shadow);
  max-width: 250px;
  z-index: 1000;
}

.submission-status h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--brown-dark);
  margin-bottom: 12px;
}

.submission-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--grey-lighter);
  font-size: 14px;
}

.submission-item:last-child {
  border-bottom: none;
}

.submission-item.submitted {
  color: var(--success);
}

.submission-item.pending {
  color: var(--grey-medium);
}

/* Voting Screen */
.voting-header {
  max-width: 1000px;
  margin: 0 auto 48px;
  padding: 0 20px;
}

.voting-header h1 {
  font-family: 'Caveat', cursive !important;
}

.articles-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 24px;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 0 20px 100px;
  box-sizing: border-box;
  overflow-x: hidden;
}

/* Override container-clean for voting screen to allow wider content */
#votingScreen.container-clean {
  max-width: 100%;
  padding: 40px 0;
}

.article-card {
  background: var(--white);
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 24px;
  cursor: pointer;
  transition: all 0.3s ease;
  position: relative;
  width: 100%;
  box-sizing: border-box;
  overflow: hidden;
  min-width: 0;
}

.article-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(0,0,0,0.1);
  border-color: var(--brown-medium);
}

.article-card.favorited {
  border-color: var(--brown-dark);
  border-width: 3px;
  background: #fffbf0;
}

.article-card.own-paper {
  opacity: 0.5;
  cursor: not-allowed;
}

.article-card.own-paper:hover {
  transform: none;
}

.article-card-title {
  font-family: 'Georgia', serif;
  font-size: clamp(20px, 3.5vw, 22px);
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 16px;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  display: block;
  max-width: 100%;
}

.article-card-preview {
  font-family: 'Georgia', serif;
  font-size: 14px;
  line-height: 1.6;
  color: #666;
  margin-bottom: 16px;
  max-height: 100px;
  overflow: hidden;
  position: relative;
}

.article-card-preview::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, white);
}

.article-card-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid #e0e0e0;
}

.article-card-btn {
  font-size: 13px;
  color: var(--brown-dark);
  text-decoration: none;
  font-weight: 600;
}

.favorite-badge {
  font-size: 24px;
  position: absolute;
  top: 16px;
  right: 16px;
}

/* Voting Progress Sidebar */
.voting-progress {
  position: fixed;
  top: 100px;
  right: 24px;
  background: var(--white);
  padding: 20px;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  max-width: 250px;
  z-index: 1000;
}

.voting-progress h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--brown-dark);
  margin: 0 0 16px 0;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.voting-status-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 13px;
}

.voting-status-item:last-child {
  border-bottom: none;
}

.voting-status-item.voted {
  color: var(--success);
}

.voting-status-item.pending {
  color: #666;
}

/* Article Modal */
.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: 2000;
  padding: 20px;
  overflow-y: auto;
}

.modal-content {
  background: var(--white);
  border-radius: 8px;
  max-width: 800px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  margin: auto;
}

.modal-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 36px;
  cursor: pointer;
  color: #666;
  line-height: 1;
  padding: 8px;
  z-index: 1;
}

.modal-close:hover {
  color: #000;
}

.modal-article {
  padding: 48px;
}

.article-title {
  font-family: 'Georgia', serif;
  font-size: clamp(26px, 4.5vw, 36px);
  font-weight: 700;
  color: #1a1a1a;
  margin-bottom: 24px;
  line-height: 1.3;
  word-wrap: break-word;
  overflow-wrap: break-word;
  word-break: break-word;
  white-space: normal;
  display: block;
  max-width: 100%;
}

.modal-article-content {
  font-family: 'Georgia', serif;
  font-size: 18px;
  line-height: 1.8;
  color: #1a1a1a;
  margin: 32px 0;
}

.modal-article-content p {
  margin-bottom: 24px;
  text-indent: 2em;
}

.modal-article-content p:first-child {
  text-indent: 0;
}

.modal-actions {
  text-align: center;
  margin-top: 48px;
  padding-top: 24px;
  border-top: 1px solid #e0e0e0;
}

.btn-favorite {
  padding: 16px 48px;
  background: var(--white);
  color: var(--brown-dark);
  border: 3px solid var(--brown-dark);
  border-radius: 8px;
  font-size: 18px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  font-family: 'Georgia', serif;
}

.btn-favorite:hover {
  background: var(--brown-dark);
  color: var(--white);
}

.btn-favorite.favorited {
  background: var(--brown-dark);
  color: var(--white);
}

.btn-favorite .heart {
  font-size: 24px;
  margin-right: 8px;
}

.btn-favorite.favorited .heart {
  content: '♥';
}

.vote-count {
  text-align: center;
  margin-top: 24px;
  font-size: 24px;
  font-weight: bold;
  color: var(--brown-dark);
}

/* Hidden */
.hidden {
  display: none !important;
}

/* Utilities */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.flex-center {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
}

.flex-between {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* Speculation Notification */
.speculation-notification {
  position: fixed;
  bottom: -100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--brown-dark);
  color: var(--white);
  padding: 16px 24px;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
  z-index: 3000;
  display: flex;
  align-items: center;
  font-size: 15px;
  font-weight: 600;
  transition: bottom 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  max-width: 90%;
}

.speculation-notification.show {
  bottom: 32px;
}

/* Timed-out styles */
.submission-item.timed-out {
  color: var(--error);
  opacity: 0.7;
}

.participant-card.timed-out {
  opacity: 0.5;
  border: 2px dashed var(--error);
}
