/* =========================================================================
   Monster Haul — style.css
   Retro pixel UI. The canvas fills the screen; overlays sit on top.
   ========================================================================= */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --ink: #0b0e1a;
  --panel: #16213e;
  --panel2: #1d2b53;
  --accent: #ffec27;
  --accent2: #29adff;
  --good: #00e436;
  --bad: #ff004d;
  --text: #fff1e8;
}

html, body {
  width: 100%; height: 100%;
  background: #05060c;
  overflow: hidden;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  color: var(--text);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: none;
}

#game {
  position: fixed; inset: 0;
  width: 100%; height: 100%;
}

#c {
  display: block;
  width: 100%; height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #2f6b3a;
  cursor: crosshair;
}

/* controls hint, lower-left while playing */
.hint {
  position: absolute; left: 10px; bottom: calc(8px + env(safe-area-inset-bottom, 0px));
  font-size: 10px; color: rgba(255,241,232,0.55);
  pointer-events: none; letter-spacing: 0.5px;
  text-shadow: 1px 1px 0 #000;
}

/* ---------------- overlays ---------------- */
.overlay {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at center, rgba(10,12,26,0.78), rgba(5,6,12,0.93));
  z-index: 10;
  padding: 16px;
}
.overlay.hidden { display: none; }

.panel {
  background: linear-gradient(180deg, #1b2747, #121a30);
  border: 4px solid #0a0e1a;
  box-shadow: 0 0 0 4px #2b3a66, 0 14px 40px rgba(0,0,0,0.6);
  border-radius: 4px;
  padding: 22px 26px;
  max-width: 620px; width: 100%;
  text-align: center;
  max-height: 94vh; overflow-y: auto;
}
.panel.small { max-width: 460px; }

.title {
  font-size: clamp(26px, 6vw, 48px);
  letter-spacing: 2px; line-height: 1.1;
  color: var(--accent);
  text-shadow: 3px 3px 0 #ab5236, 6px 6px 0 rgba(0,0,0,0.5);
  margin-bottom: 6px;
}
.subtitle { font-size: 10px; color: #9fb0d0; margin-bottom: 16px; letter-spacing: 1px; }

.section { margin: 14px 0; }
.section-label {
  font-size: 9px; color: var(--accent2); margin-bottom: 8px; letter-spacing: 1px;
}

/* how-to-play panel */
.how { display: flex; flex-direction: column; gap: 8px; margin: 16px auto 4px; max-width: 460px; text-align: left; }
.how-row { display: flex; align-items: center; gap: 10px; background: #0e1730; border: 2px solid #243460; border-radius: 4px; padding: 8px 10px; }
.how-row .k { flex: 0 0 64px; font-size: 8px; color: var(--accent); letter-spacing: 1px; }
.how-row em { font-size: 8px; font-style: normal; color: #b8c4e0; line-height: 1.5; }

/* big action button */
.big-btn {
  margin-top: 16px;
  background: linear-gradient(180deg, #ffec27, #f0a500);
  color: #2a1a05;
  border: 3px solid #000;
  border-radius: 4px;
  padding: 14px 28px;
  font-family: inherit; font-size: 16px; letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 0 #9a6a00, 0 8px 14px rgba(0,0,0,0.4);
  transition: transform .06s, box-shadow .06s;
}
.big-btn:hover { transform: translateY(-1px); }
.big-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #9a6a00; }

.ghost-btn {
  background: #0e1730; color: var(--text);
  border: 2px solid #2b3a66; border-radius: 4px;
  padding: 9px 14px; margin: 6px 4px 0;
  font-family: inherit; font-size: 9px; cursor: pointer;
  transition: border-color .1s, background .1s;
}
.ghost-btn:hover { border-color: var(--accent2); background: #16224a; }

.footer { margin-top: 14px; display: flex; flex-direction: column; align-items: center; gap: 8px; }
.credit { font-size: 8px; color: #6f7fa6; letter-spacing: 0.5px; }
.terms { margin-top: 10px; font-size: 7px; color: #5f6f96; line-height: 1.6; }
.terms a { color: #8aa0d0; text-decoration: underline; }

/* ---------------- level up ---------------- */
.lu-title {
  font-size: 22px; color: var(--accent); letter-spacing: 1px;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.5); margin-bottom: 4px;
}
.lu-title.danger { color: var(--bad); text-shadow: 2px 2px 0 #5a0020; }

.cards { display: flex; gap: 12px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.card {
  position: relative;
  background: #0e1730;
  border: 3px solid #2b3a66; border-radius: 4px;
  width: 150px; min-height: 150px;
  padding: 14px 10px;
  cursor: pointer; color: var(--text); font-family: inherit;
  display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform .08s, border-color .1s, background .1s;
}
.card:hover { transform: translateY(-3px); border-color: var(--accent); background: #1a2a52; }
.card .pv { image-rendering: pixelated; }
.card strong { font-size: 10px; color: var(--accent); line-height: 1.4; }
.card span { font-size: 8px; color: #b8c4e0; line-height: 1.5; }
.card kbd {
  position: absolute; top: 6px; right: 8px;
  font-size: 9px; color: #6f7fa6; border: 1px solid #2b3a66;
  border-radius: 3px; padding: 1px 4px; background: #06091a;
}

/* ---------------- game over stats ---------------- */
.stats { display: flex; justify-content: center; gap: 20px; margin: 18px 0; }
.stats div { display: flex; flex-direction: column; gap: 6px; }
.stats span { font-size: 8px; color: #9fb0d0; }
.stats b { font-size: 20px; color: var(--accent); }

/* ---------------- top HUD buttons (mobile + desktop) ---------------- */
.hudbtns {
  position: absolute; top: calc(6px + env(safe-area-inset-top, 0px));
  right: calc(8px + env(safe-area-inset-right, 0px));
  display: flex; gap: 8px; z-index: 8;
}
.hudbtns.hidden { display: none; }
.icon-btn {
  width: 40px; height: 40px; border-radius: 6px;
  background: rgba(14,23,48,0.78); border: 2px solid #2b3a66; color: var(--text);
  font-size: 18px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.icon-btn:hover { border-color: var(--accent2); }
.icon-btn:active { transform: scale(0.92); }

/* ---------------- home screen ---------------- */
#start.overlay {
  overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 48%, rgba(29,43,83,0.48), rgba(5,6,12,0.88) 68%),
    rgba(5,6,12,0.86);
}
#start.overlay::before {
  content: "";
  position: absolute; inset: 0;
  z-index: 0;
  background:
    repeating-linear-gradient(0deg, rgba(255,241,232,0.035) 0 1px, transparent 1px 5px),
    radial-gradient(circle at 50% 52%, transparent 0 42%, rgba(0,0,0,0.34) 78%);
  opacity: 0.75;
  pointer-events: none;
}

.panel.home {
  position: relative;
  isolation: isolate;
  z-index: 2;
  max-width: 700px;
  padding: 22px 24px 18px;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(29,43,83,0.94), rgba(11,14,26,0.98));
  border-color: #05060c;
  box-shadow:
    0 0 0 4px #1d2b53,
    0 0 0 7px rgba(5,6,12,0.38),
    0 20px 60px rgba(0,0,0,0.72);
  animation: homeIn 0.42s cubic-bezier(.2,.9,.18,1) both;
}
.panel.home::before {
  content: "";
  position: absolute; inset: 6px;
  border: 1px solid rgba(255,241,232,0.16);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.36);
  pointer-events: none;
  z-index: -1;
}
.panel.home::after {
  content: "";
  position: absolute; left: 12px; right: 12px; top: 10px; height: 2px;
  background: linear-gradient(90deg, transparent, rgba(255,236,39,0.6), rgba(41,173,255,0.45), transparent);
  pointer-events: none;
}

.home-top {
  min-height: 16px;
  display: flex; align-items: center; justify-content: flex-end;
  position: relative; z-index: 4;
}
.best {
  min-height: 13px;
  margin: 0;
  color: rgba(255,236,39,0.92);
  font-size: 9px;
  line-height: 1.4;
  letter-spacing: 0;
  text-align: right;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.55);
}

.home-stage {
  position: relative;
  height: 226px;
  margin: 2px 0 10px;
  display: flex; align-items: center; justify-content: center;
  overflow: hidden;
  background: radial-gradient(ellipse at 50% 54%, rgba(41,173,255,0.12), transparent 58%);
}
.home-stage::after {
  content: "";
  position: absolute; left: 18%; right: 18%; bottom: 18px; height: 18px;
  background: radial-gradient(ellipse, rgba(0,0,0,0.35), transparent 68%);
}

.logo {
  position: relative;
  z-index: 5;
  display: flex; flex-direction: column; align-items: center;
  line-height: 0.88;
  transform-origin: center bottom;
  animation: logoBob 3.4s ease-in-out infinite;
}
.logo-mon {
  font-size: 46px;
  letter-spacing: 0;
  color: var(--accent);
  text-shadow: 3px 3px 0 #ab5236, 6px 6px 0 rgba(0,0,0,0.58);
}
.logo-haul {
  font-size: 84px;
  letter-spacing: 0;
  color: var(--bad);
  text-shadow:
    3px 3px 0 #5a0020,
    7px 7px 0 rgba(0,0,0,0.58);
  -webkit-text-stroke: 2px #0a0e1a;
}

.home-subtitle {
  max-width: 620px;
  margin: 0 auto 16px;
  color: #c2c3c7;
  font-size: 10px;
  line-height: 1.7;
  letter-spacing: 0;
}

.home-sprite {
  position: absolute;
  pointer-events: none;
}
.home-sprite { z-index: 3; filter: drop-shadow(4px 6px 0 rgba(0,0,0,0.45)); }
.home-sprite canvas,
[data-home-icon] canvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.hero-pose {
  left: 70px; bottom: 48px;
  animation: heroReady 2.3s ease-in-out infinite;
}
.mob { opacity: 0.96; }
.mob-a { right: 82px; bottom: 48px; animation: mobHop 2.4s ease-in-out infinite; }

.home-actions {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  flex-wrap: wrap;
  position: relative; z-index: 4;
}
.play-btn {
  position: relative;
  min-width: 190px;
  min-height: 58px;
  margin-top: 0;
  padding: 10px 20px;
  display: inline-flex; align-items: center; justify-content: center; gap: 14px;
  overflow: hidden;
}
.play-mark {
  position: relative; z-index: 1;
  width: 30px; height: 30px;
  display: flex; align-items: center; justify-content: center;
  color: #fff1e8;
  background: #ff004d;
  border: 3px solid #05060c;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.5);
  font-size: 17px;
  line-height: 1;
}
.play-copy {
  position: relative; z-index: 1;
  display: flex;
  text-align: left;
  white-space: nowrap;
}
.play-copy b { font-size: 18px; line-height: 1; }
.sound-btn {
  min-height: 46px;
  margin-top: 0;
  align-self: stretch;
}

.home-loadout {
  position: relative;
  min-height: 46px;
  margin: 18px auto 12px;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  opacity: 0.9;
}
.home-loadout::before,
.home-loadout::after {
  content: "";
  position: absolute; left: 18%; right: 18%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255,241,232,0.22), transparent);
  pointer-events: none;
}
.home-loadout::before { top: 0; }
.home-loadout::after { bottom: 0; }
.home-loadout > span {
  flex: 0 0 36px;
  width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center;
}

.home-controls {
  display: flex; justify-content: center; gap: 16px; flex-wrap: wrap;
  margin: 4px auto 0;
  color: #8aa0d0;
  font-size: 7px;
  line-height: 1.5;
}

@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.045); } }
@keyframes homeIn { from { opacity: 0; transform: translateY(10px) scale(0.985); } to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes logoBob { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-4px); } }
@keyframes heroReady { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-3px); } }
@keyframes mobHop { 0%,100% { transform: translateY(0); } 50% { transform: translateY(-5px); } }

