/* Game layout patterns */
.game-screen {
  padding: var(--header-height) var(--space-md) var(--space-lg);
  min-height: 100vh;
  animation: fadeIn var(--transition-normal);
  display: flex;
  flex-direction: column;
}

.game-instruction {
  text-align: center;
  padding: var(--space-md) 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.game-question {
  font-size: var(--text-lg);
  font-weight: 600;
  text-align: center;
  padding: var(--space-md) 0;
  line-height: 1.5;
}

.game-question-sub {
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin-top: var(--space-xs);
}

.game-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: var(--space-md);
  padding: var(--space-md) 0;
}

.game-footer {
  padding: var(--space-md) 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.game-score-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: var(--space-sm) 0;
  font-size: var(--text-sm);
  color: var(--text-secondary);
}

/* Memory match grid */
.memory-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  padding: var(--space-md) 0;
}

.memory-card {
  aspect-ratio: 1;
  perspective: 800px;
  cursor: pointer;
}

.memory-card-inner {
  width: 100%;
  height: 100%;
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
  position: relative;
}

.memory-card.flipped .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card-front, .memory-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--space-xs);
  font-size: var(--text-sm);
  text-align: center;
  word-break: break-word;
}

.memory-card-front {
  background: var(--bg-card);
  border: 2px solid var(--teal);
  color: var(--teal);
  font-size: var(--text-2xl);
}

.memory-card-back {
  background: var(--bg-card-hover);
  transform: rotateY(180deg);
  color: var(--text-primary);
}

.memory-card.matched {
  pointer-events: none;
}

.memory-card.matched .memory-card-inner {
  transform: rotateY(180deg);
}

.memory-card.matched .memory-card-back {
  border: 2px solid var(--green);
  background: rgba(0, 212, 170, 0.1);
}

/* Prompt builder blocks */
.block-tray {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  min-height: 80px;
}

.prompt-block {
  padding: var(--space-sm) var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  border: 1px solid var(--text-muted);
  cursor: pointer;
  user-select: none;
  touch-action: auto;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.prompt-block.placed {
  opacity: 0.3;
}

.prompt-assembly {
  min-height: 100px;
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border: 2px dashed var(--text-muted);
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  align-content: flex-start;
}

.prompt-assembly .prompt-block {
  border-color: var(--teal);
  cursor: pointer;
}

/* Radar chart */
.radar-chart {
  width: 200px;
  height: 200px;
  margin: 0 auto;
}

/* Duel layout */
.duel-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.duel-card {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  border: 2px solid transparent;
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  line-height: 1.5;
  transition: all var(--transition-fast);
  min-height: 120px;
}

.duel-card:active { border-color: var(--teal); }
.duel-card.selected { border-color: var(--teal); box-shadow: var(--shadow-glow-teal); }
.duel-card.correct { border-color: var(--green); }
.duel-card.wrong { border-color: var(--red); }

/* Terminal sandbox */
.terminal {
  background: #1a1a2e;
  border-radius: var(--radius-md);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--green);
  min-height: 200px;
  overflow-y: auto;
  max-height: 300px;
}

