/* ============================================================
   SPIDER-CHESTER — style.css  (comic-book UI)
   ============================================================ */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { width: 100%; height: 100%; overflow: hidden; position: fixed; }
body {
  font-family: "Arial Rounded MT Bold", "Avenir-Heavy", "Arial Black", Arial, sans-serif;
  background: #0d1330; color: #fff;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}
#game { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
button { font-family: inherit; cursor: pointer; border: none; color: inherit; background: none; }
.hidden { display: none !important; }

/* ---------- splash ---------- */
#splash {
  position: absolute; inset: 0; z-index: 60;
  background: radial-gradient(circle at 50% 35%, #23306b, #0d1330 70%);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px;
}
#splash .spin { font-size: 64px; animation: bounce 0.9s infinite alternate ease-in-out; }
#splash .stitle { font-size: 30px; font-weight: 900; letter-spacing: 2px; color: #ffc832; text-shadow: 3px 3px 0 #b3172a; }
#splash .ssub { opacity: 0.7; font-size: 14px; }
@keyframes bounce { from { transform: translateY(-12px) } to { transform: translateY(10px) } }

/* ---------- screens ---------- */
.screen {
  position: absolute; inset: 0; z-index: 40; display: none;
  align-items: center; justify-content: center;
  background: rgba(8, 12, 34, 0.55);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.screen.show { display: flex; }
.menuInner, .panelInner, .card {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  max-width: min(92vw, 760px); max-height: 94vh; overflow-y: auto; overflow-x: hidden;
  padding: 20px 26px;
  scrollbar-width: none;
}
.menuInner::-webkit-scrollbar, .panelInner::-webkit-scrollbar, .card::-webkit-scrollbar { display: none; }
.card {
  background: linear-gradient(160deg, #1b2450, #131a3c);
  border: 4px solid #ffc832; border-radius: 26px;
  box-shadow: 0 14px 40px rgba(0,0,0,0.5), 0 0 0 6px rgba(217,37,47,0.35);
  transform: rotate(-0.6deg);
}
h1 {
  font-size: clamp(34px, 7vw, 62px); font-weight: 900; letter-spacing: 2px;
  color: #ff3243; -webkit-text-stroke: 2px #fff;
  text-shadow: 4px 4px 0 #7d0e1e, 8px 8px 0 rgba(0,0,0,0.35);
  transform: rotate(-2deg);
}
h1 .gold { color: #ffc832; }
h2 {
  font-size: clamp(22px, 4.5vw, 34px); font-weight: 900; color: #ffc832;
  text-shadow: 3px 3px 0 #b3172a; letter-spacing: 1px; text-align: center;
}
.tagline { font-size: clamp(13px, 2.4vw, 17px); opacity: 0.92; letter-spacing: 1px; }
.dedic { margin-top: 6px; font-size: 12px; opacity: 0.6; }
.kicker { font-size: 13px; letter-spacing: 3px; color: #9adcff; }
.story { font-size: clamp(14px, 2.6vw, 17px); text-align: center; line-height: 1.45; max-width: 480px; }
.missionline { font-size: clamp(15px, 2.8vw, 18px); font-weight: 900; color: #ffc832; text-align: center; }
.tipline { font-size: clamp(12px, 2.3vw, 15px); opacity: 0.85; text-align: center; }
.webcorner { position: absolute; font-size: 44px; opacity: 0.5; }
.webcorner.tl { top: 8px; left: 10px; }
.webcorner.tr { top: 8px; right: 10px; transform: scaleX(-1); }

/* ---------- birthday photo badge ---------- */
#photoWrap { position: relative; margin-bottom: -4px; }
#menuPhoto {
  width: 118px; height: 118px; border-radius: 50%; object-fit: cover; display: block;
  border: 4px solid #ffc832;
  box-shadow: 0 0 0 5px #d9252f, 0 8px 24px rgba(0,0,0,0.5);
  animation: photobob 3s ease-in-out infinite;
}
#photoSpider {
  position: absolute; top: -16px; right: -12px; font-size: 26px;
  transform: rotate(20deg);
}
@keyframes photobob { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-6px) rotate(2deg); } }
#bday {
  background: linear-gradient(180deg, #ffe08a, #ffc832);
  color: #7d3400; font-weight: 900; letter-spacing: 1px;
  font-size: clamp(14px, 2.8vw, 19px);
  padding: 7px 20px; border-radius: 999px; border: 3px solid #fff;
  transform: rotate(-2deg);
  box-shadow: 0 4px 0 #9a6a00, 0 6px 14px rgba(0,0,0,0.35);
}
#bday sup { font-size: 0.6em; }
@media (max-height: 500px) {
  #menuPhoto { width: 76px; height: 76px; }
  #photoSpider { font-size: 18px; top: -10px; }
}

/* ---------- buttons ---------- */
.bigbtn {
  font-size: clamp(20px, 4vw, 28px); font-weight: 900; letter-spacing: 1px;
  padding: 16px 44px; border-radius: 999px; color: #fff;
  background: linear-gradient(180deg, #ff4152, #c31226);
  border: 4px solid #fff; box-shadow: 0 8px 0 #7d0e1e, 0 12px 22px rgba(0,0,0,0.45);
  transition: transform 0.08s;
}
.midbtn {
  font-size: clamp(14px, 2.6vw, 18px); font-weight: 900;
  padding: 12px 22px; border-radius: 999px; color: #10173a;
  background: linear-gradient(180deg, #ffe08a, #ffc832);
  border: 3px solid #fff; box-shadow: 0 5px 0 #9a6a00, 0 8px 14px rgba(0,0,0,0.35);
  transition: transform 0.08s;
}
.backbtn {
  font-size: 15px; font-weight: 900; color: #9adcff;
  padding: 10px 18px; border-radius: 999px; border: 2px solid #9adcff55;
}
.bigbtn:active, .midbtn:active, .tbtn.on, .levelCard:active, .diffCard:active { transform: scale(0.93); }
.menurow { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.notelet { font-size: 12px; opacity: 0.65; text-align: center; max-width: 380px; }

/* ---------- level grid ---------- */
#levelGrid {
  display: grid; grid-template-columns: repeat(4, minmax(130px, 1fr));
  gap: 12px; width: min(88vw, 720px);
}
.levelCard {
  background: linear-gradient(165deg, #223065, #17204a);
  border: 3px solid #ffc832; border-radius: 18px;
  padding: 12px 8px; display: flex; flex-direction: column; align-items: center; gap: 6px;
  box-shadow: 0 6px 0 rgba(0,0,0,0.35);
  transition: transform 0.08s;
}
.levelCard .lnum { font-size: 30px; }
.levelCard .lname { font-size: 13px; font-weight: 900; text-align: center; }
.levelCard .lstars { font-size: 15px; color: #ffc832; letter-spacing: 2px; }
.levelCard.locked { filter: grayscale(1) brightness(0.6); border-color: #666; }
.dim { opacity: 0.25; }

/* ---------- difficulty cards ---------- */
#diffRow { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }
.diffCard {
  width: min(200px, 27vw); min-width: 150px;
  background: linear-gradient(165deg, #223065, #17204a);
  border: 3px solid #5a6aa5; border-radius: 20px;
  padding: 16px 10px; display: flex; flex-direction: column; align-items: center; gap: 8px;
  transition: transform 0.08s;
}
.diffCard.sel, .pdiff.sel { border-color: #7dff9e; box-shadow: 0 0 18px rgba(125,255,158,0.45); }
.diffCard .de { font-size: 38px; }
.diffCard .dn { font-weight: 900; font-size: 18px; color: #ffc832; }
.diffCard .dd { font-size: 12px; opacity: 0.85; text-align: center; line-height: 1.4; }

/* ---------- help ---------- */
.helpCols { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.helpCard {
  width: min(220px, 80vw);
  background: rgba(255,255,255,0.07); border-radius: 16px; padding: 14px;
  font-size: 13px; line-height: 1.5;
}
.helpCard h3 { font-size: 15px; color: #9adcff; margin-bottom: 8px; }
.helpCard p { margin-bottom: 6px; }

/* ---------- results ---------- */
#resStars { font-size: clamp(40px, 9vw, 64px); color: #ffc832; letter-spacing: 8px; text-shadow: 0 4px 0 #b3172a; animation: popstar 0.5s ease-out; }
@keyframes popstar { from { transform: scale(0.2); } to { transform: scale(1); } }
.scoreline { font-size: 20px; font-weight: 900; }
.bestline { font-size: 13px; opacity: 0.7; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; z-index: 30; pointer-events: none; }
#objChip {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: calc(12px + env(safe-area-inset-left));
  background: rgba(10, 16, 44, 0.75); border: 3px solid #ffc832; border-radius: 999px;
  padding: 8px 16px; font-size: 20px; font-weight: 900; display: flex; gap: 8px; align-items: center;
}
#timer {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  background: rgba(10, 16, 44, 0.75); border: 3px solid #9adcff; border-radius: 999px;
  padding: 8px 18px; font-size: 20px; font-weight: 900;
}
#timer.urgent { border-color: #ff4152; color: #ff8a94; animation: pulse 0.5s infinite alternate; }
@keyframes pulse { from { transform: translateX(-50%) scale(1); } to { transform: translateX(-50%) scale(1.08); } }
#hudBtns {
  position: absolute; top: calc(10px + env(safe-area-inset-top)); right: calc(12px + env(safe-area-inset-right));
  display: flex; gap: 10px; pointer-events: auto;
}
.hudbtn {
  width: 46px; height: 46px; border-radius: 50%; font-size: 20px;
  background: rgba(10, 16, 44, 0.75); border: 3px solid #5a6aa5;
}
#mission {
  position: absolute; top: calc(62px + env(safe-area-inset-top)); left: 50%; transform: translateX(-50%);
  max-width: min(86vw, 620px); text-align: center;
  font-size: clamp(13px, 2.6vw, 17px); font-weight: 900; color: #fff;
  text-shadow: 0 2px 4px #000, 0 0 12px rgba(0,0,0,0.7);
}
#toast {
  position: absolute; top: 34%; left: 50%; z-index: 35;
  transform: translate(-50%, -50%) scale(0.3); opacity: 0;
  font-size: clamp(26px, 6vw, 44px); font-weight: 900; color: #ffc832;
  -webkit-text-stroke: 1.5px #7d0e1e;
  text-shadow: 4px 4px 0 rgba(0,0,0,0.4);
  transition: transform 0.15s, opacity 0.15s; pointer-events: none; white-space: nowrap;
}
#toast.show { transform: translate(-50%, -50%) scale(1) rotate(-3deg); opacity: 1; }

/* ---------- touch controls ---------- */
#touchUI { position: absolute; inset: 0; z-index: 32; pointer-events: none; }
#stickZone {
  position: absolute; left: 0; bottom: 0; width: 46%; height: 72%;
  pointer-events: auto; touch-action: none;
}
#stickBase {
  position: absolute; width: 120px; height: 120px; margin: -60px 0 0 -60px;
  border-radius: 50%; border: 3px solid rgba(255,255,255,0.45);
  background: rgba(255,255,255,0.08); display: none;
}
#stickBase.on { display: block; }
#stickKnob {
  position: absolute; left: 50%; top: 50%; width: 58px; height: 58px; margin: -29px 0 0 -29px;
  border-radius: 50%; background: rgba(255,255,255,0.55);
  box-shadow: 0 0 14px rgba(0,0,0,0.4);
}
.tbtn {
  position: absolute; pointer-events: auto; touch-action: none;
  border-radius: 50%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-weight: 900; color: #fff;
  background: rgba(10, 16, 44, 0.6); border: 3px solid rgba(255,255,255,0.55);
  text-shadow: 0 2px 3px #000;
}
.tbtn b { font-size: 26px; }
.tbtn span { font-size: 11px; letter-spacing: 1px; }
#btnJump {
  right: calc(18px + env(safe-area-inset-right)); bottom: calc(20px + env(safe-area-inset-bottom));
  width: 96px; height: 96px; border-color: #7dff9e88;
}
#btnWeb {
  right: calc(34px + env(safe-area-inset-right)); bottom: calc(130px + env(safe-area-inset-bottom));
  width: 86px; height: 86px; border-color: #9adcff88; background: rgba(37, 69, 217, 0.45);
}
#btnZap {
  right: calc(128px + env(safe-area-inset-right)); bottom: calc(26px + env(safe-area-inset-bottom));
  width: 74px; height: 74px; border-color: #ffc83288;
}
.tbtn.on { background: rgba(255, 200, 50, 0.5); }

/* ---------- rotate hint ---------- */
#rotateNote {
  position: absolute; left: 50%; bottom: 132px; transform: translate(-50%, 400%);
  z-index: 55; background: #ffc832; color: #10173a; font-weight: 900;
  padding: 10px 20px; border-radius: 999px; font-size: 14px;
  transition: transform 0.3s, opacity 0.3s;
  opacity: 0; pointer-events: none;
}
#rotateNote.show { transform: translate(-50%, 0); opacity: 1; }

/* small screens: tighten things */
@media (max-height: 460px) {
  #levelGrid { grid-template-columns: repeat(4, 1fr); gap: 8px; }
  .levelCard .lnum { font-size: 22px; }
  .menuInner, .panelInner, .card { gap: 9px; padding: 12px 16px; }
  h1 { font-size: 30px; }
  .bigbtn { padding: 10px 30px; }
}
