* { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #131316;
  --panel: #1e1e23;
  --panel2: #26262c;
  --line: #35353d;
  --text: #eceaf0;
  --muted: #8b8b96;
  --pink: #f2a7b8;
  --red: #e5484d;
  --gold: #f0c86b;
  --green: #7ecb8f;
  --blue: #7fb5e8;
}
html, body { height: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  overflow: hidden;
}
#app { height: 100vh; display: flex; flex-direction: column; padding: 14px 18px 12px; gap: 12px; }

/* ---------- top bar ---------- */
#topbar { display: flex; justify-content: space-between; align-items: center; }
.title { font-size: 20px; font-weight: 700; letter-spacing: 1px; }
.title span { color: var(--pink); }
.top-right { display: flex; gap: 10px; align-items: center; }
.turn-chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 14px; font-size: 13px; color: var(--muted); }
.turn-chip b { color: var(--text); }
#topbar button {
  background: var(--panel); border: 1px solid var(--line); color: var(--text);
  width: 32px; height: 32px; border-radius: 10px; font-size: 15px; cursor: pointer;
}
#topbar button:hover { border-color: var(--pink); }

/* ---------- board ---------- */
#board { flex: 1; display: flex; gap: 12px; min-height: 0; }
#stage {
  flex: 1.35; position: relative; background: radial-gradient(ellipse at 50% 70%, #232028 0%, var(--panel) 65%);
  border: 1px solid var(--line); border-radius: 18px; display: flex; align-items: center; justify-content: center;
  overflow: hidden;
}
#cat-wrap { display: flex; align-items: flex-end; justify-content: center; height: 62%; }
#cat-img { max-height: 100%; max-width: 320px; filter: drop-shadow(0 14px 18px rgba(0,0,0,.45)); transition: opacity .18s; }
#cat-img.flip { transform: scaleX(-1); }
#cat-img.acting { animation: pop .5s ease; }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 60% { transform: scale(1.06); } 100% { transform: scale(1); } }
@keyframes bob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-8px); } }
#cat-img.idlebob { animation: bob 3.2s ease-in-out infinite; }

.state-chip {
  position: absolute; top: 16px; left: 16px; background: var(--panel2); border: 1px solid var(--line);
  padding: 6px 14px; border-radius: 999px; font-size: 13px; color: var(--pink); font-weight: 600;
}
.bubble {
  position: absolute; top: 14%; left: 50%; transform: translateX(-50%);
  background: #fff; color: #222; font-size: 14px; font-weight: 600;
  padding: 8px 16px; border-radius: 16px; white-space: nowrap; z-index: 5;
  animation: bubblein .25s ease;
}
.bubble::after {
  content: ""; position: absolute; bottom: -7px; left: 50%; transform: translateX(-50%);
  border: 8px solid transparent; border-top-color: #fff; border-bottom: none;
}
@keyframes bubblein { from { opacity: 0; transform: translateX(-50%) translateY(6px); } }

#floaties { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.floaty {
  position: absolute; font-size: 17px; font-weight: 800; animation: floatup 1.3s ease-out forwards;
  text-shadow: 0 2px 6px rgba(0,0,0,.6);
}
.floaty.crit { font-size: 22px; }
@keyframes floatup { 0% { opacity: 0; transform: translateY(10px) scale(.8); } 15% { opacity: 1; transform: translateY(0) scale(1); } 100% { opacity: 0; transform: translateY(-70px); } }

#combo-banner {
  position: absolute; top: 16px; right: 16px; background: linear-gradient(90deg, #f2a7b8, #f0c86b);
  color: #2a1a1e; font-weight: 800; font-size: 13px; padding: 6px 14px; border-radius: 999px;
  animation: bubblein .25s ease;
}

#hint-bar {
  position: absolute; bottom: 12px; left: 50%; transform: translateX(-50%);
  max-width: 92%; background: #26262cd9; border: 1px solid var(--line); backdrop-filter: blur(6px);
  border-radius: 12px; padding: 8px 16px; font-size: 12.5px; line-height: 1.5; color: var(--text);
  animation: bubblein .3s ease; width: max-content; text-align: center;
}
#hint-bar b { color: var(--gold); }
#hint-bar .warn { color: var(--red); }

