*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
:root {
  --bg: #0a0a0f;
  --surface: #111118;
  --surface2: #1a1a24;
  --border: #2a2a3a;
  --green: #4ade80;
  --green-dk: #16a34a;
  --green-bg: #052e16;
  --red-bg: #3b0a0a;
  --red: #f87171;
  --amber: #f59e0b;
  --amber-bg: #2d1f00;
  --text: #f1f5f9;
  --muted: #64748b;
  --radius: 14px;
}
body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, sans-serif;
  min-height: 100vh;
}
/* ── HEADER ── */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 16px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}
.header-logo {
  font-size: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-width: 40px;
  min-height: 40px;
}
.tiny-spinner {
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
.header-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}
.header-sub {
  font-size: 11px;
  color: var(--muted);
  margin-top: 2px;
}
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
}
.badge {
  font-size: 11px;
  color: var(--green);
  background: var(--green-bg);
  border: 1px solid var(--green-dk);
  padding: 4px 12px;
  border-radius: 999px;
}
#cart-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  font-weight: 600;
  padding: 8px 18px;
  border-radius: var(--radius);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: border-color .2s;
}
#cart-btn:hover {
  border-color: var(--green);
}
#cart-count {
  background: var(--green);
  color: #0a0a0f;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 999px;
  display: none;
}
/* ── PAGES ── */
.page {
  display: none;
}
.page.active {
  display: block;
}
/* ── MAIN ── */
main {
  max-width: 1050px;
  margin: 0 auto;
  padding: 48px 24px;
}
/* ── LOADING / ERROR ── */
#loading-screen {
  text-align: center;
  padding: 100px 0;
}
#loading-screen p {
  color: var(--muted);
  font-size: 15px;
  margin-top: 16px;
}
.big-spinner {
  display: inline-block;
  width: 48px;
  height: 48px;
  border: 4px solid var(--surface2);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
.tiny-spinner {
  display: inline-block;
  width: 24px;
  height: 24px;
  border: 2px solid var(--surface2);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.input-error {
  border-color: var(--red) !important;
  background: var(--red-bg) !important;
}

#error-screen {
  display: none;
  text-align: center;
  padding: 100px 0;
}
#error-screen .e-icon {
  font-size: 52px;
  margin-bottom: 16px;
}
#error-screen h3 {
  font-size: 18px;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 8px;
}
#error-screen p {
  color: var(--muted);
  font-size: 13px;
  margin-bottom: 24px;
}
.btn-retry {
  background: var(--green);
  color: #0a0a0f;
  font-weight: 700;
  font-size: 14px;
  border: none;
  border-radius: var(--radius);
  padding: 12px 28px;
  cursor: pointer;
}
.btn-retry:hover {
  background: #86efac;
}
/* ── STORE ── */
#store-panel {
  display: none;
}
.category {
  margin-bottom: 48px;
}
.cat-header {
  display: flex;
  align-items: baseline;
  gap: 12px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 12px;
  margin-bottom: 20px;
}
.cat-name {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
}
.cat-desc {
  font-size: 13px;
  color: var(--muted);
}
.cat-count {
  margin-left: auto;
  font-size: 11px;
  color: var(--muted);
}
.pkg-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 18px;
}
/* ── PACKAGE CARD ── */
.pkg-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: border-color .2s, box-shadow .2s;
}
.pkg-card:hover {
  border-color: var(--green);
  box-shadow: 0 0 18px rgba(74, 222, 128, .08);
}
/* Owned card — greyed out, no green hover */
.pkg-card.pkg-owned {
  opacity: 0.5;
  filter: grayscale(0.4);
}
.pkg-card.pkg-owned:hover {
  border-color: var(--border);
  box-shadow: none;
}
.pkg-card.pkg-ineligible:hover {
  border-color: var(--border);
  box-shadow: none;
}
.pkg-ineligible-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--amber);
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.pkg-img {
  width: 100%;
  border-radius: 10px;
  object-fit: cover;
  max-height: 130px;
  display: block;
}
.pkg-placeholder {
  width: 100%;
  height: 100px;
  border-radius: 10px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}
