/* ============================================================
   合成猫咪 —— 样式表
   温馨霓虹深色风：紫为主色，青 / 粉 / 金点缀
   ============================================================ */

:root {
  --primary: #7c5cff;
  --cyan: #22d3ee;
  --pink: #ff5ca8;
  --gold: #ffb347;
  --panel-bg: rgba(255, 255, 255, .06);
  --panel-border: rgba(255, 255, 255, .12);
  --text-main: #eef1ff;
  --text-dim: rgba(238, 241, 255, .62);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text-main);
  font-family: system-ui, -apple-system, "Segoe UI", "Microsoft YaHei", sans-serif;
  background: radial-gradient(circle at 50% 30%, #171a3a, #0b0e20);
  background-attachment: fixed;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 540px;
  margin: 0 auto;
  padding: 18px 16px 24px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* ---------------- 顶部栏 ---------------- */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.brand-mark {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 1rem;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, var(--primary), var(--pink));
  box-shadow: 0 4px 16px rgba(124, 92, 255, .45);
}

.brand-title {
  margin: 0;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: 2px;
  background: linear-gradient(90deg, #fff, #c9c2ff 55%, var(--cyan));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  white-space: nowrap;
}

.back-link {
  flex: none;
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--text-main);
  font-size: .88rem;
  text-decoration: none;
  transition: transform .15s ease, background .2s ease;
}

.back-link:hover { background: rgba(255, 255, 255, .12); transform: translateY(-1px); }
.back-link:active { transform: translateY(1px); }

/* ---------------- 通用面板与按钮 ---------------- */

.panel {
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.stage {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.btn {
  font-family: inherit;
  font-size: .92rem;
  font-weight: 700;
  color: var(--text-main);
  padding: 10px 18px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: var(--panel-bg);
  cursor: pointer;
  transition: transform .12s ease, box-shadow .15s ease, background .2s ease, opacity .2s ease;
}

.btn:hover { background: rgba(255, 255, 255, .12); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.97); }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none; }

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #5b8cff);
  border-color: rgba(124, 92, 255, .55);
  box-shadow: 0 6px 18px rgba(124, 92, 255, .38);
}

.btn-primary:hover { background: linear-gradient(135deg, #8d72ff, #6f9bff); }

.btn-mini { padding: 8px 12px; font-size: .84rem; white-space: nowrap; }

/* ---------------- HUD 计分栏 ---------------- */

.hud {
  width: 100%;
  display: flex;
  align-items: stretch;
  gap: 10px;
  padding: 12px;
  margin-bottom: 14px;
}

.score-box {
  position: relative;
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 6px 4px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .07);
  overflow: hidden;
}

.score-label {
  font-size: .72rem;
  letter-spacing: 2px;
  color: var(--text-dim);
}

.score-value {
  font-size: 1.45rem;
  font-weight: 800;
  line-height: 1.2;
  font-variant-numeric: tabular-nums;
}

#scoreValue.bump { animation: score-bump .26s ease; }

@keyframes score-bump {
  0% { transform: scale(1); }
  45% { transform: scale(1.25); color: var(--cyan); text-shadow: 0 0 14px rgba(34, 211, 238, .8); }
  100% { transform: scale(1); }
}

.score-float {
  position: absolute;
  top: 3px;
  left: 50%;
  font-size: .92rem;
  font-weight: 800;
  color: var(--cyan);
  text-shadow: 0 0 10px rgba(34, 211, 238, .75);
  pointer-events: none;
  animation: score-rise .8s ease-out forwards;
}

@keyframes score-rise {
  0% { opacity: 0; transform: translate(-50%, 10px) scale(.8); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -28px) scale(1.1); }
}

.hud-actions {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------------- 棋盘 ---------------- */

.board-wrap { width: 100%; display: flex; justify-content: center; }

.board {
  position: relative;
  width: min(92vw, 460px);
  aspect-ratio: 1 / 1;
  overflow: hidden;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .45), inset 0 0 30px rgba(124, 92, 255, .06);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.game-canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------------- 遮罩 ---------------- */

.overlay {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  border-radius: 20px;
  background: rgba(9, 11, 28, .66);
  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
  animation: overlay-in .25s ease;
}

.hidden { display: none !important; }

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.overlay-card {
  width: 100%;
  max-width: 320px;
  padding: 24px 22px;
  text-align: center;
  background: rgba(20, 23, 52, .85);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  box-shadow: 0 16px 44px rgba(0, 0, 0, .5);
}

.logo-canvas {
  width: 104px;
  height: 104px;
  margin-bottom: 4px;
}

.overlay-title {
  margin: 4px 0 8px;
  font-size: 1.55rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.overlay-title.win {
  background: linear-gradient(90deg, var(--gold), #ffe39a, var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-shadow: 0 0 26px rgba(255, 179, 71, .35);
}

.overlay-title.lose { color: var(--pink); text-shadow: 0 0 18px rgba(255, 92, 168, .5); }

.overlay-text {
  margin: 0 0 20px;
  font-size: .92rem;
  line-height: 1.7;
  color: var(--text-dim);
}

.overlay-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

/* ---------------- 图鉴面板 ---------------- */

.codex-mask {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(7, 9, 22, .72);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  animation: overlay-in .2s ease;
}

.codex {
  width: min(94vw, 460px);
  max-height: 88vh;
  overflow-y: auto;
  padding: 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .55);
}

.codex-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 14px;
}

.codex-title {
  margin: 0 0 2px;
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 2px;
}

.codex-sub {
  margin: 0;
  font-size: .82rem;
  color: var(--text-dim);
}

.codex-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.codex-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, .045);
  border: 1px solid rgba(255, 255, 255, .07);
}

.codex-item.unlocked {
  border-color: rgba(124, 92, 255, .4);
  background: rgba(124, 92, 255, .08);
}

.codex-item canvas {
  flex: none;
  width: 64px;
  height: 64px;
}

.codex-info { min-width: 0; }

.codex-name {
  display: block;
  font-size: .98rem;
  font-weight: 800;
  line-height: 1.3;
}

.codex-level {
  display: block;
  margin-top: 2px;
  font-size: .72rem;
  letter-spacing: 1px;
  color: var(--text-dim);
}

.codex-item.locked .codex-name { color: rgba(238, 241, 255, .5); }

/* ---------------- 底部说明 ---------------- */

.tips {
  margin-top: 14px;
  text-align: center;
  font-size: .78rem;
  line-height: 1.7;
  color: var(--text-dim);
}

/* ---------------- 手机端自适应 ---------------- */

@media (max-width: 480px) {
  .app { padding: 12px 10px 20px; }
  .brand-title { font-size: 1.08rem; letter-spacing: 1px; }
  .brand-mark { width: 30px; height: 30px; font-size: .9rem; }
  .back-link { padding: 7px 10px; font-size: .8rem; }
  .score-value { font-size: 1.2rem; }
  .hud { gap: 8px; padding: 10px; }
  .btn-mini { padding: 7px 9px; font-size: .78rem; }
  .hud-actions { gap: 6px; }
}

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