:root{
  --glass:rgba(18,31,38,.68);
  --line:rgba(255,255,255,.22);
  --text:#fff;
}
*{box-sizing:border-box;-webkit-tap-highlight-color:transparent}
html{
  -webkit-text-size-adjust:100%;
  text-size-adjust:100%;
  width:100%;
  height:100%;
  overflow:hidden;
  background:#7fc8dc
}
body{
  margin:0;
  width:100%;
  height:100%;
  overflow:hidden;
  font-family:ui-rounded,system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
  color:var(--text);
  background:#7fc8dc;
  user-select:none;
  -webkit-user-select:none;
  overscroll-behavior:none;
  touch-action:none;
  position:fixed;
  inset:0
}
button{font:inherit}
#app{position:absolute;inset:0;overflow:hidden;background:#7fc8dc}
#game{position:absolute;inset:0;width:100%;height:100%;display:block;touch-action:none}

#hud{position:absolute;inset:0;pointer-events:none;z-index:6}
.topbar{
  position:absolute;
  left:max(10px,env(safe-area-inset-left));
  right:max(10px,env(safe-area-inset-right));
  top:max(7px,env(safe-area-inset-top));
  display:flex;
  justify-content:space-between;
  align-items:flex-start;
  gap:7px
}
.pill{
  background:var(--glass);
  border:1px solid var(--line);
  border-radius:15px;
  padding:7px 10px;
  backdrop-filter:blur(11px);
  -webkit-backdrop-filter:blur(11px);
  box-shadow:0 8px 20px rgba(0,0,0,.14);
  font-size:11px;
  font-weight:850;
  line-height:1.25;
  text-shadow:0 1px 2px #000
}
#questPill{max-width:45%;text-align:center}
#weatherPill{text-align:right}
#toast{
  position:absolute;
  left:50%;
  top:17%;
  transform:translateX(-50%);
  background:rgba(11,20,27,.82);
  border:1px solid rgba(255,255,255,.2);
  border-radius:16px;
  padding:9px 13px;
  font-size:12px;
  font-weight:900;
  opacity:0;
  transition:opacity .18s;
  white-space:nowrap;
  max-width:84%;
  overflow:hidden;
  text-overflow:ellipsis;
  backdrop-filter:blur(9px);
  -webkit-backdrop-filter:blur(9px)
}
#contextHint{
  position:absolute;
  left:50%;
  bottom:22%;
  transform:translateX(-50%);
  background:rgba(10,18,24,.72);
  border:1px solid rgba(255,255,255,.18);
  border-radius:13px;
  padding:7px 10px;
  font-size:11px;
  font-weight:850;
  opacity:0;
  transition:opacity .18s
}
#stormWarn{
  position:absolute;
  left:50%;
  top:64px;
  transform:translateX(-50%);
  display:none;
  background:rgba(75,35,45,.82);
  border:1px solid rgba(255,190,205,.35);
  border-radius:14px;
  padding:7px 10px;
  font-size:11px;
  font-weight:950
}

