:root {
  color-scheme: dark;
  --ink: #211926;
  --panel: #fff1c7;
  --panel-2: #ffd76a;
  --line: #211926;
  --shadow: #5b335c;
  --sky: #5bd7ff;
  --mint: #63df95;
  --rose: #ff6b8f;
  --violet: #8b6cff;
  --paper: #fff8e6;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    linear-gradient(45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%) 0 0 / 18px 18px,
    linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.06) 75%) 0 0 / 18px 18px,
    #2a2142;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: "Courier New", "Microsoft YaHei", monospace;
  image-rendering: pixelated;
}

button {
  font: inherit;
}

input,
textarea,
select {
  width: 100%;
  color: var(--ink);
  border: 3px solid var(--line);
  background: var(--paper);
  font: inherit;
}

input,
select {
  min-height: 40px;
  padding: 8px;
}

textarea {
  min-height: 86px;
  padding: 8px;
  resize: vertical;
}

.shop-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.admin-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.detail-shell {
  width: min(980px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 36px;
}

.login-shell {
  display: grid;
  place-items: center;
  min-height: 100vh;
  width: min(460px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0;
}

.shop-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding: 18px;
  color: var(--paper);
  border: 4px solid var(--line);
  background: #3d2f62;
  box-shadow: 6px 6px 0 var(--shadow);
}

.status-line {
  margin: 0 0 8px;
  color: var(--mint);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0;
}

.admin-summary {
  margin: 8px 0 0;
  color: var(--panel-2);
  font-size: 13px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 7vw, 64px);
  line-height: 0.95;
  text-shadow: 4px 4px 0 #14101d;
}

.coin-counter {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 8px 12px;
  color: var(--ink);
  font-weight: 900;
  border: 4px solid var(--line);
  background: var(--panel-2);
  box-shadow: 4px 4px 0 #14101d;
}

.coin-counter span {
  width: 14px;
  height: 14px;
  background: var(--mint);
  border: 3px solid var(--line);
  box-shadow: 2px 2px 0 #14101d;
}

.product-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.product-window {
  display: grid;
  grid-template-rows: auto auto 1fr auto auto;
  min-height: 482px;
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shadow);
}

.window-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
  padding: 7px 10px;
  border-bottom: 4px solid var(--line);
  background: var(--panel-2);
  font-size: 14px;
  font-weight: 900;
}

.window-dot {
  width: 14px;
  height: 14px;
  border: 3px solid var(--line);
  background: var(--rose);
}

.product-art {
  display: block;
  width: calc(100% - 22px);
  aspect-ratio: 1 / 1;
  margin: 11px;
  object-fit: cover;
  border: 4px solid var(--line);
  background: var(--paper);
}

.product-info {
  padding: 0 14px 14px;
}

.product-info h2 {
  margin: 2px 0 9px;
  font-size: 22px;
  line-height: 1.15;
}

.product-info p {
  min-height: 48px;
  margin: 0 0 14px;
  color: #574a61;
  font-size: 14px;
  line-height: 1.55;
}

.product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 36px;
}

.product-meta strong {
  font-size: 24px;
}

.product-meta span {
  padding: 5px 8px;
  color: var(--paper);
  border: 3px solid var(--line);
  background: #2f7de1;
  font-size: 13px;
  font-weight: 900;
}

.buy-button {
  width: calc(100% - 22px);
  min-height: 48px;
  margin: 0 11px 11px;
  color: var(--ink);
  cursor: pointer;
  border: 4px solid var(--line);
  background: var(--mint);
  box-shadow: 0 5px 0 #2f8f5e;
  font-size: 18px;
  font-weight: 900;
}

.detail-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: calc(100% - 22px);
  min-height: 40px;
  margin: 0 11px 11px;
  color: var(--ink);
  text-decoration: none;
  border: 4px solid var(--line);
  background: var(--panel-2);
  box-shadow: 0 5px 0 #c6932f;
  font-size: 16px;
  font-weight: 900;
}

.buy-button:hover {
  transform: translateY(2px);
  box-shadow: 0 3px 0 #2f8f5e;
}

.buy-button:active {
  transform: translateY(5px);
  box-shadow: none;
}

.admin-link,
.secondary-button,
.item-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  padding: 8px 12px;
  color: var(--ink);
  text-decoration: none;
  cursor: pointer;
  border: 3px solid var(--line);
  background: var(--panel-2);
  box-shadow: 3px 3px 0 #14101d;
  font-weight: 900;
}

