:root{
  --bg:#0b1220;
  --card:#121b2e;
  --card2:#0f1729;
  --text:#eaf0ff;
  --muted:#b7c3e6;
  --good:#7CFFB2;
  --warn:#ffd27c;
  --bad:#ff7c9e;
  --accent:#8dbbff;
  --accent2:#b58dff;
  --shadow: 0 18px 50px rgba(0,0,0,.35);
  --radius: 18px;
}
*{box-sizing:border-box}
body{
  margin:0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial;
  background: radial-gradient(1200px 700px at 20% 10%, #1b2b55 0%, rgba(27,43,85,0) 60%),
              radial-gradient(900px 600px at 80% 15%, #3b1b55 0%, rgba(59,27,85,0) 55%),
              linear-gradient(180deg, #070b14 0%, #0b1220 100%);
  color:var(--text);
  height:100vh;
  overflow:hidden;
  padding:0;
}
.app{
  width:100%;
  height:100vh;
  display:grid;
  grid-template-columns: 30% 1fr;
  gap:0;
  padding:0;
}
@media (max-width: 900px){
  .app{
    grid-template-columns:1fr;
    height:auto;
  }
}
.card{
  background: linear-gradient(180deg, rgba(255,255,255,.06), rgba(255,255,255,.02));
  border: 1px solid rgba(255,255,255,.09);
  box-shadow: var(--shadow);
  overflow-y:auto;
  overflow-x:hidden;
  height:100vh;
}
.card.left{
  border-radius: 0;
  border-left:none;
  border-top:none;
  border-bottom:none;
}
.card.left .pad{
  padding-bottom:40px;
}
.card.right{
  border-radius: 0;
  border:none;
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
  padding:0;
}
.pad{padding:16px}
h1{
  margin:0 0 6px 0;
  font-size:22px;
  letter-spacing:.2px;
  display:flex;
  align-items:center;
  gap:10px;
}
.sub{color:var(--muted); font-size:13px}
.row{display:flex; gap:10px; flex-wrap:wrap; align-items:center}
.pill{
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: 999px;
  padding:7px 10px;
  font-size:13px;
  color:var(--muted);
  display:inline-flex;
  gap:8px;
  align-items:center;
}
.big{
  font-size:46px;
  letter-spacing: 1px;
  font-weight:800;
  margin:8px 0 6px 0;
  line-height:1.0;
}
.equation{
  display:flex;
  align-items:baseline;
  gap:10px;
  flex-wrap:wrap;
}
.eq{
  background: rgba(0,0,0,.22);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 14px;
  padding:14px 14px;
  min-height:78px;
  width:100%;
}
.inputWrap{
  display:flex;
  gap:10px;
  margin-top:10px;
  align-items:center;
  flex-wrap:wrap;
}
input[type="text"]{
  width:min(220px, 100%);
  padding:14px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(255,255,255,.06);
  color:var(--text);
  font-size:18px;
  outline:none;
}
input[type="text"]:focus{border-color: rgba(141,187,255,.7)}
button{
  border:none;
  border-radius: 14px;
  padding:12px 14px;
  font-size:15px;
  cursor:pointer;
  color:#0b1220;
  font-weight:700;
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  box-shadow: 0 12px 30px rgba(141,187,255,.18);
}
button.secondary{
  background: rgba(255,255,255,.08);
  color: var(--text);
  border: 1px solid rgba(255,255,255,.14);
  box-shadow:none;
  font-weight:650;
}
button:active{transform: translateY(1px)}
#saveSettingsBtn:hover{
  transform: scale(1.02);
  box-shadow: 0 12px 35px rgba(102, 126, 234, 0.6);
}
#saveSettingsBtn:active{
  transform: scale(0.98);
}
.msg{
  margin-top:10px;
  padding:10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(255,255,255,.05);
  color: var(--muted);
  font-size:14px;
  min-height:44px;
  display:flex;
  align-items:center;
  gap:10px;
}
.msg.good{border-color: rgba(124,255,178,.35); background: rgba(124,255,178,.08); color: var(--good)}
.msg.bad{border-color: rgba(255,124,158,.35); background: rgba(255,124,158,.08); color: var(--warn)}
.grid2{display:grid; grid-template-columns:1fr 1fr; gap:10px}
.panelTitle{font-weight:800; margin:0 0 8px 0}
.opt{
  padding:12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.20);
}
.opt label{display:flex; gap:10px; align-items:center; justify-content:space-between; color:var(--muted); font-size:14px}
.opt input[type="checkbox"]{transform: scale(1.15)}
select{
  width:100%;
  padding:12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--text);
  outline:none;
}
.stats{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:10px;
}
.stat{
  padding:12px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.10);
  background: rgba(0,0,0,.22);
}
.stat .k{color:var(--muted); font-size:12px}
.stat .v{font-size:20px; font-weight:900; margin-top:4px}
.small{font-size:12px; color:var(--muted)}
.badgeRow{display:flex; gap:8px; flex-wrap:wrap; margin-top:10px}
.badge{
  padding:8px 10px;
  border-radius: 999px;
  border: 1px dashed rgba(255,255,255,.20);
  background: rgba(255,255,255,.06);
  color: var(--muted);
  font-size:13px;
}
.badge.on{border-style: solid; color: var(--text)}
.footerBtns{display:flex; gap:10px; flex-wrap:wrap; margin-top:12px}
.sparkle{
  position: fixed;
  pointer-events:none;
  inset:0;
  overflow:hidden;
}
.sparkle span{
  position:absolute;
  font-size:16px;
  animation: pop 900ms ease-out forwards;
  opacity:0;
}
@keyframes pop{
  0%{transform: translateY(0) scale(.8); opacity:0}
  20%{opacity:1}
  100%{transform: translateY(-80px) scale(1.2); opacity:0}
}
.worldSection{margin-top:16px}
.worldGrid{
  display:grid;
  grid-template-columns: repeat(12, 1fr);
  gap:3px;
  margin-top:10px;
  padding:16px;
  border-radius: 16px;
  background:
    linear-gradient(180deg, rgba(135,206,235,.15) 0%, rgba(124,252,0,.08) 40%, rgba(34,139,34,.12) 100%);
  border: 2px solid rgba(139,69,19,.3);
  min-height:400px;
  max-height:500px;
  overflow-y:auto;
  box-shadow: inset 0 2px 20px rgba(0,0,0,.2);
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
@media (max-width: 600px){
  .worldGrid{
    grid-template-columns: repeat(8, 1fr);
    gap:2px;
    padding:8px;
  }
  .gridCell{font-size:18px}
}
.gridCell{
  aspect-ratio: 1;
  border-radius: 2px;
  border: 1px solid rgba(0,0,0,.2);
  background:
    linear-gradient(135deg, rgba(124,252,0,.3) 0%, rgba(34,139,34,.4) 100%);
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:24px;
  cursor:pointer;
  transition: all 150ms;
  position:relative;
  box-shadow:
    inset -1px -1px 3px rgba(0,0,0,.3),
    inset 1px 1px 2px rgba(255,255,255,.2),
    0 2px 4px rgba(0,0,0,.1);
}
.gridCell:hover{
  transform: translateY(-2px) scale(1.05);
  box-shadow:
    inset -1px -1px 3px rgba(0,0,0,.3),
    inset 1px 1px 2px rgba(255,255,255,.3),
    0 4px 8px rgba(141,187,255,.4);
  border-color: rgba(141,187,255,.6);
}
.gridCell:active{
  transform: translateY(0) scale(0.98);
}
.gridCell.filled{
  background:
    linear-gradient(135deg, rgba(139,69,19,.6) 0%, rgba(101,67,33,.7) 100%);
  border-color: rgba(0,0,0,.4);
  box-shadow:
    inset -2px -2px 4px rgba(0,0,0,.5),
    inset 2px 2px 3px rgba(255,255,255,.1),
    0 3px 6px rgba(0,0,0,.2);
}
.gridCell.filled:hover{
  background:
    linear-gradient(135deg, rgba(139,69,19,.7) 0%, rgba(101,67,33,.8) 100%);
}
.removeBtn{
  position:absolute;
  top:-4px;
  right:-4px;
  width:20px;
  height:20px;
  border-radius:50%;
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  color:#fff;
  font-size:12px;
  display:none;
  align-items:center;
  justify-content:center;
  cursor:pointer;
  font-weight:900;
  box-shadow: 0 2px 8px rgba(255,107,107,.4);
  transition: transform 100ms;
}
.removeBtn:hover{
  transform: scale(1.1);
}
.gridCell.filled:hover .removeBtn{display:flex}

.worldTitle{
  font-size:16px;
  font-weight:800;
  display:flex;
  align-items:center;
  gap:8px;
  color:var(--text);
  text-shadow: 0 2px 4px rgba(0,0,0,.3);
}
.shop{margin-top:12px}
.shopCategories{display:flex; gap:8px; flex-wrap:wrap; margin-bottom:10px}
.categoryTab{
  padding:8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--muted);
  font-size:13px;
  cursor:pointer;
  transition: all 200ms;
}
.categoryTab:hover{background: rgba(255,255,255,.1)}
.categoryTab.active{
  background: linear-gradient(135deg, var(--accent), var(--accent2));
  color:#0b1220;
  border-color: transparent;
  font-weight:700;
}
.categoryTab.locked{
  opacity:.4;
  cursor:not-allowed;
}
.shopItems{
  display:grid;
  grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
  gap:8px;
}
.shopItem{
  padding:10px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(0,0,0,.2);
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:6px;
  cursor:pointer;
  transition: all 200ms;
  position:relative;
}
.shopItem:hover{
  background: rgba(255,255,255,.08);
  border-color: rgba(141,187,255,.4);
  transform: translateY(-2px);
}
.shopItem.selected{
  background: rgba(141,187,255,.15);
  border: 2px solid var(--accent);
  box-shadow: 0 0 20px rgba(141,187,255,.3);
}
.shopItem.locked{
  opacity:.3;
  cursor:not-allowed;
}
.shopItem.locked:hover{transform:none}
.shopItemEmoji{font-size:32px}
.shopItemName{font-size:11px; color:var(--muted)}
.shopItemCost{
  font-size:12px;
  font-weight:700;
  color:var(--good);
  display:flex;
  align-items:center;
  gap:4px;
}
.newBadge{
  position:absolute;
  top:-6px;
  right:-6px;
  background: var(--warn);
  color:#000;
  font-size:9px;
  font-weight:900;
  padding:2px 6px;
  border-radius:999px;
  animation: pulse 2s infinite;
}
.tab .newBadge{
  position:relative;
  top:0;
  right:0;
  margin-left:6px;
  display:inline-block;
}
@keyframes pulse{
  0%, 100%{transform: scale(1)}
  50%{transform: scale(1.1)}
}
.inventoryCount{
  position:absolute;
  bottom:4px;
  right:4px;
  background: rgba(0,0,0,.7);
  color: var(--text);
  font-size:10px;
  font-weight:800;
  padding:2px 5px;
  border-radius:999px;
  min-width:16px;
  text-align:center;
}
.worldEmpty{
  grid-column: 1/-1;
  display:flex;
  flex-direction:column;
  align-items:center;
  justify-content:center;
  gap:8px;
  color:var(--muted);
  font-size:14px;
  padding:40px 20px;
}
.worldEmpty .big{font-size:48px; margin:0}
.tabBar{
  display:flex;
  gap:8px;
  margin-bottom:12px;
  border-bottom:1px solid rgba(255,255,255,.1);
  padding-bottom:8px;
}
.tab{
  padding:8px 14px;
  border-radius: 10px 10px 0 0;
  background: rgba(255,255,255,.06);
  color: var(--muted);
  border:1px solid rgba(255,255,255,.1);
  border-bottom:none;
  cursor:pointer;
  font-size:14px;
  font-weight:600;
  transition: all 200ms;
}
.tab:hover{background: rgba(255,255,255,.1)}
.tab.active{
  background: rgba(141,187,255,.15);
  color: var(--text);
  border-color: rgba(141,187,255,.3);
}
.tabContent{display:none}
.tabContent.active{display:block}
.modalTabContent{display:none}
.modalTabContent.active{display:block}