.terminal-line {
  padding: 2px 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.terminal-line.output {
  color: var(--text-secondary);
}

.terminal-line.error {
  color: var(--red);
}

.terminal-input-line {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.terminal-prompt {
  color: var(--teal);
  flex-shrink: 0;
}

.terminal-input {
  flex: 1;
  background: none;
  border: none;
  color: var(--green);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  outline: none;
  caret-color: var(--green);
}

/* Mascot */
.mascot-container {
  display: flex;
  align-items: flex-end;
  gap: var(--space-md);
  padding: var(--space-md) 0;
}

.mascot-avatar {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
}

.mascot-bubble {
  background: var(--bg-card);
  border-radius: var(--radius-md);
  border-bottom-left-radius: var(--space-xs);
  padding: var(--space-md);
  position: relative;
  color: var(--text-primary);
  font-size: var(--text-sm);
  line-height: 1.6;
  animation: slideUp var(--transition-normal);
}

/* Hongbao */
.hongbao-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  animation: fadeIn var(--transition-fast);
}

.hongbao-envelope {
  width: 200px;
  height: 280px;
  background: linear-gradient(135deg, var(--hongbao-red), #c41e10);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-lg);
  animation: bounceIn 0.5s;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.hongbao-circle {
  width: 80px;
  height: 80px;
  background: var(--hongbao-gold);
  border-radius: var(--radius-full);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-3xl);
  color: var(--hongbao-red);
  font-weight: 700;
}

.hongbao-text {
  color: var(--hongbao-gold);
  font-size: var(--text-lg);
  font-weight: 600;
  margin-top: var(--space-md);
}

.hongbao-particle {
  position: absolute;
  width: 8px;
  height: 8px;
  background: var(--hongbao-gold);
  border-radius: var(--radius-full);
  animation: particle 1s ease-out forwards;
}

@keyframes particle {
  from { transform: translate(0, 0) scale(1); opacity: 1; }
  to { transform: translate(var(--tx), var(--ty)) scale(0); opacity: 0; }
}

/* Certificate */
.certificate-preview {
  background: var(--white);
  color: var(--black);
  padding: var(--space-xl);
  border-radius: var(--radius-md);
  text-align: center;
  margin: var(--space-md) 0;
}

/* Workflow slots */
.workflow-slots {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.workflow-slot {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.slot-number {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--teal);
  color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: var(--text-sm);
  flex-shrink: 0;
}

/* Prompt repair word bank */
.word-bank {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
  padding: var(--space-md);
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
}

.word-token {
  padding: var(--space-xs) var(--space-sm);
  background: var(--bg-card);
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  cursor: pointer;
  border: 1px solid var(--text-muted);
  transition: all var(--transition-fast);
  min-height: var(--tap-target);
  display: flex;
  align-items: center;
}

.word-token:active {
  border-color: var(--teal);
}

.word-token.selected {
  border-color: var(--teal);
  background: rgba(0, 212, 170, 0.1);
}

.word-token.removed {
  text-decoration: line-through;
  opacity: 0.4;
}

/* Editable prompt area */
.editable-prompt {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  line-height: 1.8;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}

/* === Mobile Responsive === */

/* Small phones — memory grid 3 columns */
@media (max-width: 380px) {
  .memory-grid {
    grid-template-columns: repeat(3, 1fr);
  }

  .memory-card-back {
    font-size: var(--text-xs);
  }

  .duel-container {
    grid-template-columns: 1fr;
  }

  .duel-card {
    min-height: 80px;
  }

  .flip-card {
    height: 180px;
  }

  .game-question {
    font-size: var(--text-lg);
  }

  .block-tray {
    padding: var(--space-sm);
  }
}

/* iPad — larger game elements */
@media (min-width: 768px) {
  .game-screen {
    padding-top: calc(var(--header-height) + var(--space-md));
  }

  .game-question {
    font-size: var(--text-xl);
  }

  .flip-card {
    height: 260px;
  }

  .memory-grid {
    gap: var(--space-md);
  }

  .memory-card-back {
    font-size: var(--text-base);
  }

  .terminal {
    min-height: 260px;
    max-height: 400px;
    font-size: var(--text-base);
  }

  .duel-card {
    min-height: 160px;
    font-size: var(--text-base);
  }

  .option-btn {
    padding: var(--space-md) var(--space-lg);
  }

  .block-tray {
    min-height: 100px;
  }

  .prompt-assembly {
    min-height: 120px;
  }
}

/* Editable prompt area */
.editable-prompt {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  padding: var(--space-md);
  background: var(--bg-card);
  border-radius: var(--radius-md);
  line-height: 1.8;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-xs);
}
