/* --------------------------------------------------
   Global reset & base layout
-------------------------------------------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 16px;
  font-family: sans-serif;
  background: #000;
  color: #fff;
}

main {
  max-width: 1200px;
  margin: 0 auto;
}

/* --------------------------------------------------
   Header
-------------------------------------------------- */

.page-header {
  display: flex;
  justify-content: center;
}

.title-image {
  display: block;
  width: min(100%, 700px);
  height: auto;
}

/* --------------------------------------------------
   Sections & panels
-------------------------------------------------- */

section {
  margin-bottom: 24px;
}

.upgrades,
.shop {
  padding: 16px;
  border: 2px solid #a855f7;
  border-radius: 14px;
  background: linear-gradient(
    to bottom,
    rgb(168 85 247 / 0.22),
    rgb(168 85 247 / 0)
  );
  box-shadow:
    0 0 0 1px rgb(168 85 247 / 0.15),
    0 0 24px rgb(168 85 247 / 0.12);
}

.upgrades h2,
.shop h2 {
  margin-top: 0;
  margin-bottom: 12px;
  color: #f5e9ff;
}

/* --------------------------------------------------
   Controls
-------------------------------------------------- */

.controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) 30px;
  gap: 12px;
  margin: 16px 0 24px;
  align-items: end;
}

.field {
  min-width: 0;
}

.field label,
.field-title {
  display: block;
  margin-bottom: 4px;
  font-weight: 600;
}

.field input,
.field select {
  width: 100%;
  background: #111;
  color: #fff;
  border: 1px solid #7e22ce;
  border-radius: 8px;
  padding: 8px 10px;
}

.field input::placeholder {
  color: #bbb;
}

.help-mark {
  color: #d8b4fe;
  text-decoration-line: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  cursor: help;
}

.reset-button {
  margin-top: -8px;
  margin-left: auto;
  display: block;
  padding: 6px 12px;
  border-radius: 999px;
  border: 1px solid #a855f7;
  background: transparent;
  color: #f5e9ff;
  font-size: 0.85rem;
  cursor: pointer;
}

.reset-button:hover {
  background: rgb(168 85 247 / 0.15);
}

.reset-button:active {
  background: rgb(168 85 247 / 0.25);
}

/* Nothing? curse control */

.curse-field {
  width: max-content;
  justify-self: start;
}

.curse-control {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
}

.curse-control img {
  display: block;
  width: 32px;
  height: 32px;
  object-fit: contain;
  background: transparent;
}

.curse-control input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: #a855f7;
  margin: 0;
}

.visually-hidden-label {
  visibility: hidden;
}

/* Responsive controls grid */

@media (max-width: 1000px) {
  .controls {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (max-width: 700px) {
  .controls {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 500px) {
  .controls {
    grid-template-columns: 1fr;
  }
}

/* --------------------------------------------------
   Upgrades grid & cards
-------------------------------------------------- */

.upgrade-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 12px;
}

.upgrade-card {
  padding: 0;
  border: 0;
  background: transparent;
  cursor: pointer;
  position: relative;
  color: #fff;
}

.upgrade-card img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: contain;
  background: transparent;
  border: 0;
}

.upgrade-cost {
  position: absolute;
  right: 6px;
  bottom: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 700;
}

.upgrade-card.not-yet-available,
.upgrade-card.missing-prerequisite {
  opacity: 0.55;
}

.upgrade-card.owned {
  background: #1d4ed8;
}

.upgrade-card.fully-owned {
  outline: 2px solid #93c5fd;
}

.upgrade-owned {
  position: absolute;
  top: 6px;
  left: 6px;
  padding: 2px 6px;
  border-radius: 6px;
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  font-size: 0.8rem;
}

/* --------------------------------------------------
   Tooltip
-------------------------------------------------- */

.upgrade-tooltip {
  position: fixed;
  top: 0;
  left: 0;
  z-index: 1000;
  max-width: 280px;
  padding: 10px 12px;
  border: 1px solid #a855f7;
  background: #111;
  color: #fff;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  border-radius: 8px;
  font-size: 14px;
}

.upgrade-tooltip[hidden] {
  display: none;
}

.upgrade-tooltip h3 {
  margin: 0 0 6px;
  font-size: 16px;
}

.upgrade-tooltip p {
  margin: 4px 0;
}

/* --------------------------------------------------
   Shop
-------------------------------------------------- */

.shop {
  margin-top: 2rem;
}

.shop-money {
  margin: 0.5rem 0 1rem;
  font-weight: 700;
}

.shop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.75rem;
}