/* Stickervel styling */
.stickerPage{
  background: #fff;
  border-radius: 0;
  padding:32px;
  box-shadow: none;
  height:100%;
  overflow-y:auto;
}
.stickerPageTitle{
  font-size:32px;
  font-weight:900;
  color:#2d3748;
  margin:0 0 8px 0;
  text-align:center;
}
.stickerPageSub{
  text-align:center;
  color:#718096;
  font-size:15px;
  margin-bottom:28px;
}
.stickerGrid{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap:20px;
  margin-bottom:30px;
  max-width:1200px;
  margin-left:auto;
  margin-right:auto;
}
@media (max-width: 900px){
  .stickerGrid{
    grid-template-columns: repeat(2, 1fr);
    gap:16px;
  }
}
.stickerSlot{
  aspect-ratio: 1;
  border:4px dashed #cbd5e0;
  border-radius: 16px;
  background: #f7fafc;
  display:flex;
  align-items:center;
  justify-content:center;
  position:relative;
  transition: all 300ms;
  overflow:hidden;
  min-height:200px;
}
.stickerSlot.locked{
  background: linear-gradient(135deg, #edf2f7 0%, #e2e8f0 100%);
}
.stickerSlot.unlocked{
  border-style:solid;
  border-color:#48bb78;
  background: #fff;
  box-shadow: 0 6px 16px rgba(72,187,120,.25);
  cursor:pointer;
}
.stickerSlot.unlocked:hover{
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 12px 28px rgba(72,187,120,.35);
}
.stickerSlot img{
  width:85%;
  height:85%;
  object-fit:contain;
  transition: transform 200ms;
}
.stickerSlot.unlocked img:hover{
  transform: scale(1.05);
}
.stickerNumber{
  position:absolute;
  top:8px;
  left:8px;
  background: rgba(0,0,0,.7);
  color:#fff;
  font-size:13px;
  font-weight:800;
  padding:4px 10px;
  border-radius:999px;
  box-shadow: 0 2px 6px rgba(0,0,0,.3);
}
.stickerLock{
  font-size:64px;
  opacity:.25;
}
.newStickerBadge{
  position:absolute;
  top:-8px;
  right:-8px;
  background: linear-gradient(135deg, #ff6b6b, #ee5a6f);
  color:#fff;
  font-size:10px;
  font-weight:900;
  padding:4px 8px;
  border-radius:999px;
  box-shadow: 0 4px 12px rgba(255,107,107,.4);
  animation: bounce 1s infinite;
}
@keyframes bounce{
  0%, 100%{transform: translateY(0)}
  50%{transform: translateY(-4px)}
}
.progressBar{
  background: #e2e8f0;
  border-radius: 999px;
  height:40px;
  overflow:hidden;
  margin-bottom:32px;
  position:relative;
  box-shadow: inset 0 2px 6px rgba(0,0,0,.12);
  max-width:800px;
  margin-left:auto;
  margin-right:auto;
}
.progressFill{
  height:100%;
  background: linear-gradient(90deg, #48bb78, #38a169);
  transition: width 500ms ease-out;
  display:flex;
  align-items:center;
  justify-content:flex-end;
  padding-right:16px;
  color:#fff;
  font-weight:700;
  font-size:15px;
}
.progressText{
  position:absolute;
  top:50%;
  left:50%;
  transform: translate(-50%, -50%);
  font-size:15px;
  font-weight:800;
  color:#2d3748;
  pointer-events:none;
}
/* Sticker Popup */
.stickerPopup{
  display:none;
  position:fixed;
  inset:0;
  background: rgba(0,0,0,.85);
  z-index:2000;
  padding:40px;
  align-items:center;
  justify-content:center;
  animation: fadeIn 200ms;
}
.stickerPopup.show{
  display:flex;
}
@keyframes fadeIn{
  from{opacity:0}
  to{opacity:1}
}
.stickerPopupContent{
  background: #fff;
  border-radius: 24px;
  padding:40px;
  max-width:90vw;
  max-height:90vh;
  overflow:auto;
  position:relative;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
  animation: scaleIn 300ms ease-out;
  display:flex;
  flex-direction:column;
  align-items:center;
}
@keyframes scaleIn{
  from{transform: scale(0.9); opacity:0}
  to{transform: scale(1); opacity:1}
}
.stickerPopupClose{
  position:absolute;
  top:16px;
  right:16px;
  width:44px;
  height:44px;
  border-radius:50%;
  background: #f7fafc;
  border:2px solid #e2e8f0;
  color:#2d3748;
  font-size:28px;
  cursor:pointer;
  display:flex;
  align-items:center;
  justify-content:center;
  transition: all 200ms;
  font-weight:700;
  line-height:1;
  z-index:10;
}
.stickerPopupClose:hover{
  background: #e2e8f0;
  transform: rotate(90deg);
}
.stickerPopupImage{
  width:100%;
  max-width:min(800px, 80vw);
  max-height:70vh;
  margin:0 auto;
  display:block;
  border-radius:16px;
  box-shadow: 0 12px 40px rgba(0,0,0,.25);
  object-fit:contain;
}
.stickerPopupNumber{
  text-align:center;
  font-size:24px;
  font-weight:900;
  color:#2d3748;
  margin-top:20px;
  margin-bottom:8px;
}
.stickerPopupName{
  text-align:center;
  font-size:16px;
  color:#718096;
}
/* Modal specific overrides for readability */
#settingsModal .panelTitle{
  color:var(--text);
}
#settingsModal .sub{
  color:var(--muted);
}
#settingsModal .opt{
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.12);
}
#settingsModal select,
#settingsModal input[type="text"]{
  background: rgba(255,255,255,.08);
  color: var(--text);
  border-color: rgba(255,255,255,.15);
}
#settingsModal .stat{
  background: rgba(255,255,255,.05);
  border-color: rgba(255,255,255,.12);
}
#settingsModal .badge{
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.15);
  color: var(--muted);
}
#settingsModal .badge.on{
  background: rgba(141,187,255,.2);
  border-color: rgba(141,187,255,.4);
  color: var(--accent);
}
/* Login modal */
.loginModal{
  position: fixed;
  inset: 0;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.loginModal.hidden{display:none}
.loginBox{
  background: #fff;
  border-radius: 24px;
  padding: 48px 40px;
  max-width: 440px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,.3);
}
.loginTitle{
  font-size: 32px;
  font-weight: 900;
  color: #2d3748;
  margin: 0 0 8px 0;
  text-align: center;
}
.loginSub{
  text-align: center;
  color: #718096;
  font-size: 15px;
  margin-bottom: 32px;
}
.loginForm{
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.loginForm input{
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: 2px solid #e2e8f0;
  background: #f7fafc;
  color: #2d3748;
  font-size: 16px;
  outline: none;
  transition: all 200ms;
}
.loginForm input:focus{
  border-color: #667eea;
  background: #fff;
}
.loginForm button{
  width: 100%;
  padding: 14px 16px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(135deg, #667eea, #764ba2);
  color: #fff;
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 150ms;
}
.loginForm button:hover{
  transform: translateY(-2px);
}
.loginForm button:active{
  transform: translateY(0);
}
.loginForm button.secondary{
  background: transparent;
  color: #718096;
  border: 2px solid #e2e8f0;
  margin-top: 8px;
}
.loginForm button.secondary:hover{
  background: #f7fafc;
  color: #2d3748;
}
.loginError{
  background: #fff5f5;
  border: 2px solid #fc8181;
  color: #c53030;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  display: none;
}
.loginError.show{display:block}
.loginSuccess{
  background: #f0fff4;
  border: 2px solid #48bb78;
  color: #22543d;
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  display: none;
}
.loginSuccess.show{display:block}
.loginToggle{
  text-align: center;
  margin-top: 20px;
  color: #718096;
  font-size: 14px;
}
.loginToggle a{
  color: #667eea;
  text-decoration: none;
  font-weight: 600;
  cursor: pointer;
}
.loginToggle a:hover{
  text-decoration: underline;
}
.logoutBtn{
  position: fixed;
  top: 20px;
  right: 20px;
  background: rgba(0,0,0,.2);
  border: 1px solid rgba(255,255,255,.2);
  color: var(--text);
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 13px;
  cursor: pointer;
  z-index: 100;
  transition: all 200ms;
}
.logoutBtn:hover{
  background: rgba(0,0,0,.3);
}
.saveIndicator{
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: rgba(0,0,0,.8);
  color: white;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 13px;
  z-index: 1000;
  display: none;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 12px rgba(0,0,0,.3);
}
.saveIndicator.show{
  display: flex;
}
.saveIndicator.success{
  background: #48bb78;
}
.saveIndicator.error{
  background: #fc8181;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.spinner{
  width: 14px;
  height: 14px;
  border: 2px solid rgba(255,255,255,.3);
  border-top-color: white;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}
