/* Desert Oasis Light Theme Styling - Cactus Edition */

:root {
  /* Soft, warm light-themed desert palette */
  --bg-desert: #fdfaf2;
  --bg-card: rgba(255, 255, 255, 0.85);
  --border-sandy: #e9e0cf;
  --text-primary: #3f3f46;
  --text-secondary: #71717a;
  --text-muted: #a1a1aa;
  
  --subject-color: #0284c7;
  --subject-bg: #f0f9ff;
  --subject-border: #bae6fd;

  --verb-color: #db2777;
  --verb-bg: #fdf2f8;
  --verb-border: #fbcfe8;

  --object-color: #059669;
  --object-bg: #ecfdf5;
  --object-border: #a7f3d0;

  --accent-sandy: #f59e0b;
  --accent-green: #10b981;
  --accent-green-dark: #047857;

  --success-color: #10b981;
  --error-color: #ef4444;

  --font-display: 'Outfit', 'Inter', system-ui, sans-serif;
  --font-body: 'Inter', system-ui, sans-serif;
  
  --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  --radius-lg: 18px;
  --radius-md: 12px;
  --shadow-warm: 0 10px 25px -5px rgba(220, 210, 190, 0.4), 0 8px 10px -6px rgba(220, 210, 190, 0.3);
}

/* Global Reset */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font-body);
}

body {
  background-color: var(--bg-desert);
  color: var(--text-primary);
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
  padding: 1.5rem 1rem;
  background-image: 
    radial-gradient(circle at 100% 150%, #fef3c7 24%, #fde68a 25%, #fde68a 28%, transparent 29%),
    radial-gradient(circle at 0% 150%, #fef3c7 24%, #fde68a 25%, #fde68a 28%, transparent 29%);
  background-size: 100px 100px;
}

/* Background Sun and Floating Clouds */
.desert-sun {
  position: absolute;
  top: 40px;
  right: 60px;
  width: 90px;
  height: 90px;
  background: radial-gradient(circle, #fcd34d 0%, #f59e0b 80%);
  border-radius: 50%;
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.4);
  z-index: -1;
  animation: sunPulse 6s ease-in-out infinite alternate;
}

@keyframes sunPulse {
  0% { transform: scale(1); box-shadow: 0 0 30px rgba(245, 158, 11, 0.3); }
  100% { transform: scale(1.05); box-shadow: 0 0 50px rgba(245, 158, 11, 0.5); }
}

.cloud {
  position: absolute;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 50px;
  z-index: -1;
  filter: blur(2px);
}

.cloud-1 {
  width: 150px;
  height: 40px;
  top: 80px;
  left: 10%;
  animation: floatCloud 45s linear infinite;
}

.cloud-2 {
  width: 220px;
  height: 50px;
  top: 150px;
  right: 15%;
  animation: floatCloudInverse 60s linear infinite;
}

@keyframes floatCloud {
  0% { transform: translateX(-100px); }
  100% { transform: translateX(calc(100vw + 100px)); }
}

@keyframes floatCloudInverse {
  0% { transform: translateX(100px); }
  100% { transform: translateX(calc(-100vw - 100px)); }
}

#success-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 9999;
}

/* App Layout Container */
.app-container {
  max-width: 1240px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.75rem;
  background: var(--bg-card);
  border: 1px solid var(--border-sandy);
  box-shadow: var(--shadow-warm);
  border-radius: var(--radius-lg);
}

.brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.logo-icon {
  background: linear-gradient(135deg, var(--accent-green), var(--accent-sandy));
  width: 44px;
  height: 44px;
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.brand h1 {
  font-family: var(--font-display);
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: #1e293b;
}

.tagline {
  font-size: 0.825rem;
  color: var(--text-secondary);
}

/* Mode Switcher Tabs */
.mode-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: rgba(233, 224, 207, 0.5);
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  padding: 0.25rem;
}

.tab-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border: none;
  background: none;
  border-radius: calc(var(--radius-md) - 2px);
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: var(--transition-smooth);
}

.tab-btn:hover {
  color: #1e293b;
}

.tab-btn.active {
  background: #fff;
  color: var(--accent-green-dark);
  box-shadow: 0 4px 12px rgba(220, 210, 190, 0.3);
}

/* Workspace Grid */
.workspace-grid {
  display: grid;
  grid-template-columns: 310px 1fr;
  gap: 1.25rem;
  transition: var(--transition-smooth);
}

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

