* {
  box-sizing: border-box;
}

:root {
  --bg: #0f141b;
  --panel: #18212c;
  --panel-2: #1d2835;
  --line: #2a3645;
  --text: #ecf2f8;
  --muted: #a9b7c7;
  --primary: #4ea1ff;
  --primary-hover: #78b7ff;
  --success: #33c27f;
  --danger: #ff6b6b;
  --warning: #ffb84d;
  --slot: #131b24;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  --radius: 16px;
  --star: #ffd76a;

  --fire: #ff6b6b;
  --water: #59a8ff;
  --wind: #52d27d;
  --light: #ffd76a;
  --dark: #b27cff;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  font-family: "Segoe UI", "Hiragino Sans", "Yu Gothic UI", sans-serif;
  background: linear-gradient(180deg, #0b1016 0%, #121925 100%);
  color: var(--text);
}

button,
input,
select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.app-shell {
  width: min(1440px, calc(100% - 20px));
  margin: 12px auto 28px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  margin-bottom: 12px;
}

.topbar h1 {
  margin: 0 0 4px;
  font-size: 24px;
  line-height: 1.2;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.topbar-status,
.badge-group {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.badge {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 8px 12px;
  border-radius: 999px;
  background: #162231;
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 13px;
}

.tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.tab-btn {
  flex: 1;
  padding: 12px 14px;
  border: 1px solid var(--line);
  background: #131b24;
  color: var(--text);
  border-radius: 12px;
  cursor: pointer;
  transition: 0.2s ease;
  min-height: 48px;
}

.tab-btn:hover {
  border-color: var(--primary);
}

.tab-btn.active {
  background: var(--primary);
  color: #08111a;
  border-color: var(--primary);
  font-weight: 700;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.page-grid {
  display: grid;
  grid-template-columns: 460px 1fr;
  gap: 14px;
}

.panel {
  background: rgba(24, 33, 44, 0.96);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 16px;
  box-shadow: var(--shadow);
}

.left-panel {
  position: sticky;
  top: 12px;
  align-self: start;
}

.panel h2 {
  margin: 0 0 12px;
  font-size: 20px;
}

.section-label {
  margin: 12px 0 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.input-label {
  display: block;
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 13px;
}

.text-input,
.select-input {
  width: 100%;
  min-height: 48px;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: #101821;
  color: var(--text);
  outline: none;
}

.text-input:focus,
.select-input:focus {
  border-color: var(--primary);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 12px;
}

.form-grid.one-col {
  grid-template-columns: 1fr;
}

.filter-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  margin-top: 12px;
}

.filter-grid.two-col {
  grid-template-columns: 1fr 1fr;
}

.toolbar-row {
  display: flex;
  gap: 10px;
  margin-top: 12px;
}

.toolbar-row.wrap {
  flex-wrap: wrap;
}

.sticky-action-row {
  position: sticky;
  top: 0;
  z-index: 4;
  background: linear-gradient(180deg, rgba(24, 33, 44, 1) 70%, rgba(24, 33, 44, 0));
  padding-top: 4px;
  padding-bottom: 4px;
}

.primary-btn,
.secondary-btn,
.success-btn,
.danger-btn {
  border: none;
  border-radius: 12px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 700;
  transition: 0.2s ease;
  min-height: 48px;
}

.primary-btn {
  background: var(--primary);
  color: #09111b;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

.secondary-btn {
  background: #223142;
  color: var(--text);
}

.secondary-btn:hover {
  background: #2b3d52;
}

.success-btn {
  background: var(--success);
  color: #08160f;
}

.success-btn:hover {
  filter: brightness(1.08);
}

.danger-btn {
  background: var(--danger);
  color: white;
}

.slots {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.compact-slots .slot-card {
  min-height: 128px;
}

.slot-card {
  min-height: 142px;
  border: 1px dashed #3a4b5f;
  border-radius: 14px;
  background: var(--slot);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 10px;
  text-align: center;
  gap: 8px;
  position: relative;
}

.slot-card.filled {
  border-style: solid;
  background: #101a25;
}

.slot-card.leader-slot {
  box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.35);
}

.slot-badge {
  position: absolute;
  left: 6px;
  top: 6px;
  padding: 4px 8px;
  font-size: 11px;
  border-radius: 999px;
  background: #243140;
  color: var(--muted);
  border: 1px solid #33485d;
}

.slot-badge.leader {
  background: rgba(255, 215, 106, 0.12);
  color: var(--star);
  border-color: rgba(255, 215, 106, 0.35);
}

.slot-card img {
  width: 60px;
  height: 60px;
  object-fit: contain;
}

.slot-empty {
  font-size: 28px;
  color: #55687d;
}

.slot-name {
  font-size: 12px;
  line-height: 1.35;
  color: var(--text);
  word-break: break-word;
}

.slot-remove-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  border: none;
  background: rgba(255, 107, 107, 0.12);
  color: #ff8e8e;
  cursor: pointer;
  font-weight: 700;
}

.small-note {
  margin: 10px 0 12px;
  color: var(--muted);
  font-size: 13px;
}

.monster-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  max-height: 60vh;
  overflow: auto;
  padding-right: 2px;
}

.monster-card {
  border: 2px solid var(--line);
  background: var(--panel-2);
  border-radius: 12px;
  padding: 8px 6px;
  text-align: center;
  cursor: pointer;
  transition: 0.15s;
  min-height: 120px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.monster-card:hover {
  transform: translateY(-2px);
  filter: brightness(1.05);
}

.monster-card.disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.25);
}

.monster-card img {
  width: 84px;
  height: 84px;
  object-fit: contain;
  pointer-events: none;
}

.monster-star {
  margin-top: 4px;
  color: var(--star);
  font-size: 11px;
  letter-spacing: 1px;
  min-height: 15px;
  pointer-events: none;
}

.monster-card.element-fire {
  border-color: rgba(255, 107, 107, 0.78);
  box-shadow: inset 0 0 0 1px rgba(255, 107, 107, 0.18);
}

.monster-card.element-water {
  border-color: rgba(89, 168, 255, 0.8);
  box-shadow: inset 0 0 0 1px rgba(89, 168, 255, 0.18);
}

.monster-card.element-wind {
  border-color: rgba(82, 210, 125, 0.8);
  box-shadow: inset 0 0 0 1px rgba(82, 210, 125, 0.18);
}

.monster-card.element-light {
  border-color: rgba(255, 215, 106, 0.84);
  box-shadow: inset 0 0 0 1px rgba(255, 215, 106, 0.2);
}

.monster-card.element-dark {
  border-color: rgba(178, 124, 255, 0.84);
  box-shadow: inset 0 0 0 1px rgba(178, 124, 255, 0.2);
}

.result-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.sort-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.summary-box,
.message-box {
  border: 1px solid var(--line);
  background: #111a24;
  border-radius: 14px;
  padding: 14px;
  margin-bottom: 14px;
  color: var(--text);
  line-height: 1.6;
}

.message-box {
  min-height: 54px;
}

.result-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #111923;
  padding: 14px;
}

.result-top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.result-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-pill {
  background: #1c2a39;
  border: 1px solid #2e4258;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 999px;
  font-size: 13px;
}

.meta-pill.score {
  background: rgba(78, 161, 255, 0.14);
  border-color: rgba(78, 161, 255, 0.35);
}

.team-line {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.team-monster {
  width: 92px;
  text-align: center;
}

.team-monster img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.team-monster-name {
  margin-top: 6px;
  font-size: 12px;
  line-height: 1.35;
}

.team-monster-role {
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.team-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 8px;
}

.divider {
  border: none;
  border-top: 1px solid var(--line);
  margin: 18px 0;
}

.segment-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.segment-btn {
  flex: 1;
  min-height: 46px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #131b24;
  color: var(--text);
  cursor: pointer;
}

.segment-btn.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #08111a;
  font-weight: 700;
}

.empty-state {
  border: 1px dashed #334457;
  border-radius: 14px;
  padding: 28px 16px;
  color: var(--muted);
  text-align: center;
}

.mobile-register-sticky {
  position: static;
}

@media (max-width: 1100px) {
  .page-grid {
    grid-template-columns: 1fr;
  }

  .left-panel {
    position: static;
  }
}

@media (max-width: 768px) {
  .app-shell {
    width: min(100%, calc(100% - 12px));
    margin: 8px auto 20px;
  }

  .topbar {
    flex-direction: column;
    gap: 8px;
    margin-bottom: 10px;
  }

  .topbar h1 {
    font-size: 20px;
  }

  .subtitle {
    font-size: 12px;
  }

  .panel {
    padding: 12px;
    border-radius: 14px;
  }

  .tabs {
    position: sticky;
    top: 0;
    z-index: 20;
    background: linear-gradient(180deg, rgba(11,16,22,0.98) 75%, rgba(11,16,22,0));
    padding-bottom: 6px;
  }

  .tab-btn {
    min-height: 46px;
    padding: 10px 12px;
    font-size: 14px;
  }

  .filter-grid.two-col {
    grid-template-columns: 1fr 1fr;
  }

  .toolbar-row {
    gap: 8px;
  }

  .toolbar-row > button {
    flex: 1 1 calc(50% - 4px);
  }

  .sticky-action-row {
    position: static;
    background: transparent;
    padding-top: 0;
    padding-bottom: 0;
  }

  .mobile-register-sticky {
    position: sticky;
    top: 52px;
    z-index: 10;
    background: linear-gradient(180deg, rgba(24,33,44,1) 82%, rgba(24,33,44,0.96));
    margin: -4px -4px 10px;
    padding: 4px 4px 10px;
    border-bottom: 1px solid rgba(42, 54, 69, 0.8);
  }

  .slots {
    gap: 8px;
  }

  .slot-card,
  .compact-slots .slot-card {
    min-height: 112px;
    padding: 8px;
  }

  .slot-card img {
    width: 52px;
    height: 52px;
  }

  .slot-name {
    font-size: 11px;
  }

  .monster-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    max-height: none;
    overflow: visible;
  }

  .monster-card {
    min-height: 126px;
    padding: 10px 6px;
  }

  .monster-card img {
    width: 88px;
    height: 88px;
  }

  .result-card {
    padding: 12px;
  }

  .team-monster {
    width: 84px;
  }

  .team-monster img {
    width: 58px;
    height: 58px;
  }
}

@media (max-width: 480px) {
  .filter-grid.two-col {
    grid-template-columns: 1fr;
  }

  .toolbar-row > button {
    flex: 1 1 100%;
  }

  .monster-card {
    min-height: 122px;
  }

  .monster-card img {
    width: 82px;
    height: 82px;
  }

  .badge {
    font-size: 12px;
    min-height: 32px;
  }
}