.comps-shell {
  width: min(1180px, calc(100% - 32px));
}

.comps-main h1 {
  margin: 8px 0 8px;
  font-family: var(--font-display);
  font-size: clamp(2rem, 4vw, 3rem);
  letter-spacing: -0.03em;
  line-height: 1.05;
}

.comps-lede {
  max-width: 62ch;
  color: var(--muted);
  margin: 0 0 18px;
}

.comps-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}

.comps-head {
  align-items: flex-end;
}

.mode-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

.mode-chip {
  --mode: var(--gold);
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid color-mix(in srgb, var(--mode) 45%, var(--line));
  background: color-mix(in srgb, var(--mode) 12%, transparent);
  color: var(--ink);
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
  text-decoration: none;
}

.mode-chip .count {
  font-variant-numeric: tabular-nums;
  font-size: 0.68rem;
  padding: 1px 4px;
  border-radius: 4px;
  background: rgba(0, 0, 0, 0.22);
}

.mode-chip.is-on {
  background: var(--mode);
  border-color: var(--mode);
  color: #140818;
}

.mode-chip[data-mode="story"].is-on,
.mode-chip[data-mode="boss"].is-on,
.mode-chip[data-mode="dojo"].is-on {
  color: #fff;
}

.mode-dot {
  width: 6px;
  height: 6px;
  border-radius: 99px;
  background: var(--mode);
  flex: 0 0 auto;
}

.mode-chip.is-on .mode-dot {
  background: currentColor;
  box-shadow: none;
}

.comps-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.sort-switch {
  display: flex;
  padding: 3px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(14, 7, 24, 0.45);
}

.sort-switch button {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-weight: 700;
  font-size: 0.75rem;
  min-height: 26px;
  padding: 0 10px;
  border-radius: 999px;
  cursor: pointer;
}

.sort-switch button.is-on {
  background: var(--panel-solid);
  color: var(--ink);
}

.comps-search {
  width: 100%;
  margin: 0 0 16px;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(14, 7, 24, 0.45);
  color: var(--ink);
  font: inherit;
}

.comp-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.comp-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  border-left: 4px solid var(--mode, var(--gold));
  background: var(--panel);
  color: inherit;
  text-decoration: none;
}

.comp-card:hover {
  border-color: color-mix(in srgb, var(--mode) 55%, var(--line));
  color: inherit;
}

.comp-card h2 {
  margin: 6px 0 4px;
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.comp-meta {
  color: var(--muted);
  font-size: 0.85rem;
}

.face-row {
  display: flex;
  gap: 4px;
  align-items: center;
  justify-content: flex-end;
}

.face {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--line);
  background: rgba(14, 7, 24, 0.65);
  display: grid;
  place-items: center;
}

.face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.score {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
  min-width: 2.2ch;
  text-align: right;
}

.comps-empty {
  padding: 28px 8px;
  color: var(--muted);
}

.builder-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.builder-panel {
  margin-bottom: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 8px;
}

