:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --line: #dfe4ea;
  --text: #1f2933;
  --muted: #667085;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --warn-bg: #fff7ed;
  --warn-line: #fed7aa;
  --warn-text: #9a3412;
  --bad-bg: #fff1f2;
  --bad-line: #fecdd3;
  --bad-text: #be123c;
  --ok-bg: #ecfdf5;
  --ok-line: #a7f3d0;
  --ok-text: #047857;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--text);
}

button,
a {
  font: inherit;
}

.page {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 28px 0 48px;
}

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

.eyebrow,
.section-label {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 30px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 0;
  font-size: 22px;
  line-height: 1.25;
}

h3 {
  margin-bottom: 8px;
  font-size: 18px;
  line-height: 1.3;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 6px 12px;
  border: 1px solid var(--ok-line);
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok-text);
  font-size: 14px;
  white-space: nowrap;
}

.badge.bad {
  border-color: var(--bad-line);
  background: var(--bad-bg);
  color: var(--bad-text);
}

.notice {
  margin-bottom: 16px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.notice.warn {
  border-color: var(--warn-line);
  background: var(--warn-bg);
  color: var(--warn-text);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.06);
}

.player-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  margin-bottom: 18px;
  padding: 18px;
}

.muted,
.hint {
  color: var(--muted);
}

.player-info {
  display: grid;
  grid-template-columns: repeat(2, minmax(130px, 1fr));
  gap: 10px;
  min-width: 320px;
}

.player-info div {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.player-info span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.player-info strong {
  display: block;
  margin-top: 3px;
  overflow-wrap: anywhere;
}

.catalog {
  min-width: 0;
}

.mall-section {
  margin-top: 18px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.ghost-button,
.ghost-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 36px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
}

.ghost-button:hover,
.ghost-link:hover {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.product-search-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 0 0 14px;
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1 1 360px;
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.search-box span {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--text);
  font: inherit;
}

.product-count {
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

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

.points-panel {
  display: grid;
  gap: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.points-summary {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.points-summary div {
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.points-summary span,
.points-form label {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.points-summary strong {
  display: block;
  margin-top: 4px;
  font-size: 20px;
}

.points-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(120px, auto) minmax(120px, auto);
  gap: 10px;
  align-items: end;
}

.points-form label {
  grid-column: 1 / -1;
}

.points-form input {
  min-height: 44px;
  min-width: 0;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--text);
  font: inherit;
}

.pay-type-field {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.pay-type-field span {
  color: var(--muted);
  font-size: 13px;
}

.pay-type-field select {
  width: 100%;
  min-height: 44px;
  min-width: 0;
  padding: 0 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  font: inherit;
}

.points-cost {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  color: var(--muted);
  white-space: nowrap;
}

.product-card {
  display: grid;
  grid-template-rows: auto auto minmax(42px, 1fr) auto;
  gap: 10px;
  width: 100%;
  min-height: 190px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  text-align: left;
}

.product-card:hover,
.product-card.highlighted {
  border-color: var(--primary);
  box-shadow: 0 10px 22px rgba(15, 118, 110, 0.14);
}

.product-head {
  display: grid;
  gap: 6px;
}

.product-head strong {
  font-size: 17px;
  line-height: 1.3;
}

.price {
  color: #b45309;
  font-size: 24px;
  font-weight: 800;
}

.meta,
.reward {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.primary-button {
  width: 100%;
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.primary-button:hover:not(:disabled) {
  background: var(--primary-dark);
}

.primary-button:disabled {
  background: #98a2b3;
  cursor: not-allowed;
}

.buy-button {
  align-self: end;
}

.tier-note {
  align-self: end;
  min-height: 44px;
  display: flex;
  align-items: center;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.hint {
  margin: 10px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.result {
  margin-top: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.result.ok {
  border-color: var(--ok-line);
  background: var(--ok-bg);
}

.result.bad {
  border-color: var(--bad-line);
  background: var(--bad-bg);
}

.result h3 {
  margin-bottom: 10px;
}

.result dl {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 8px 10px;
  margin: 0;
}

.result dt {
  color: var(--muted);
}

.result dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.result a {
  color: var(--primary-dark);
}

.result-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.result-actions .ghost-button,
.result-actions .primary-button {
  width: 100%;
}

.redirect-note {
  margin: 12px 0 10px;
  color: var(--ok-text);
  font-size: 13px;
  line-height: 1.5;
}

.payment-link {
  width: 100%;
}

.payment-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 23, 42, 0.52);
}

.payment-modal-backdrop[hidden] {
  display: none;
}

.payment-modal {
  width: min(520px, 100%);
  max-height: calc(100vh - 40px);
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 22px 60px rgba(15, 23, 42, 0.28);
}

.payment-modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.payment-modal-head h3 {
  margin-bottom: 0;
}

.modal-close-button {
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
  cursor: pointer;
}

.modal-close-button:hover:not(:disabled) {
  border-color: var(--primary);
  color: var(--primary-dark);
}

.modal-close-button:disabled {
  cursor: not-allowed;
  opacity: 0.7;
}

.payment-summary {
  display: grid;
  grid-template-columns: 100px minmax(0, 1fr);
  gap: 8px 10px;
  margin: 0 0 14px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
}

.payment-summary dt {
  color: var(--muted);
}

.payment-summary dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 700;
}

.modal-payment-choices {
  display: grid;
  gap: 10px;
}

.modal-payment-choice {
  display: grid;
  gap: 4px;
  width: 100%;
  min-height: 62px;
  padding: 11px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.modal-payment-choice:hover:not(:disabled),
.modal-payment-choice.selected {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.12);
}

.modal-payment-choice.selected strong {
  color: var(--primary-dark);
}

.modal-payment-choice:disabled {
  color: var(--muted);
  cursor: not-allowed;
  opacity: 0.72;
}

.modal-payment-choice strong {
  font-size: 15px;
  line-height: 1.25;
}

.modal-payment-choice span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.modal-payment-error {
  margin-top: 12px;
  padding: 10px 12px;
  border: 1px solid var(--bad-line);
  border-radius: 8px;
  background: var(--bad-bg);
  color: var(--bad-text);
  font-weight: 700;
  line-height: 1.45;
}

.payment-modal-actions {
  display: grid;
  grid-template-columns: minmax(0, 140px) minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
}

.payment-modal-actions .primary-button,
.payment-modal-actions .ghost-button {
  width: 100%;
}

.empty {
  padding: 22px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--muted);
}

.empty.error {
  border-color: var(--bad-line);
  color: var(--bad-text);
}

.primary-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  padding: 0 18px;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 860px) {
  .player-panel {
    grid-template-columns: 1fr;
  }

  .player-info {
    min-width: 0;
    grid-template-columns: 1fr;
  }

  .points-summary,
  .points-form,
  .result-actions,
  .payment-modal-actions {
    grid-template-columns: 1fr;
  }

  .payment-summary {
    grid-template-columns: 86px minmax(0, 1fr);
  }
}

@media (max-width: 560px) {
  .page {
    width: min(100% - 20px, 1180px);
    padding-top: 18px;
  }

  .topbar,
  .section-head,
  .product-search-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .search-box {
    flex-basis: auto;
    width: 100%;
  }

  h1 {
    font-size: 26px;
  }

  .product-grid {
    grid-template-columns: 1fr;
  }
}
