:root {
  --bg: #f3efe5;
  --panel: rgba(255, 252, 245, 0.88);
  --panel-border: rgba(89, 64, 37, 0.15);
  --ink: #221a13;
  --muted: #6c6258;
  --accent: #c48d18;
  --accent-strong: #4eaf0a;
  --danger: #9d3412;
  --shadow: 0 20px 60px rgba(47, 28, 7, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(196, 141, 24, 0.18), transparent 22%),
    linear-gradient(180deg, #f8f3e8 0%, #ede7d8 100%);
}

.layout {
  width: min(1200px, calc(100vw - 32px));
  margin: 32px auto 48px;
}

.hero {
  display: grid;
  grid-template-columns: 1.6fr 1fr;
  gap: 24px;
  align-items: stretch;
  margin-bottom: 24px;
}

.eyebrow {
  margin: 0 0 8px;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.85rem;
  color: var(--accent-strong);
}

h1,
h2,
.preview-title {
  font-family: "Trebuchet MS", "Gill Sans", sans-serif;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 3.6rem);
  line-height: 0.95;
}

.lead {
  max-width: 58ch;
  font-size: 1.05rem;
  color: var(--muted);
}

.hero-card,
.panel,
.game-card {
  border: 1px solid var(--panel-border);
  background: var(--panel);
  backdrop-filter: blur(12px);
  border-radius: 24px;
  box-shadow: var(--shadow);
}

.hero-card {
  padding: 24px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.78), rgba(244, 232, 205, 0.95)),
    linear-gradient(180deg, rgba(87, 171, 23, 0.08), transparent);
}

.hero-label {
  margin: 0 0 12px;
  color: var(--muted);
}

.hero-card code {
  white-space: pre-wrap;
  font-size: 0.95rem;
  color: #624917;
}

.panel {
  padding: 24px;
  margin-bottom: 24px;
}

.status-row,
.actions,
.section-head,
.editor-header {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: space-between;
  align-items: center;
}

.status-pill {
  border-radius: 999px;
  padding: 8px 12px;
  background: rgba(78, 175, 10, 0.12);
  color: #275c03;
  font-size: 0.92rem;
}

.status-pill.muted {
  background: rgba(34, 26, 19, 0.06);
  color: var(--muted);
}

label {
  display: block;
  font-weight: 600;
  margin-bottom: 10px;
}

textarea,
input,
button {
  font: inherit;
}

textarea,
input {
  width: 100%;
  border: 1px solid rgba(34, 26, 19, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
}

textarea {
  min-height: 220px;
  resize: vertical;
  margin-bottom: 16px;
}

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: var(--accent-strong);
  color: white;
  cursor: pointer;
  transition: transform 120ms ease, opacity 120ms ease;
}

button.secondary {
  background: #5f4c28;
}

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

button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.hint,
#result-count,
.match-score {
  color: var(--muted);
}

.message-box {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(157, 52, 18, 0.1);
  color: var(--danger);
}

.message-box.hidden {
  display: none;
}

.progress-panel {
  margin-top: 16px;
  padding: 14px 16px;
  border-radius: 14px;
  background: rgba(34, 26, 19, 0.06);
}

.progress-panel.hidden {
  display: none;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  color: var(--ink);
}

.progress-bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(34, 26, 19, 0.1);
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #c48d18, #4eaf0a);
  transition: width 180ms ease;
}

.results {
  display: grid;
  gap: 18px;
}

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

select {
  width: 100%;
  border: 1px solid rgba(34, 26, 19, 0.14);
  border-radius: 14px;
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.92);
  font: inherit;
}

.result-dump {
  margin-top: 16px;
  padding: 14px;
  border-radius: 14px;
  background: rgba(34, 26, 19, 0.06);
  overflow: auto;
  font-size: 0.9rem;
}

.result-dump.hidden {
  display: none;
}

.download-list {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.download-list.hidden {
  display: none;
}

.download-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(34, 26, 19, 0.06);
}

.download-item a {
  color: white;
  background: #4eaf0a;
  text-decoration: none;
  padding: 10px 14px;
  border-radius: 999px;
  white-space: nowrap;
}

.title-review-panel {
  border: 1px solid rgba(196, 141, 24, 0.2);
  background: linear-gradient(180deg, rgba(255, 250, 240, 0.96), rgba(247, 240, 221, 0.98));
}

