/* 全局样式 */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: #FAFAFA;
  color: #1A1A1A;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
  touch-action: manipulation;
}

#app {
  width: 100%;
  height: 100%;
  max-width: 450px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #fff;
}

.screen.active {
  display: flex !important;
}

/* 启动页 */
.start-content {
  text-align: center;
  padding: 40px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.logo-area {
  margin-bottom: 20px;
}

.logo-stickman {
  margin-bottom: 16px;
  animation: stickman-bounce 2s ease-in-out infinite;
}

@keyframes stickman-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

.title {
  font-size: 36px;
  font-weight: 800;
  letter-spacing: 6px;
  margin-bottom: 8px;
  color: #1A1A1A;
}

.subtitle {
  font-size: 14px;
  color: #999;
  letter-spacing: 10px;
  margin-bottom: 32px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 160px;
  height: 48px;
  border: none;
  border-radius: 24px;
  font-size: 16px;
  font-weight: 600;
  font-family: inherit;
  letter-spacing: 1px;
  cursor: pointer;
  transition: all 0.2s ease;
  padding: 0 24px;
}

.btn-primary {
  background: #1A1A1A;
  color: #fff;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.btn-primary:active {
  transform: scale(0.96);
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.btn-secondary {
  background: #F0F0F0;
  color: #1A1A1A;
}

.btn-secondary:active {
  background: #E0E0E0;
  transform: scale(0.96);
}

.btn-ghost {
  background: transparent;
  color: #666;
  font-size: 14px;
  min-width: auto;
  height: 40px;
}

.btn-ghost:active {
  color: #1A1A1A;
}

/* 教程页 */
.tutorial-content {
  padding: 30px 24px;
  width: 100%;
  max-width: 380px;
  text-align: center;
}

.tutorial-content h2 {
  font-size: 24px;
  font-weight: 700;
  margin-bottom: 24px;
}

.tutorial-steps {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 24px;
}

.tutorial-step {
  display: flex;
  align-items: center;
  gap: 16px;
  text-align: left;
  padding: 12px;
  border-radius: 12px;
  background: #F8F8F8;
}

.step-icon {
  flex-shrink: 0;
  width: 50px;
  height: 50px;
}

.step-text h3 {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 2px;
}

.step-text p {
  font-size: 13px;
  color: #666;
  line-height: 1.4;
}

.tutorial-tips {
  background: #FFF8E1;
  border-radius: 12px;
  padding: 16px;
  text-align: left;
  margin-bottom: 24px;
}

.tutorial-tips h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  color: #F57C00;
}

.tutorial-tips ul {
  list-style: none;
  padding: 0;
}

.tutorial-tips li {
  font-size: 13px;
  color: #666;
  padding: 4px 0;
  padding-left: 16px;
  position: relative;
}

.tutorial-tips li::before {
  content: '•';
  position: absolute;
  left: 0;
  color: #F57C00;
  font-weight: bold;
}

/* 关卡选择页 */
.levels-header {
  padding: 24px 0 12px;
  text-align: center;
}

.levels-header h2 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 2px;
}

.levels-progress {
  font-size: 13px;
  color: #999;
  margin-top: 4px;
}

.levels-filters {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  width: 100%;
}

.filter-row {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.filter-btn {
  padding: 6px 12px;
  border: 1px solid #E0E0E0;
  border-radius: 16px;
  background: #fff;
  color: #666;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
}

.filter-btn.active {
  background: #1A1A1A;
  color: #fff;
  border-color: #1A1A1A;
}

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

.diff-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  letter-spacing: 1px;
}

.filter-label {
  font-size: 12px;
  color: #999;
  display: flex;
  align-items: center;
  margin-right: 4px;
}

.levels-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  padding: 12px 20px;
  max-height: 45vh;
  overflow-y: auto;
  width: 100%;
}

.level-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  aspect-ratio: 1;
  border: 2px solid #E8E8E8;
  border-radius: 12px;
  background: #fff;
  color: #1A1A1A;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s ease;
  padding: 2px;
  gap: 2px;
}

.level-card:active {
  transform: scale(0.92);
  background: #F0F0F0;
}