.header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.admin-layout {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 16px;
  align-items: start;
}

.admin-form,
.admin-list-panel,
.password-panel,
.orders-panel {
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shadow);
}

.login-window {
  width: 100%;
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shadow);
}

.login-body {
  display: grid;
  gap: 14px;
  padding: 18px;
}

.login-body h1 {
  color: var(--ink);
  font-size: 36px;
  text-shadow: none;
}

.login-body label {
  display: grid;
  gap: 8px;
  font-weight: 900;
}

.login-body .buy-button,
.login-body .secondary-button {
  width: auto;
  margin: 0;
}

.admin-form {
  display: grid;
  gap: 12px;
}

.admin-form label,
.password-panel label {
  display: grid;
  gap: 6px;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 900;
}

.admin-form .window-top,
.admin-list-panel .window-top,
.password-panel .window-top,
.orders-panel .window-top {
  margin-bottom: 2px;
}

.password-panel {
  display: grid;
  gap: 12px;
  grid-column: 1 / -1;
}

.password-panel .secondary-button {
  margin: 0 14px 14px;
}

.orders-panel {
  grid-column: 1 / -1;
}

.orders-list {
  display: grid;
  gap: 8px;
  padding: 12px;
}

.order-item {
  display: grid;
  grid-template-columns: 1.4fr 1fr auto auto auto;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border: 3px solid var(--line);
  background: var(--paper);
  font-size: 13px;
}

.order-item button {
  min-height: 32px;
  color: var(--ink);
  cursor: pointer;
  border: 3px solid var(--line);
  background: var(--mint);
  font-weight: 900;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  padding: 0 14px;
}

.form-row label {
  padding: 0;
}

.checkbox-line {
  display: flex !important;
  grid-template-columns: none !important;
  align-items: center;
  gap: 8px !important;
}

.checkbox-line input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--mint);
}

.upload-preview {
  display: block;
  width: calc(100% - 28px);
  aspect-ratio: 1 / 1;
  margin: 0 14px;
  object-fit: cover;
  border: 3px solid var(--line);
  background: var(--paper);
}

.admin-actions {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  padding: 0 14px 14px;
}

.admin-actions .buy-button {
  width: auto;
  margin: 0;
}

.admin-product-list {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.admin-item {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 10px;
  border: 3px solid var(--line);
  background: var(--paper);
}

.admin-item.is-offline {
  filter: saturate(0.35);
  opacity: 0.72;
}

.admin-item img {
  width: 76px;
  aspect-ratio: 1 / 1;
  border: 3px solid var(--line);
  background: var(--panel);
  object-fit: cover;
}

.admin-item h2 {
  margin: 0 0 5px;
  font-size: 18px;
  line-height: 1.2;
}

.admin-item p {
  margin: 0 0 8px;
  color: #574a61;
  font-size: 13px;
  line-height: 1.4;
}

.admin-item strong {
  margin-right: 10px;
  font-size: 18px;
}

.admin-item span {
  padding: 3px 6px;
  color: var(--paper);
  border: 2px solid var(--line);
  background: #2f7de1;
  font-size: 11px;
  font-weight: 900;
}

.item-actions {
  display: grid;
  gap: 8px;
}

.item-actions button {
  min-width: 64px;
  min-height: 34px;
  padding: 6px 8px;
  font-size: 13px;
}

.item-actions button[data-action="delete"] {
  background: var(--rose);
}

.empty-state {
  grid-column: 1 / -1;
  margin: 0;
  padding: 28px;
  color: var(--paper);
  border: 4px solid var(--line);
  background: #3d2f62;
  box-shadow: 6px 6px 0 var(--shadow);
  font-weight: 900;
  text-align: center;
}

.detail-window {
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shadow);
}

.checkout-window {
  border: 4px solid var(--line);
  background: var(--panel);
  box-shadow: 6px 6px 0 var(--shadow);
}

.detail-body {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.checkout-body {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(0, 1fr);
  gap: 18px;
  padding: 18px;
}

.checkout-form label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  font-weight: 900;
}

.delivery-box {
  border: 4px solid var(--line);
  background: var(--paper);
  padding: 12px;
}

.delivery-box pre {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font: inherit;
}