.title-review-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.title-review-empty {
  margin: 0;
  color: var(--muted);
}

.title-review-item {
  display: grid;
  gap: 10px;
  padding: 14px 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(196, 141, 24, 0.16);
}

.title-review-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
}

.title-review-head strong {
  display: block;
}

.title-review-note {
  margin: 4px 0 0;
  color: var(--muted);
}

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

.title-review-actions select {
  max-width: 100%;
}

.title-review-item .actions {
  margin-top: 2px;
}

.results.empty {
  place-items: center;
  min-height: 120px;
  color: var(--muted);
}

.game-card {
  display: grid;
  grid-template-columns: minmax(320px, 640px) minmax(280px, 1fr);
  gap: 20px;
  padding: 20px;
}

.preview-card {
  min-height: 240px;
  display: grid;
  grid-template-columns: 126px 1fr 180px;
  gap: 22px;
  align-items: center;
  padding: 18px 22px;
  border-radius: 18px;
  background: linear-gradient(180deg, #ffffff 0%, #faf6eb 100%);
  border: 1px solid rgba(196, 141, 24, 0.14);
}

.preview-left {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.image-frame {
  width: 108px;
  height: 136px;
  border-radius: 8px;
  overflow: hidden;
  background: #eff4fa;
  position: relative;
  border: 2px solid rgba(87, 171, 23, 0.24);
}

.image-frame img,
.image-frame .image-fallback {
  width: 100%;
  height: 100%;
}

.image-frame img {
  object-fit: cover;
  display: none;
}

.image-frame.has-image img {
  display: block;
}

.image-frame.has-image .image-fallback {
  display: none;
}

.image-fallback {
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 0.9rem;
}

.source-badge {
  text-decoration: none;
  color: white;
  background: #111;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.76rem;
}

.preview-title {
  color: #d39b0e;
  font-size: clamp(2rem, 3vw, 3rem);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

.preview-subtitle {
  color: #3658aa;
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.1;
}

.preview-title[data-size="md"] {
  font-size: clamp(1.7rem, 2.45vw, 2.35rem);
}

.preview-title[data-size="lg"] {
  font-size: clamp(1.45rem, 2.1vw, 2rem);
}

.preview-title[data-size="xl"] {
  font-size: clamp(1.15rem, 1.75vw, 1.6rem);
}

.preview-meta {
  display: grid;
  gap: 6px;
  font-size: 1.2rem;
  color: var(--accent-strong);
  font-weight: 700;
}

.preview-meta div {
  display: flex;
  gap: 8px;
  align-items: center;
}

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

.cover-picker {
  margin: 14px 0 16px;
}

.match-switcher {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin: 14px 0 12px;
}

.match-switcher select {
  max-width: 100%;
}

.match-search {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: end;
  margin: 0 0 12px;
}

.match-search input {
  max-width: 100%;
}

.cover-picker-head {
  font-size: 0.92rem;
  font-weight: 700;
  margin-bottom: 8px;
}

.cover-options {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(88px, 1fr));
  gap: 10px;
  max-height: 260px;
  overflow: auto;
}

.cover-option {
  border: 2px solid rgba(34, 26, 19, 0.08);
  border-radius: 12px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.7);
  cursor: pointer;
}

.cover-option.active {
  border-color: #4eaf0a;
  box-shadow: 0 0 0 2px rgba(78, 175, 10, 0.12);
}

.cover-option img {
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  display: block;
  border-radius: 8px;
  margin-bottom: 6px;
}

.cover-option span {
  display: block;
  font-size: 0.72rem;
  line-height: 1.2;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
}

.field-grid label {
  margin: 0;
  font-size: 0.92rem;
}

.field-grid input {
  margin-top: 6px;
}

@media (max-width: 980px) {
  .hero,
  .game-card {
    grid-template-columns: 1fr;
  }

  .preview-card {
    grid-template-columns: 108px 1fr;
  }

  .preview-meta {
    grid-column: 1 / -1;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .layout {
    width: min(100vw - 18px, 1200px);
    margin-top: 14px;
  }

  .panel,
  .hero-card,
  .game-card {
    border-radius: 18px;
  }

  .preview-card {
    grid-template-columns: 1fr;
  }

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

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