#controls{position:absolute;inset:0;z-index:8;pointer-events:none}
#pauseBtn{
  position:absolute;right:max(12px,env(safe-area-inset-right));top:max(56px,calc(env(safe-area-inset-top) + 49px));
  width:42px;height:42px;border-radius:13px;border:1px solid var(--line);pointer-events:auto;
  color:#fff;background:var(--glass);font-weight:1000;font-size:17px;backdrop-filter:blur(9px)
}
#joyZone{
  position:absolute;
  left:max(12px,env(safe-area-inset-left));
  bottom:max(12px,env(safe-area-inset-bottom));
  width:148px;
  height:148px;
  pointer-events:auto;
  touch-action:none
}
#joyBase{
  position:absolute;
  left:12px;
  top:12px;
  width:124px;
  height:124px;
  border-radius:50%;
  background:radial-gradient(circle at 50% 35%,rgba(255,255,255,.12),rgba(0,0,0,.22));
  border:2px solid rgba(255,255,255,.3);
  box-shadow:inset 0 0 28px rgba(255,255,255,.05),0 10px 25px rgba(0,0,0,.14)
}
#joyBase::before{
  content:"↑";
  position:absolute;
  left:50%;
  top:8px;
  transform:translateX(-50%);
  font-size:14px;
  font-weight:1000;
  color:rgba(255,255,255,.6)
}
#joyBase::after{
  content:"MOVE";
  position:absolute;
  left:50%;
  bottom:8px;
  transform:translateX(-50%);
  font-size:8px;
  font-weight:950;
  letter-spacing:.11em;
  color:rgba(255,255,255,.45)
}
#joyKnob{
  position:absolute;
  left:46px;
  top:46px;
  width:56px;
  height:56px;
  border-radius:50%;
  background:linear-gradient(145deg,#fff,#d4eef0);
  border:2px solid rgba(255,255,255,.7);
  box-shadow:0 8px 18px rgba(0,0,0,.22)
}
.action{
  position:absolute;
  pointer-events:auto;
  touch-action:none;
  border:1px solid rgba(255,255,255,.35);
  color:#fff;
  font-weight:950;
  display:grid;
  place-items:center;
  text-shadow:0 1px 2px rgba(0,0,0,.65);
  box-shadow:0 10px 25px rgba(0,0,0,.2);
  backdrop-filter:blur(8px);
  -webkit-backdrop-filter:blur(8px)
}
.action:active{transform:scale(.94)}
#useBtn{
  right:max(16px,env(safe-area-inset-right));
  bottom:max(18px,env(safe-area-inset-bottom));
  width:88px;
  height:88px;
  border-radius:50%;
  background:linear-gradient(145deg,rgba(70,196,132,.96),rgba(48,137,99,.96));
  font-size:12px
}
#toolBtn{
  right:max(116px,calc(env(safe-area-inset-right) + 116px));
  bottom:max(55px,calc(env(safe-area-inset-bottom) + 55px));
  width:78px;
  height:78px;
  border-radius:50%;
  background:linear-gradient(145deg,rgba(237,171,84,.96),rgba(185,106,46,.96));
  font-size:11px
}
#toolChip{
  position:absolute;
  right:max(108px,calc(env(safe-area-inset-right) + 108px));
  bottom:max(14px,env(safe-area-inset-bottom));
  pointer-events:auto;
  touch-action:none;
  background:rgba(12,21,27,.7);
  border:1px solid rgba(255,255,255,.18);
  border-radius:13px;
  padding:6px 9px;
  font-size:10px;
  font-weight:900;
  min-width:92px;
  text-align:center;
  color:#fff
}
#dialogue{
  position:absolute;
  left:50%;
  bottom:12px;
  transform:translateX(-50%);
  z-index:15;
  width:min(640px,86%);
  display:none;
  background:rgba(18,31,38,.9);
  border:1px solid rgba(255,255,255,.22);
  border-radius:18px;
  padding:12px 14px 13px;
  box-shadow:0 16px 45px rgba(0,0,0,.28);
  backdrop-filter:blur(13px);
  -webkit-backdrop-filter:blur(13px)
}
#dialogueName{font-size:12px;font-weight:1000;color:#ffe3a9;margin-bottom:4px}
#dialogueText{font-size:13px;line-height:1.35;color:#fff;padding-right:78px}
#dialogue button{
  position:absolute;
  right:10px;
  bottom:10px;
  border:0;
  border-radius:12px;
  background:#fff;
  color:#16232b;
  padding:9px 13px;
  font-size:11px;
  font-weight:950
}