.sidebar-card {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.sidebar-section {
  background: var(--bg-card);
  border: 1px solid var(--border-sandy);
  box-shadow: var(--shadow-warm);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
}

.sidebar-section h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: #1e293b;
  margin-bottom: 0.75rem;
  border-bottom: 1.5px solid var(--border-sandy);
  padding-bottom: 0.4rem;
}

.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.progress-bar-bg {
  background: rgba(0, 0, 0, 0.05);
  height: 8px;
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  background: linear-gradient(to right, var(--accent-green), #60a5fa);
  height: 100%;
  border-radius: 4px;
  transition: var(--transition-smooth);
}

.progress-stats {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  color: var(--text-secondary);
}

/* Lesson Navigation Select Dropdown */
.level-select-container {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.select-label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 0.35rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.select-label svg {
  width: 14px;
  height: 14px;
  color: var(--accent-green-dark);
}

.section-select-dropdown {
  background: #fff;
  border: 1.5px solid var(--border-sandy);
  border-radius: var(--radius-md);
  padding: 0.5rem 1.8rem 0.5rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  font-weight: 600;
  color: #1e293b;
  cursor: pointer;
  outline: none;
  transition: var(--transition-smooth);
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2378350f' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.6rem center;
  background-size: 0.85rem;
  min-width: 280px;
  box-shadow: var(--shadow-warm);
}

.section-select-dropdown:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.12);
}

.section-select-dropdown option {
  font-weight: 500;
  padding: 0.3rem;
}

/* Classroom Leaderboard */
.leaderboard-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.leader-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 0.75rem;
  background: #fff;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  transition: var(--transition-smooth);
}

.leader-item.user {
  background: #fffbeb;
  border-color: #fef08a;
  font-weight: 700;
}