.pkg-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.pkg-name {
  font-weight: 700;
  font-size: 15px;
}
/* Owned badge on card */
.pkg-owned-badge {
  font-size: 10px;
  font-weight: 700;
  color: var(--muted);
  background: var(--surface2);
  border: 1px solid var(--border);
  padding: 2px 8px;
  border-radius: 999px;
  letter-spacing: 0.04em;
  flex-shrink: 0;
}
.pkg-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
}
.pkg-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex-wrap: wrap;
}
/* Price block */
.pkg-price {
  margin-right: auto;
  min-width: 80px;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.price-main {
  font-size: 17px;
  font-weight: 700;
  color: var(--green);
  line-height: 1;
}
/* Owned card price is muted */
.pkg-owned .price-main {
  color: var(--muted);
}
.price-original {
  font-size: 10px;
  color: var(--muted);
  text-decoration: line-through;
  line-height: 1;
}
.price-upgrade-label {
  font-size: 9px;
  color: var(--muted);
  letter-spacing: 0.03em;
  line-height: 1;
  margin-top: 1px;
}
.btn-action {
  font-weight: 700;
  font-size: 12px;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  flex-shrink: 0;
}
.btn-add {
  font-weight: 700;
  font-size: 12px;
  border: none;
  border-radius: 10px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background .15s, opacity .15s;
  flex-shrink: 0;
}
.btn-add.add {
  background: var(--green);
  color: #0a0a0f;
}
.btn-add.add:hover {
  background: #86efac;
}
.btn-add.in-cart {
  background: var(--surface2);
  color: var(--green);
  border: 1px solid var(--green-dk);
}
.btn-add.in-cart:hover {
  background: var(--red-bg);
  color: var(--red);
  border-color: var(--red);
}
/* Owned "Thank You" button */
.btn-add.owned-btn {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: default;
  font-size: 11px;
}
.btn-view {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-view:hover {
  border-color: var(--green);
  background: var(--surface);
}
/* View Modal */
#view-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  z-index: 500;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#view-overlay.open {
  display: flex;
}
#view-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .6);
  position: relative;
}
#view-modal .v-icon {
  font-size: 48px;
  margin-bottom: 16px;
}
#view-modal h3 {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 12px;
}
#view-modal .view-price {
  font-size: 16px;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 4px;
}
#view-modal .view-price-original {
  font-size: 12px;
  color: var(--muted);
  text-decoration: line-through;
  margin-bottom: 4px;
}
#view-modal .view-upgrade-note {
  font-size: 11px;
  color: var(--muted);
  margin-bottom: 20px;
}
#view-modal .view-desc {
  font-size: 14px;
  color: var(--text);
  line-height: 1.8;
  margin-bottom: 28px;
  white-space: pre-wrap;
  word-break: break-word;
}
#view-modal .modal-actions {
  display: flex;
  gap: 12px;
}
#view-modal .modal-actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 14px;
  cursor: pointer;
  transition: background .15s;
}
#btn-view-add {
  background: var(--green);
  color: #0a0a0f;
}
#btn-view-add:hover:not(:disabled) {
  background: #86efac;
}
#btn-view-add:disabled {
  background: var(--surface2);
  color: var(--muted);
  border: 1px solid var(--border);
  cursor: default;
}
#btn-view-close {
  background: var(--surface2);
  color: var(--text);
  border: 1px solid var(--border);
}
#btn-view-close:hover {
  border-color: var(--green);
}
.empty {
  text-align: center;
  padding: 80px 0;
  color: var(--muted);
}
.empty .e-icon {
  font-size: 52px;
  margin-bottom: 12px;
}
/* ── CART PAGE ── */
#page-cart {
  max-width: 1050px;
  margin: 0 auto;
  padding: 48px 24px;
}
.cart-page-header {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 36px;
}
.btn-back {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  padding: 8px 16px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: border-color .2s;
}
.btn-back:hover {
  border-color: var(--green);
}
.cart-page-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
}
.cart-layout {
  display: grid;
  grid-template-columns: 1fr 320px;
  gap: 28px;
  align-items: start;
}
@media (max-width: 720px) {
  .cart-layout {
    grid-template-columns: 1fr;
  }
}
.cart-items-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.cart-empty-msg {
  text-align: center;
  padding: 60px 0;
  color: var(--muted);
}
.cart-empty-msg .e-icon {
  font-size: 48px;
  margin-bottom: 12px;
}
.cart-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color .3s;
}
.cart-item.owned {
  border-color: var(--amber);
  background: var(--amber-bg);
}
.cart-item.checking {
  opacity: .6;
}
.cart-item-img {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}
.cart-item-placeholder {
  width: 64px;
  height: 64px;
  border-radius: 10px;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  flex-shrink: 0;
}
.cart-item-info {
  flex: 1;
  min-width: 0;
}
.cart-item-name {
  font-weight: 700;
  font-size: 15px;
  margin-bottom: 4px;
}
.cart-item-price {
  font-size: 14px;
  color: var(--green);
  font-weight: 600;
}
.owned-tag {
  display: inline-block;
  margin-left: 8px;
  font-size: 11px;
  color: var(--amber);
  background: rgba(245, 158, 11, .15);
  border: 1px solid var(--amber);
  padding: 2px 8px;
  border-radius: 999px;
  font-weight: 600;
  vertical-align: middle;
}
.cart-item-remove {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color .15s, background .15s;
  flex-shrink: 0;
}
.cart-item-remove:hover {
  color: var(--red);
  background: var(--red-bg);
}
/* Checkout panel */
.checkout-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  position: sticky;
  top: 90px;
}
.checkout-panel h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--green);
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.summary-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 8px;
}
.summary-row.total {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}
.summary-row.total span:last-child {
  color: var(--green);
}
.field-label {
  font-size: 11px;
  color: var(--muted);
  margin: 20px 0 6px;
  display: block;
}
.username-wrap {
  position: relative;
}
#cart-username {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
}
#cart-username:focus {
  border-color: var(--green);
}
#cart-username::placeholder {
  color: var(--muted);
}
#check-status {
  font-size: 11px;
  margin-top: 6px;
  min-height: 18px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.btn-primary {
  width: 100%;
  padding: 14px;
  background: var(--green);
  border: none;
  border-radius: var(--radius);
  color: #0a0a0f;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
  margin-top: 16px;
}
.btn-primary:hover {
  background: #86efac;
}
.btn-primary:disabled {
  opacity: .5;
  cursor: not-allowed;
}
#checkout-error {
  background: var(--red-bg);
  border: 1px solid #7f1d1d;
  color: var(--red);
  font-size: 12px;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 12px;
  display: none;
}
#owned-warning {
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  color: var(--amber);
  font-size: 12px;
  border-radius: 10px;
  padding: 10px 14px;
  margin-top: 12px;
  display: none;
  line-height: 1.5;
}
/* Success modal */
#success-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .8);
  z-index: 300;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#success-overlay.open {
  display: flex;
}
#success-modal {
  background: var(--surface);
  border: 1px solid var(--green-dk);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .6);
}
#success-modal .s-icon {
  font-size: 56px;
  margin-bottom: 16px;
}
#success-modal h3 {
  font-size: 20px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
}
#success-modal p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 28px;
  line-height: 1.6;
}
#btn-go-pay {
  display: block;
  width: 100%;
  padding: 15px;
  background: var(--green);
  color: #0a0a0f;
  font-weight: 700;
  font-size: 15px;
  border-radius: var(--radius);
  text-decoration: none;
  margin-bottom: 12px;
  transition: background .15s;
}
#btn-go-pay:hover {
  background: #86efac;
}
#btn-keep-shopping {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
}
#btn-keep-shopping:hover {
  color: var(--text);
}
/* Spinner */
.spinner {
  display: inline-block;
  width: 13px;
  height: 13px;
  border: 2px solid rgba(0, 0, 0, .25);
  border-top-color: #0a0a0f;
  border-radius: 50%;
  animation: spin .6s linear infinite;
  vertical-align: middle;
  margin-right: 5px;
}
.spinner-sm {
  display: inline-block;
  width: 11px;
  height: 11px;
  border: 2px solid var(--border);
  border-top-color: var(--green);
  border-radius: 50%;
  animation: spin .6s linear infinite;
}
footer {
  border-top: 1px solid var(--border);
  text-align: center;
  padding: 24px;
  font-size: 12px;
  color: var(--muted);
}
footer span {
  color: var(--green);
}
/* Login Modal */
#login-overlay {
  display: flex;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .6);
  z-index: 400;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
#login-overlay.hidden {
  display: none;
}
#login-modal {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 40px 36px;
  width: 100%;
  max-width: 360px;
  text-align: center;
  box-shadow: 0 16px 60px rgba(0, 0, 0, .6);
}
#login-modal .l-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 64px;
}
#login-modal h2 {
  font-size: 22px;
  font-weight: 700;
  color: var(--green);
  margin-bottom: 8px;
}
#login-modal p {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 24px;
  line-height: 1.5;
}
#login-username {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 14px;
  color: var(--text);
  outline: none;
  transition: border-color .2s;
  margin-bottom: 16px;
}
#login-username:focus {
  border-color: var(--green);
}
#login-username::placeholder {
  color: var(--muted);
}
.btn-login {
  width: 100%;
  padding: 14px;
  background: var(--green);
  border: none;
  border-radius: var(--radius);
  color: #0a0a0f;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  transition: background .15s;
}
.btn-login:hover {
  background: #86efac;
}
.btn-login:disabled {
  opacity: .5;
  cursor: not-allowed;
}
.btn-login .spinner {
  border-color: rgba(10, 10, 15, .25);
  border-top-color: #0a0a0f;
}
@media (max-width: 480px) {
  main,
  #page-cart {
    padding: 32px 16px;
  }
}