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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #1a2129;
  font-family: -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: #e8eef2;
  -webkit-user-select: none; user-select: none;
  touch-action: manipulation;
}

#game { position: fixed; inset: 0; display: block; }

#ui { position: fixed; inset: 0; pointer-events: none; }
#ui .screen, #ui button, #ui .plate, #shop-items { pointer-events: auto; }

.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; }
.hud-panel {
  position: absolute; top: 12px;
  background: rgba(16, 22, 28, .78);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px;
  padding: 10px 14px;
  backdrop-filter: blur(6px);
  min-width: 190px;
}
#hud-left  { left: 12px; }
#hud-right { right: 12px; text-align: right; min-width: 150px; }
#hud-name  { font-weight: 700; margin-bottom: 6px; font-size: 14px; }
#depth-label { font-weight: 700; font-size: 13px; margin-bottom: 4px; }
#fossil-count, #potion-count { font-size: 13px; opacity: .9; }

#hint {
  position: absolute; bottom: 10px; left: 50%; transform: translateX(-50%);
  font-size: 12px; color: rgba(255,255,255,.55);
  background: rgba(16,22,28,.6); padding: 5px 12px; border-radius: 999px;
  white-space: nowrap;
}

/* ---------- Bars ---------- */
.bar {
  position: relative; height: 14px; border-radius: 7px;
  background: rgba(255,255,255,.12); overflow: hidden; margin-bottom: 5px;
}
.bar.sm { height: 11px; }
.bar .fill { height: 100%; width: 100%; border-radius: 7px; transition: none; }
.hpbar .fill { background: linear-gradient(180deg, #6ede73, #3aa84a); }
.hpbar .fill.low { background: linear-gradient(180deg, #f1c15a, #d98a2b); }
.hpbar .fill.crit { background: linear-gradient(180deg, #f26d6d, #c23a3a); }
.xpbar .fill { background: linear-gradient(180deg, #7ec3f2, #3f7fc4); }
.stabar .fill { background: linear-gradient(180deg, #f2d97e, #c4a13f); }
.bar-label {
  position: absolute; inset: 0; text-align: center;
  font-size: 10px; line-height: 14px; font-weight: 700;
  color: rgba(0,0,0,.55); text-shadow: 0 1px 0 rgba(255,255,255,.25);
}
.bar.sm .bar-label { line-height: 11px; font-size: 9px; }

/* ---------- Banner ---------- */
#banner {
  position: absolute; top: 18%; left: 50%; transform: translateX(-50%);
  font-size: clamp(20px, 4vw, 34px); font-weight: 800; letter-spacing: 1px;
  color: #fff; text-shadow: 0 2px 12px rgba(0,0,0,.6);
  background: rgba(16,22,28,.55); padding: 10px 26px; border-radius: 14px;
  white-space: nowrap;
}

/* ---------- Battle ---------- */
#battle-ui { position: absolute; inset: 0; }
.plate {
  position: absolute; top: 14px;
  background: rgba(16, 22, 28, .82);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 12px; padding: 10px 14px;
  width: min(250px, 42vw);
  backdrop-filter: blur(6px);
}
#plate-p { left: 14px; }
#plate-e { right: 14px; }
.plate-name { font-weight: 700; font-size: 13px; margin-bottom: 6px; }
.status-row { font-size: 11px; min-height: 14px; margin-top: 2px; }
.status-row .tag { display: inline-block; padding: 1px 7px; border-radius: 999px; margin-right: 4px; font-weight: 700; }
.tag.bleed { background: #6e2430; color: #ffb3bd; }
.tag.stun  { background: #6e5d24; color: #ffe9a8; }
.tag.atkdn { background: #24406e; color: #a8ccff; }
.tag.defup { background: #24606e; color: #a8f0ff; }

#battle-bottom {
  position: absolute; left: 50%; bottom: 12px; transform: translateX(-50%);
  width: min(680px, 96vw);
  background: rgba(16, 22, 28, .85);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 16px; padding: 12px 14px;
  backdrop-filter: blur(8px);
  pointer-events: auto;
}
#battle-log { font-size: 14px; min-height: 20px; margin-bottom: 10px; font-weight: 600; }
#battle-buttons { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }

/* ---------- Buttons ---------- */
.btn {
  font: inherit; font-weight: 700; color: #e8eef2;
  background: linear-gradient(180deg, #33424f, #26333e);
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 10px; padding: 10px 14px;
  cursor: pointer;
  transition: transform .06s, filter .12s;
}
.btn:hover:not(:disabled) { filter: brightness(1.18); }
.btn:active:not(:disabled) { transform: scale(.96); }
.btn:disabled { opacity: .38; cursor: default; }
.btn.big {
  font-size: 18px; padding: 14px 40px; margin-top: 18px;
  background: linear-gradient(180deg, #4b8b3f, #35662c);
  border-color: rgba(255,255,255,.22);
  letter-spacing: 2px;
}
.btn.move { display: flex; flex-direction: column; align-items: center; gap: 2px; }
.btn.move .cost { font-size: 10px; font-weight: 600; opacity: .7; }
.btn.flee { background: linear-gradient(180deg, #5a4632, #453526); }
.btn.defend { background: linear-gradient(180deg, #32505a, #26404a); }

/* ---------- Screens ---------- */
.screen {
  position: absolute; inset: 0; display: flex;
  align-items: center; justify-content: center;
  background: rgba(10, 14, 18, .55);
}
.panel {
  background: rgba(18, 25, 32, .92);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 20px;
  padding: 34px 44px;
  text-align: center;
  box-shadow: 0 18px 60px rgba(0,0,0,.5);
  max-width: 92vw; max-height: 90vh; overflow-y: auto;
}
.panel.wide { width: min(760px, 94vw); }
.logo {
  font-family: "Arial Black", "Avenir Next Condensed", Impact, sans-serif;
  font-weight: 900; font-style: italic;
  font-size: clamp(42px, 8vw, 74px); line-height: .95; letter-spacing: 1px;
  background:
    linear-gradient(115deg, transparent 35%, rgba(255,255,255,.5) 50%, transparent 65%) no-repeat,
    linear-gradient(180deg, #f4ffd6 0%, #cdeb9a 38%, #79a84e 72%, #4e7a2e 100%);
  background-size: 250% 100%, 100% 100%;
  background-position: -150% 0, 0 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter:
    drop-shadow(0 2px 0 #223d14)
    drop-shadow(0 3px 0 #14260c)
    drop-shadow(0 8px 18px rgba(0,0,0,.55));
  animation:
    logo-in .7s cubic-bezier(.2, 1.4, .4, 1) both,
    logo-shine 5s ease-in-out 1.2s infinite;
}
.logo-x {
  display: inline-block;
  background: linear-gradient(180deg, #ffe9a8 0%, #f1c15a 45%, #c47a1e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  transform: rotate(7deg) scale(1.18);
  animation: x-stomp .5s cubic-bezier(.3, 1.6, .5, 1) .45s both;
}
@keyframes logo-in {
  from { opacity: 0; transform: translateY(-22px) scale(1.08); }
  to   { opacity: 1; transform: none; }
}
@keyframes logo-shine {
  0%, 55% { background-position: -150% 0, 0 0; }
  100%    { background-position: 250% 0, 0 0; }
}
@keyframes x-stomp {
  from { opacity: 0; transform: rotate(7deg) scale(2.6); }
  to   { opacity: 1; transform: rotate(7deg) scale(1.18); }
}
.tagline {
  margin-top: 12px; color: rgba(255,255,255,.6);
  font-size: 12px; letter-spacing: 4px; text-transform: uppercase;
  display: flex; align-items: center; justify-content: center; gap: 12px;
}
.tagline::before, .tagline::after {
  content: ""; height: 1px; width: 46px;
  background: linear-gradient(90deg, transparent, rgba(241,193,90,.6));
}
.tagline::after { background: linear-gradient(90deg, rgba(241,193,90,.6), transparent); }
.dedication {
  margin-top: 12px;
  font-family: "Arial Black", "Avenir Next Condensed", Impact, sans-serif;
  font-weight: 900; font-style: italic; text-transform: uppercase;
  font-size: 15px; letter-spacing: 3px;
  background: linear-gradient(180deg, #ffe9a8 0%, #f1c15a 50%, #c47a1e 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 #4a3208) drop-shadow(0 4px 10px rgba(0,0,0,.5));
  animation: dedication-crash .8s cubic-bezier(.25, .9, .3, 1.2) 1s both;
}
@keyframes dedication-crash {
  0%   { opacity: 0; transform: translate(60vw, -30vh) rotate(28deg) scale(3); }
  55%  { opacity: 1; transform: translate(0, 0) rotate(-4deg) scale(.85); }
  68%  { transform: translate(-2px, 1px) rotate(3deg) scale(1.12); }
  80%  { transform: translate(2px, -1px) rotate(-2.5deg) scale(.96); }
  90%  { transform: translate(-1px, 0) rotate(1deg) scale(1.03); }
  100% { transform: rotate(-2deg) scale(1); }
}
.fineprint { margin-top: 14px; font-size: 12px; color: rgba(255,255,255,.45); }
h2 { font-size: 26px; letter-spacing: 1px; margin-bottom: 6px; }
h2.danger { color: #f26d6d; font-size: 34px; letter-spacing: 4px; }
h2.gold { color: #f1c15a; font-size: 32px; letter-spacing: 3px; }
.subtle { color: rgba(255,255,255,.55); font-size: 14px; margin-bottom: 12px; }
.stats { margin: 16px 0; font-size: 15px; line-height: 1.8; color: rgba(255,255,255,.85); }

/* ---------- Starter cards ---------- */
#starter-cards { display: flex; gap: 16px; justify-content: center; flex-wrap: wrap; margin-top: 16px; }
.starter-card {
  width: 200px; padding: 14px; border-radius: 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.1);
  cursor: pointer; text-align: center;
  transition: transform .1s, border-color .15s, background .15s;
}
.starter-card:hover { transform: translateY(-4px); border-color: #79a84e; background: rgba(121,168,78,.12); }
.starter-card canvas { width: 150px; height: 110px; }
.starter-card h3 { font-size: 16px; margin: 4px 0 2px; }
.starter-card .blurb { font-size: 11.5px; color: rgba(255,255,255,.55); min-height: 32px; margin-bottom: 8px; }
.statbars { text-align: left; font-size: 10px; }
.statbars .row { display: flex; align-items: center; gap: 6px; margin: 3px 0; }
.statbars .row span { width: 30px; color: rgba(255,255,255,.55); font-weight: 700; }
.statbars .track { flex: 1; height: 6px; border-radius: 3px; background: rgba(255,255,255,.1); }
.statbars .track i { display: block; height: 100%; border-radius: 3px; background: #79a84e; }

/* ---------- Shop ---------- */
#shop-fossils { font-size: 20px; font-weight: 800; margin: 6px 0 14px; color: #f1c15a; }
#shop-items { display: flex; flex-direction: column; gap: 10px; }
.shop-item {
  display: flex; align-items: center; gap: 12px;
  background: rgba(255,255,255,.05); border: 1px solid rgba(255,255,255,.08);
  border-radius: 12px; padding: 10px 14px; text-align: left;
}
.shop-item .icon { font-size: 24px; }
.shop-item .info { flex: 1; }
.shop-item .info b { font-size: 14px; }
.shop-item .info small { display: block; color: rgba(255,255,255,.5); font-size: 11.5px; }
.shop-item button { min-width: 92px; }

@media (max-width: 640px) {
  .panel { padding: 24px 18px; }
  .hud-panel { min-width: 150px; padding: 8px 10px; }
  #hint { font-size: 10px; }
}