.big-btn.revive { background: linear-gradient(180deg, #00e436, #00a028); color: #042a0e; box-shadow: 0 4px 0 #006a1a, 0 8px 14px rgba(0,0,0,0.4); }

/* watch-ad-for-2-upgrades button on the level-up screen */
.ad-btn {
  margin-top: 14px; padding: 12px 18px; border-radius: 4px;
  background: linear-gradient(180deg, #00e436, #00a028); color: #042a0e;
  border: 3px solid #000; font-family: inherit; font-size: 11px; cursor: pointer;
  box-shadow: 0 3px 0 #006a1a; transition: transform .06s; -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.ad-btn:hover { transform: translateY(-1px); }
.ad-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #006a1a; }
.ad-btn.hidden { display: none; }
.ad-btn.granted { background: #1a2a52; color: var(--accent); border-color: var(--accent); cursor: default; box-shadow: none; }
.newbest { font-size: 12px; color: var(--accent); margin-bottom: 8px; animation: pulse 0.9s ease-in-out infinite; }
.newbest.hidden, .big-btn.revive.hidden { display: none; }

@media (max-width: 760px) {
  .panel.home { max-width: 560px; padding: 18px; }
  .home-stage { height: 202px; }
  .logo-mon { font-size: 34px; }
  .logo-haul { font-size: 62px; }
  .hero-pose { left: 34px; bottom: 40px; }
  .mob-a { right: 38px; bottom: 40px; }
}

@media (max-width: 480px) {
  .panel { padding: 16px; }
  .panel.home {
    width: min(100%, 390px);
    max-height: calc(100vh - 22px);
    padding: 13px;
  }
  .title { font-size: 30px; }
  .card { width: 132px; min-height: 132px; padding: 16px 10px; }
  .hint { font-size: 8px; }
  .big-btn { padding: 16px 30px; font-size: 16px; }    /* bigger tap targets */
  .icon-btn { width: 44px; height: 44px; }
  .home-top { min-height: 8px; justify-content: center; }
  .best { text-align: center; font-size: 7px; min-height: 10px; }
  .home-stage { height: 146px; margin-top: 0; }
  .logo-mon { font-size: 25px; text-shadow: 2px 2px 0 #ab5236, 4px 4px 0 rgba(0,0,0,0.58); }
  .logo-haul { font-size: 46px; text-shadow: 2px 2px 0 #5a0020, 5px 5px 0 rgba(0,0,0,0.58), 0 0 12px rgba(255,0,77,0.45); -webkit-text-stroke: 1px #0a0e1a; }
  .home-sprite { display: none; }
  .home-subtitle { font-size: 8px; line-height: 1.55; margin-bottom: 10px; }
  .home-actions { gap: 8px; }
  .play-btn { min-width: 176px; min-height: 56px; padding: 9px 16px; }
  .play-mark { width: 28px; height: 28px; font-size: 14px; }
  .play-copy b { font-size: 15px; }
  .sound-btn { min-height: 40px; font-size: 8px; }
  .home-loadout { min-height: 44px; margin: 12px -4px 8px; gap: 8px; }
  .home-loadout > span { flex-basis: 34px; width: 34px; height: 34px; }
  .home-loadout canvas { transform: scale(0.82); }
  .home-controls { gap: 6px; font-size: 6px; flex-direction: column; }
  .home .terms { margin-top: 8px; font-size: 6px; }
  .how { display: none; }                               /* keep the mobile home compact */
}

@media (prefers-reduced-motion: reduce) {
  #start.overlay::before,
  .panel.home,
  .panel.home::after,
  .logo,
  .home-sprite,
  .big-btn.pulse {
    animation: none !important;
  }
}