.shop-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4rem;
  padding: 0.75rem;
  border: 1px solid #444;
  border-radius: 10px;
  background: transparent;
  color: #fff;
}

.shop-card img {
  display: block;
  width: 84px;
  height: 84px;
  object-fit: contain;
  background: transparent;
}

.shop-name,
.shop-cost {
  color: #fff;
}

.shop-card.selected {
  background: #2563eb;
  border-color: #93c5fd;
}

.shop-card.unaffordable {
  background: #7f1d1d;
  border-color: #ef4444;
}

.shop-name {
  text-align: center;
  font-size: 0.9rem;
}

.shop-cost {
  font-weight: 700;
}

.shop-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.shop-header-info {
  display: grid;
}

.shop-actions {
  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.shop-money-field {
  width: 220px;
}

.shop-money-field input {
  width: 100%;
}



/* --------------------------------------------------
   Footer & extras
-------------------------------------------------- */

.page-footer {
  margin-top: 28px;
  padding-top: 12px;
  text-align: center;
  color: #c084fc;
  border-top: 1px solid rgba(168, 85, 247, 0.35);
}

.bottom-gif {
  margin-top: 24px;
  display: flex;
  justify-content: center;
}

.bottom-gif img {
  display: block;
  max-width: min(100%, 320px);
  height: auto;
}

.page-footer a,
.page-credit a {
  color: #d8b4fe;
  text-decoration: underline;
}

.page-footer a:hover,
.page-credit a:hover {
  color: #f5d0fe;
}

.footer-note {
  margin: 10px 0 0;
  color: #e9d5ff;
  font-size: 0.75rem;
}

.top-actions {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  flex-wrap: wrap;
}

.purchase-button,
.help-button,
.reset-button {
  padding: 10px 16px;
  border: 2px solid #a855f7;
  border-radius: 10px;
  background: rgba(32, 16, 48, 0.92);
  color: #f3e8ff;
  font-weight: 700;
  margin-top: -8px;
}

.purchase-button:hover,
.help-button:hover,
.reset-button:hover {
  background: rgba(56, 24, 88, 0.96);
}

.purchase-button:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(10, 6, 20, 0.7);
  z-index: 1000;
}

.modal-panel {
  width: min(680px, 100%);
  border: 2px solid #a855f7;
  border-radius: 16px;
  background: rgba(24, 12, 40, 0.98);
  color: #f5ecff;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.45);
  padding: 20px;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 16px;
}

.modal-header h2 {
  margin: 0;
}

.modal-close {
  width: 40px;
  height: 40px;
  border: 2px solid #a855f7;
  border-radius: 10px;
  background: rgba(40, 18, 62, 0.95);
  color: #f3e8ff;
  font-size: 1.25rem;
  line-height: 1;
}

.modal-close:hover {
  background: rgba(64, 28, 97, 0.98);
}

.modal-content {
  display: grid;
  gap: 12px;
  color: #ead9ff;
}

.modal-content p {
  margin: 0;
  line-height: 1.6;
}

[hidden] {
  display: none !important;
}

.demo-figure {
  margin: 8px 0 0;
  padding: 12px;
}

.demo-gif {
  display: block;
  width: 100%;
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid rgba(232, 217, 255, 0.2);
  background: rgba(12, 8, 20, 0.9);
}

.demo-figure figcaption {
  margin-top: 10px;
  color: #d8c4f8;
  font-size: 0.95rem;
  line-height: 1.5;
}