.leader-rank-badge {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #e2e8f0;
  color: #475569;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.leader-item:nth-child(1) .leader-rank-badge { background: #fef08a; color: #a16207; }
.leader-item:nth-child(2) .leader-rank-badge { background: #e2e8f0; color: #475569; }
.leader-item:nth-child(3) .leader-rank-badge { background: #ffedd5; color: #ea580c; }

.leader-name {
  flex-grow: 1;
  margin-left: 0.75rem;
  color: #1e293b;
}

.leader-score {
  font-weight: 700;
  color: var(--accent-green-dark);
}

/* Split container: Pot & Gameplay */
.gameplay-split-container {
  display: grid;
  grid-template-columns: 240px 1fr;
  gap: 1.25rem;
}

@media (max-width: 750px) {
  .gameplay-split-container {
    grid-template-columns: 1fr;
  }
}

/* Cactus Pot Gardening card */
.cactus-pot-card {
  background: var(--bg-card);
  border: 1px solid var(--border-sandy);
  box-shadow: var(--shadow-warm);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.cactus-pot-card h3 {
  font-family: var(--font-display);
  font-size: 1rem;
  color: #1e293b;
  margin-bottom: 0.75rem;
  width: 100%;
  border-bottom: 1.5px solid var(--border-sandy);
  padding-bottom: 0.4rem;
}

.cactus-display-box {
  position: relative;
  width: 100%;
  height: 200px;
  background: linear-gradient(to bottom, #eff6ff, #dbeafe);
  border-radius: var(--radius-md);
  border: 1px solid #bfdbfe;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 10px;
  margin-bottom: 0.75rem;
}

.cactus-svg {
  width: 100px;
  height: 140px;
  z-index: 10;
}

.hidden-growth {
  opacity: 0;
  transform: scale(0.1);
  transform-origin: bottom center;
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.show-growth {
  opacity: 1 !important;
  transform: scale(1) !important;
}

#cactus-flower {
  transition: r 0.8s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.cactus-status {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-green-dark);
}

/* Watering droplets effect */
.water-droplets {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 20;
}

.drop {
  position: absolute;
  background: #60a5fa;
  width: 4px;
  height: 10px;
  border-radius: 50%;
  opacity: 0.7;
  animation: fall 0.8s linear forwards;
}

@keyframes fall {
  0% { transform: translateY(0); opacity: 0.7; }
  100% { transform: translateY(180px); opacity: 0; }
}

/* Steppers */
.phase-stepper {
  display: flex;
  align-items: center;
  background: var(--bg-card);
  border: 1px solid var(--border-sandy);
  padding: 0.6rem 1.25rem;
  border-radius: var(--radius-lg);
  margin-bottom: 0.75rem;
  box-shadow: var(--shadow-warm);
}

.step {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  opacity: 0.6;
}

.step.active {
  color: #1e293b;
  opacity: 1;
}

.step.completed {
  color: var(--success-color);
  opacity: 1;
}

.step-num {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1.5px solid currentColor;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 700;
}

.step.completed .step-num {
  background: var(--success-color);
  border-color: var(--success-color);
  color: #fff;
}

.step-label {
  font-weight: 600;
}

.step-line {
  flex-grow: 1;
  height: 2px;
  background: var(--border-sandy);
  margin: 0 0.75rem;
}

.step-line.completed {
  background: var(--success-color);
}

/* Interactive Card */
.game-card {
  background: var(--bg-card);
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  box-shadow: var(--shadow-warm);
}

.level-info-board {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

.badge {
  background: var(--accent-sandy);
  color: #fff;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
}

.drill-count-badge {
  background: #e2e8f0;
  color: #475569;
  padding: 0.25rem 0.6rem;
  border-radius: 12px;
  font-size: 0.7rem;
  font-weight: 700;
}

.level-info-board h2 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: #1e293b;
}

.instruction-box {
  background: rgba(245, 158, 11, 0.05);
  border-left: 3px solid var(--accent-sandy);
  padding: 0.6rem 0.85rem;
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.info-icon {
  color: var(--accent-sandy);
  flex-shrink: 0;
}

.instruction-box p {
  font-size: 0.8rem;
  color: #1e293b;
  line-height: 1.35;
}

/* Sentence Tokens Box */
.sentence-box-container {
  background: #fcfbfa;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.sentence-bubble-label {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
  font-weight: 700;
}

.sentence-display {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  align-items: center;
  min-height: 44px;
}

.word-token {
  padding: 0.35rem 0.7rem;
  background: #fff;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  font-weight: 500;
  color: #1e293b;
  cursor: grab;
  user-select: none;
  transition: var(--transition-smooth);
}

.word-token:hover {
  border-color: #cbd5e1;
  background: #fafaf9;
  transform: translateY(-1px);
}

.word-token.dragging { opacity: 0.4; }
.word-token.classified { opacity: 0.15; pointer-events: none; }

.help-hint-tap {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.7rem;
  color: var(--text-secondary);
}

/* S-V-O Columns */
.svo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

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

.svo-column {
  background: #fcfbfa;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  padding: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.svo-column.drag-over {
  background: #fef3c7;
  border-color: var(--accent-sandy);
}

.col-header {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.column-indicator {
  width: 18px;
  height: 18px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.7rem;
  font-weight: 800;
  color: #fff;
}

.indicator-s { background: var(--subject-color); }
.indicator-v { background: var(--verb-color); }
.indicator-o { background: var(--object-color); }

.col-header h4 {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  color: #1e293b;
}

.drop-zone {
  min-height: 70px;
  border: 1.5px dashed var(--border-sandy);
  border-radius: var(--radius-md);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem;
  background: #fff;
}

.placeholder-text {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Placed badges */
.placed-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.65rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 700;
}

.placed-badge.subject { background: var(--subject-bg); color: var(--subject-color); border: 1px solid var(--subject-border); }
.placed-badge.verb { background: var(--verb-bg); color: var(--verb-color); border: 1px solid var(--verb-border); }
.placed-badge.object { background: var(--object-bg); color: var(--object-color); border: 1px solid var(--object-border); }

.placed-badge .remove-btn {
  background: none;
  border: none;
  color: currentColor;
  cursor: pointer;
  opacity: 0.7;
}

.placed-badge .remove-btn:hover { opacity: 1; }

/* Rewrite Input Area */
.rewrite-panel {
  background: #fdfdfd;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: slideUp 0.3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

.rewrite-input-box {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

#rewrite-text-input {
  width: 100%;
  padding: 0.6rem 0.85rem;
  background: #fff;
  border: 1.5px solid var(--border-sandy);
  border-radius: var(--radius-md);
  font-size: 0.95rem;
  font-weight: 600;
  color: #1e293b;
  outline: none;
  transition: var(--transition-smooth);
}

#rewrite-text-input:focus {
  border-color: var(--accent-green);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.15);
}

.rewrite-hint {
  font-size: 0.725rem;
  color: var(--text-secondary);
}

/* Action button configurations */
.action-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
  border-top: 1px solid var(--border-sandy);
  padding-top: 0.75rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.55rem 1.1rem;
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  font-weight: 700;
  cursor: pointer;
  transition: var(--transition-smooth);
  border: none;
}

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

.btn-primary {
  background: linear-gradient(135deg, var(--accent-green-dark), var(--accent-green));
  color: #fff;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.15);
}

.btn-primary:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.25);
}

.btn-secondary {
  background: #fff;
  border: 1px solid var(--border-sandy);
  color: var(--text-primary);
}

.btn-secondary:hover { background: #fafaf9; }

.btn-secondary-danger {
  background: #fee2e2;
  border: 1px solid #fca5a5;
  color: #dc2626;
}

.btn-secondary-danger:hover { background: #fecaca; }

/* Feedback Card design updates */
.feedback-card {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: fadeIn 0.4s ease;
}

.feedback-status-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.success-icon-badge {
  background: var(--success-color);
  color: #fff;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.25);
}

.feedback-status-header h3 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  color: var(--accent-green-dark);
}

.feedback-status-header p {
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.sentence-reveal-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 0.75rem;
  background: #fff;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  padding: 1rem;
}

.reveal-box {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.reveal-tag {
  font-size: 0.6rem;
  font-weight: 700;
  text-transform: uppercase;
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  width: fit-content;
}

.tag-flawed { background: #fee2e2; color: #ef4444; border: 1px solid #fecaca; }
.tag-clean { background: #dcfce7; color: #10b981; border: 1px solid #bbf7d0; }

.reveal-box p {
  font-size: 0.9rem;
  font-weight: 600;
}

.reveal-icon { color: var(--text-muted); text-align: center; }

.rule-explanation-box {
  background: #fcfbfa;
  border: 1px solid var(--border-sandy);
  padding: 0.85rem;
  border-radius: var(--radius-md);
}

.rule-title {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--accent-green-dark);
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
}

#feedback-rule-text {
  font-size: 0.825rem;
  line-height: 1.4;
  color: #374151;
  margin-top: 0.25rem;
}

/* 2P Duel Panel Settings */
.duel-workspace {
  background: #fefcf6;
  border: 1.5px solid #d97706;
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  animation: fadeIn 0.4s ease;
}

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

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

.player-panel {
  background: #fff;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-warm);
}

.player-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.75rem;
  border-bottom: 1.5px solid var(--border-sandy);
  padding-bottom: 0.4rem;
}

.player-header h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.score-pill {
  background: #fef3c7;
  color: #b45309;
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  border-radius: 8px;
}

.duel-sentence-box {
  background: #fcfbfa;
  padding: 0.75rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-sandy);
  margin-bottom: 0.75rem;
  font-weight: 600;
  font-size: 0.85rem;
  min-height: 48px;
}

.duel-rewrite-box {
  margin-top: 0.75rem;
  margin-bottom: 0.75rem;
}

.duel-rewrite-box input {
  width: 100%;
  padding: 0.55rem 0.75rem;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  font-weight: 600;
  outline: none;
}

.duel-rewrite-box input:focus {
  border-color: #d97706;
}

.duel-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.25rem;
  border-top: 1.5px solid var(--border-sandy);
  padding-top: 0.75rem;
}

.duel-match-round {
  font-size: 0.85rem;
  font-weight: 700;
  color: #b45309;
}

/* Modals */
.classify-modal, .library-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.modal-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
}

.classify-modal-content, .library-modal-content {
  position: relative;
  background: #fff;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: 0 20px 40px rgba(0,0,0,0.15);
  z-index: 1001;
}

.classify-modal-content { max-width: 380px; width: 100%; display: flex; flex-direction: column; gap: 0.75rem; }
.library-modal-content { max-width: 600px; width: 100%; display: flex; flex-direction: column; gap: 1rem; max-height: 80vh; }

.modal-header h2 { font-size: 1.2rem; color: #1e293b; }
.modal-body { overflow-y: auto; display: flex; flex-direction: column; gap: 0.75rem; max-height: 60vh; }

.library-rule-item {
  background: #fcfbfa;
  border: 1px solid var(--border-sandy);
  border-radius: var(--radius-md);
  padding: 0.75rem;
}

.library-rule-item h4 { font-size: 0.85rem; color: var(--accent-green-dark); margin-bottom: 0.2rem; }
.library-rule-item p { font-size: 0.75rem; color: var(--text-primary); line-height: 1.35; margin-bottom: 0.4rem; }

.library-rule-examples { display: grid; grid-template-columns: 1fr 1fr; gap: 0.4rem; font-size: 0.7rem; }
.lib-ex-flawed { color: #b91c1c; background: #fee2e2; padding: 0.25rem 0.4rem; border-radius: 4px; }
.lib-ex-corrected { color: #047857; background: #dcfce7; padding: 0.25rem 0.4rem; border-radius: 4px; }

.hidden { display: none !important; }

/* ===== CANTONESE ERROR MODAL ===== */
.cantonese-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.cantonese-modal-content {
  position: relative;
  z-index: 10;
  background: #fff;
  border-radius: 20px;
  width: 100%;
  max-width: 520px;
  box-shadow: 0 25px 60px -10px rgba(0,0,0,0.25), 0 0 0 1px rgba(239, 68, 68, 0.12);
  overflow: hidden;
  animation: cantoneseSlideIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes cantoneseSlideIn {
  from { opacity: 0; transform: scale(0.88) translateY(30px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.cantonese-modal-header {
  display: flex;
  align-items: flex-start;
  gap: 0.85rem;
  padding: 1.25rem 1.25rem 1rem;
  background: linear-gradient(135deg, #fff7ed 0%, #fef2f2 100%);
  border-bottom: 1px solid #fde8d8;
}

.cantonese-icon-badge {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  background: linear-gradient(135deg, #f97316, #ef4444);
  border-radius: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
}

.cantonese-header-text { flex: 1; min-width: 0; }

.cantonese-tag {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9a3412;
  background: rgba(251, 146, 60, 0.15);
  padding: 0.15rem 0.5rem;
  border-radius: 20px;
  margin-bottom: 0.25rem;
}

.cantonese-modal-header h3 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #1e293b;
  font-family: var(--font-display);
  line-height: 1.3;
}

.cantonese-modal-body {
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.cantonese-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #b45309;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 0.35rem;
}

.cantonese-label svg { width: 14px; height: 14px; }

.cantonese-explanation-box {
  background: #fff7ed;
  border: 1.5px solid #fed7aa;
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.cantonese-explanation-box p {
  font-size: 0.92rem;
  color: #431407;
  line-height: 1.65;
  margin: 0;
}

.cantonese-compare-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.compare-box {
  flex: 1;
  border-radius: 10px;
  padding: 0.65rem 0.8rem;
}

.compare-tag {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 0.2rem;
}

.compare-wrong { background: #fef2f2; border: 1.5px solid #fca5a5; }
.compare-wrong .compare-tag { color: #b91c1c; }
.compare-wrong p { color: #7f1d1d; font-size: 0.82rem; font-weight: 600; line-height: 1.4; margin: 0; }

.compare-right { background: #f0fdf4; border: 1.5px solid #86efac; }
.compare-right .compare-tag { color: #15803d; }
.compare-right p { color: #14532d; font-size: 0.82rem; font-weight: 600; line-height: 1.4; margin: 0; }

.compare-arrow { font-size: 1.3rem; color: #94a3b8; flex-shrink: 0; font-weight: 700; }

.cantonese-action-box {
  background: linear-gradient(135deg, #ecfdf5 0%, #f0f9ff 100%);
  border: 1.5px solid #a7f3d0;
  border-radius: 12px;
  padding: 0.85rem 1rem;
}

.cantonese-action-box p {
  font-size: 0.9rem;
  color: #064e3b;
  line-height: 1.65;
  margin: 0;
}

.cantonese-modal-footer {
  padding: 0.9rem 1.25rem 1.25rem;
  border-top: 1px solid #f1f5f9;
  background: #fafaf9;
}

.cantonese-modal-footer .btn {
  width: 100%;
  justify-content: center;
  font-size: 0.92rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, #f97316, #ef4444);
  color: white;
  border: none;
  border-radius: 12px;
  gap: 0.5rem;
  box-shadow: 0 4px 12px rgba(239, 68, 68, 0.25);
  transition: var(--transition-smooth);
}

.cantonese-modal-footer .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(239, 68, 68, 0.35);
  background: linear-gradient(135deg, #ea580c, #dc2626);
}

@keyframes shakeError {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-6px); }
  40% { transform: translateX(6px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake-error { animation: shakeError 0.45s ease-in-out; }

/* ===== PASSWORD GATE SCREEN ===== */
.password-gate {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: #fdfaf2;
  overflow: hidden;
}

.password-gate-bg {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.gate-sun {
  position: absolute;
  top: 50px;
  right: 80px;
  width: 100px;
  height: 100px;
  background: radial-gradient(circle, #fcd34d 0%, #f59e0b 80%);
  border-radius: 50%;
  box-shadow: 0 0 60px rgba(245,158,11,0.5);
  animation: sunPulse 6s ease-in-out infinite alternate;
}

.gate-cloud {
  position: absolute;
  background: rgba(255,255,255,0.85);
  border-radius: 50px;
  filter: blur(2px);
}

.gate-cloud-1 { width: 180px; height: 50px; top: 12%; left: 5%; animation: cloudDrift 18s linear infinite; }
.gate-cloud-2 { width: 120px; height: 35px; top: 20%; right: 15%; animation: cloudDrift 24s linear infinite reverse; opacity: 0.7; }
.gate-cloud-3 { width: 90px; height: 28px; top: 8%; left: 40%; animation: cloudDrift 20s linear infinite; opacity: 0.6; }

.gate-cactus-row {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-end;
  justify-content: space-around;
  padding: 0 5%;
  opacity: 0.55;
}

.gate-cactus {
  flex-shrink: 0;
}

/* Password Card */
.password-card {
  position: relative;
  z-index: 10;
  background: rgba(255,255,255,0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1.5px solid rgba(245,158,11,0.2);
  border-radius: 28px;
  padding: 2.5rem 2.25rem 2rem;
  width: 100%;
  max-width: 420px;
  box-shadow:
    0 20px 60px -10px rgba(180, 140, 60, 0.2),
    0 4px 16px rgba(180,140,60,0.12);
  display: flex;
  flex-direction: column;
  gap: 1.6rem;
  animation: cardRise 0.6s cubic-bezier(0.34, 1.3, 0.64, 1) both;
}

@keyframes cardRise {
  from { opacity: 0; transform: translateY(40px) scale(0.95); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.password-logo {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
}

.password-logo-icon {
  font-size: 3rem;
  line-height: 1;
  filter: drop-shadow(0 4px 8px rgba(16, 185, 129, 0.25));
  animation: sway 4s ease-in-out infinite alternate;
}

@keyframes sway {
  from { transform: rotate(-4deg); }
  to   { transform: rotate(4deg); }
}

.password-logo h1 {
  font-size: 1.55rem;
  font-family: var(--font-display);
  font-weight: 800;
  color: #1e293b;
  letter-spacing: -0.02em;
}

.password-tagline {
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.password-form-area {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.password-label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.07em;
  cursor: default;
}

.password-label svg { width: 14px; height: 14px; }

.password-input-row {
  display: flex;
  align-items: center;
  background: #fff;
  border: 2px solid var(--border-sandy);
  border-radius: 14px;
  overflow: hidden;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.password-input-row:focus-within {
  border-color: var(--accent-green);
  box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.password-input-row.error {
  border-color: var(--error-color);
  box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
  animation: shakeError 0.4s ease-in-out;
}

.password-input {
  flex: 1;
  border: none;
  outline: none;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-family: var(--font-body);
  color: var(--text-primary);
  background: transparent;
  letter-spacing: 0.05em;
}

.password-input::placeholder { color: var(--text-muted); letter-spacing: 0; }

.btn-toggle-pw {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.75rem 0.9rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  transition: color 0.2s;
}

.btn-toggle-pw:hover { color: var(--accent-green); }
.btn-toggle-pw svg { width: 18px; height: 18px; }

.password-error {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--error-color);
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
}

.password-error svg { width: 14px; height: 14px; flex-shrink: 0; }

.btn-enter {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  padding: 0.9rem 1rem;
  background: linear-gradient(135deg, #10b981, #059669);
  color: white;
  font-weight: 700;
  font-size: 1rem;
  font-family: var(--font-display);
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 0 4px 15px rgba(16, 185, 129, 0.35);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  margin-top: 0.3rem;
}

.btn-enter:hover {
  background: linear-gradient(135deg, #059669, #047857);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(16, 185, 129, 0.4);
}

.btn-enter:active { transform: translateY(0); }
.btn-enter svg { width: 18px; height: 18px; }

.password-footer-note {
  text-align: center;
  font-size: 0.72rem;
  color: var(--text-muted);
  margin-top: -0.5rem;
}

/* Gate unlock animation */
@keyframes gateUnlock {
  0%   { opacity: 1; transform: scale(1); }
  50%  { opacity: 1; transform: scale(1.03); }
  100% { opacity: 0; transform: scale(0.92); pointer-events: none; }
}

.password-gate.unlocking {
  animation: gateUnlock 0.55s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

/* Hide mode tabs (2P Versus) and leaderboard panel to integrate clean Solo mode */
.mode-tabs {
  display: none !important;
}

.leaderboard-section {
  display: none !important;
}