.pickup-note {
  margin: 0;
  color: var(--paper);
  line-height: 1.7;
}

.pickup-body {
  display: grid;
  gap: 12px;
  padding: 18px;
}

.pickup-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
}

.pickup-card {
  display: grid;
  grid-template-columns: 140px minmax(0, 1fr);
  gap: 14px;
  padding: 12px;
  border: 3px solid var(--line);
  background: var(--paper);
}

.pickup-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 3px solid var(--line);
  background: var(--panel);
}

.pickup-card h2 {
  margin: 0 0 8px;
  font-size: 24px;
}

.pickup-card p {
  margin: 0 0 10px;
  line-height: 1.6;
}

.pickup-actions {
  display: grid;
  grid-template-columns: minmax(0, 220px) minmax(0, 180px);
  gap: 10px;
  align-items: stretch;
  margin-top: 12px;
}

.pickup-actions .buy-button,
.pickup-actions .secondary-button {
  width: 100%;
}

.detail-art {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 4px solid var(--line);
  background: var(--paper);
}

.detail-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.detail-info .status-line {
  color: #2f7de1;
}

.detail-info h2 {
  margin: 0 0 12px;
  font-size: 36px;
  line-height: 1.05;
}

.detail-info p {
  margin: 0 0 16px;
  color: #574a61;
  font-size: 16px;
  line-height: 1.65;
}

.detail-price {
  margin: auto 0 14px;
  font-size: 40px;
  font-weight: 900;
}

.detail-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-list {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
}

.detail-list span {
  padding: 8px 10px;
  border: 3px solid var(--line);
  background: var(--paper);
  font-size: 14px;
  font-weight: 900;
}

.detail-tags span {
  padding: 5px 8px;
  color: var(--paper);
  border: 3px solid var(--line);
  background: #2f7de1;
  font-size: 13px;
  font-weight: 900;
}

.detail-actions {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 10px;
}

.detail-actions .buy-button,
.detail-actions .secondary-button {
  width: auto;
  margin: 0;
}

.detail-actions .buy-button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.6;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 5;
  max-width: min(360px, calc(100vw - 32px));
  padding: 12px 14px;
  color: var(--paper);
  border: 4px solid var(--line);
  background: #3d2f62;
  box-shadow: 5px 5px 0 #14101d;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: opacity 120ms linear, transform 120ms linear;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

