:root {
  color-scheme: light;
  --bg: #f6f0e8;
  --paper: #fffaf3;
  --paper-strong: #fffdf8;
  --ink: #2d241d;
  --muted: #76695f;
  --line: #e5d7c7;
  --accent: #8f4d2d;
  --accent-dark: #6f321b;
  --danger: #9d2d2d;
  --shadow: 0 20px 55px rgba(70, 45, 26, 0.14);
  --radius: 22px;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 15% 0%, rgba(207, 143, 85, 0.22), transparent 34rem),
    radial-gradient(circle at 90% 10%, rgba(126, 73, 38, 0.14), transparent 28rem),
    var(--bg);
  color: var(--ink);
}

button, input, textarea, select { font: inherit; }

button { cursor: pointer; }

a { color: var(--accent-dark); }

.hero {
  max-width: 1180px;
  margin: 0 auto;
  padding: 42px 22px 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 360px);
  gap: 22px;
  align-items: stretch;
}

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

h1 {
  margin-bottom: 12px;
  font-size: clamp(2.3rem, 5vw, 5rem);
  line-height: 0.92;
  letter-spacing: -0.07em;
}

h2 { margin-bottom: 8px; font-size: clamp(1.25rem, 2.5vw, 1.7rem); }

h3 { margin-bottom: 8px; }

.hero-text {
  max-width: 620px;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.55;
}

.eyebrow {
  margin-bottom: 10px;
  color: var(--accent-dark);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

.muted { color: var(--muted); font-size: 0.95rem; }

.login-card, .panel, .toolbar, .empty, .modal-card {
  border: 1px solid rgba(229, 215, 199, 0.82);
  background: rgba(255, 250, 243, 0.86);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow);
  border-radius: var(--radius);
}

.login-card {
  padding: 18px;
  align-self: center;
}

.login-card label {
  display: block;
  margin-bottom: 9px;
  font-weight: 800;
}

.login-row {
  display: flex;
  gap: 8px;
}

.login-row input { min-width: 0; }

.container {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 22px 64px;
}

.tabs {
  max-width: 1180px;
  margin: 0 auto 18px;
  padding: 0 22px;
  display: flex;
  gap: 10px;
}

.tab {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 11px 18px;
  background: rgba(255, 250, 243, 0.72);
  color: var(--muted);
  font-weight: 800;
}

.tab.active {
  background: var(--ink);
  border-color: var(--ink);
  color: #fffaf3;
}

.tab-panel { display: none; }
.tab-panel.active { display: block; }

.panel {
  padding: 22px;
  margin-bottom: 20px;
}

.add-panel {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(260px, 1.1fr);
  gap: 18px;
  align-items: start;
}

.add-form {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px 13px;
  background: var(--paper-strong);
  color: var(--ink);
  outline: none;
}

textarea { resize: vertical; }

input:focus, textarea:focus, select:focus {
  border-color: rgba(143, 77, 45, 0.62);
  box-shadow: 0 0 0 4px rgba(143, 77, 45, 0.12);
}

.button {
  border: 0;
  border-radius: 14px;
  padding: 12px 16px;
  background: var(--accent);
  color: white;
  font-weight: 850;
  transition: transform .14s ease, background .14s ease, opacity .14s ease;
}

.button:hover { transform: translateY(-1px); background: var(--accent-dark); }
.button:disabled { cursor: not-allowed; opacity: 0.55; transform: none; }

.button.secondary {
  border: 1px solid var(--line);
  background: var(--paper-strong);
  color: var(--ink);
}

.button.secondary:hover { background: #f5eadf; }

.button.danger { background: var(--danger); }
.button.danger:hover { background: #7f2020; }

.manual-add {
  grid-column: 1 / -1;
  border-top: 1px solid var(--line);
  padding-top: 14px;
}

.manual-add summary {
  cursor: pointer;
  font-weight: 850;
  color: var(--accent-dark);
}

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

.form-grid.compact { margin-top: 14px; }

.form-grid label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.92rem;
  font-weight: 800;
}

.form-grid label > input,
.form-grid label > textarea,
.form-grid label > select {
  color: var(--ink);
  font-weight: 500;
}

.wide { grid-column: 1 / -1; }

.toolbar {
  margin: 18px 0;
  padding: 18px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.toolbar h2 { margin-bottom: 4px; }

.sort-controls {
  display: flex;
  gap: 12px;
  align-items: end;
}

.sort-controls label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-weight: 800;
  font-size: 0.88rem;
}

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

.game-card, .preorder-card {
  position: relative;
  overflow: hidden;
  min-height: 318px;
  border: 1px solid rgba(229, 215, 199, 0.9);
  border-radius: 24px;
  background: var(--paper);
  box-shadow: 0 14px 34px rgba(70, 45, 26, 0.11);
  transition: transform .16s ease, box-shadow .16s ease;
}

.game-card:hover, .preorder-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 18px 44px rgba(70, 45, 26, 0.16);
}

.card-button {
  width: 100%;
  height: 100%;
  padding: 0;
  border: 0;
  background: transparent;
  text-align: left;
  color: inherit;
}

.cover {
  width: 100%;
  height: 190px;
  background: linear-gradient(135deg, #d6b08c, #876149);
  display: grid;
  place-items: center;
  color: rgba(255,255,255,.9);
  font-size: 0.95rem;
  font-weight: 900;
}

.cover img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.card-content { padding: 14px; }

.card-content h3 {
  min-height: 48px;
  font-size: 1.05rem;
  line-height: 1.25;
}

.badges {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  margin: 10px 0;
}

.badge {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 9px;
  background: #fffdf8;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 850;
}

.badge.strong { color: var(--accent-dark); }

.card-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
  font-size: 0.82rem;
}

.empty {
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(45, 36, 29, 0.42);
}

.modal.hidden { display: none; }

.modal-card {
  width: min(880px, 100%);
  max-height: min(90vh, 980px);
  overflow: auto;
  padding: 24px;
  position: relative;
  background: var(--paper);
}

.icon-button {
  border: 0;
  border-radius: 50%;
  background: #f4e7d8;
  color: var(--ink);
  width: 40px;
  height: 40px;
  font-size: 1.5rem;
  line-height: 1;
}

.close-modal {
  position: absolute;
  right: 18px;
  top: 18px;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.upload-row input { padding: 10px; }
.upload-row .button { margin-top: 4px; }

.toast {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 40;
  max-width: min(460px, calc(100vw - 36px));
  border-radius: 18px;
  padding: 14px 16px;
  background: var(--ink);
  color: #fffaf3;
  box-shadow: var(--shadow);
  font-weight: 750;
}

.hidden { display: none !important; }

.preorder-card { min-height: 250px; }
.preorder-card .cover { height: 130px; }

.payment-list {
  margin: 10px 0 0;
  padding-left: 18px;
  color: var(--muted);
  font-size: 0.9rem;
}

body:not(.is-admin) .admin-only { opacity: 0.52; }
body:not(.is-admin) .admin-only input,
body:not(.is-admin) .admin-only textarea,
body:not(.is-admin) .admin-only select,
body:not(.is-admin) .admin-only button { pointer-events: none; }

@media (max-width: 820px) {
  .hero { grid-template-columns: 1fr; padding-top: 28px; }
  .add-panel { grid-template-columns: 1fr; }
  .add-form { flex-direction: column; }
  .toolbar { align-items: stretch; flex-direction: column; }
  .sort-controls { flex-direction: column; align-items: stretch; }
  .form-grid { grid-template-columns: 1fr; }
  .wide { grid-column: auto; }
  .login-row { flex-direction: column; }
}
