/* ============ 侏罗纪求生 · 样式 ============ */
:root {
  --bg: #08120c;
  --ink: #e9f4ec;
  --muted: #9db3a5;
  --line: rgba(255, 255, 255, 0.14);
  --glass: rgba(9, 24, 17, 0.72);
  --hp: #ef5a4c;
  --food: #f0a636;
  --water: #46b4ee;
  --stam: #7ede63;
  --exp: #c78bf5;
  --mana: #9b7bff;
  --gold: #ffce54;
  --pad: calc(10px + env(safe-area-inset-left, 0px));
  --padr: calc(10px + env(safe-area-inset-right, 0px));
  --padt: calc(8px + env(safe-area-inset-top, 0px));
  --padb: calc(10px + env(safe-area-inset-bottom, 0px));
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0; padding: 0; height: 100%; width: 100%;
  overflow: hidden; background: var(--bg); color: var(--ink);
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", system-ui, sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: none; overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

#app { position: fixed; inset: 0; overflow: hidden; }

canvas#game {
  position: absolute; inset: 0; width: 100%; height: 100%;
  display: block; touch-action: none;
}

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
#hud { position: absolute; inset: 0; pointer-events: none; z-index: 5; }
#hud button { pointer-events: auto; }

.panel-left {
  position: absolute; left: var(--pad); top: var(--padt);
  width: min(46vw, 240px);
  background: var(--glass);
  border: 1px solid var(--line); border-radius: 14px;
  padding: 7px 9px 8px; backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.idcard { display: flex; align-items: center; gap: 5px; flex-wrap: wrap; margin-bottom: 6px; }
.idcard > span:first-child { font-weight: 800; font-size: 14px; letter-spacing: 0.5px; }
.tag {
  font-size: 10px; padding: 1px 6px; border-radius: 20px;
  background: rgba(255, 255, 255, 0.13); color: #d9ebdd;
}
.tag.lv { background: rgba(255, 206, 84, 0.2); color: var(--gold); font-weight: 700; }

.bars { display: flex; flex-direction: column; gap: 4px; }
.bar {
  position: relative; height: 13px; border-radius: 8px;
  background: rgba(255, 255, 255, 0.1); overflow: hidden;
}
.bar i {
  position: absolute; left: 0; top: 0; bottom: 0; width: 60%;
  border-radius: 8px; transition: width 0.18s linear;
}
.bar span {
  position: absolute; left: 7px; top: 0; line-height: 13px;
  font-size: 9px; letter-spacing: 1px; color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}
.bar.hp i { background: linear-gradient(90deg, #c33, var(--hp)); }
.bar.food i { background: linear-gradient(90deg, #b9701c, var(--food)); }
.bar.water i { background: linear-gradient(90deg, #1e6d99, var(--water)); }
.bar.stam i { background: linear-gradient(90deg, #3f9c34, var(--stam)); }
.bar.mana i { background: linear-gradient(90deg, #4a35a8, var(--mana)); }
.bar.exp { height: 7px; }
.bar.exp i { background: linear-gradient(90deg, #7a45b8, var(--exp)); }
.bar.exp span { display: none; }

.relics { display: flex; gap: 4px; margin-top: 5px; min-height: 4px; flex-wrap: wrap; }
.relics i {
  font-size: 12px; font-style: normal; width: 21px; height: 21px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(255, 255, 255, 0.12); border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.14);
}
.relics i.bl { background: rgba(255, 206, 84, 0.26); border-color: rgba(255, 206, 84, 0.5); }

.panel-right {
  position: absolute; right: var(--padr); top: var(--padt);
  display: flex; flex-direction: column; align-items: flex-end; gap: 6px;
}
.topline { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; }
.chip {
  background: var(--glass); border: 1px solid var(--line);
  border-radius: 20px; padding: 3px 9px; font-size: 11px;
  backdrop-filter: blur(8px); white-space: nowrap;
}
#minimap {
  width: 96px; height: 96px; border-radius: 12px;
  border: 1px solid var(--line); background: rgba(4, 14, 10, 0.7);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
}
.sysbtns { display: flex; gap: 6px; }
.sys {
  width: 38px; height: 38px; border-radius: 11px;
  background: var(--glass); color: var(--ink);
  border: 1px solid var(--line); font-size: 15px;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(8px); cursor: pointer;
}
.sys:active { transform: scale(0.92); background: rgba(255, 255, 255, 0.18); }
.sys.off { opacity: 0.45; }

.prompt {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--padb) + 118px);
  background: rgba(8, 22, 16, 0.8); border: 1px solid var(--line);
  border-radius: 20px; padding: 5px 14px; font-size: 12px; color: #dff0e4;
  backdrop-filter: blur(6px); white-space: nowrap;
}

#toasts {
  position: absolute; left: 50%; transform: translateX(-50%);
  top: calc(var(--padt) + 6px); width: min(78vw, 380px);
  display: flex; flex-direction: column; align-items: center; gap: 5px;
}
.toast {
  background: rgba(10, 26, 19, 0.88); border: 1px solid var(--line);
  border-left: 3px solid var(--gold);
  border-radius: 10px; padding: 6px 12px; font-size: 12.5px;
  animation: pop 0.25s ease-out; backdrop-filter: blur(6px);
  max-width: 100%; text-align: center;
}
.toast.bad { border-left-color: var(--hp); }
.toast.good { border-left-color: var(--stam); }
.toast.info { border-left-color: var(--water); }
.toast.fade { opacity: 0; transform: translateY(-6px); transition: all 0.4s ease; }
@keyframes pop { from { opacity: 0; transform: translateY(-10px) scale(0.96); } to { opacity: 1; } }

.keyhint {
  position: absolute; left: 50%; transform: translateX(-50%);
  bottom: var(--padb); font-size: 11px; color: rgba(220, 235, 225, 0.5);
  white-space: nowrap; pointer-events: none;
}

/* ---------------- 触屏控制 ---------------- */
#touch { position: absolute; inset: 0; z-index: 6; pointer-events: none; }
#stickzone {
  position: absolute; left: 0; bottom: 0; width: 50%; height: 74%;
  pointer-events: auto;
}
#touch.right #stickzone { left: auto; right: 0; }
#touch.right #pad { right: auto; left: var(--pad); }

#stick {
  position: absolute; width: 132px; height: 132px; margin: -66px 0 0 -66px;
  left: 96px; top: calc(100% - 106px);
  border-radius: 50%; border: 2px solid rgba(255, 255, 255, 0.16);
  background: radial-gradient(circle, rgba(255, 255, 255, 0.1), rgba(255, 255, 255, 0.03) 70%);
  opacity: 0.5; transition: opacity 0.18s;
}
#stick.on { opacity: 0.95; }
#knob {
  position: absolute; left: 50%; top: 50%; width: 56px; height: 56px;
  margin: -28px 0 0 -28px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f5fff8, #9fd7ae);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.45);
}

#pad {
  position: absolute; right: var(--padr); bottom: var(--padb);
  width: 236px; height: 214px; pointer-events: none;
}
.pbtn {
  position: absolute; pointer-events: auto; border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: rgba(14, 34, 25, 0.62); color: #eaf7ee;
  font-size: 14px; font-weight: 700; font-family: inherit;
  backdrop-filter: blur(6px); cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.06s, background 0.1s;
}
.pbtn.down { transform: scale(0.9); background: rgba(120, 220, 150, 0.42); }
.pbtn.big {
  width: 90px; height: 90px; right: 0; bottom: 0; font-size: 20px;
  background: rgba(200, 70, 55, 0.55); border-color: rgba(255, 170, 160, 0.35);
}
.pbtn.big.down { background: rgba(255, 110, 90, 0.75); }
.pbtn.breath {
  width: 70px; height: 70px; right: 94px; bottom: 10px; font-size: 19px;
  background: linear-gradient(160deg, rgba(150, 90, 220, 0.62), rgba(230, 120, 60, 0.62));
  border-color: rgba(220, 180, 255, 0.42);
}
.pbtn.breath.down { background: linear-gradient(160deg, rgba(190, 130, 255, 0.85), rgba(255, 160, 80, 0.85)); }
.pbtn.mid { width: 62px; height: 62px; }
#btn-act { right: 170px; bottom: 30px; font-size: 12.5px; }
#btn-sprint { right: 6px; bottom: 96px; font-size: 12.5px; }
.pbtn.tiny { width: 50px; height: 50px; font-size: 12.5px; }
#btn-roar { right: 68px; bottom: 116px; }
#btn-nest { right: 132px; bottom: 104px; }
.pbtn.dim { opacity: 0.38; }

/* ---------------- 屏幕面板 ---------------- */
.screen {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--padt) + 6px) var(--padr) calc(var(--padb) + 6px) var(--pad);
  background:
    radial-gradient(120% 90% at 50% 0%, rgba(30, 78, 52, 0.5), transparent 60%),
    rgba(4, 10, 8, 0.82);
  backdrop-filter: blur(7px);
  animation: fadein 0.22s ease-out;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

.sheet {
  width: min(94vw, 560px); max-height: 100%;
  background: linear-gradient(180deg, rgba(18, 42, 30, 0.96), rgba(9, 22, 16, 0.96));
  border: 1px solid var(--line); border-radius: 20px;
  padding: 16px 16px 14px; overflow: hidden;
  display: flex; flex-direction: column; gap: 9px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.sheet.narrow { width: min(92vw, 420px); }
.brand { text-align: center; }
.sheet h1 {
  margin: 2px 0 0; font-size: clamp(24px, 7vw, 38px); letter-spacing: 3px;
  background: linear-gradient(180deg, #fff5cf, #ffb03a);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}
.sheet h2 { margin: 2px 0; font-size: 20px; text-align: center; }
.sheet h3 { margin: 10px 0 4px; font-size: 14px; color: var(--gold); }
.sub { margin: 2px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.pick-tip { margin: 4px 0 0; font-size: 12px; color: var(--muted); text-align: center; }
.foot { margin: 0; font-size: 10.5px; color: rgba(157, 179, 165, 0.7); text-align: center; }

.speclist { display: grid; grid-template-columns: repeat(4, 1fr); gap: 7px; }
.spec {
  border: 1px solid var(--line); border-radius: 13px; padding: 6px 3px 7px;
  background: rgba(255, 255, 255, 0.05); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  font-family: inherit; color: var(--ink); transition: all 0.15s;
}
.spec canvas { width: 100%; height: 46px; }
.spec b { font-size: 12px; }
.spec em { font-size: 9.5px; font-style: normal; color: var(--muted); }
.spec.sel {
  border-color: var(--gold); background: rgba(255, 206, 84, 0.14);
  box-shadow: 0 0 0 1px rgba(255, 206, 84, 0.4) inset;
}
.spec:active { transform: scale(0.96); }

.detail {
  font-size: 11.5px; color: #cfe3d5; line-height: 1.55;
  background: rgba(0, 0, 0, 0.25); border-radius: 12px; padding: 8px 10px;
  min-height: 58px;
}
.detail .stats { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px; color: var(--muted); }
.detail .stats b { color: #eaf7ee; }

.row { display: flex; gap: 8px; }
.row.tight { gap: 6px; }
.row button { flex: 1; }
button.main, button.ghost {
  font-family: inherit; font-size: 15px; font-weight: 700;
  padding: 13px 10px; border-radius: 14px; cursor: pointer;
  border: 1px solid transparent; color: #06180f;
  background: linear-gradient(180deg, #9fe6a5, #4fbf6a);
  min-height: 48px;
}
button.ghost {
  background: rgba(255, 255, 255, 0.08); color: var(--ink);
  border-color: var(--line); font-size: 13.5px; font-weight: 600;
  padding: 11px 8px; min-height: 44px;
}
button.main:active, button.ghost:active { transform: scale(0.97); filter: brightness(1.08); }

.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; touch-action: pan-y; padding-right: 4px; }
.rules { margin: 4px 0; padding-left: 18px; font-size: 12.5px; line-height: 1.7; color: #d8e9dc; }
.rules b { color: var(--gold); font-weight: 700; }

.setrow {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 4px; border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  font-size: 13.5px;
}
.opt {
  font-family: inherit; font-size: 13px; font-weight: 700; color: var(--ink);
  background: rgba(255, 255, 255, 0.1); border: 1px solid var(--line);
  border-radius: 10px; padding: 7px 16px; min-width: 78px; cursor: pointer;
}
.opt:active { transform: scale(0.95); }
.opt.danger { color: #ff9b8f; border-color: rgba(255, 120, 100, 0.35); }

.statgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 12.5px; }
.statgrid div {
  background: rgba(255, 255, 255, 0.06); border-radius: 10px; padding: 7px 10px;
  display: flex; justify-content: space-between; gap: 6px;
}
.statgrid b { color: var(--gold); }
.grade { text-align: center; font-size: 30px; font-weight: 900; color: var(--gold); letter-spacing: 2px; }

.rotate {
  position: absolute; left: 50%; bottom: calc(var(--padb) + 6px);
  transform: translateX(-50%); z-index: 30;
  background: rgba(0, 0, 0, 0.7); border-radius: 20px;
  padding: 6px 14px; font-size: 12px; color: #ffe6a8;
}

/* ---------------- 自适应 ---------------- */
@media (max-height: 460px) {
  .panel-left { width: min(40vw, 200px); padding: 5px 7px 6px; }
  .bar { height: 11px; }
  .bar span { line-height: 11px; font-size: 8.5px; }
  #minimap { width: 74px; height: 74px; }
  .sys { width: 34px; height: 34px; }
  .keyhint { display: none; }
  .sheet { padding: 10px 12px; gap: 6px; border-radius: 16px; }
  .sheet h1 { font-size: 22px; }
  .spec canvas { height: 34px; }
  button.main, button.ghost { min-height: 40px; padding: 9px; font-size: 13.5px; }
}
@media (max-width: 420px) {
  #pad { transform: scale(0.9); transform-origin: bottom right; }
  .speclist { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 360px) {
  #pad { transform: scale(0.82); transform-origin: bottom right; }
}
#touch.right #pad { transform-origin: bottom left; }
@media (pointer: fine) and (min-width: 900px) {
  .keyhint { font-size: 12px; }
}