/* ---------- side ---------- */
#side { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 300px; max-width: 380px; min-height: 0; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 14px 16px; }
#stats-panel { display: flex; flex-direction: column; gap: 10px; }
.stat-head { display: flex; align-items: baseline; gap: 6px; font-size: 13px; margin-bottom: 5px; color: var(--muted); }
.stat-head b { color: var(--text); font-size: 15px; margin-left: auto; }
.stat-head i { font-style: normal; font-size: 11px; }
.bar { position: relative; height: 10px; background: #101014; border-radius: 6px; overflow: hidden; }
.fill { height: 100%; border-radius: 6px; transition: width .45s cubic-bezier(.2,.8,.3,1); }
.fill.bond { background: linear-gradient(90deg, #e5748c, var(--pink)); }
.fill.mood { background: linear-gradient(90deg, #d9a24e, var(--gold)); }
.fill.sat { background: linear-gradient(90deg, #4f9e64, var(--green)); }
.fill.energy { background: linear-gradient(90deg, #4f7fb0, var(--blue)); }
.goal { position: absolute; top: -2px; bottom: -2px; width: 2px; background: #fff6; right: 0; }
.divider { height: 1px; background: var(--line); margin: 2px 0; }
.pill-row { display: flex; gap: 8px; }
.pill { flex: 1; background: var(--panel2); border-radius: 10px; padding: 7px 0; text-align: center; font-size: 12px; color: var(--muted); }
.pill b { color: var(--text); font-size: 14px; }
.pill i { font-style: normal; font-size: 11px; }

#log-panel { flex: 1; min-height: 0; overflow: hidden; display: flex; }
#log { flex: 1; overflow-y: auto; font-size: 12.5px; line-height: 1.75; color: var(--muted); scrollbar-width: thin; }
#log .t { color: var(--pink); font-weight: 700; }
#log .good { color: var(--green); }
#log .bad { color: var(--red); }
#log .ev { color: var(--gold); }

/* ---------- hand ---------- */
#hand-area { display: flex; gap: 12px; align-items: stretch; }
#hand { flex: 1; display: flex; gap: 10px; justify-content: center; }
.card {
  width: 148px; background: var(--panel); border: 1.5px solid var(--line); border-radius: 14px;
  padding: 10px 10px 9px; cursor: pointer; position: relative; user-select: none;
  transition: transform .15s, border-color .15s, box-shadow .15s;
  display: flex; flex-direction: column; gap: 5px;
}
.card:hover { transform: translateY(-8px); }
.card.favored { border-color: var(--gold); box-shadow: 0 0 14px #f0c86b33; }
.card.risky { border-color: var(--red); box-shadow: 0 0 12px #e5484d2e; }
.card.disabled { opacity: .42; cursor: not-allowed; }
.card.disabled:hover { transform: none; }
.card-top { display: flex; align-items: center; gap: 6px; }
.card-cost {
  width: 22px; height: 22px; border-radius: 50%; background: var(--blue); color: #10131a;
  font-weight: 800; font-size: 13px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.card-name { font-size: 13.5px; font-weight: 700; }
.card-rarity { margin-left: auto; font-size: 10px; color: var(--gold); }
.card-art { height: 56px; display: flex; align-items: center; justify-content: center; }
.card-art img { max-height: 56px; max-width: 90px; }
.card-type { font-size: 10px; padding: 1px 8px; border-radius: 999px; align-self: flex-start; }
.type-亲密 { background: #f2a7b826; color: var(--pink); }
.type-照护 { background: #7ecb8f26; color: var(--green); }
.type-游戏 { background: #7fb5e826; color: var(--blue); }
.type-特殊 { background: #f0c86b26; color: var(--gold); }
.card-desc { font-size: 10.5px; color: var(--muted); line-height: 1.45; flex: 1; }
.card-hint { font-size: 10px; line-height: 1.4; }
.card-hint.good { color: var(--gold); }
.card-hint.bad { color: var(--red); }
.card-cd {
  position: absolute; inset: 0; background: #131316cc; border-radius: 14px;
  display: flex; align-items: center; justify-content: center; font-size: 26px; font-weight: 800; color: var(--muted);
}
#btn-end {
  width: 108px; border-radius: 14px; border: 1px solid var(--line); background: var(--panel2);
  color: var(--pink); font-size: 15px; font-weight: 700; cursor: pointer; font-family: inherit;
}
#btn-end:hover { border-color: var(--pink); }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 50; }
.modal { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 24px 28px; width: 440px; max-height: 84vh; overflow-y: auto; }
.modal h2 { font-size: 17px; margin-bottom: 16px; }
.modal .muted { color: var(--muted); font-size: 12px; font-weight: 400; }
.modal.center { text-align: center; }
.modal.center img { max-height: 180px; margin-bottom: 10px; }
#over-desc { color: var(--muted); font-size: 13.5px; margin-top: 8px; line-height: 1.7; }
.slider-row { display: flex; align-items: center; gap: 12px; margin-bottom: 13px; font-size: 13px; }
.slider-row label { width: 130px; color: var(--muted); }
.slider-row input { flex: 1; accent-color: var(--pink); }
.slider-row b { width: 44px; text-align: right; }
.modal-btns { display: flex; gap: 10px; justify-content: flex-end; margin-top: 18px; }
.modal-btns button {
  background: var(--pink); color: #2a1a1e; border: none; border-radius: 10px;
  padding: 9px 20px; font-size: 14px; font-weight: 700; cursor: pointer; font-family: inherit;
}
.modal-btns button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line); }
.hidden { display: none !important; }

/* ---------- tutorial ---------- */
.modal.tut { width: 480px; }
.tut-step { text-align: center; min-height: 300px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.tut-step img { max-height: 130px; margin: 6px 0 2px; }
.tut-step h2 { font-size: 18px; margin-bottom: 0; }
.tut-step p { color: var(--muted); font-size: 13.5px; line-height: 1.8; }
.tut-step p b { color: var(--text); }
.tut-step p .gd { color: var(--gold); }
.tut-step p .rd { color: var(--red); }
.tut-step p .pk { color: var(--pink); }
.tut-dots { display: flex; gap: 7px; justify-content: center; margin-top: 12px; }
.tut-dots i { width: 7px; height: 7px; border-radius: 50%; background: var(--line); }
.tut-dots i.on { background: var(--pink); }
.state-table { width: 100%; border-collapse: collapse; font-size: 12px; margin-top: 4px; text-align: left; }
.state-table td { padding: 5px 8px; border-bottom: 1px solid var(--line); color: var(--muted); line-height: 1.5; }
.state-table td:first-child { color: var(--pink); font-weight: 700; white-space: nowrap; }
.demo-cards { display: flex; gap: 10px; justify-content: center; margin: 4px 0; }
.demo-card { border: 1.5px solid var(--line); border-radius: 10px; padding: 6px 12px; font-size: 12px; color: var(--muted); }
.demo-card.gold { border-color: var(--gold); box-shadow: 0 0 10px #f0c86b33; color: var(--gold); }
.demo-card.red { border-color: var(--red); box-shadow: 0 0 10px #e5484d2e; color: var(--red); }

/* ---------- mobile ---------- */
@media (max-width: 820px) {
  body { overflow: auto; }
  #app { height: auto; min-height: 100vh; padding: 10px 10px 16px; }
  #board { flex-direction: column; }
  #stage { min-height: 340px; flex: none; }
  #cat-wrap { height: 240px; }
  #hint-bar { max-width: 94%; width: auto; white-space: normal; font-size: 11.5px; }
  #side { max-width: none; min-width: 0; flex-direction: column-reverse; }
  #log-panel { max-height: 130px; }
  #hand-area { flex-direction: column; }
  #hand { overflow-x: auto; justify-content: flex-start; padding-bottom: 4px; -webkit-overflow-scrolling: touch; }
  .card { min-width: 138px; }
  .card:hover { transform: none; }
  #btn-end { width: 100%; padding: 12px 0; }
  .modal { width: 94vw; padding: 18px 16px; }
  .title { font-size: 17px; }
}