.panel-head h2,
.picker-panel h2,
.section-kicker {
  margin: 0;
  font-family: var(--font-display);
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.panel-head .count-readout {
  margin-left: auto;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
  color: var(--gold);
}

.panel-head .btn {
  min-height: 32px;
  padding: 0 10px;
  font-size: 0.8rem;
}

.builder-form {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.section-kicker {
  margin-bottom: 10px;
}

.board-block {
  margin-top: 16px;
}

[data-detail].is-missing .mode-option {
  border-color: var(--danger, #ff7a8a);
}

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

.mode-grid-2 {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.mode-option {
  --mode: var(--gold);
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(14, 7, 24, 0.45);
  color: var(--muted);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 700;
  text-align: left;
  cursor: pointer;
}

.mode-option.is-on {
  color: var(--ink);
  border-color: color-mix(in srgb, var(--mode) 75%, var(--line));
  background: color-mix(in srgb, var(--mode) 16%, rgba(14, 7, 24, 0.55));
  box-shadow: inset 3px 0 0 var(--mode);
}

.detail-label {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.submit-comp {
  width: 100%;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.filter-chip {
  min-height: 26px;
  padding: 0 8px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
}

.filter-chip.is-on {
  background: var(--gold);
  border-color: var(--gold);
  color: #1a1020;
}

.picker-panel {
  position: sticky;
  top: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.picker-panel h2 {
  margin: 0 0 10px;
}

.picker-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0;
}

.picker-tools input,
.field input,
.field textarea,
.field select {
  width: 100%;
  min-height: 42px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(14, 7, 24, 0.55);
  color: var(--ink);
  font: inherit;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 12px;
}

.field span,
.board-head p,
.seo-preview {
  color: var(--muted);
  font-size: 0.85rem;
}

.seo-preview strong {
  color: var(--gold);
  font-weight: 700;
}

.picker-list {
  max-height: min(62vh, 560px);
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding-right: 2px;
}

.tatari-pick {
  display: grid;
  touch-action: none;
  cursor: grab;
  user-select: none;
  grid-template-columns: 36px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  width: 100%;
  text-align: left;
  padding: 4px 6px;
  border-radius: 10px;
  border: 1px solid transparent;
  background: transparent;
  color: inherit;
  font: inherit;
  cursor: pointer;
}

.tatari-pick.is-on,
.tatari-pick:hover {
  border-color: var(--line);
  background: rgba(14, 7, 24, 0.4);
}

.tatari-pick img,
.tatari-pick .comp-letter {
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.tatari-pick small {
  color: var(--muted);
}

.tier-pill {
  font-size: 0.72rem;
  font-weight: 800;
  color: var(--gold);
}

.board-wrap {
  display: inline-flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid color-mix(in srgb, var(--mode, var(--gold)) 50%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, var(--mode, var(--gold)) 16%, transparent), transparent 42%),
    rgba(14, 7, 24, 0.35);
}

.comp-board {
  --cell: 58px;
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  gap: 6px;
}

.comp-cell {
  width: var(--cell);
  height: var(--cell);
  padding: 0;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: rgba(14, 7, 24, 0.62);
  color: var(--ink);
  display: grid;
  place-items: center;
  cursor: pointer;
  overflow: hidden;
  touch-action: none;
}

.comp-cell img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.comp-cell.is-drop {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 2px var(--gold);
}

.drag-ghost {
  position: fixed;
  z-index: 50;
  width: 56px;
  height: 56px;
  pointer-events: none;
  border-radius: 10px;
  overflow: hidden;
  transform: translate(-50%, -60%);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
}

.drag-ghost img,
.drag-ghost .comp-letter {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.drag-ghost.is-team-blue { background: color-mix(in srgb, #3aa0e8 30%, #120a18); }
.drag-ghost.is-team-red { background: color-mix(in srgb, #ff5d6c 30%, #120a18); }

body.is-dragging,
body.is-dragging * {
  cursor: grabbing;
}

.comp-cell.is-filled {
  position: relative;
  cursor: grab;
  border-color: var(--el, var(--gold));
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--el, var(--gold)) 55%, transparent);
}

.comp-cell[data-element="Fire"] { --el: #e85d3a; }
.comp-cell[data-element="Water"] { --el: #3aa0e8; }
.comp-cell[data-element="Grass"] { --el: #4cbf6a; }
.comp-cell[data-element="Rock"] { --el: #c4a06a; }
.comp-cell[data-element="Lightning"] { --el: #f0c53a; }

.comp-letter {
  font-family: var(--font-display);
  font-weight: 800;
}

.side-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.side-label.is-blue { color: #8fd0ff; }
.side-label.is-red { color: #ff9aa6; }

.board-wrap.is-blue,
.board-wrap.is-red {
  border-width: 2px;
}

.board-wrap.is-blue {
  border-color: color-mix(in srgb, #3aa0e8 72%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, #3aa0e8 22%, transparent), transparent 48%),
    rgba(14, 7, 24, 0.4);
}

.board-wrap.is-red {
  border-color: color-mix(in srgb, #ff5d6c 72%, var(--line));
  background:
    linear-gradient(180deg, color-mix(in srgb, #ff5d6c 20%, transparent), transparent 48%),
    rgba(14, 7, 24, 0.4);
}

.comp-cell.is-team-blue { --team: #3aa0e8; }
.comp-cell.is-team-red { --team: #ff5d6c; }

.comp-cell.is-team-blue,
.comp-cell.is-team-red {
  background:
    linear-gradient(color-mix(in srgb, var(--team) 30%, transparent), color-mix(in srgb, var(--team) 30%, transparent)),
    rgba(14, 7, 24, 0.62);
  box-shadow: none;
}

.comp-cell.is-team-blue img,
.comp-cell.is-team-red img,
.comp-cell.is-team-blue .comp-letter,
.comp-cell.is-team-red .comp-letter {
  width: 86%;
  height: 86%;
}

.team-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin: 10px 0 14px;
}

.tips-field textarea {
  min-height: 280px;
}

.tips,
.rate-panel {
  margin-top: 18px;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
}

.tips {
  max-width: 72ch;
}

.tips h2,
.rate-panel h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.rate-panel {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  grid-column: 2;
  grid-row: 1 / span 3;
  align-self: center;
  position: static;
  margin-top: 0;
  max-width: none;
}

.rate-panel .score {
  font-size: 1.7rem;
  text-align: center;
  min-width: 0;
}

.rate-panel .comp-meta {
  margin: 0;
  text-align: center;
}

.rate-panel .btn.is-on[data-vote="up"] {
  background: #3aa0e8;
  border-color: #3aa0e8;
  color: #140818;
}

.rate-panel .btn.is-on[data-vote="down"] {
  background: #ff5d6c;
  border-color: #ff5d6c;
  color: #140818;
}

.score.is-negative {
  color: #ff8b96;
}

.boards {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
}

.form-error {
  min-height: 1.2em;
  color: var(--danger);
  font-weight: 700;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 14px;
  color: var(--ink);
}

.view-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 240px;
  column-gap: 28px;
  row-gap: 16px;
  align-items: start;
  border-top: 4px solid var(--mode, var(--gold));
  padding-top: 16px;
}

.view-head,
.boards,
.tips,
.comments,
.view-actions {
  grid-column: 1;
}

.view-head .view-actions {
  margin-top: 8px;
}

.boards-horde {
  flex-wrap: nowrap;
  gap: 4px;
  align-items: flex-start;
}

.boards-horde .board-wrap {
  padding: 6px;
  gap: 4px;
}

.boards-horde .comp-board {
  --cell: 48px;
  gap: 3px;
}

.boards-horde .comp-cell {
  border-radius: 8px;
}

.boards-horde .side-label {
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  gap: 6px;
}

.comments {
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  max-width: 72ch;
}

.comments h2 {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 1rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.comment {
  padding: 10px 0;
  border-top: 1px solid var(--line);
}

.comment p {
  margin: 4px 0 0;
  white-space: pre-wrap;
}

.comment-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}

.comment-form textarea {
  width: 100%;
  min-height: 110px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: rgba(14, 7, 24, 0.55);
  color: var(--ink);
  font: inherit;
  resize: vertical;
}

.view-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 14px 0;
}

.notes {
  white-space: pre-wrap;
  max-width: 70ch;
}

@media (min-width: 760px) {
  .mode-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .mode-grid-2 {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 800px) {
  .view-layout {
    display: flex;
    flex-direction: column;
  }
  .view-head { order: 0; }
  .boards { order: 1; }
  .tips { order: 2; }
  .rate-panel {
    order: 3;
    position: static;
    width: 100%;
  }
  .comments {
    order: 4;
    width: 100%;
    max-width: none;
    align-self: stretch;
  }
  .boards-horde .comp-board { --cell: 42px; }
}

@media (max-width: 900px) {
  .builder-layout {
    grid-template-columns: 1fr;
  }
  .picker-panel {
    position: static;
  }
  .comp-card {
    grid-template-columns: 1fr;
  }
  .face-row {
    justify-content: flex-start;
  }
  .comp-board { --cell: 46px; }
}

@media (max-width: 420px) {
  .comp-board { --cell: 40px; }
}
