/* 小猫厨房偷鱼干 —— 界面样式（像素素材版） */
:root {
  --ink: #4a2f1d;
  --ink-soft: #6b452a;
  --gold: #d98b2b;
  --line: rgba(138, 90, 48, 0.35);
  --cream: #fbf3e3;
  --panel-cream: #feeed9;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: radial-gradient(1100px 620px at 50% -10%, #4a3527 0%, #2a1c14 45%, #140e0b 100%);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, sans-serif;
  color: var(--ink);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
body::before {
  content: "";
  position: fixed;
  inset: -20%;
  pointer-events: none;
  background: radial-gradient(closest-side at 50% 45%, rgba(255, 180, 90, 0.10), transparent 70%);
}

.app { width: min(96vw, 1120px, calc((100vh - 96px) * 1.6)); position: relative; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 960 / 600;
  border-radius: 14px;
  overflow: hidden;
  background: #2a1c14;
  box-shadow:
    0 30px 70px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(255, 210, 150, 0.16),
    inset 0 1px 0 rgba(255, 220, 170, 0.06);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}
.stage > .bg {
  width: 150%;
  height: 150%;
  max-width: none;
  object-fit: fill;
  transform-origin: 0 0;
  will-change: transform;
  position: absolute;
  left: 0;
  top: 0;
  display: block;
  image-rendering: pixelated;
  image-rendering: pixelated;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.stage > canvas {
  z-index: 1;
}
canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
}
img { image-rendering: pixelated; }

/* ---------------- HUD ---------------- */
.hud {
  position: absolute;
  inset: 0;
  padding: 14px 16px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  pointer-events: none;
  z-index: 2;
}
.hud-left { display: flex; gap: 8px; align-items: center; }
.hud-center { flex: 1; display: flex; justify-content: center; }
.hud-right { display: flex; align-items: center; gap: 8px; }

/* 所有胶囊/圆角块都来自 assets/pill.png（横向 3-slice） */
.chip,
.hearts,
.icon-btn,
.combo {
  height: 30px;
  display: inline-flex;
  align-items: center;
  border-style: solid;
  border-color: transparent;
  border-width: 0 15px;
  border-image: url(assets/pill.png) 0 15 fill stretch;
  background: none;
  color: var(--ink);
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 0 4px;
  white-space: nowrap;
  filter: drop-shadow(0 3px 6px rgba(0, 0, 0, 0.35));
}

.chip { gap: 6px; font-size: 13px; }
.score-chip { font-size: 17px; }
.score-chip b { font-variant-numeric: tabular-nums; }
.score-chip .ico { width: 22px; height: 22px; }
.level-chip { font-size: 11px; color: var(--ink-soft); letter-spacing: 1px; }
.level-chip b { font-size: 15px; margin-left: 2px; color: var(--ink); }

.combo {
  gap: 5px;
  font-size: 14px;
  font-weight: 900;
  opacity: 0;
  transform: translateY(-6px) scale(0.9);
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.combo.show { opacity: 1; transform: translateY(0) scale(1); }
.combo-ico { width: 22px; height: 22px; }

.hearts { gap: 2px; padding: 0 4px; }
.heart { width: 22px; height: 22px; display: block; }
.heart img { width: 100%; height: 100%; display: block; }
.heart.off img { opacity: 0.25; filter: grayscale(1); }

.icon-btn {
  pointer-events: auto;
  width: 54px;
  padding: 0;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s;
}
.icon-btn img { width: 24px; height: 24px; display: none; }
.icon-btn .ico-on,
.icon-btn .ico-pause { display: block; }
.icon-btn.muted .ico-on { display: none; }
.icon-btn.muted .ico-off { display: block; }
.icon-btn.paused .ico-pause { display: none; }
.icon-btn.paused .ico-play { display: block; }
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn:active { transform: translateY(1px); }

/* ---------------- 覆盖层 ---------------- */
.overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  padding: 18px;
  background: radial-gradient(ellipse at center, rgba(24, 15, 10, 0.2) 0%, rgba(18, 11, 7, 0.6) 85%);
  transition: opacity 0.22s ease, visibility 0.22s ease;
  overflow-y: auto;
}
.overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.panel {
  width: min(480px, 96%);
  margin: auto;
  border: 30px solid transparent;
  border-image: url(assets/panel.png) 30 stretch;
  background: var(--panel-cream) padding-box;
  padding: 4px 12px 16px;
  text-align: center;
  color: var(--ink);
  filter: drop-shadow(0 22px 36px rgba(0, 0, 0, 0.55));
  animation: pop 0.26s cubic-bezier(0.2, 0.9, 0.3, 1.2) both;
}
@keyframes pop {
  from { opacity: 0; transform: translateY(10px) scale(0.96); }
  to { opacity: 1; transform: none; }
}

.logo { display: flex; justify-content: center; align-items: center; gap: 8px; margin: 0 0 2px; }
.logo-ico { width: 34px; height: 34px; }
.logo-ico.big { width: 46px; height: 46px; }
.float { animation: float 2.4s ease-in-out infinite; }
@keyframes float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }

h1 {
  margin: 8px 0 4px;
  font-size: clamp(23px, 3vw, 32px);
  letter-spacing: 3px;
  color: #3f2614;
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.55);
}
h2 { margin: 8px 0 4px; font-size: 21px; letter-spacing: 1.5px; color: #3f2614; }
.sub { margin: 0; color: var(--ink-soft); font-size: 13.5px; line-height: 1.7; }

.keys {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 14px;
  margin: 16px 0 2px;
  font-size: 12.5px;
  color: var(--ink-soft);
}
kbd {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 3px;
  background: #f0e0c4;
  border: 2px solid #8a5a30;
  border-bottom-width: 3px;
  font-family: inherit;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--ink);
}
.touch-hint { display: none; font-size: 12px; color: var(--ink-soft); margin: 8px 0 0; }

.btn {
  display: block;
  width: 100%;
  height: 48px;
  margin: 14px 0 0;
  padding: 0 10px;
  border: 12px solid transparent;
  border-image: url(assets/btn-primary.png) 12 24 fill stretch;
  background: none;
  color: #4a2a10;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  letter-spacing: 3px;
  line-height: 24px;
  cursor: pointer;
  transition: transform 0.1s, filter 0.1s;
  filter: drop-shadow(0 5px 8px rgba(90, 50, 20, 0.35));
}
.btn:hover { filter: brightness(1.05) drop-shadow(0 6px 10px rgba(90, 50, 20, 0.4)); }
.btn:active { transform: translateY(2px); }
.btn.ghost {
  height: 44px;
  margin-top: 8px;
  border-width: 10px 20px;
  border-image: url(assets/btn-secondary.png) 10 20 fill stretch;
  color: #5a3a20;
  font-size: 14px;
  letter-spacing: 2px;
  line-height: 24px;
}

.best-line { margin-top: 14px; font-size: 12.5px; color: var(--ink-soft); letter-spacing: 1px; }
.best-line b { color: var(--gold); font-size: 16px; }

