:root {
  --bg-1: #16334f;
  --bg-2: #1f4773;
  --panel: #ffffff;
  --accent: #3dd6c6;
  --accent-2: #4ecdc4;
  --gold: #ffc940;
  --warn: #ffb020;
  --danger: #ff5c5c;
  --good: #5ae07b;
  --text-dark: #0c1c2e;
  --text: #e8f1ff;
  --muted: #8aa0c0;
  --border: #3a557a;
}

* { box-sizing: border-box; }

html, body { margin: 0; }

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 800px at 50% -200px, #2a5a8e 0%, var(--bg-1) 60%),
    linear-gradient(180deg, var(--bg-1), #0a1e33 100%);
  color: var(--text);
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
}

#wrap {
  max-width: 1360px;
  margin: 0 auto;
  padding: 14px;
}

/* ---------- HUD ---------- */
.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  background: linear-gradient(180deg, #234a73, #183657);
  border: 2px solid #3a5e89;
  border-radius: 16px;
  padding: 10px 18px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.1),
    0 4px 16px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.brand .logo {
  filter: drop-shadow(0 0 10px rgba(61, 214, 198, 0.4));
}
.brand .title-main {
  font-weight: 900;
  font-size: 22px;
  letter-spacing: 0.02em;
  line-height: 1;
  color: #ffffff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.3);
}
.brand .title-sub {
  color: #a8c5e0;
  font-size: 11px;
  margin-top: 4px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  font-weight: 700;
}

