.tutorial-intro {
  color: var(--color-text-muted);
  margin: 0 auto 2.5rem;
  text-align: center;
  max-width: 640px;
  font-size: 1.05rem;
}

.level-grid {
  display: grid;
  gap: 1.25rem;
  max-width: 760px;
  margin: 0 auto 3rem;
}

.level-card {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--color-surface-panel);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  position: relative;
  box-shadow: var(--shadow-soft);
}

.level-card:hover {
  border-color: var(--color-border-strong);
  box-shadow: 0 16px 30px rgba(20, 20, 20, 0.12);
  transform: translateY(-2px);
}

.level-card.completed {
  border-color: var(--color-border-success);
  background: var(--color-success-soft);
}

.level-card.locked {
  opacity: 0.6;
  cursor: not-allowed;
  background: var(--color-surface-soft);
  border-color: var(--color-border-soft);
}

.level-card.battle-level {
  border-color: var(--color-battle-border);
  background: var(--color-battle-soft);
}

.level-card.battle-level .level-number {
  background: var(--color-battle-primary);
}

.level-card.battle-level.completed {
  border-color: var(--color-battle-primary-strong);
  background: var(--color-battle-soft-strong);
}

.level-card.battle-level.completed .level-number {
  background: var(--color-success);
}

.level-number {
  width: 48px;
  height: 48px;
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  font-weight: bold;
  flex-shrink: 0;
}

.level-card.completed .level-number {
  background: var(--color-success);
}

.level-info {
  flex: 1;
}

.level-info h2 {
  margin: 0 0 0.25rem;
  font-size: 1.1rem;
}

