/* LDwiki Rune List
   Dark theme, iPhone SE min width friendly
*/
:root{
  --bg:#0b0f14;
  --panel:#101723;
  --panel2:#0f1622;
  --text:#e7eef7;
  --muted:#9bb0c6;
  --line:rgba(255,255,255,.08);
  --accent:#7dd3fc;
  --danger:#fb7185;
  --shadow: 0 10px 30px rgba(0,0,0,.45);

  --radius:14px;
  --radius2:18px;

  --topbar-h:56px;
  --gap:10px;
  --font: system-ui, -apple-system, Segoe UI, Roboto, "Hiragino Kaku Gothic ProN","Noto Sans JP", Meiryo, sans-serif;
}

*{ box-sizing:border-box; }
html,body{ height:100%; touch-action: manipulation; }
body{
  margin:0;
  background:linear-gradient(180deg, rgba(125,211,252,.06), transparent 180px), var(--bg);
  color:var(--text);
  font-weight:900;
  font-family:var(--font);
}

.topbar{
  position:sticky;
  top:0;
  z-index:50;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: calc(env(safe-area-inset-top) + 6px) 10px 8px 10px;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  background:rgba(11,15,20,.88);
  backdrop-filter: blur(8px);
  border-bottom:1px solid var(--line);
}


.topbar__title{
  font-weight:800;
  letter-spacing:.02em;
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
  font-size:clamp(15px, 4.4vw, 18px);
  max-width: 40vw;
}


.topbar__actions{
  display:flex;
  gap:8px;
  flex-wrap:nowrap;
  justify-content:flex-end;
  overflow-x:auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width:none;
}
.topbar__actions::-webkit-scrollbar{ display:none; }
.topbar__actions .btn{
  padding:6px 8px;
  border-radius:10px;
  font-size:12px;
  white-space:nowrap;
}


.page{
  padding:10px;
  max-width:1200px;
  margin:0 auto;
}

.controls{
  display:grid;
  grid-template-columns: 1fr;
  gap:10px;
  margin-top:8px;
}

.controls__block{
  background:linear-gradient(180deg, rgba(255,255,255,.03), transparent), var(--panel);
  border:1px solid rgba(125,211,252,.45);
  border-radius:var(--radius2);
  padding: 8px;
}

.controls__label{
  font-size: 11px;
  color:var(--muted);
  margin-bottom:6px;
}

.chiplist{
  display:grid;
  width:100%;
  row-gap:6px;
  column-gap:10px;
  align-items:center;
}

/* 2段レイアウト（スマホで右にはみ出さない） */
.chiplist--cols{
  grid-template-columns: repeat(3, minmax(0, 1fr)); /* 6項目想定：2段×3列 */
}
.chiplist--rarity{
  grid-template-columns: repeat(4, minmax(0, 1fr)); /* 8項目想定：2段×4列 */
}

