:root {
  --sg-bg: #07111d;
  --sg-panel: rgba(8, 18, 31, 0.86);
  --sg-panel-strong: rgba(11, 24, 42, 0.95);
  --sg-border: rgba(219, 177, 83, 0.28);
  --sg-gold: #e2b75b;
  --sg-cyan: #50d7ff;
  --sg-text: #f7fbff;
  --sg-muted: #9fb0c7;
  --sg-danger: #ff6b6b;
  --sg-ok: #77f0b2;
  --sg-radius: 14px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--sg-text);
  font-family: Inter, Segoe UI, Arial, sans-serif;
  background: var(--sg-bg);
  overflow-x: hidden;
}

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

button {
  cursor: pointer;
}

.sideguide-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(circle at 18% 12%, rgba(45, 178, 255, 0.22), transparent 28%),
    radial-gradient(circle at 88% 20%, rgba(226, 183, 91, 0.16), transparent 30%),
    linear-gradient(145deg, rgba(4, 9, 16, 0.94), rgba(5, 18, 32, 0.88)),
    url("/assets/mesa.jpg") center/cover no-repeat;
}

.sideguide-bg::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.84), rgba(0, 0, 0, 0.28), rgba(0, 0, 0, 0.76));
  backdrop-filter: blur(2px);
}

.sg-topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px clamp(16px, 3vw, 42px);
  border-bottom: 1px solid rgba(226, 183, 91, 0.28);
  background: rgba(2, 9, 17, 0.78);
  backdrop-filter: blur(16px);
}

.sg-brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--sg-text);
  text-decoration: none;
  font-weight: 900;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.sg-brand img {
  width: 48px;
  height: 48px;
  object-fit: contain;
}

.sg-topbar nav {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow-x: auto;
  scrollbar-width: none;
}

.sg-topbar nav::-webkit-scrollbar {
  display: none;
}

.sg-topbar nav a {
  flex: 0 0 auto;
  color: #dfe9f6;
  text-decoration: none;
  padding: 9px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
}

.sg-app {
  width: min(1480px, calc(100% - 32px));
  margin: 22px auto 48px;
}

.sg-hero-panel,
.sg-panel,
.sg-card-preview,
.sg-matchup-card {
  border: 1px solid var(--sg-border);
  border-radius: var(--sg-radius);
  background: var(--sg-panel);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
  backdrop-filter: blur(16px);
}

.sg-hero-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 24px;
  margin-bottom: 18px;
}

.sg-kicker,
.sg-panel-title p,
.sg-section-title p {
  margin: 0 0 6px;
  color: var(--sg-gold);
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.sg-hero-panel h1,
.sg-section-title h2,
.sg-panel-title h2 {
  margin: 0;
}

.sg-hero-panel h1 {
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 0.94;
  text-transform: uppercase;
}

.sg-meta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.sg-meta-row span,
.sg-meta-row a {
  color: #dce8f5;
  text-decoration: none;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  padding: 8px 12px;
}

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

.sg-primary,
.sg-hero-actions button,
.sg-panel-title button,
.sg-section-title button,
.sg-matchup-actions button,
.sg-row button {
  min-height: 40px;
  border: 1px solid rgba(226, 183, 91, 0.4);
  border-radius: 10px;
  color: var(--sg-text);
  background: linear-gradient(135deg, rgba(226, 183, 91, 0.25), rgba(42, 150, 255, 0.12));
}

.sg-primary {
  color: #06111d;
  font-weight: 900;
  background: linear-gradient(135deg, #ffd778, #60dcff);
}

.sg-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(260px, 0.55fr);
  gap: 18px;
  align-items: start;
}

.sg-panel,
.sg-card-preview {
  padding: 18px;
}

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

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

.sg-deck-panel {
  grid-column: 1;
}

.sg-card-preview {
  position: sticky;
  top: 92px;
  grid-column: 2;
  grid-row: span 3;
}

.sg-preview-frame {
  display: grid;
  place-items: center;
  min-height: 460px;
  border: 1px dashed rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
  overflow: hidden;
}

.sg-preview-frame img {
  width: min(100%, 320px);
  border-radius: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.55);
}

#cardPreviewEmpty {
  display: grid;
  gap: 8px;
  text-align: center;
  color: var(--sg-muted);
}

#cardPreviewEmpty span {
  color: var(--sg-text);
  font-weight: 800;
}