.result { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 16px 0 4px; }
.result > div {
  background: rgba(233, 211, 175, 0.6);
  border: 2px solid rgba(138, 90, 48, 0.45);
  padding: 8px 6px;
}
.result span { display: block; font-size: 12px; color: var(--ink-soft); letter-spacing: 1px; }
.result b { display: block; margin-top: 3px; font-size: 24px; color: #3f2614; font-variant-numeric: tabular-nums; }
.stat-line { font-size: 12.5px; color: var(--ink-soft); margin-top: 6px; }

.footer { margin: 12px 0 0; text-align: center; font-size: 12.5px; color: #a8875f; letter-spacing: 1px; }
.rotate-hint { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint { display: inline; }
}

#errbox {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  z-index: 9;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(150, 30, 30, 0.92);
  color: #fff;
  font-size: 12px;
  font-family: ui-monospace, monospace;
  white-space: pre-wrap;
}

@media (pointer: coarse) {
  .touch-hint { display: block; }
  .keys { display: none; }
}
@media (max-width: 720px) {
  .hud { padding: 8px 10px; }
  .hud-left { gap: 5px; }
  .chip { height: 26px; border-width: 0 13px; border-image-slice: 0 15 fill; font-size: 12px; }
  .score-chip { font-size: 15px; }
  .hearts { height: 26px; border-width: 0 13px; }
  .icon-btn { height: 26px; width: 40px; border-width: 0 13px; }
  .combo { height: 26px; font-size: 12px; border-width: 0 13px; }
  .panel { border-width: 22px; border-image-slice: 30; padding: 2px 8px 12px; }
  h1 { font-size: 21px; letter-spacing: 2px; }
  .btn { height: 42px; border-width: 10px 20px; border-image-slice: 12 24; font-size: 14px; line-height: 22px; }
  .btn.ghost { height: 38px; }
  .logo-ico.big { width: 38px; height: 38px; }
}

/* ---------------- 进化条 / 进化提示 ---------------- */
.evo-bar {
  position: absolute;
  left: 16px;
  top: 56px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border-radius: 12px;
  background: rgba(38, 22, 12, 0.62);
  border: 2px solid rgba(138, 90, 48, 0.85);
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.25);
  backdrop-filter: blur(2px);
  transition: opacity 0.25s ease;
  pointer-events: none;
}
.evo-bar.hidden { opacity: 0; }
.evo-portrait {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  background: rgba(251, 243, 227, 0.92);
  border: 2px solid #8a5a30;
  image-rendering: pixelated;
  display: block;
}
.evo-main { display: flex; flex-direction: column; gap: 3px; }
.evo-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font: 700 10px/1 -apple-system, "PingFang SC", sans-serif;
  color: #f7ead5;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.evo-line span:last-child { color: #f0bf6a; font-weight: 800; }
.evo-track {
  height: 8px;
  width: 132px;
  background: rgba(30, 18, 10, 0.8);
  border: 2px solid rgba(138, 90, 48, 0.9);
  border-radius: 6px;
  overflow: hidden;
}
#evoFill {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #e8b45c, #ffe6b0);
  transition: width 0.28s ease;
}
.evo-pips { display: flex; gap: 3px; margin-left: 2px; }
.evo-pips i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(247, 234, 213, 0.25);
  border: 1px solid rgba(74, 47, 29, 0.7);
}
.evo-pips i.on { background: #f0bf6a; box-shadow: 0 0 4px rgba(240, 191, 106, 0.9); }

.evo-toast {
  position: absolute;
  top: 12px;
  left: 50%;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px 8px 8px;
  transform: translate(-50%, -16px);
  opacity: 0;
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(72, 44, 26, 0.97), rgba(48, 29, 16, 0.97));
  border: 2px solid #c98f52;
  box-shadow: 0 0 0 2px rgba(38, 22, 12, 0.85), 0 10px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: opacity 0.28s ease, transform 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
}
.evo-toast.show { opacity: 1; transform: translate(-50%, 0); }
.evo-toast[hidden] { display: none; }
.evo-toast > img {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: rgba(251, 243, 227, 0.95);
  border: 2px solid #8a5a30;
  image-rendering: pixelated;
}
.evo-toast-main { display: flex; flex-direction: column; gap: 3px; }
.evo-toast-title {
  font: 800 15px/1.15 -apple-system, "PingFang SC", sans-serif;
  color: #ffe6b0;
  letter-spacing: 0.5px;
}
.evo-toast-title b { color: #f7ead5; margin-left: 4px; }
.evo-toast-note {
  font: 600 11px/1.3 -apple-system, "PingFang SC", sans-serif;
  color: #dcbf98;
}
.evo-toast-glow {
  position: absolute;
  inset: -6px;
  border-radius: 18px;
  pointer-events: none;
  background: radial-gradient(60% 80% at 50% 50%, rgba(255, 220, 150, 0.35), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.evo-toast.show .evo-toast-glow { opacity: 1; }

@media (max-width: 720px) {
  .evo-bar { top: 50px; left: 10px; gap: 6px; padding: 4px 8px 4px 4px; }
  .evo-portrait { width: 26px; height: 26px; }
  .evo-track { width: 96px; }
  .evo-line { font-size: 9px; }
  .evo-toast > img { width: 42px; height: 42px; }
  .evo-toast-title { font-size: 13px; }
  .evo-toast-note { font-size: 10px; }
}