.level-info p {
  margin: 0;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.level-status {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.status-badge {
  font-size: 0.75rem;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-weight: 600;
}

.status-badge.completed {
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
}

.status-badge.in-progress {
  background: var(--color-surface-track);
  color: var(--color-text-strong);
}

.status-badge.not-started {
  background: var(--color-surface-muted);
  color: var(--color-text-subtle);
}

.status-badge.locked {
  background: var(--color-surface-disabled);
  color: var(--color-text-disabled);
}

.alert {
  background: var(--color-alert-surface);
  border: 1px solid var(--color-alert-border);
  color: var(--color-alert-text);
  padding: 0.85rem 1.1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1.5rem;
  text-align: center;
}

.skip-battle {
  text-align: center;
  margin: 1.5rem 0 2rem;
}

.skip-battle-form {
  display: inline;
}

.skip-battle-btn {
  padding: 0.7rem 1.6rem;
  border-radius: 999px;
  border: 1px solid var(--color-surface-dark);
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.skip-battle-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(20, 20, 20, 0.24);
}

.skip-battle-note {
  margin-top: 0.5rem;
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.level-status .stat {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.level-status .stat.perfect {
  color: var(--color-success);
  font-weight: 500;
}

.ai-badge {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-size: 0.7rem;
  padding: 0.15rem 0.4rem;
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  border-radius: 4px;
}

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

.back-link {
  color: var(--color-text-strong);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 600;
}

.back-link:hover {
  text-decoration: underline;
}

.back-link::before {
  content: "← ";
}

.restart-form {
  display: inline;
}

.restart-btn {
  background: transparent;
  border: 1px solid var(--color-border-muted);
  color: var(--color-text-subtle);
  padding: 0.45rem 0.85rem;
  border-radius: 999px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

.restart-btn:hover {
  background: var(--color-surface-muted);
  border-color: var(--color-border-strong);
  color: var(--color-text-strong);
}

.tutorial-description {
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.step-message {
  font-size: 1.1rem;
  font-weight: 600;
  padding: 1rem 1.3rem;
  background: var(--color-surface-card);
  border-radius: var(--radius-md);
  margin-bottom: 1.5rem;
  text-align: center;
  border: 1px solid var(--color-border-soft);
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.08);
}

.error-message {
  color: var(--color-danger);
  background: var(--color-danger-soft);
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  text-align: center;
}

.level-complete {
  text-align: center;
  padding: 2rem;
  background: var(--color-success-soft);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-success);
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.5rem;
}

.level-complete h2 {
  color: var(--color-success);
  margin-bottom: 0.5rem;
}

.level-complete p {
  color: var(--color-text-muted);
  margin-bottom: 1rem;
}

.next-level-btn {
  display: inline-block;
  padding: 0.75rem 2.1rem;
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  text-decoration: none;
  border-radius: 999px;
  font-weight: 600;
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.next-level-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(20, 20, 20, 0.24);
}

.progress-stats {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin: 1rem 0;
  padding: 0.9rem 1rem;
  background: var(--color-surface-panel);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-soft);
}

.progress-stats .stat {
  color: var(--color-text-muted);
  font-size: 0.9rem;
}

.achievements-earned {
  margin: 1.5rem 0;
  padding: 1rem;
  background: linear-gradient(135deg, var(--color-highlight-surface), var(--color-highlight-surface-strong));
  border-radius: var(--radius-md);
  border: 1px solid var(--color-highlight-border);
}

.achievement {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0.5rem;
}

.achievement-name {
  font-weight: bold;
  color: var(--color-highlight-strong);
  font-size: 1.1rem;
}

.achievement-description {
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.all-complete {
  font-size: 1.1rem;
  color: var(--color-accent-primary);
  font-weight: 500;
  margin-top: 1rem;
}

.result-page {
  max-width: 640px;
  margin: 0 auto;
  padding: 2rem;
  background: var(--color-surface-panel);
  border: 1px solid var(--color-border-soft);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-soft);
}

.result-header {
  text-align: center;
  margin-bottom: 2rem;
}

.result-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  background: linear-gradient(135deg, var(--color-success), var(--color-success-strong));
  color: var(--color-text-inverse);
  border-radius: 50%;
  font-size: 2rem;
  margin-bottom: 1rem;
}

.result-header h1 {
  margin: 0 0 0.5rem;
}

.result-status {
  color: var(--color-success);
  font-weight: 500;
}

.result-stats {
  display: flex;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  flex: 1;
  background: var(--color-surface-panel);
  border-radius: var(--radius-sm);
  border: 1px solid var(--color-border-soft);
  padding: 1rem;
  text-align: center;
}

.stat-label {
  display: block;
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin-bottom: 0.25rem;
}

.stat-value {
  display: block;
  font-size: 1.25rem;
  font-weight: bold;
  color: var(--color-text-primary);
}

.result-achievements {
  background: linear-gradient(135deg, var(--color-highlight-surface), var(--color-highlight-surface-strong));
  border: 1px solid var(--color-highlight-border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: 2rem;
}

.result-achievements h3 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  color: var(--color-highlight-text);
}

.result-achievement {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
}

.result-achievement + .result-achievement {
  border-top: 1px solid var(--color-highlight-line);
}

.result-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.inline-form {
  display: inline;
}

.replay-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  color: var(--color-text-strong);
  border: 1px solid var(--color-border-muted);
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.replay-btn:hover {
  transform: translateY(-1px);
  background: var(--color-surface-muted);
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.12);
}

.next-btn {
  padding: 0.75rem 1.5rem;
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  text-decoration: none;
  border-radius: 999px;
  font-size: 1rem;
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.next-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(20, 20, 20, 0.24);
}

/* Battle Mode Styles */

.battle-title {
  text-align: center;
  color: var(--color-battle-text);
}

.battle-status {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 2rem;
  margin-bottom: 1.5rem;
  padding: 1rem;
  background: var(--color-battle-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-battle-border);
  box-shadow: var(--shadow-soft);
}

.win-tracker {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.win-tracker.large {
  justify-content: center;
  margin: 1.5rem 0;
}

.win-tracker.large .win-star {
  font-size: 2.5rem;
}

.win-label,
.hint-label {
  font-weight: 500;
  color: var(--color-text-muted);
  margin-right: 0.5rem;
}

.win-star {
  font-size: 1.5rem;
  color: var(--color-neutral-300);
  transition: color 0.3s ease;
}

.win-star.earned {
  color: var(--color-warning);
  text-shadow: 0 0 10px rgba(255, 193, 7, 0.5);
}

.hint-tracker {
  display: flex;
  align-items: center;
}

.hint-icon {
  font-size: 1.25rem;
}

.game-number {
  font-weight: 500;
  color: var(--color-text-muted);
  padding: 0.25rem 0.75rem;
  background: var(--color-surface-panel);
  border-radius: 20px;
  border: 1px solid var(--color-border-soft);
}

.battle-actions {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.hint-btn {
  padding: 0.75rem 1.5rem;
  background: transparent;
  border: 1px solid var(--color-border-muted);
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  color: var(--color-text-strong);
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.hint-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  background: var(--color-surface-muted);
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.12);
}

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

.game-over-message {
  text-align: center;
  padding: 2rem;
  background: var(--color-battle-soft);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-battle-border);
  box-shadow: var(--shadow-soft);
  margin-bottom: 1.5rem;
}

.game-over-message h2 {
  margin-bottom: 0.5rem;
}

.new-game-btn {
  margin-top: 1rem;
  padding: 0.75rem 2rem;
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  border: none;
  border-radius: 999px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.new-game-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(20, 20, 20, 0.24);
}

.battle-complete-page .result-check {
  background: var(--color-battle-primary);
  font-size: 2.5rem;
  width: 80px;
  height: 80px;
}

.waitlist-signup {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--color-surface-panel);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border-soft);
  text-align: center;
  box-shadow: var(--shadow-soft);
}