@media (max-width: 980px) {
  .product-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .admin-layout {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  html {
    background:
      linear-gradient(45deg, rgba(255, 255, 255, 0.06) 25%, transparent 25%) 0 0 / 14px 14px,
      linear-gradient(45deg, transparent 75%, rgba(255, 255, 255, 0.06) 75%) 0 0 / 14px 14px,
      #2a2142;
  }

  .shop-shell {
    width: min(100% - 16px, 430px);
    padding: 8px 0 22px;
  }

  .admin-shell {
    width: min(100% - 16px, 430px);
    padding: 8px 0 22px;
  }

  .shop-header {
    align-items: center;
    flex-direction: row;
    gap: 10px;
    margin-bottom: 10px;
    padding: 10px;
    border-width: 3px;
    box-shadow: 4px 4px 0 var(--shadow);
  }

  .status-line {
    margin-bottom: 4px;
    font-size: 10px;
    line-height: 1.2;
  }

  h1 {
    font-size: 30px;
    text-shadow: 3px 3px 0 #14101d;
  }

  .coin-counter {
    flex: 0 0 auto;
    min-height: 32px;
    padding: 6px 8px;
    border-width: 3px;
    box-shadow: 3px 3px 0 #14101d;
    font-size: 13px;
  }

  .header-actions {
    flex: 0 0 auto;
    gap: 6px;
  }

  .admin-link {
    min-height: 32px;
    padding: 6px 8px;
    font-size: 12px;
  }

  .coin-counter span {
    width: 11px;
    height: 11px;
    border-width: 2px;
  }

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

  .product-window {
    display: grid;
    grid-template-columns: 106px minmax(0, 1fr);
    grid-template-rows: auto 1fr auto auto;
    min-height: 0;
    border-width: 3px;
    box-shadow: 4px 4px 0 var(--shadow);
  }

  .window-top {
    grid-column: 1 / -1;
    min-height: 28px;
    padding: 4px 8px;
    border-bottom-width: 3px;
    font-size: 12px;
  }

  .window-dot {
    width: 11px;
    height: 11px;
    border-width: 2px;
  }

  .product-art {
    grid-column: 1;
    grid-row: 2 / 4;
    width: 90px;
    margin: 8px;
    border-width: 3px;
  }

  .product-info {
    grid-column: 2;
    grid-row: 2;
    min-width: 0;
    padding: 8px 8px 0 0;
  }

  .product-info h2 {
    margin: 0 0 5px;
    font-size: 18px;
    line-height: 1.2;
  }

  .product-info p {
    min-height: 0;
    margin-bottom: 8px;
    font-size: 12px;
    line-height: 1.45;
  }

  .product-meta {
    min-height: 28px;
  }

  .product-meta strong {
    font-size: 20px;
  }

  .product-meta span {
    padding: 3px 6px;
    border-width: 2px;
    font-size: 11px;
  }

  .buy-button {
    grid-column: 2;
    grid-row: 3;
    width: auto;
    min-height: 38px;
    margin: 6px 8px 8px 0;
    border-width: 3px;
    box-shadow: 0 4px 0 #2f8f5e;
    font-size: 15px;
  }

  .detail-button {
    grid-column: 2;
    grid-row: 4;
    width: auto;
    min-height: 34px;
    margin: 0 8px 8px 0;
    border-width: 3px;
    box-shadow: 0 4px 0 #c6932f;
    font-size: 14px;
  }

  .toast {
    right: 8px;
    bottom: 8px;
    max-width: calc(100vw - 16px);
    padding: 10px;
    border-width: 3px;
    box-shadow: 4px 4px 0 #14101d;
    font-size: 13px;
  }

  .admin-layout {
    gap: 10px;
  }

  .admin-form,
  .admin-list-panel {
    border-width: 3px;
    box-shadow: 4px 4px 0 var(--shadow);
  }

  .admin-form {
    gap: 10px;
  }

  .admin-form label {
    padding: 0 10px;
    font-size: 12px;
  }

  .upload-preview {
    width: calc(100% - 20px);
    margin: 0 10px;
  }

  input,
  select {
    min-height: 36px;
    padding: 7px;
  }

  textarea {
    min-height: 74px;
  }

  .form-row {
    padding: 0 10px;
    gap: 8px;
  }

  .admin-actions {
    grid-template-columns: 1fr;
    padding: 0 10px 10px;
  }

  .admin-product-list {
    padding: 8px;
  }

  .admin-item {
    grid-template-columns: 68px minmax(0, 1fr);
    gap: 8px;
    padding: 8px;
  }

  .admin-item img {
    width: 62px;
  }

  .admin-item h2 {
    font-size: 16px;
  }

  .admin-item p {
    font-size: 12px;
  }

  .item-actions {
    grid-column: 1 / -1;
    grid-template-columns: repeat(3, 1fr);
  }

  .item-actions button {
    min-width: 0;
  }

  .order-item {
    grid-template-columns: 1fr;
  }

  .detail-shell {
    width: min(100% - 16px, 430px);
    padding: 8px 0 22px;
  }

  .detail-window,
  .checkout-window {
    border-width: 3px;
    box-shadow: 4px 4px 0 var(--shadow);
  }

  .detail-body,
  .checkout-body {
    grid-template-columns: 1fr;
    gap: 10px;
    padding: 10px;
  }

  .pickup-search,
  .pickup-card {
    grid-template-columns: 1fr;
  }

  .pickup-note {
    color: var(--ink);
    background: var(--panel);
    border: 3px solid var(--line);
    padding: 8px;
  }

  .pickup-actions {
    grid-template-columns: 1fr;
  }

  .detail-art {
    border-width: 3px;
  }

  .detail-info h2 {
    font-size: 26px;
  }

  .detail-info p {
    font-size: 13px;
  }

  .detail-price {
    margin-top: 0;
    font-size: 32px;
  }

  .detail-actions {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 360px) {
  .shop-shell {
    width: min(100% - 12px, 360px);
  }

  .shop-header {
    padding: 8px;
  }

  h1 {
    font-size: 26px;
  }

  .coin-counter {
    font-size: 12px;
  }

  .product-window {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .product-art {
    width: 78px;
    margin: 7px;
  }

  .product-info h2 {
    font-size: 16px;
  }

  .product-info p {
    font-size: 11px;
  }
}
