* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: radial-gradient(1200px 600px at 50% -10%, #fdf7ff 0%, #f2effb 60%, #eae7f7 100%);
  color: #2a2054;
  font-family: 'Fredoka', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  overflow: hidden;
}

#game {
  position: absolute;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  z-index: 0;
}

#ui {
  position: absolute;
  top: 12px;
  left: 12px;
  right: 12px;
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
  z-index: 2;
}

#scoreboard {
  display: flex;
  gap: 8px;
}

.score-item {
  pointer-events: auto;
  background: rgba(255,255,255,0.8);
  color: #2a2054;
  border-radius: 12px;
  padding: 8px 12px;
  box-shadow: 0 8px 24px rgba(32, 0, 93, 0.15);
  display: flex;
  gap: 8px;
  align-items: baseline;
}
.score-item .label {
  opacity: 0.7;
  font-size: 13px;
}
.score-item span:last-child {
  font-weight: 700;
  font-size: 20px;
}

#next-bar {
  pointer-events: auto;
  background: rgba(255,255,255,0.8);
  border-radius: 12px;
  padding: 8px 8px;
  box-shadow: 0 8px 24px rgba(32, 0, 93, 0.15);
  display: flex;
  align-items: center;
  gap: 8px;
}
#next-list {
  display: flex;
  align-items: center;
  gap: 6px;
}
.next-token {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
}

#controls { pointer-events: auto; }
#restart, #play, #shopBtn, #settingsBtn, .settings-actions .primary {
  cursor: pointer;
  border: none;
  background: linear-gradient(180deg, #6b64ff, #4b42e2);
  color: white;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(49, 43, 171, 0.3);
}
#restart:hover, #play:hover, #shopBtn:hover, #settingsBtn:hover, .settings-actions .primary:hover { filter: brightness(1.05); }
#restart:active, #play:active, #shopBtn:active, #settingsBtn:active, .settings-actions .primary:active { filter: brightness(0.95); }

#overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(22, 0, 61, 0.24);
  backdrop-filter: blur(4px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 3;
}
#overlay.show { opacity: 1; pointer-events: auto; }
#overlay .panel {
  background: white;
  color: #2a2054;
  width: min(520px, calc(100vw - 32px));
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(32, 0, 93, 0.3);
}
#overlay h1 { margin: 0 0 8px; }
#overlay p { opacity: 0.8; }

#shopOverlay, #settingsOverlay {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  background: rgba(22, 0, 61, 0.24);
  backdrop-filter: blur(4px);
  z-index: 3;
}
#shopOverlay.show, #settingsOverlay.show { display: grid; }
#settingsOverlay .panel {
  background: white;
  color: #2a2054;
  width: min(720px, calc(100vw - 32px));
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(32, 0, 93, 0.3);
}
#shopOverlay .panel {
  background: white;
  color: #2a2054;
  width: min(720px, calc(100vw - 32px));
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 20px 60px rgba(32, 0, 93, 0.3);
  max-height: min(90vh, calc(100vh - 24px));
  overflow: auto;
}
.shop-header { display: flex; align-items: center; justify-content: space-between; }
.shop-header .ghost { background: transparent; color: #2a2054; box-shadow: none; border: 1px solid rgba(42,32,84,0.2); }
.shop-tabs { display: flex; gap: 8px; margin-top: 12px; }
.shop-tabs .tab { background: rgba(42,32,84,0.08); color: #2a2054; border-radius: 10px; padding: 8px 12px; border: none; cursor: pointer; }
.shop-tabs .tab.active { background: #4b42e2; color: white; }
.shop-content { margin-top: 12px; }
.tab-pane { display: none; }
.tab-pane.active { display: block; }

.shop-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px; }
.shop-card { background: rgba(245,245,255,0.9); border: 1px solid rgba(42,32,84,0.1); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.shop-card h3 { margin: 0; font-size: 16px; }
.shop-card p { margin: 0; opacity: 0.8; font-size: 14px; }
.shop-card .actions { display: flex; gap: 8px; align-items: center; justify-content: space-between; }
.shop-card .price { font-weight: 700; }
.shop-card .btn { cursor: pointer; border: none; border-radius: 10px; padding: 8px 10px; font-weight: 700; }
.shop-card .btn.primary { background: #4b42e2; color: white; }
.shop-card .btn.ghost { background: transparent; color: #2a2054; border: 1px solid rgba(42,32,84,0.2); }
.shop-card .about-content { margin-top: 8px; font-size: 14px; line-height: 1.4; color: #2a2054; }

/* media preview inside shop cards */
.shop-card .media {
  width: 100%;
  aspect-ratio: 1 / 1;
  background: rgba(230, 225, 255, 0.5);
  border: 1px solid rgba(42,32,84,0.08);
  border-radius: 10px;
  overflow: hidden;
  display: grid;
  place-items: center;
}
.shop-card .media canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.settings-content { margin-top: 12px; }
.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.settings-grid .field { background: rgba(245,245,255,0.9); border: 1px solid rgba(42,32,84,0.1); border-radius: 12px; padding: 12px; display: grid; gap: 6px; }
.settings-grid label { font-weight: 600; font-size: 14px; }
.settings-grid input[type='number'], .settings-grid select, .settings-grid input[type='range'] { width: 100%; }
.settings-grid .row { display: flex; gap: 8px; align-items: center; }
.settings-actions { display: flex; align-items: center; margin-top: 12px; }
.settings-actions .spacer { flex: 1; }
.settings-actions .ghost { background: transparent; color: #2a2054; box-shadow: none; border: 1px solid rgba(42,32,84,0.2); border-radius: 10px; padding: 8px 12px; cursor: pointer; }

@media (max-width: 520px) {
  .score-item span:last-child { font-size: 18px; }
  .score-item .label { font-size: 12px; }
} 

/* Mobile responsive UI */
@media (max-width: 720px) {
  #ui {
    gap: 8px;
    align-items: stretch;
    flex-wrap: wrap;
  }
  #scoreboard {
    flex: 1 1 100%;
    order: 1;
  }
  #next-bar {
    order: 2;
    flex: 1 1 100%;
    justify-content: space-between;
  }
  #controls {
    order: 3;
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: space-between;
  }
  #restart, #play, #shopBtn, #settingsBtn {
    padding: 8px 10px;
    font-size: 14px;
    border-radius: 10px;
  }
  .score-item {
    padding: 6px 10px;
  }
  .next-token { width: 24px; height: 24px; font-size: 11px; }
}

@media (max-width: 420px) {
  #ui { top: 8px; left: 8px; right: 8px; }
  #restart, #play, #shopBtn, #settingsBtn { padding: 7px 8px; font-size: 13px; }
  .score-item span:last-child { font-size: 16px; }
} 

/* Standalone pages (shop/about) */
body.standalone-page {
  overflow: auto;
}
.page-bar {
  position: sticky;
  top: 0;
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 12px;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(4px);
  z-index: 10;
}
.page-bar .spacer { flex: 1; }
.page-content { padding: 16px; max-width: 960px; margin: 0 auto; }

/* Generic button for page links */
.btn {
  display: inline-block;
  text-decoration: none;
  cursor: pointer;
  background: linear-gradient(180deg, #6b64ff, #4b42e2);
  color: white;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(49, 43, 171, 0.3);
}
.btn:hover { filter: brightness(1.05); }
.btn:active { filter: brightness(0.95); } 