.sg-deck-input {
  width: 100%;
  min-height: 210px;
  resize: vertical;
  padding: 14px;
  color: var(--sg-text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(1, 8, 15, 0.72);
  outline: none;
}

.sg-deck-input:focus,
.sg-modal input:focus,
.sg-modal select:focus,
.sg-matchup-body textarea:focus,
.sg-row input:focus {
  border-color: rgba(80, 215, 255, 0.75);
  box-shadow: 0 0 0 3px rgba(80, 215, 255, 0.12);
}

.sg-help {
  color: var(--sg-muted);
  margin: 10px 0 0;
}

.sg-card-list {
  display: grid;
  gap: 8px;
}

.sg-deck-group {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.sg-deck-group h3 {
  margin: 0;
  padding: 7px 10px;
  color: #07111d;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--sg-gold), #78ddff);
  font-size: 0.78rem;
  font-weight: 950;
  letter-spacing: 0.09em;
}

.sg-card-line {
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.sg-card-line strong {
  color: var(--sg-gold);
  text-align: right;
}

.sg-card-line button {
  width: fit-content;
  max-width: 100%;
  border: 0;
  color: var(--sg-text);
  background: transparent;
  text-align: left;
  padding: 0;
}

.sg-matchups {
  margin-top: 20px;
}

.sg-matchup-list {
  display: grid;
  gap: 12px;
}

.sg-matchup-card {
  overflow: hidden;
}

.sg-matchup-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 18px;
  border: 0;
  color: var(--sg-text);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.055), rgba(255, 255, 255, 0.015));
  text-align: left;
  list-style: none;
}

.sg-matchup-header::-webkit-details-marker {
  display: none;
}

.sg-matchup-header strong {
  font-size: 1.05rem;
}

.sg-tier {
  color: #08121f;
  border-radius: 999px;
  background: var(--sg-gold);
  padding: 5px 9px;
  font-size: 0.8rem;
  font-weight: 900;
}

.sg-meta-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  justify-content: flex-end;
}

.sg-meta-pills span:not(.sg-tier) {
  color: #dce8f5;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  padding: 5px 9px;
  font-size: 0.78rem;
  font-weight: 800;
}

.sg-matchup-body {
  display: none;
  padding: 18px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.sg-matchup-card.is-open .sg-matchup-body,
.sg-matchup-card[open] .sg-matchup-body {
  display: grid;
  gap: 16px;
}

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

.sg-text-box {
  display: grid;
  gap: 8px;
}

.sg-text-box label,
.sg-sidebox-title {
  color: var(--sg-gold);
  font-weight: 900;
}

.sg-text-box textarea {
  min-height: 126px;
  resize: vertical;
  padding: 12px;
  color: var(--sg-text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.18);
}

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

.sg-sidebox {
  display: grid;
  gap: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.16);
}

.sg-row {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr) 38px;
  gap: 8px;
}

.sg-row input {
  min-width: 0;
  height: 38px;
  padding: 8px 10px;
  color: var(--sg-text);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.05);
}

.sg-row button {
  min-height: 38px;
  color: var(--sg-danger);
  background: rgba(255, 107, 107, 0.08);
  border-color: rgba(255, 107, 107, 0.2);
}

.sg-add-line {
  width: fit-content;
  padding: 9px 12px;
}

.sg-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.72);
  backdrop-filter: blur(10px);
}

.sg-modal-card {
  width: min(520px, 100%);
  display: grid;
  gap: 14px;
  padding: 24px;
  border: 1px solid var(--sg-border);
  border-radius: 18px;
  background: rgba(6, 17, 31, 0.96);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.55);
}

.sg-modal-card h2 {
  margin: 0 0 4px;
  font-size: 2rem;
}

.sg-modal label {
  display: grid;
  gap: 7px;
  color: var(--sg-muted);
  font-weight: 700;
}

.sg-modal input,
.sg-modal select {
  height: 46px;
  color: var(--sg-text);
  border: 1px solid rgba(255, 255, 255, 0.13);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.055);
  padding: 0 12px;
}

.sg-modal .sg-primary {
  height: 50px;
  margin-top: 6px;
}

@media (max-width: 980px) {
  .sg-grid,
  .sg-analysis-grid,
  .sg-sideboard-grid {
    grid-template-columns: 1fr;
  }

  .sg-card-preview {
    position: static;
    grid-column: auto;
    grid-row: auto;
  }

  .sg-preview-frame {
    min-height: 260px;
  }

  .sg-preview-frame img {
    width: min(100%, 220px);
  }
}

@media (max-width: 680px) {
  .sg-topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .sg-topbar nav {
    width: 100%;
  }

  .sg-app {
    width: min(100% - 20px, 1480px);
    margin-top: 12px;
  }

  .sg-hero-panel,
  .sg-panel-title,
  .sg-section-title {
    align-items: stretch;
    flex-direction: column;
  }

  .sg-hero-actions {
    justify-content: stretch;
  }

  .sg-hero-actions button {
    width: 100%;
  }
}