.level-card .level-num {
  font-size: 15px;
  font-weight: 700;
  line-height: 1.2;
}

.level-card .level-difficulty {
  font-size: 8px;
  letter-spacing: 1px;
  line-height: 1;
}

.level-card .level-deaths {
  font-size: 9px;
  color: #FF4444;
  line-height: 1;
  position: absolute;
  top: 3px;
  right: 4px;
  font-weight: 700;
}

.level-card .level-rating {
  font-size: 8px;
  color: #FFC107;
  line-height: 1;
  position: absolute;
  bottom: 3px;
  left: 4px;
}

.level-card.locked {
  border-color: #E0E0E0;
  color: #CCC;
  cursor: not-allowed;
}

.level-card.passed {
  border-color: #4CAF50;
  background: #E8F5E9;
  color: #2E7D32;
}

.level-card.passed::after {
  content: '✓';
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 10px;
  color: #4CAF50;
  font-weight: 700;
}

.level-card.perfect {
  border-color: #FFC107;
  background: #FFF8E1;
}

.levels-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.capsule-pagination {
  display: flex;
  align-items: center;
  background: #F5F5F5;
  border-radius: 24px;
  padding: 4px;
  gap: 2px;
}

.btn-page {
  width: 40px;
  height: 36px;
  min-width: auto;
  padding: 0;
  border-radius: 18px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  cursor: pointer;
}

.btn-page:active {
  background: #E0E0E0;
  transform: scale(0.95);
}

.btn-page:disabled {
  opacity: 0.3;
}

.btn-back-page {
  background: transparent;
  color: #666;
  font-size: 14px;
  min-width: 50px;
  height: 36px;
  padding: 0 16px;
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
  cursor: pointer;
  margin-left: 4px;
  position: relative;
}

.btn-back-page::before {
  content: '';
  position: absolute;
  left: -4px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: #D0D0D0;
}

.btn-back-page:active {
  color: #1A1A1A;
  background: #E0E0E0;
}

#page-info {
  font-size: 13px;
  color: #666;
  min-width: 40px;
  text-align: center;
}

/* 游戏页 */
#screen-game {
  flex-direction: column;
  justify-content: flex-start;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  height: 52px;
  padding: 0 12px;
  border-bottom: 1px solid #F0F0F0;
  flex-shrink: 0;
}

.btn-back {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.15s;
}

.btn-back:active {
  background: #F0F0F0;
}

.level-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

#level-num {
  font-size: 13px;
  font-weight: 600;
  color: #999;
}

#level-name {
  font-size: 15px;
  font-weight: 600;
}

.header-spacer {
  width: 36px;
}

.game-canvas-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  overflow: hidden;
  position: relative;
}

#game-canvas {
  background: #fff;
  touch-action: none;
  border-radius: 4px;
}

.fail-reason {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(244, 67, 54, 0.9);
  color: #fff;
  padding: 6px 14px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 500;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
  white-space: nowrap;
}

.fail-reason.show {
  opacity: 1;
}

.game-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px 20px;
  border-top: 1px solid #F0F0F0;
  flex-shrink: 0;
}

.controls-row {
  display: flex;
  gap: 12px;
}

.draw-info {
  font-size: 11px;
  color: #999;
  letter-spacing: 0.5px;
}

.pass-rating {
  font-size: 20px;
  color: #FFC107;
  letter-spacing: 2px;
}

/* 结果页 */
.result-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
}

.result-icon {
  margin-bottom: 8px;
}

.result-content h2 {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 2px;
}

.stats {
  font-size: 13px;
  color: #999;
  margin-bottom: 8px;
}

.fail-reason-text {
  font-size: 14px;
  color: #F44336;
  background: #FFEBEE;
  padding: 8px 16px;
  border-radius: 20px;
  margin-bottom: 4px;
}

.result-buttons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
}

/* 滚动条 */
.levels-grid::-webkit-scrollbar {
  width: 4px;
}

.levels-grid::-webkit-scrollbar-thumb {
  background: #DDD;
  border-radius: 2px;
}

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

.result-content {
  animation: fadeIn 0.3s ease;
}