#petSelect{
  position:absolute;
  inset:0;
  z-index:35;
  display:none;
  place-items:center;
  padding:12px;
  background:linear-gradient(#8fcfde,#bfe4d0 72%,#79af72);
}
#pauseMenu{
  position:absolute;inset:0;z-index:44;display:none;place-items:center;padding:12px;
  background:rgba(10,20,24,.82);backdrop-filter:blur(10px)
}
.storeMenu{
  position:absolute;inset:0;z-index:46;display:none;place-items:center;padding:12px;
  background:rgba(9,20,24,.86);backdrop-filter:blur(12px)
}
.storePanel{width:min(700px,92%);max-height:88vh;overflow:auto}
.storeGrid{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:9px;margin-top:13px}
.storeItem{border:1px solid rgba(255,255,255,.2);border-radius:15px;padding:11px;background:rgba(255,255,255,.08);text-align:left;color:#fff}
.storeItem b,.storeItem small{display:block}.storeItem small{opacity:.72;margin-top:3px}.storeItem:disabled{opacity:.38}
.storeFooter{display:flex;justify-content:space-between;align-items:center;gap:10px;margin-top:13px}
@media(max-width:620px){.storeGrid{grid-template-columns:1fr}.storePanel{max-height:82vh}}
.menuRow{display:flex;flex-wrap:wrap;justify-content:center;gap:9px;margin-top:12px}
.secondary{border:1px solid rgba(255,255,255,.25);border-radius:13px;padding:10px 13px;color:#fff;background:rgba(255,255,255,.1);font-weight:900}
.petGrid{
  display:grid;
  grid-template-columns:repeat(3,1fr);
  gap:10px;
  margin-top:12px
}
.petChoice{
  border:1px solid rgba(255,255,255,.24);
  border-radius:18px;
  min-height:96px;
  padding:10px 8px;
  color:#fff;
  background:rgba(16,34,36,.7);
  font-weight:950;
  touch-action:none
}
.petChoice span{display:block;font-size:34px;margin-bottom:4px}
.petChoice:active{transform:scale(.96)}

#start,#loading,#error,#win{
  position:absolute;
  inset:0;
  z-index:30;
  display:grid;
  place-items:center;
  padding:12px
}
#start{
  background:
    radial-gradient(circle at 25% 25%,rgba(255,225,141,.35),transparent 26%),
    radial-gradient(circle at 78% 18%,rgba(119,184,225,.28),transparent 28%),
    linear-gradient(#91d6e4,#b8e5d2 70%,#7bb475)
}
.panel{
  width:min(560px,88%);
  background:rgba(19,38,39,.76);
  border:1px solid rgba(255,255,255,.23);
  border-radius:24px;
  padding:18px;
  text-align:center;
  box-shadow:0 24px 60px rgba(0,0,0,.25);
  backdrop-filter:blur(15px);
  -webkit-backdrop-filter:blur(15px)
}
.brandIcon{font-size:35px;line-height:1}
.title{font-size:clamp(29px,5vw,46px);font-weight:1000;letter-spacing:-.035em;line-height:.96;margin-top:5px}
.subtitle{font-size:13px;line-height:1.4;opacity:.84;margin:10px auto 0;max-width:480px}
.primary{
  margin-top:14px;
  border:0;
  border-radius:15px;
  padding:12px 19px;
  min-width:190px;
  font-size:15px;
  font-weight:1000;
  color:#183029;
  background:linear-gradient(135deg,#fff0a5,#a7f0c9);
  box-shadow:0 10px 24px rgba(0,0,0,.16)
}
.tiny{font-size:10px;opacity:.62;margin-top:8px;line-height:1.3}
#loading{z-index:40;background:#87cddd}
.spinner{
  width:40px;
  height:40px;
  border:4px solid rgba(255,255,255,.22);
  border-top-color:#fff;
  border-radius:50%;
  animation:spin .9s linear infinite;
  margin:auto
}
@keyframes spin{to{transform:rotate(360deg)}}
#error{display:none;z-index:50;background:#15242b}
#win{display:none;z-index:45;background:rgba(14,25,27,.87)}
#rotate{
  position:absolute;
  inset:0;
  z-index:60;
  display:none;
  place-items:center;
  text-align:center;
  padding:22px;
  background:#193038
}
#rotate b{display:block;font-size:25px;margin-bottom:7px}
#profiles{position:absolute;inset:0;z-index:65;display:grid;place-items:center;background:linear-gradient(145deg,#193e40,#507c62);padding:14px;overflow:auto;touch-action:pan-y}
#profiles .panel{max-height:94dvh;overflow:auto;touch-action:pan-y;width:min(720px,96%)}
#profileSlots{display:grid;grid-template-columns:repeat(auto-fit,minmax(115px,1fr));gap:8px;margin:12px 0}
#profileSlots button{min-height:70px;color:white;border:1px solid #91baad;border-radius:12px;background:#284f4b;font:inherit;font-weight:800}
#profileSlots button[aria-pressed="true"]{outline:3px solid #ffe4a0}
#profileForm{display:grid;grid-template-columns:100px 1fr;gap:12px;text-align:left}
#profileFields{display:grid;grid-template-columns:1fr 1fr;gap:8px}
#profileFields label{font-size:12px;font-weight:800;display:grid;gap:4px}
#profileFields input,#profileFields select{min-height:38px;width:100%;border:1px solid #9cb9ad;border-radius:9px;padding:6px;font-size:16px;background:#eff5ec;color:#173c35;touch-action:manipulation;user-select:text}
#profileMessage{min-height:24px;font-size:12px;margin-top:8px;color:#ffe7aa}
#profilePreview{width:100px;height:145px;background:#a3c9b6;border-radius:16px}
#profiles button{touch-action:manipulation}
@media(max-height:450px){#profiles .panel{padding:10px}#profileSlots button{min-height:44px}#profilePreview{height:110px}#profiles .primary{margin-top:6px;padding:8px}#profiles .title{font-size:23px!important}}

@media (orientation:portrait) and (max-width:760px){#rotate{display:grid}}
@media (orientation:landscape) and (max-height:500px){
  #start .panel{width:min(500px,76vw);padding:11px 15px;border-radius:20px}
  #start .brandIcon{font-size:26px}
  #start .title{font-size:clamp(25px,4.2vw,36px);margin-top:2px}
  #start .subtitle{font-size:11px;line-height:1.28;margin-top:6px}
  #start .primary{margin-top:8px;padding:9px 15px;min-width:165px;font-size:13px}
  #start .tiny{font-size:9px;margin-top:5px}
}
@media (max-height:430px){
  .pill{font-size:9px;padding:5px 7px}
  #stormWarn{top:48px;font-size:9px}
  #joyZone{width:132px;height:132px}
  #joyBase{width:108px;height:108px}
  #joyKnob{left:40px;top:40px;width:52px;height:52px}
  #useBtn{width:76px;height:76px;font-size:10px}
  #toolBtn{width:68px;height:68px;right:max(102px,calc(env(safe-area-inset-right) + 102px));bottom:max(48px,calc(env(safe-area-inset-bottom) + 48px))}
}
