/* ============================================================
   图形序列复刻 — 样式（Chrome 61 基线，记忆紫系）
   约束：无 flex gap / aspect-ratio / clamp() / inset / 逻辑属性 / :has / dvh
   色块按钮用宽高固定 + margin 排布（无 gap）
   ============================================================ */
html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #f4f0ff;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
  user-select: none;
}

* {
  box-sizing: border-box;
}

body {
  font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  color: #2a3a4a;
  height: var(--app-height, 100vh);
  overflow: hidden;
}

#app-main {
  height: calc(100% - 118px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.view {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px 16px 24px;
  min-height: 100%;
}

/* ---------- 头部 ---------- */
.app-header {
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(124, 92, 240, 0.14);
  position: relative;
  z-index: 5;
}

.header-brand {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  max-width: 480px;
  margin: 0 auto;
  padding: 10px 16px;
}

.header-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  margin-right: 10px;
}

.header-title {
  font-size: 18px;
  font-weight: 700;
  color: #2a3a4a;
}

.header-ver {
  margin-left: 8px;
  font-size: 12px;
  color: #7a8ea3;
  background: #f1edfd;
  padding: 2px 6px;
  border-radius: 8px;
}

/* ---------- 通用按钮 ---------- */
button {
  font-family: inherit;
  border: none;
  background: none;
  padding: 0;
  cursor: pointer;
  min-height: 48px;
  min-width: 48px;
  -webkit-tap-highlight-color: transparent;
}

.btn-checkin {
  display: block;
  width: 100%;
  max-width: 480px;
  margin: 14px auto 0;
  padding: 12px 16px;
  background: #7c5cf0;
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  border-radius: 12px;
  box-shadow: 0 4px 12px rgba(124, 92, 240, 0.28);
}

.btn-checkin:active {
  background: #6a4ae0;
  -webkit-transform: scale(0.98);
  transform: scale(0.98);
}

.btn-ghost-sm {
  padding: 8px 14px;
  font-size: 13px;
  color: #7c5cf0;
  background: #f1edfd;
  border-radius: 10px;
}

.btn-ghost-sm:active {
  background: #e5defc;
}

/* ---------- 难度选择页 ---------- */
.page-title {
  font-size: 20px;
  font-weight: 700;
  text-align: center;
  margin: 22px 0 8px;
}

.home-hint {
  text-align: center;
  color: #7a8ea3;
  font-size: 14px;
  margin-bottom: 18px;
}

.diff-list {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-direction: column;
  flex-direction: column;
}

.diff-btn {
  background: #fff;
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 12px;
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  -webkit-align-items: center;
  align-items: center;
  box-shadow: 0 2px 8px rgba(124, 92, 240, 0.1);
  text-align: left;
}

.diff-btn:active {
  background: #f8f6ff;
  -webkit-transform: scale(0.99);
  transform: scale(0.99);
}

.diff-head {
  font-size: 16px;
  font-weight: 700;
  color: #2a3a4a;
}

.diff-sub {
  font-size: 12px;
  color: #7a8ea3;
  margin-top: 4px;
  display: block;
}

/* ---------- 游戏页 ---------- */
.topbar {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: space-between;
  justify-content: space-between;
  margin-bottom: 12px;
}

.level-title {
  font-size: 16px;
  font-weight: 700;
  color: #2a3a4a;
}

.top-timer {
  font-size: 14px;
  color: #e76f51;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.seq-round {
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  color: #7c5cf0;
  margin: 4px 0 10px;
}

.seq-preview {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  min-height: 26px;
  margin-bottom: 8px;
}

.seq-dot {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  margin: 0 5px;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
}

.game-status {
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: #7a8ea3;
  min-height: 22px;
  margin-bottom: 18px;
}

/* 色块按钮区（3~5 个大色块，flex 单行居中；下移减少中下部留白） */
.color-kbd {
  display: -webkit-flex;
  display: flex;
  -webkit-justify-content: center;
  justify-content: center;
  margin-top: 48px;
}

.color-btn {
  width: 76px;
  height: 76px;
  border-radius: 18px;
  margin: 0 8px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.12);
  -webkit-transition: -webkit-transform 0.15s;
  transition: transform 0.15s;
}

.color-btn:active {
  -webkit-transform: scale(0.92);
  transform: scale(0.92);
}

/* 播放点亮（600ms） */
.color-btn.lit {
  -webkit-transform: scale(1.12);
  transform: scale(1.12);
  box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.14), 0 6px 16px rgba(0, 0, 0, 0.2);
}

/* 复刻正确闪（300ms） */
.color-btn.flash-ok {
  -webkit-transform: scale(1.15);
  transform: scale(1.15);
  box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.85), 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* 复刻错误红闪（400ms） */
