:root {
  --bg: #0b0e14;
  --ink: #e8ecf4;
  --ink-dim: #9aa7bd;
  --ink-faint: #67748e;
  --gold: #e6b566;
  --gold-2: #f5d9a0;
  --cyan: #6fd3c9;
  --jade: #7fc9a0;
  --ember: #d97a5a;
  --serif: "Noto Serif SC", "Songti SC", serif;
  --sans: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--bg); color: var(--ink); font-family: var(--sans);
  min-height: 100vh; overflow-x: hidden;
}

.g-bg { position: fixed; inset: 0; z-index: -1; }
.g-bg img { width: 100%; height: 100%; object-fit: cover; }
.g-bg-veil {
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(11,14,20,0.82), rgba(11,14,20,0.72) 45%, rgba(11,14,20,0.92));
}

.g-scene { max-width: 1000px; margin: 0 auto; padding: 20px 20px 60px; }

/* ---------- Header ---------- */
.g-header {
  display: flex; align-items: center; justify-content: space-between; gap: 14px; flex-wrap: wrap;
  padding: 16px 22px; border: 1px solid rgba(180,200,230,0.14); border-radius: 12px;
  background: rgba(16,20,29,0.7); backdrop-filter: blur(8px); margin-bottom: 22px;
}
.g-back { font-size: 13px; color: var(--ink-dim); letter-spacing: 1px; transition: color 0.25s; }
.g-back:hover { color: var(--gold-2); }
.g-title { text-align: center; }
.g-title h1 {
  font-family: var(--serif); font-size: 26px; letter-spacing: 4px;
  background: linear-gradient(120deg, #f7e6c2, var(--gold), #b88a3f);
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.g-title p { font-size: 11px; color: var(--ink-faint); letter-spacing: 2px; margin-top: 2px; }
.g-favor { text-align: right; font-size: 12px; color: var(--ink-dim); display: flex; flex-direction: column; gap: 3px; }
.g-favor b { font-size: 20px; color: var(--ember); font-family: var(--serif); }
.g-favor i { font-style: normal; font-size: 12px; color: var(--ink-dim); }
.g-favor .fruit-num { color: var(--gold-2); font-size: 16px; }

/* ---------- Battle ---------- */
.g-battle { display: grid; grid-template-columns: 1fr 140px 1fr; gap: 14px; align-items: stretch; }

.g-side {
  position: relative; background: rgba(16,20,29,0.78); border: 1px solid rgba(180,200,230,0.14);
  border-radius: 14px; padding: 20px; display: flex; flex-direction: column; gap: 14px;
  transition: border-color 0.3s; overflow: hidden;
}
.g-side.busy { border-color: rgba(230,181,102,0.45); box-shadow: 0 0 24px rgba(230,181,102,0.18); }

.g-avatar { display: flex; align-items: center; gap: 12px; }
.g-avatar img {
  width: 52px; height: 52px; border-radius: 50%; object-fit: cover;
  border: 2px solid var(--gold); box-shadow: 0 0 16px rgba(230,181,102,0.35);
}
.g-name { font-family: var(--serif); font-size: 16px; letter-spacing: 2px; color: var(--gold-2); }

.g-question {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(180,200,230,0.12);
  border-radius: 10px; padding: 16px; text-align: center; min-height: 118px;
  display: flex; flex-direction: column; justify-content: center;
}
.q-label { font-size: 11px; color: var(--ink-faint); letter-spacing: 3px; margin-bottom: 8px; }
.q-text {
  font-family: var(--serif); font-size: clamp(26px, 3.4vw, 36px); font-weight: 700;
  letter-spacing: 3px; color: var(--ink); word-break: break-all;
}
.q-text.done { color: var(--jade); }

.g-answer { display: flex; gap: 8px; }
.g-answer input {
  flex: 1; background: rgba(255,255,255,0.06); border: 1px solid rgba(180,200,230,0.2);
  border-radius: 8px; padding: 11px 14px; color: var(--ink); font-size: 18px; letter-spacing: 2px;
  font-family: var(--serif); outline: none; transition: border-color 0.25s;
}
.g-answer input:focus { border-color: var(--gold); }
.g-answer input:disabled { opacity: 0.4; }
.g-answer button {
  padding: 0 20px; border: 0; border-radius: 8px; cursor: pointer;
  background: linear-gradient(135deg, var(--gold), #b07f35); color: #191204;
  font-weight: 700; font-size: 15px; letter-spacing: 2px; transition: transform 0.2s, box-shadow 0.2s;
}
.g-answer button:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 8px 20px rgba(230,181,102,0.35); }
.g-answer button:disabled { opacity: 0.4; cursor: default; }
.g-answer.ai {
  align-items: center; justify-content: center; min-height: 46px;
  background: rgba(255,255,255,0.03); border: 1px solid rgba(180,200,230,0.12); border-radius: 8px;
}

.thinking { display: flex; gap: 6px; }
.thinking span {
  width: 9px; height: 9px; border-radius: 50%; background: var(--cyan);
  animation: blink 1.1s infinite;
}
.thinking span:nth-child(2) { animation-delay: 0.18s; }
.thinking span:nth-child(3) { animation-delay: 0.36s; }
@keyframes blink { 0%, 60%, 100% { opacity: 0.2; transform: scale(0.8); } 30% { opacity: 1; transform: scale(1.1); } }
.thinking.idle span { background: var(--ink-faint); animation: none; opacity: 0.5; }

.g-hint { min-height: 20px; text-align: center; font-size: 12.5px; letter-spacing: 1px; }
.g-hint.ok { color: var(--jade); }
.g-hint.err { color: var(--ember); }
.g-hint.info { color: var(--cyan); }

.g-progress { display: flex; gap: 5px; justify-content: center; flex-wrap: wrap; }
.g-progress i {
  width: 18px; height: 8px; border-radius: 4px; background: rgba(255,255,255,0.08);
  border: 1px solid rgba(180,200,230,0.15); transition: background 0.3s, box-shadow 0.3s;
}
.g-progress i.on { background: linear-gradient(90deg, var(--gold), #b07f35); box-shadow: 0 0 8px rgba(230,181,102,0.5); border-color: transparent; }

.g-state { text-align: center; font-size: 11px; color: var(--ink-faint); letter-spacing: 2px; }
.g-state.hit { color: var(--ember); }

/* ---------- VS ---------- */
.g-vs { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; position: relative; }
.vs-badge {
  font-family: var(--serif); font-size: 34px; letter-spacing: 6px; color: var(--gold);
  text-shadow: 0 0 30px rgba(230,181,102,0.5);
}
.g-toast {
  min-height: 44px; display: flex; align-items: center; text-align: center;
  font-size: 13px; color: var(--cyan); letter-spacing: 1px; line-height: 1.6;
}
.g-start {
  padding: 13px 30px; border: 0; border-radius: 40px; cursor: pointer;
  background: linear-gradient(135deg, var(--gold), #b07f35); color: #191204;
  font-weight: 700; font-size: 16px; letter-spacing: 4px; font-family: var(--serif);
  transition: transform 0.25s, box-shadow 0.25s;
}
.g-start:hover { transform: translateY(-3px); box-shadow: 0 12px 30px rgba(230,181,102,0.4); }
.g-start:disabled { opacity: 0.5; cursor: default; transform: none; }
.g-rule { font-size: 11px; color: var(--ink-faint); text-align: center; line-height: 1.8; letter-spacing: 1px; }

/* ---------- Counter ---------- */
.g-counter { margin-top: 24px; background: rgba(16,20,29,0.78); border: 1px solid rgba(180,200,230,0.14); border-radius: 12px; padding: 16px 22px; }
.c-head { text-align: center; font-size: 12px; color: var(--ink-faint); letter-spacing: 3px; margin-bottom: 12px; }
.c-bars { display: flex; flex-direction: column; gap: 10px; }
.c-bar { display: flex; align-items: center; gap: 12px; }
.c-name { width: 62px; font-size: 12px; color: var(--ink-dim); letter-spacing: 1px; text-align: right; }
.c-track { flex: 1; height: 12px; border-radius: 6px; background: rgba(255,255,255,0.06); overflow: hidden; }
.c-track i { display: block; height: 100%; width: 0%; border-radius: 6px; transition: width 0.5s var(--ease); }
#cPlayer { background: linear-gradient(90deg, var(--cyan), #3f8fd0); }
#cBeast { background: linear-gradient(90deg, var(--gold), #b07f35); }
.c-bar em { width: 22px; font-style: normal; font-size: 14px; color: var(--ink); font-family: var(--serif); text-align: center; }

/* ---------- Egg overlay ---------- */
.egg-fly { position: fixed; z-index: 90; pointer-events: none; }
.egg-fly.fly { transition: transform 0.9s var(--ease); }
.egg {
  width: 34px; height: 46px; border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  background: linear-gradient(160deg, #fff7e0, #e8c88a 55%, #c89a4e);
  box-shadow: inset -5px -6px 10px rgba(150,110,40,0.35), 0 6px 16px rgba(0,0,0,0.4);
}

/* splat overlay */
.splat {
  position: absolute; inset: 0; z-index: 20; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px;
  background:
    radial-gradient(circle at 30% 25%, rgba(240,214,120,0.85) 0 8px, transparent 9px),
    radial-gradient(circle at 62% 40%, rgba(240,214,120,0.8) 0 12px, transparent 13px),
    radial-gradient(circle at 40% 70%, rgba(238,205,110,0.9) 0 10px, transparent 11px),
    radial-gradient(circle at 75% 65%, rgba(245,224,140,0.85) 0 9px, transparent 10px),
    radial-gradient(circle at 55% 18%, rgba(232,196,100,0.8) 0 7px, transparent 8px),
    linear-gradient(160deg, rgba(240,210,110,0.92), rgba(210,165,70,0.92));
  backdrop-filter: blur(3px);
  opacity: 0; transition: opacity 0.3s;
}
.g-side.splatted .splat { opacity: 1; }
.splat span { font-family: var(--serif); font-size: 18px; letter-spacing: 3px; color: #4a3510; font-weight: 700; }
.splat em { font-style: normal; font-size: 12px; color: rgba(74,53,16,0.8); letter-spacing: 2px; }

/* ---------- Result ---------- */
.g-result {
  position: fixed; inset: 0; z-index: 120; display: flex; align-items: center; justify-content: center;
  background: rgba(8,10,15,0.8); backdrop-filter: blur(6px);
  opacity: 0; visibility: hidden; transition: opacity 0.5s var(--ease), visibility 0.5s;
}
.g-result.show { opacity: 1; visibility: visible; }
.result-card {
  width: min(440px, 90vw); text-align: center; padding: 36px 34px;
  background: linear-gradient(180deg, #161b27, #10141d); border: 1px solid rgba(230,181,102,0.4);
  border-radius: 18px; box-shadow: 0 30px 80px rgba(0,0,0,0.6);
  transform: translateY(24px) scale(0.96); transition: transform 0.5s var(--ease);
}
.g-result.show .result-card { transform: translateY(0) scale(1); }
.result-card h2 { font-family: var(--serif); font-size: 32px; letter-spacing: 6px; margin-bottom: 8px; }
.g-result.win h2 { color: var(--gold-2); text-shadow: 0 0 24px rgba(230,181,102,0.5); }
.g-result.lose h2 { color: var(--ember); }
.result-sub { font-size: 13px; color: var(--ink-dim); margin-bottom: 20px; letter-spacing: 1px; }
.reward { display: flex; justify-content: center; gap: 40px; margin-bottom: 22px; }
.reward-item { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fruit-ico, .heart-ico { width: 40px; height: 40px; border-radius: 50%; }
.fruit-ico {
  background: radial-gradient(circle at 35% 30%, #ffe9b0, var(--gold) 55%, #c8903f);
  box-shadow: 0 6px 18px rgba(230,181,102,0.45);
}
.heart-ico {
  background: radial-gradient(circle at 35% 30%, #f8c0b0, var(--ember) 55%, #a8462c);
  clip-path: polygon(50% 88%, 0 38%, 12% 12%, 38% 12%, 50% 30%, 62% 12%, 88% 12%, 100% 38%);
  box-shadow: 0 6px 18px rgba(217,122,90,0.4);
}
.reward-item b { font-family: var(--serif); font-size: 24px; color: var(--gold-2); }
.reward-item em { font-style: normal; font-size: 12px; color: var(--ink-faint); letter-spacing: 2px; }
.result-note { font-size: 12px; color: var(--ink-faint); line-height: 1.8; margin-bottom: 22px; }
.result-actions { display: flex; gap: 12px; justify-content: center; }
.btn-again, .btn-back {
  padding: 11px 26px; border-radius: 40px; font-size: 14px; letter-spacing: 2px; cursor: pointer;
  transition: transform 0.25s, box-shadow 0.25s;
}
.btn-again { border: 0; background: linear-gradient(135deg, var(--gold), #b07f35); color: #191204; font-weight: 700; }
.btn-again:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(230,181,102,0.4); }
.btn-back { border: 1px solid rgba(180,200,230,0.3); color: var(--ink-dim); background: transparent; text-decoration: none; display: inline-block; }
.btn-back:hover { color: var(--ink); border-color: var(--ink-dim); }

.shake { animation: shake 0.4s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-7px); }
  50% { transform: translateX(7px); }
  75% { transform: translateX(-5px); }
}

/* ---------- Design note ---------- */
.g-design {
  margin-top: 30px; padding: 34px 34px 36px;
  background: rgba(16,20,29,0.82); border: 1px solid rgba(230,181,102,0.25);
  border-radius: 16px;
}
.g-design .d-head {
  display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap;
  margin-bottom: 22px;
}
.g-design .d-kicker { font-size: 11px; letter-spacing: 4px; color: var(--cyan); }
.g-design .d-title { font-family: var(--serif); font-size: 24px; letter-spacing: 3px; color: var(--gold-2); }
.g-design .d-sub { font-size: 12px; color: var(--ink-faint); letter-spacing: 1px; }
.g-design .d-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 26px; }
.g-design .d-cell {
  background: rgba(255,255,255,0.04); border: 1px solid rgba(180,200,230,0.12);
  border-radius: 10px; padding: 16px 16px 14px;
}
.g-design .d-cell b { display: block; font-family: var(--serif); font-size: 15px; color: var(--gold-2); letter-spacing: 1px; margin-bottom: 8px; }
.g-design .d-cell p { font-size: 12.5px; color: var(--ink-dim); line-height: 1.7; }
.g-design .d-block { margin-bottom: 24px; }
.g-design .d-block h4 { font-family: var(--serif); font-size: 15px; letter-spacing: 2px; color: var(--cyan); margin-bottom: 12px; }
.g-design .d-block p { font-size: 13.5px; color: var(--ink-dim); line-height: 1.9; margin-bottom: 10px; }
.g-design .d-block ul { list-style: none; }
.g-design .d-block li {
  position: relative; padding-left: 20px; font-size: 13.5px; color: var(--ink-dim); line-height: 1.9;
}
.g-design .d-block li::before {
  content: ""; position: absolute; left: 2px; top: 11px; width: 7px; height: 7px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff8e8, var(--gold));
  box-shadow: 0 0 8px rgba(230,181,102,0.5);
}
.g-design table.d-table { width: 100%; border-collapse: collapse; font-size: 13px; color: var(--ink-dim); margin-bottom: 14px; }
.g-design table.d-table th, .g-design table.d-table td { padding: 11px 12px; text-align: center; border-bottom: 1px solid rgba(180,200,230,0.12); }
.g-design table.d-table thead th { color: var(--gold-2); font-family: var(--serif); font-size: 12.5px; letter-spacing: 2px; background: rgba(230,181,102,0.06); }
.g-design table.d-table tbody tr:last-child td { border-bottom: none; }
.g-design table.d-table td b { color: var(--ink); }
.g-design .d-note { font-size: 12px; color: var(--ink-faint); letter-spacing: 1px; line-height: 1.8; }

@media (max-width: 900px) { .g-design .d-grid { grid-template-columns: 1fr 1fr; } }
@media (max-width: 560px) { .g-design .d-grid { grid-template-columns: 1fr; } }

/* ---------- Responsive ---------- */
@media (max-width: 760px) {
  .g-battle { grid-template-columns: 1fr; }
  .g-vs { order: -1; flex-direction: row; flex-wrap: wrap; }
  .vs-badge { font-size: 24px; }
  .g-rule { flex-basis: 100%; }
  .g-toast { order: 3; flex-basis: 100%; }
  .g-header { justify-content: center; text-align: center; }
  .g-favor { flex-direction: row; gap: 16px; }
}