.waitlist-signup h3 {
  margin-bottom: 0.5rem;
}

.waitlist-form {
  margin-top: 1rem;
}

.waitlist-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.waitlist-fields input[type="email"] {
  min-width: 240px;
  padding: 0.75rem 1rem;
  border-radius: 999px;
  border: 1px solid var(--color-border-soft);
  background: var(--color-surface-card);
}

.waitlist-submit {
  padding: 0.75rem 1.75rem;
  border-radius: 999px;
  border: none;
  background: var(--color-surface-dark);
  color: var(--color-text-inverse);
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(20, 20, 20, 0.18);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.waitlist-submit:hover {
  transform: translateY(-1px);
  box-shadow: 0 18px 32px rgba(20, 20, 20, 0.24);
}

@media (max-width: 720px) and (orientation: landscape) {
  .tutorial-header {
    flex-wrap: wrap;
    gap: 0.75rem;
  }

  .step-message {
    font-size: 1rem;
    padding: 0.85rem 1rem;
  }

  .battle-status,
  .progress-stats,
  .result-stats {
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
  }

  .result-actions {
    flex-direction: column;
    align-items: center;
  }

  .result-page {
    padding: 1.5rem;
  }

  #tutorial-content,
  #battle-content {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  #board {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    overflow-x: clip;
  }

  #board .tutorial-board {
    transform: scale(0.75);
    transform-origin: center;
    margin: -0.5rem auto 1.5rem;
  }
}

@media (max-width: 640px) and (orientation: portrait) {
  .tutorial-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .tutorial-intro {
    font-size: 1rem;
    margin-bottom: 2rem;
  }

  .level-grid {
    gap: 1rem;
  }

  .level-card {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .level-number {
    width: 44px;
    height: 44px;
    font-size: 1.1rem;
  }

  .level-info h2 {
    font-size: 1rem;
  }

  .step-message {
    font-size: 1rem;
    padding: 0.85rem 1rem;
  }

  .battle-status,
  .progress-stats,
  .result-stats {
    flex-direction: column;
    gap: 0.75rem;
  }

  .result-actions {
    flex-direction: column;
    align-items: center;
  }

  .result-page {
    padding: 1.5rem;
  }

  #tutorial-content,
  #battle-content {
    width: 100%;
    max-width: 100%;
    overflow-x: clip;
  }

  #board {
    width: 100%;
    max-width: 100%;
    display: flex;
    justify-content: center;
    overflow-x: clip;
  }

  #board .tutorial-board {
    transform: scale(0.6);
    transform-origin: center;
    margin: -1rem auto 1.5rem;
  }
}

@media (max-width: 480px) and (orientation: portrait) {
  .tutorial-description {
    margin-bottom: 1.25rem;
  }

  .step-message {
    font-size: 0.95rem;
    padding: 0.75rem 0.9rem;
  }

  .level-card {
    padding: 1rem;
  }

  .result-page {
    padding: 1.25rem;
  }

  .result-check {
    width: 52px;
    height: 52px;
    font-size: 1.7rem;
  }

  .result-actions {
    gap: 0.75rem;
  }

  .waitlist-fields {
    flex-direction: column;
    align-items: stretch;
  }

  .waitlist-fields input[type="email"],
  .waitlist-submit {
    width: 100%;
  }

  #board .tutorial-board {
    transform: scale(0.48);
    margin: -1.7rem auto 1.25rem;
  }
}

@media (max-width: 360px) and (orientation: portrait) {
  #board .tutorial-board {
    transform: scale(0.44);
    margin: -1.9rem auto 1.1rem;
  }
}

@media (max-width: 320px) and (orientation: portrait) {
  #board .tutorial-board {
    transform: scale(0.4);
    margin: -2.1rem auto 1rem;
  }
}