.color-btn.flash-wrong {
  -webkit-animation: wrongFlash 0.4s ease-out;
  animation: wrongFlash 0.4s ease-out;
}

@-webkit-keyframes wrongFlash {
  0% { -webkit-filter: brightness(0.55); filter: brightness(0.55); }
  50% { -webkit-filter: brightness(0.3); filter: brightness(0.3); }
  100% { -webkit-filter: brightness(1); filter: brightness(1); }
}

@keyframes wrongFlash {
  0% { -webkit-filter: brightness(0.55); filter: brightness(0.55); }
  50% { -webkit-filter: brightness(0.3); filter: brightness(0.3); }
  100% { -webkit-filter: brightness(1); filter: brightness(1); }
}

/* ---------- 页脚 ---------- */
.app-footer {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: #ffffff;
  box-shadow: 0 -2px 8px rgba(124, 92, 240, 0.1);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
}

.game-footer {
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  max-width: 480px;
  margin: 0 auto;
}

.game-footer .btn-ghost-sm {
  margin: 0 6px;
}

.footer-errors {
  margin-left: 10px;
  font-size: 14px;
  font-weight: 600;
  color: #ff6b6b;
  min-width: 52px;
  text-align: center;
}

/* ---------- 结算浮层 ---------- */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(30, 20, 60, 0.55);
  display: -webkit-flex;
  display: flex;
  -webkit-align-items: center;
  align-items: center;
  -webkit-justify-content: center;
  justify-content: center;
  z-index: 50;
  padding: 24px;
}

.overlay-card {
  background: #fff;
  border-radius: 18px;
  padding: 24px 22px 20px;
  width: 100%;
  max-width: 340px;
  text-align: center;
  box-shadow: 0 8px 30px rgba(30, 20, 60, 0.25);
  -webkit-animation: popCard 0.3s ease-out;
  animation: popCard 0.3s ease-out;
}

@-webkit-keyframes popCard {
  0% { -webkit-transform: scale(0.85); transform: scale(0.85); opacity: 0; }
  100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}

@keyframes popCard {
  0% { -webkit-transform: scale(0.85); transform: scale(0.85); opacity: 0; }
  100% { -webkit-transform: scale(1); transform: scale(1); opacity: 1; }
}

.overlay-title {
  font-size: 22px;
  font-weight: 700;
  color: #2a3a4a;
  margin-bottom: 6px;
}

.overlay-sub {
  font-size: 14px;
  color: #7a8ea3;
  margin-bottom: 10px;
}

.summary {
  margin-bottom: 14px;
}

.stars-line {
  font-size: 36px;
  line-height: 1.2;
  color: #f5a623;
  letter-spacing: 4px;
}

.record-badge {
  display: inline-block;
  margin-top: 8px;
  background: #e8faf0;
  color: #12b76a;
  font-size: 13px;
  font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
}

.checkin-line {
  margin-top: 8px;
  font-size: 13px;
  color: #12b76a;
  font-weight: 600;
}

.overlay-btns {
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  -webkit-justify-content: center;
  justify-content: center;
}

.overlay-btns .btn-main {
  background: #7c5cf0;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  padding: 12px 28px;
  border-radius: 12px;
  margin: 6px 5px;
  box-shadow: 0 4px 12px rgba(124, 92, 240, 0.3);
}

.overlay-btns .btn-ghost {
  background: #f1edfd;
  color: #7c5cf0;
  font-size: 14px;
  font-weight: 600;
  padding: 12px 22px;
  border-radius: 12px;
  margin: 6px 5px;
}

/* ---------- 打卡日历 ---------- */
.calendar {
  background: #ffffff;
  border-radius: 14px;
  padding: 16px;
  box-shadow: 0 2px 8px rgba(124, 92, 240, 0.12);
}

.calendar-grid {
  display: -webkit-box;
  display: -webkit-flex;
  display: flex;
  -webkit-flex-wrap: wrap;
  flex-wrap: wrap;
  margin-top: 8px;
}

.calendar-grid > * {
  width: 14.28%;
  padding: 4px;
}

.cal-day {
  width: 100%;
  padding: 8px 0;
  text-align: center;
  font-size: 13px;
  border-radius: 6px;
  color: #7a8ea3;
  background: #f4f0ff;
}

.cal-day.done {
  background: #ff9c1a;
  color: #ffffff;
  font-weight: 700;
}

.cal-day.today {
  outline: 2px solid #7c5cf0;
}

.streak-info {
  text-align: center;
  margin-top: 10px;
  font-size: 14px;
  color: #2a3a4a;
}

.streak-info b {
  color: #ff9c1a;
}

/* ---------- 响应式 ---------- */
@media (min-width: 480px) {
  .view {
    padding-top: 20px;
  }
  .color-btn {
    width: 84px;
    height: 84px;
  }
}