* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
}

/* --- Header --- */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #333;
  background: #16162a;
}

h1 {
  font-size: 1.2rem;
  color: #00d4ff;
}

.cylinder-select {
  display: flex;
  gap: 6px;
}

.btn {
  padding: 6px 16px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #2a2a3e;
  color: #ccc;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn:hover { border-color: #00d4ff; color: #fff; }
.btn.active { background: #00d4ff; color: #1a1a2e; border-color: #00d4ff; font-weight: bold; }

/* --- Main 2-pane layout --- */
.main {
  display: flex;
  height: calc(100vh - 53px);
}

/* --- Left pane --- */
.left-pane {
  width: 300px;
  min-width: 300px;
  border-right: 1px solid #333;
  display: flex;
  flex-direction: column;
  background: #1e1e34;
}

.filter-box {
  padding: 8px;
  border-bottom: 1px solid #333;
}

.filter-box input {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #2a2a3e;
  color: #fff;
  font-size: 0.9rem;
  outline: none;
}

.filter-box input:focus { border-color: #00d4ff; }

.sort-toggle {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.sort-btn {
  flex: 1;
  padding: 4px 0;
  border: 1px solid #444;
  border-radius: 4px;
  background: #2a2a3e;
  color: #888;
  cursor: pointer;
  font-size: 0.78rem;
  text-align: center;
  transition: all 0.2s;
}

.sort-btn:hover { border-color: #00d4ff; color: #ccc; }
.sort-btn.active { background: #00d4ff; color: #1a1a2e; border-color: #00d4ff; font-weight: bold; }

.card-list {
  flex: 1;
  overflow-y: auto;
}

.card-row {
  display: flex;
  align-items: center;
  padding: 8px 10px;
  cursor: pointer;
  border-bottom: 1px solid #2a2a3e;
  transition: background 0.15s;
  gap: 8px;
}

.card-row:hover { background: #2a2a4e; }
.card-row:active { background: #3a3a5e; }
.card-row.selected { background: #1a3a5e; border-left: 3px solid #00d4ff; }

.card-row .card-number {
  color: #888;
  font-size: 0.8rem;
  min-width: 72px;
}

.card-row .card-name {
  flex: 1;
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-row .card-rarity {
  font-size: 0.7rem;
  padding: 1px 5px;
  border-radius: 3px;
}

/* --- Right pane --- */
.right-pane {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  padding: 16px;
}

.selected-section { margin-bottom: 16px; }

.selected-section h3,
.result-section h3 {
  font-size: 0.95rem;
  color: #aaa;
  margin-bottom: 8px;
}

.result-section h3 { color: #00d4ff; }

.selected-cards {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.selected-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: #2a2a3e;
  border: 1px solid #444;
  border-radius: 6px;
  font-size: 0.85rem;
}

.selected-item .item-num {
  color: #00d4ff;
  font-weight: bold;
  min-width: 22px;
}

.selected-item .item-number { color: #888; }
.selected-item .item-name { flex: 1; }

.selected-item .remove {
  cursor: pointer;
  color: #888;
  font-size: 1.1rem;
  line-height: 1;
  padding: 0 2px;
}

.selected-item .remove:hover { color: #ff4444; }

.selected-empty {
  color: #555;
  font-size: 0.85rem;
  padding: 8px 0;
}

/* --- Rarity badges --- */
.rarity-C { background: #555; color: #ddd; }
.rarity-R { background: #1565c0; color: #fff; }
.rarity-M { background: #e65100; color: #fff; }
.rarity-P { background: #6a1b9a; color: #fff; }
.rarity-U { background: #c62828; color: #fff; }
.rarity-LE { background: #ffd600; color: #000; }

/* --- Result --- */
.result-content { min-height: 50px; }

.match-card {
  background: #2a2a3e;
  border: 1px solid #444;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
}

.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.match-array {
  font-size: 1.2rem;
  font-weight: bold;
  color: #00d4ff;
}

.match-position { color: #aaa; font-size: 0.9rem; }

.match-message {
  text-align: center;
  padding: 16px;
  color: #aaa;
  font-size: 0.95rem;
}

.match-message.error { color: #ff6b6b; }
.match-message.multi { color: #ffd93d; }
.match-message.waiting { color: #555; }

.upcoming-table {
  width: 100%;
  font-size: 0.85rem;
  border-collapse: collapse;
}

.upcoming-table th {
  text-align: left;
  padding: 4px 6px;
  color: #888;
  border-bottom: 1px solid #444;
  font-weight: normal;
}

.upcoming-table td {
  padding: 4px 6px;
  border-bottom: 1px solid #333;
}

.upcoming-table .pos { color: #666; width: 30px; }
.upcoming-table .num { color: #888; width: 80px; }

.upcoming-table .highlight-row {
  background: rgba(0, 212, 255, 0.15);
  border-left: 3px solid #00d4ff;
}

.upcoming-table .highlight-row td {
  color: #fff;
  font-weight: bold;
}

/* P/U/LE row highlights in upcoming table */
.upcoming-table .row-rare td { font-weight: bold; }

.upcoming-table .row-rare-P {
  background: rgba(106, 27, 154, 0.25);
  border-left: 3px solid #ce93d8;
}
.upcoming-table .row-rare-P td { color: #ce93d8; }

.upcoming-table .row-rare-U {
  background: rgba(198, 40, 40, 0.25);
  border-left: 3px solid #ef5350;
}
.upcoming-table .row-rare-U td { color: #ef5350; }

.upcoming-table .row-rare-LE {
  background: rgba(255, 214, 0, 0.2);
  border-left: 3px solid #ffd600;
}
.upcoming-table .row-rare-LE td { color: #ffd600; }

/* --- P/U rare section --- */
.pu-section {
  margin-top: 10px;
  border-top: 1px solid #444;
  padding-top: 8px;
}

.pu-header {
  font-size: 0.85rem;
  color: #e040fb;
  font-weight: bold;
  margin-bottom: 6px;
}

.pu-list {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.pu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  font-size: 0.82rem;
  background: #222240;
  border-radius: 4px;
}

.pu-item .pu-dist {
  font-size: 0.75rem;
  font-weight: bold;
  min-width: 56px;
  color: #aaa;
}

.pu-item .pu-pos { color: #666; min-width: 30px; }
.pu-item .pu-number { color: #888; min-width: 72px; }
.pu-item .pu-name { flex: 1; }

/* P/U/LE item highlights in pu list */
.pu-item-P { border-left: 3px solid #ce93d8; }
.pu-item-P .pu-dist { color: #ce93d8; }
.pu-item-P .pu-name { color: #ce93d8; }

.pu-item-U { border-left: 3px solid #ef5350; }
.pu-item-U .pu-dist { color: #ef5350; }
.pu-item-U .pu-name { color: #ef5350; }

.pu-item-LE { border-left: 3px solid #ffd600; }
.pu-item-LE .pu-dist { color: #ffd600; }
.pu-item-LE .pu-name { color: #ffd600; }

/* --- Array list view --- */
.arraylist-view {
  overflow-y: auto;
  padding: 16px;
}

.al-subtabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
  position: sticky;
  top: 0;
  background: #1a1a2e;
  padding: 8px 0;
  z-index: 10;
}

.al-subtab {
  padding: 8px 24px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #2a2a3e;
  color: #ccc;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.al-subtab:hover { border-color: #00d4ff; color: #fff; }
.al-subtab.active { background: #00d4ff; color: #1a1a2e; border-color: #00d4ff; font-weight: bold; }

.al-arraytabs {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

.al-arraytab {
  padding: 6px 12px;
  border: 1px solid #444;
  border-radius: 6px;
  background: #2a2a3e;
  color: #ccc;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: bold;
  min-width: 36px;
  text-align: center;
  transition: all 0.2s;
}

.al-arraytab:hover { border-color: #e040fb; color: #fff; }
.al-arraytab.active { background: #e040fb; color: #fff; border-color: #e040fb; }

.arraylist-content {
  max-width: 900px;
  margin: 0 auto;
}

.al-section {
  margin-bottom: 32px;
}

.al-section-title {
  font-size: 1.1rem;
  color: #00d4ff;
  border-bottom: 2px solid #00d4ff;
  padding-bottom: 6px;
  margin-bottom: 16px;
}

.al-array {
  margin-bottom: 16px;
  background: #2a2a3e;
  border: 1px solid #444;
  border-radius: 8px;
  overflow: hidden;
}

.al-array-header {
  font-size: 1rem;
  font-weight: bold;
  color: #00d4ff;
  padding: 8px 12px;
  background: #222238;
  border-bottom: 1px solid #444;
}

.al-array-header .al-count {
  font-weight: normal;
  font-size: 0.8rem;
  color: #888;
}


.al-table {
  width: 100%;
  font-size: 0.82rem;
  border-collapse: collapse;
}

.al-table th {
  text-align: left;
  padding: 3px 6px;
  color: #888;
  border-bottom: 1px solid #444;
  font-weight: normal;
  position: sticky;
  top: 0;
  background: #222238;
}

.al-table td {
  padding: 3px 6px;
  border-bottom: 1px solid #2a2a3e;
}

.al-table .pos { color: #666; width: 30px; }
.al-table .num { color: #888; width: 80px; }

.al-table .row-rare-P { background: rgba(106, 27, 154, 0.25); }
.al-table .row-rare-P td { color: #ce93d8; font-weight: bold; }

.al-table .row-rare-U { background: rgba(198, 40, 40, 0.25); }
.al-table .row-rare-U td { color: #ef5350; font-weight: bold; }

.al-table .row-rare-LE { background: rgba(255, 214, 0, 0.2); }
.al-table .row-rare-LE td { color: #ffd600; font-weight: bold; }

.al-table .row-rare-M { background: rgba(230, 81, 0, 0.15); }
.al-table .row-rare-M td { color: #ffab40; }

/* --- Mobile responsive --- */
@media (max-width: 640px) {
  .header {
    flex-direction: column;
    gap: 8px;
    align-items: flex-start;
  }

  .main {
    flex-direction: column;
    height: auto;
  }

  .left-pane {
    width: 100%;
    min-width: 100%;
    max-height: 45vh;
    border-right: none;
    border-bottom: 1px solid #333;
  }

  .right-pane {
    padding: 12px;
  }
}
