:root {
  --bg: #1a1a2e;
  --bg2: #16213e;
  --bg3: #0f3460;
  --text: #e0e0e0;
  --text2: #a0a0a0;
  --accent: #e94560;
  --border: #333;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
.header {
  background: var(--bg2);
  padding: 20px;
  text-align: center;
  border-bottom: 2px solid var(--accent);
}
.header h1 { font-size: 1.8em; color: #fff; margin-bottom: 5px; }
.header p { color: var(--text2); font-size: 0.9em; }

.sticky-toolbar {
  position: sticky;
  top: 0;
  z-index: 100;
}
.controls {
  background: var(--bg2);
  padding: 15px 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 15px;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--border);
}
.control-group { display: flex; align-items: center; gap: 8px; }
.control-group label { color: var(--text2); font-size: 0.85em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.btn-group { display: flex; gap: 2px; }
.btn {
  padding: 6px 14px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  cursor: pointer;
  font-size: 0.85em;
  transition: all 0.15s;
  border-radius: 0;
}
.btn:first-child { border-radius: 4px 0 0 4px; }
.btn:last-child { border-radius: 0 4px 4px 0; }
.btn:only-child { border-radius: 4px; }
.btn:hover { background: var(--bg3); }
.btn.active { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

.search-bar {
  background: var(--bg2);
  padding: 10px 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-bottom: 1px solid var(--border);
}
.search-bar label { color: var(--text2); font-size: 0.85em; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.search-box {
  padding: 8px 12px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  border-radius: 4px;
  width: 100%;
  max-width: 320px;
}
.search-box::placeholder { color: #666; }
.search-box:focus { outline: none; border-color: var(--accent); }

.content { padding: 20px; max-width: 1600px; margin: 0 auto; }
.episode-section { margin-bottom: 30px; }
.episode-title {
  font-size: 1.2em;
  color: #fff;
  background: var(--bg3);
  padding: 10px 15px;
  border-radius: 6px 6px 0 0;
  border: 1px solid var(--border);
  border-bottom: none;
}
.drop-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8em;
  border: 1px solid var(--border);
  table-layout: fixed;
}
.drop-table th, .drop-table td {
  padding: 6px 8px;
  border: 1px solid var(--border);
  text-align: center;
  vertical-align: middle;
}
.drop-table th {
  font-weight: 700;
  font-size: 0.85em;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.drop-table th.monster-col {
  background: #555;
  color: #fff;
  width: 160px;
  text-align: left;
  position: sticky;
  left: 0;
  z-index: 3;
  box-shadow: 3px 0 5px rgba(0, 0, 0, 0.35);
}
.drop-table td.monster-name {
  background: #444;
  color: #fff;
  font-weight: 600;
  text-align: left;
  font-size: 0.9em;
  position: sticky;
  left: 0;
  z-index: 2;
  box-shadow: 3px 0 5px rgba(0, 0, 0, 0.35);
}
.drop-table td.monster-name .mob-name {
}
.drop-table td.monster-name .drop-rate-tag {
  color: #f0c040;
  font-size: 0.8em;
  font-weight: 400;
}
.drop-table td.drop-cell {
  font-size: 0.85em;
  line-height: 1.3;
}
/* Area (layer) separator: an obvious blank break between forest/cave/mine/ruins. */
.drop-table tr.area-gap td {
  background: transparent;
  border: none;
  border-left: none;
  border-right: none;
  padding: 18px 4px 6px;
  text-align: left;
  font-size: 0.95em;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.drop-table tr.area-gap .area-label {
  display: inline-block;
  position: sticky;
  left: var(--area-label-center, 50vw);
  transform: translateX(-50%);
  white-space: nowrap;
}
.drop-table tr.area-gap.first td {
  padding-top: 6px;
}
#item-tooltip {
  display: none;
  position: fixed;
  width: 80px;
  height: 80px;
  object-fit: contain;
  image-rendering: pixelated;
  background: #1a1a2e;
  border: 2px solid #555;
  border-radius: 4px;
  padding: 4px;
  z-index: 9999;
  pointer-events: none;
}
.drop-cell .item-tooltip-img {
  display: none;
}
.drop-cell .drop-option {
  display: block;
}
.drop-cell .drop-option + .drop-option {
  border-top: 1px solid rgba(0, 0, 0, 0.22);
  margin-top: 5px;
  padding-top: 5px;
}
.drop-cell .item-name {
  font-weight: 600;
  display: block;
}
.drop-cell.ss-rare-cell {
  position: relative;
}
.drop-cell .ss-rare-item {
  color: transparent;
  background:
    linear-gradient(
      90deg,
      #ff0000,
      #ffff00,
      #00ff00,
      #00ffff,
      #0066ff,
      #ff00ff,
      #ff0000
    );
  background-size: 300%;
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  font-weight: 900;
  filter:
    drop-shadow(1px 0 0 rgba(0, 0, 0, 0.9))
    drop-shadow(-1px 0 0 rgba(0, 0, 0, 0.9))
    drop-shadow(0 1px 0 rgba(0, 0, 0, 0.9))
    drop-shadow(0 -1px 0 rgba(0, 0, 0, 0.9))
    drop-shadow(0 0 5px rgba(255, 255, 255, 0.55));
  animation: ssRareRainbow 4s linear infinite;
}

@keyframes ssRareRainbow {
  from { background-position: 0%; }
  to { background-position: 300%; }
}

@media (prefers-reduced-motion: reduce) {
  .drop-cell .ss-rare-item {
    animation: none;
    background-position: 50% 50%;
  }
}
.drop-cell .drop-rate {
  font-size: 0.85em;
}
.drop-cell.empty { color: #555; }
.drop-table tr:hover td { background-color: rgba(233, 69, 96, 0.1); }
.drop-table tr:hover td.monster-name { background-color: #5d3c49; }

.section-header { font-weight: 700 !important; }
.table-wrap {
  overflow-x: auto;
  position: relative;
  overscroll-behavior-inline: contain;
  -webkit-overflow-scrolling: touch;
}
.stats {
  text-align: center;
  padding: 8px;
  color: var(--text2);
  font-size: 0.8em;
}
.highlight {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
  position: relative;
  z-index: 1;
}
.drop-option.highlight > .item-name {
  font-weight: 800 !important;
  text-decoration: underline;
}

/* tablet */
@media (max-width: 1024px) {
  .drop-table th.monster-col { width: 120px; }
}
/* large phone / small tablet */
@media (max-width: 768px) {
  .header { padding: 14px 12px; }
  .header h1 { font-size: 1.4em; }
  .controls { padding: 10px 12px; gap: 8px; }
  .control-group label { font-size: 0.75em; }
  .btn { padding: 8px 12px; font-size: 0.8em; min-height: 44px; }
  .search-bar { padding: 8px 12px; }
  .search-box { max-width: none; }
  .content { padding: 12px; }
  .drop-table { table-layout: auto; }
  .drop-table th.monster-col { width: 112px; min-width: 112px; }
}
/* phone */
@media (max-width: 480px) {
  .header h1 { font-size: 1.2em; }
  .header p { font-size: 0.78em; }
  .controls { padding: 8px; gap: 6px; }
  .control-group { gap: 4px; }
  .btn { padding: 8px 8px; font-size: 0.8em; min-height: 44px; }
  .search-bar { padding: 8px; }
  .content { padding: 8px; }
  .episode-title { font-size: 1em; padding: 8px 10px; }
  .drop-table { font-size: 0.7em; }
  .drop-table th, .drop-table td { padding: 4px 3px; }
  .drop-table th.monster-col { width: 92px; min-width: 92px; }
}