@media (min-width: 680px){
  /* PCでは少し詰めつつ横幅に余裕を持たせる */
  .chiplist--cols{ grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .chiplist--rarity{ grid-template-columns: repeat(8, minmax(0, 1fr)); }
}


.chip{
  display:flex;
  width:100%;
  align-items:center;
  gap:4px;
  padding:0;
  border:none;
  border-radius:0;
  background:transparent;
  user-select:none;
  white-space:nowrap;
  font-size:12px;
  color:var(--text);
  font-weight:700;
}
.chip input{
  width:13px;
  height:13px;
}
.status{
  font-size:12px;
  color:var(--muted);
  padding:4px 2px 0 2px;
}

.btn{
  border:1px solid rgba(125,211,252,.45);
  background:rgba(255,255,255,.04);
  color:var(--text);
  font-weight:900;
  border-radius:12px;
  padding:8px 10px;
  font-weight:700;
  cursor:pointer;
}
.btn:active{ transform: translateY(1px); }
.btn--ghost{ background:rgba(255,255,255,.02); }
.btn--primary{
  background:rgba(125,211,252,.16);
  border-color:rgba(125,211,252,.35);
  color:var(--text);
  font-weight:900;
}
.btn--small{
  padding:6px 8px;
  border-radius:10px;
  font-size:12px;
}

.tablewrap{
  margin-top:10px;
  border:1px solid rgba(125,211,252,.45);
  border-radius:var(--radius2);
  overflow:hidden;
  background:var(--panel);
}

.tablewrap__scroll{
  max-height: calc(100vh - var(--topbar-h) - 190px);
  overflow-y:auto;
  overflow-x:hidden; /* enable only when 内部種目 is visible */
}

.tablewrap__scroll.allow-x{
  overflow-x:auto;
}

.table{
  width:100%;
  border-collapse:separate;
  border-spacing:0;
  font-size:13px;
}

thead th{
  position:sticky;
  top:0;
  z-index:10;
  background:rgba(16,23,35,.96);
  backdrop-filter: blur(6px);
  border-bottom:1px solid var(--line);
  text-align:left;
  padding:10px;
  font-size:12px;
  color:var(--muted);
  white-space:nowrap;
}

thead th.is-sortable{
  cursor:pointer;
}

thead th .sortmark{
  margin-left:6px;
  font-size:11px;
  color:rgba(125,211,252,.95);
}

tbody td{
  border-bottom:1px solid var(--line);
  padding:10px;
  vertical-align:top;
}

tbody tr:hover td{
  background:rgba(125,211,252,.05);
}

td
.col-runeno{ width: 86px; white-space:nowrap; font-variant-numeric: tabular-nums; }
.col-no{ width:74px; color:rgba(231,238,247,.92); }
td.col-grade{ width:84px; white-space:nowrap; }
td.col-buff{ width:160px; color:rgba(231,238,247,.78); font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace; font-size:12px; }
td.col-name{ white-space:nowrap; }

.col-name.name-high{ color: rgba(80, 220, 120, 0.95); font-weight:800; }

.effect{
  line-height:1.35;
  word-break: break-word;
}

.effect .param{
  color: var(--danger);
  font-weight:900;
  font-size: 15px; /* base 13px + 2pt-ish */
  padding: 0 4px;
  border-radius: 4px;
  background: rgba(0,0,0,.28);
  text-shadow: 0 1px 0 rgba(0,0,0,.65);
}

/* Rarity row coloring (subtle to keep readability) */
tbody tr.rarity-mythic td{
  background: rgba(255,149,0,.10);
}
tbody tr.rarity-immortal td{
  background: rgba(255,59,48,.10);
}
tbody tr.rarity-transcend td{
  background: rgba(64,200,255,.10);
}

tbody tr.rarity-mythic:hover td,
tbody tr.rarity-immortal:hover td,
tbody tr.rarity-transcend:hover td{
  background: rgba(125,211,252,.07);
}

.hidden-col{ display:none !important; }

/* Right panel */
.panel-handle{
  position:fixed;
  right:0;
  top: calc(var(--topbar-h) + env(safe-area-inset-top) + 110px);
  z-index:70;
  border-radius: 14px 0 0 14px;
  border:1px solid rgba(125,211,252,.45);
  border-right:none;
  background:rgba(125,211,252,.22);
  color:var(--text);
  font-weight:900;
  padding:18px 12px;
  cursor:pointer;
  box-shadow: var(--shadow);
}

.sidepanel{
  position:fixed;
  top:0;
  right:0;
  height:100%;
  /* narrower, roughly half screen */
  width: clamp(220px, 52vw, 340px);
  z-index:80;
  /* more transparent so the table behind is faintly visible */
  background: rgba(15,22,34,.72);
  backdrop-filter: blur(4px) saturate(1.05);
  border-left:1px solid var(--line);
  transform: translateX(102%);
  transition: transform .22s ease;
  box-shadow: var(--shadow);
  display:flex;
  flex-direction:column;
}

.sidepanel.is-open{ transform: translateX(0); }

.sidepanel__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding: calc(env(safe-area-inset-top) + 6px) 10px 8px 10px;
  min-height: calc(var(--topbar-h) + env(safe-area-inset-top));
  border-bottom:1px solid var(--line);
}


.sidepanel__title{
  font-weight:900;
}

.sidepanel__body{
  padding:10px;
  display:flex;
  flex-direction:column;
  gap:10px;
}
.sidepanel__tools{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}

.wordcount{
  font-size:12px;
  color:var(--muted);
  font-weight:800;
  white-space:nowrap;
}

.toggle{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px;
  border-radius:var(--radius2);
  border:1px solid rgba(125,211,252,.45);
  background:rgba(255,255,255,.02);
}

.toggle__label{
  color:var(--muted);
  font-size:12px;
  font-weight:700;
}

/* Mobile-friendly listbox replacement */
.wordlist{
  width:100%;
  border-radius:var(--radius2);
  border:1px solid rgba(125,211,252,.45);
  background:rgba(0,0,0,.15);
  color:var(--text);
  font-weight:900;
  padding:6px;
  outline:none;
  min-height: 280px;
  max-height: 48vh;
  overflow:auto;
}

.worditem{
  display:flex;
  align-items:center;
  gap:10px;
  padding:8px 6px;
  border-radius:10px;
  cursor:pointer;
}

.worditem:hover{ background: rgba(125,211,252,.06); }

.worditem input{
  width:16px;
  height:16px;
}

.worditem span{
  font-size:13px;
  line-height:1.2;
}

.help{
  color:var(--muted);
  font-size:12px;
  line-height:1.4;
}

.backdrop{
  position:fixed;
  inset:0;
  z-index:75;
  /* keep the table slightly visible */
  background: rgba(0,0,0,.18);
  backdrop-filter: blur(2px);
}

@media (min-width: 760px){
  .controls{
    grid-template-columns: 1fr 1fr;
    align-items:start;
  }
  .controls__status{
    grid-column: 1 / -1;
  }
  .tablewrap__scroll{
    max-height: calc(100vh - var(--topbar-h) - 170px);
  }
}

/* Notice footer */
.notice{
  margin-top:12px;
  padding:12px;
  border:1px solid rgba(125,211,252,.22);
  border-radius: var(--radius2);
  background: rgba(255,255,255,.02);
}
.notice__title{
  margin:0 0 8px 0;
  font-size:13px;
  color: rgba(231,238,247,.92);
  font-weight:900;
}
.notice__body{
  font-size:12px;
  color: var(--muted);
  line-height:1.5;
}
.notice__body p{ margin:0 0 8px 0; }
.notice__body ul{ margin:0 0 0 18px; padding:0; }
.notice__body li{ margin:0 0 4px 0; }

#statusText{opacity:.85;font-size:12px;margin-top:10px;}