.stats {
  display: flex;
  gap: 10px;
}
.stat-card {
  background: linear-gradient(180deg, #ffffff, #e6eef8);
  border: 2px solid #2a4466;
  border-radius: 12px;
  padding: 6px 14px;
  min-width: 118px;
  text-align: right;
  box-shadow: 0 2px 0 #1a2e48, 0 4px 8px rgba(0, 0, 0, 0.3);
}
.stat-label {
  color: #4a6890;
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-weight: 800;
}
.stat-value {
  font-weight: 900;
  font-size: 18px;
  margin-top: 2px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 6px;
  line-height: 1;
  color: #1c3256;
}
.stars {
  color: #ffb817;
  letter-spacing: 2px;
  font-size: 16px;
  text-shadow: 0 1px 0 rgba(180, 120, 0, 0.4);
}
.stars-num { color: #1c3256; font-size: 14px; }
.credit-value { color: #c9900f; }
.credit-value .coin {
  background: radial-gradient(circle at 30% 30%, #ffe181, #c98b1f);
  color: #7a5410;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  display: inline-grid;
  place-items: center;
  font-size: 11px;
  font-weight: 900;
  box-shadow: inset 0 -1px 1px rgba(0, 0, 0, 0.25), 0 1px 0 #8b6510;
  border: 1px solid #a9780d;
}
.time-value {
  color: #1c3256;
  font-variant-numeric: tabular-nums;
}

/* ---------- Stage / canvas ---------- */
.stage {
  position: relative;
  margin-top: 12px;
}

#game {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 16px;
  border: 3px solid #3a5e89;
  background: #cde2ec;
  box-shadow:
    0 20px 60px rgba(0, 0, 0, 0.55),
    inset 0 0 0 2px rgba(255, 255, 255, 0.15);
}

/* ---------- Tip bar ---------- */
.tip-bar {
  margin-top: 10px;
  padding: 10px 14px;
  color: #c2d8ee;
  font-size: 12px;
  background: rgba(30, 58, 90, 0.65);
  border: 2px solid #3a5e89;
  border-radius: 10px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
}
.tip-bar .key {
  background: linear-gradient(180deg, #f5f9ff, #cfe0f5);
  color: #1c3256;
  padding: 2px 8px;
  border-radius: 6px;
  border: 1px solid #2a4466;
  font-family: ui-monospace, Menlo, monospace;
  font-size: 11px;
  font-weight: 700;
  box-shadow: 0 2px 0 #1a2e48;
}
.tip-bar .sep { color: #3a557a; }

/* ---------- Overlays ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 8, 12, 0.78);
  z-index: 20;
}
.overlay.hidden { display: none; }

.card {
  width: min(440px, 92vw);
  background: linear-gradient(180deg, #ffffff, #e4edf8);
  border: 3px solid #1c3256;
  border-radius: 18px;
  padding: 24px;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6);
  color: #1c3256;
}
.card h2 { margin: 0 0 10px; color: #1c3256; }
.card p { margin: 0 0 18px; color: #4a6890; line-height: 1.5; }
.card button {
  width: 100%;
  padding: 12px 14px;
  border-radius: 12px;
  border: 0;
  background: linear-gradient(180deg, #4ae8d6, #2bb8a8);
  color: #04221f;
  font-weight: 900;
  letter-spacing: 0.04em;
  cursor: pointer;
  box-shadow: 0 3px 0 #0d6b5f;
}
.card button:hover { filter: brightness(1.08); }

/* ---------- Supplier modal ---------- */
.modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(3, 8, 16, 0.68);
  backdrop-filter: blur(3px);
  border-radius: 16px;
  z-index: 15;
  animation: fadeIn 0.14s ease-out;
}
.modal.hidden { display: none; }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.terminal {
  width: 94%;
  max-width: 960px;
  max-height: 92vh;
  background: linear-gradient(180deg, #f4f8fc 0%, #cfdff0 100%);
  border: 3px solid #1c3256;
  border-radius: 16px;
  overflow: hidden;
  box-shadow:
    0 30px 80px rgba(0, 0, 0, 0.6),
    0 4px 0 #0c1c2e;
  color: #1c3256;
  display: flex;
  flex-direction: column;
}
.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  background: linear-gradient(180deg, #2a4a6e, #1c3256);
  border-bottom: 2px solid #0c1c2e;
  color: #e8f1ff;
}
.terminal-title {
  font-weight: 900;
  letter-spacing: 0.18em;
  color: #ffffff;
  font-size: 14px;
  text-shadow: 0 1px 0 rgba(0, 0, 0, 0.3);
}
.close-btn {
  background: #ff6060;
  border: 2px solid #0c1c2e;
  color: #ffffff;
  width: 26px; height: 26px;
  border-radius: 50%;
  font-size: 16px;
  cursor: pointer;
  line-height: 1;
  padding: 0;
  font-weight: 900;
  box-shadow: 0 2px 0 #0c1c2e;
}
.close-btn:hover { filter: brightness(1.08); }

.terminal-body {
  padding: 14px;
  overflow: hidden;
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.term-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
  flex: 0 0 auto;
}
.tab {
  background: #ffffff;
  border: 2px solid #2a4466;
  color: #4a6890;
  padding: 8px 14px;
  border-radius: 10px;
  cursor: pointer;
  font-size: 12px;
  letter-spacing: 0.05em;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  box-shadow: 0 2px 0 #1c3256;
}
.tab.active {
  background: linear-gradient(180deg, #ffd86a, #e8a81a);
  color: #1c3256;
  border-color: #1c3256;
}

.term-content {
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: min-content;
  gap: 10px;
  align-content: start;
}

.product {
  background: linear-gradient(180deg, #ffffff, #e9f1f9);
  border: 2px solid #2a4466;
  border-radius: 12px;
  padding: 8px 10px;
  display: grid;
  grid-template-columns: 56px 1fr;
  gap: 10px;
  align-items: center;
  text-align: left;
  box-shadow: 0 2px 0 #1c3256;
  min-height: 78px;
}
.product-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.product-name {
  font-size: 13px;
  color: #1c3256;
  font-weight: 800;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.product-sub {
  font-size: 10px;
  color: #4a6890;
  font-weight: 600;
  letter-spacing: 0.03em;
}
.product-icon {
  width: 56px;
  height: 56px;
  display: grid;
  place-items: center;
  background: linear-gradient(180deg, #f0f5fa, #d9e5f0);
  border: 1px solid #b7c7da;
  border-radius: 10px;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.15));
}
.product-actions {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 4px;
  flex-wrap: wrap;
}
.qty-btn {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  border: 2px solid #1c3256;
  font-weight: 900;
  font-size: 13px;
  cursor: pointer;
  color: #fff;
  box-shadow: 0 2px 0 #0c1c2e;
  padding: 0;
  line-height: 1;
}
.qty-btn.minus { background: linear-gradient(180deg, #6b97c9, #3f6a9c); }
.qty-btn.plus { background: linear-gradient(180deg, #ff7a7a, #d64444); }
.qty-btn:hover { filter: brightness(1.08); }
.price {
  font-weight: 900;
  color: #c9900f;
  font-size: 14px;
  min-width: 42px;
}
.add-cart {
  background: linear-gradient(180deg, #3ade8a, #27a563);
  color: #0b2b18;
  border: 2px solid #0b2b18;
  padding: 3px 9px;
  border-radius: 6px;
  font-weight: 900;
  font-size: 10px;
  cursor: pointer;
  letter-spacing: 0.07em;
  box-shadow: 0 2px 0 #0b2b18;
  margin-left: auto;
}
.add-cart:hover { filter: brightness(1.08); }

.cart-panel {
  background: linear-gradient(180deg, #ffffff, #e0ecf8);
  border: 2px solid #2a4466;
  border-radius: 12px;
  padding: 12px;
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-shadow: 0 2px 0 #1c3256;
}
.cart-title {
  font-size: 12px;
  letter-spacing: 0.12em;
  color: #1c3256;
  font-weight: 900;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 2px dashed #8aa0c0;
  text-align: center;
}
.cart-items {
  list-style: none;
  padding: 0;
  margin: 0 0 10px;
  font-size: 12px;
  color: #4a6890;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}
.cart-items li {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
  gap: 8px;
  font-weight: 600;
}
.cart-items .price {
  color: #c9900f;
  font-weight: 900;
  font-size: 12px;
}
.cart-empty { font-style: italic; color: #8aa0c0; }
.cart-total {
  display: flex;
  justify-content: space-between;
  font-weight: 900;
  padding: 6px 0;
  border-top: 2px dashed #8aa0c0;
  color: #1c3256;
}
.shipping {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin: 8px 0;
  font-size: 11px;
  color: #4a6890;
  letter-spacing: 0.05em;
  font-weight: 700;
}
.shipping select {
  background: #ffffff;
  color: #1c3256;
  border: 2px solid #2a4466;
  border-radius: 8px;
  padding: 6px 8px;
  font-size: 12px;
  font-weight: 600;
}
.place-order {
  background: linear-gradient(180deg, #3ade8a, #27a563);
  color: #08210f;
  border: 2px solid #0b2b18;
  padding: 12px;
  border-radius: 10px;
  font-weight: 900;
  cursor: pointer;
  letter-spacing: 0.08em;
  box-shadow: 0 3px 0 #0b2b18, 0 6px 18px rgba(39, 165, 99, 0.35);
}
.place-order:hover { filter: brightness(1.08); }
.place-order:disabled { opacity: 0.5; cursor: not-allowed; filter: grayscale(0.3); }

/* scrollbars */
.cart-items::-webkit-scrollbar,
.product-grid::-webkit-scrollbar { width: 8px; }
.cart-items::-webkit-scrollbar-thumb,
.product-grid::-webkit-scrollbar-thumb {
  background: #8aa0c0;
  border-radius: 4px;
}

@media (max-width: 760px) {
  .stats .stat-card { min-width: 90px; padding: 4px 10px; }
  .term-content { grid-template-columns: 1fr; }
  .product-grid { max-height: 220px; }
}
