[hidden]{ display:none !important; }

:root{
  --bg:#0f1115;
  --fg:#e9edf3;
  --muted:#a7b0c0;
  --line:rgba(255,255,255,.09);
  --chip:rgba(255,255,255,.06);
  --chipOn:rgba(122,167,255,.18);
  --accent:#7aa7ff;
  --treasure:#4da3ff;
  --danger:#ff453a;
  --ok:#2ed573;
  --radius:12px;
  --pad:12px;
  --gap:8px;
}

*{ box-sizing:border-box; }
html,body{ height:100%; }
body{
  margin:0;
  background:var(--bg);
  color:var(--fg);
  font-family: system-ui,-apple-system,"Segoe UI",Roboto,"Noto Sans JP","Hiragino Kaku Gothic ProN","Yu Gothic",sans-serif;
  -webkit-font-smoothing:antialiased;
  touch-action: manipulation;
}

.topbar{
  position:sticky;
  top:0;
  z-index:10;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
  padding:10px 12px;
  background:rgba(15,17,21,.92);
  backdrop-filter: blur(10px);
  border-bottom:1px solid var(--line);
}
.topbar__title{
  font-weight:800;
  letter-spacing:.02em;
  font-size:13px;
}
.topbar__actions{
  display:flex;
  gap:8px;
}

.page{
  padding:12px 12px 22px;
}

.block{
  padding:12px;
  border:1px solid var(--line);
  border-radius:var(--radius);
  background:rgba(255,255,255,.03);
}
.block + .block{ margin-top:12px; }

.block__title{
  font-weight:800;
  font-size:13px;
  color:#dfe7ff;
  margin-bottom:8px;
}
.block__title--spaced{ margin-top:14px; }
.block__title--inline{ margin:0; }


.vaultBlock{
  margin: 8px 0;
  display:grid;
  gap:6px;
}
.vaultRow{
  display:grid;
  grid-template-columns: 50px 1fr;
  gap:10px;
  align-items:center;
}
.label--blank{
  visibility:hidden;
}

.row{
  display:flex;
  align-items:center;
  gap:10px;
  margin:8px 0;
}
.row--stack{
  align-items:flex-start;
  flex-direction:column;
  gap:6px;
}
.row--between{
  justify-content:space-between;
  align-items:center;
  margin-top:14px;
}
.label{
  flex:0 0 auto;
  font-size:12px;
  color:var(--muted);
  min-width:50px;
}
.controls{
  display:flex;
  flex-wrap:nowrap;
  gap:6px;
  overflow:hidden;
}
.controls--wrap{
  flex-wrap:wrap;
}

/* Segmented control (no per-item frame, keeps one-row layout) */
.controls--seg{
  gap:6px;
  flex-wrap:nowrap;
  border:0;
  border-radius:0;
  overflow:hidden;
  background: transparent;
}
.controls--seg .chip{
  flex:1 1 0;
  justify-content:center;
  padding:6px 8px;
  border-radius:8px;
  border:1px solid var(--line);
  background: rgba(255,255,255,.03);
}
/* Number segments (vault) */
.controls--segNum .chip{
  flex:0 0 32px;
  padding:6px 0;
  border-radius:6px;
}
/* Chip (label) base */
.chip{
  position:relative;
  display:inline-flex;
  align-items:center;
  gap:6px;
  padding:4px 6px;
  border-radius:10px;
  border:0;
  background: transparent;
  font-size:12px;
  color:var(--fg);
  user-select:none;
  white-space:nowrap;
}
.chip--small{ padding:4px 0; }
/* Hide native radio/checkbox UI to save width */
.chip input{
  position:absolute;
  opacity:0;
  width:0;
  height:0;
  pointer-events:none;
}

/* Selected state */
.chip:has(input:checked){
  background: rgba(122,167,255,.22);
  color: #eaf1ff;
}
.check{
  display:flex;
  align-items:center;
  gap:8px;
  font-size:12px;
  color:var(--fg);
}
.check input{ margin:0; transform: translateY(1px); }

.hint{
  font-size:11px;
  color:var(--muted);
  line-height:1.35;
  margin:8px 0 10px;
}
.badgeEx{
  display:inline-block;
  font-weight:900;
  -webkit-text-stroke: 2px #fff;
  color: var(--ok);
}

.btn{
  border:1px solid var(--line);
  background:rgba(255,255,255,.05);
  color:var(--fg);
  padding:7px 10px;
  border-radius:10px;
  font-size:12px;
  font-weight:700;
  letter-spacing:.02em;
}
.btn:active{ transform: scale(.98); }
.btn--primary{
  border-color: rgba(122,167,255,.55);
  background: rgba(122,167,255,.18);
}
.btn--ghost{
  background:transparent;
}

.unitGrid{
  display:grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap:6px;
}
.unitTile{
  position:relative;
  border-radius:10px;
  overflow:hidden;
  background: rgba(255,255,255,.02);
  border:1px solid rgba(255,255,255,.07);
  aspect-ratio: 1 / 1;
  padding:0;
  touch-action: manipulation;
}
.unitTile--immortal{
  background: rgba(255, 69, 58, .10);
  border-color: rgba(255, 69, 58, .22);
}
.unitTile--unowned{
  filter: none;
  opacity: 1;
}
.unitTile--unowned img{
  opacity: .28;
}
.unitTile--unowned::before{
  content:"";
  position:absolute;
  inset:0;
  border-radius: inherit;
  background: rgba(170, 125, 70, .35);
  pointer-events:none;
  z-index:1;
}
.unitTile img{
  position:relative;
  z-index:0;
  width:100%;
  height:100%;
  display:block;
  object-fit:contain;
}
.unitTile--disabled{
  opacity:.45;
}

/* --- overlay badges (Lv / 専) --- */
.overlayLv, .overlayTreasure{
  position:absolute;
  top:4px;
  z-index:4;
  font-weight:900;
  font-size:13px;
  line-height:1;
  pointer-events:none;
  text-shadow:
    -0.8px 0 0 #fff,
     0.8px 0 0 #fff,
     0 -0.8px 0 #fff,
     0  0.8px 0 #fff,
     0  1px 2px rgba(0,0,0,.35);
}

.unitTile--mythic .overlayLv{ color: var(--ok); }

.overlayLv{
  left:4px;
  right:auto;
  color: var(--danger);
  text-shadow:
    -1px 0 0 #fff,
     1px 0 0 #fff,
     0 -1px 0 #fff,
     0  1px 0 #fff,
     0  1px 2px rgba(0,0,0,.35);
}
.overlayTreasure{
  right:4px;
  left:auto;
  color: #4da3ff; /* blue */
}

.unitTile--disabled::after{
  content:"";
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.22);
  z-index:3;
  pointer-events:none;
}

.block--note{
  padding:10px 12px;
}
.note{
  font-size:11px;
  color:var(--muted);
  line-height:1.4;
}

.modal{
  position:fixed;
  inset:0;
  display:none;
  z-index:50;
}
.modal[aria-hidden="false"]{ display:block; }
.modal__backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,.55);
}
.modal__panel{
  position:absolute;
  width: min(560px, calc(100vw - 24px));
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  max-height: 78vh;
  background: rgba(15,17,21,.98);
  border-radius: 16px;
  border:1px solid var(--line);
  padding: 10px 12px 14px;
  overflow:auto;
}
.modal__header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:10px;
}
.modal__title{
  font-weight:900;
  font-size:14px;
}
.modal__sub{
  margin:6px 0 10px;
  font-size:11px;
  color:var(--muted);
}

.toast{
  position:fixed;
  left:50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: rgba(20,24,34,.92);
  border:1px solid rgba(255,255,255,.12);
  color:var(--fg);
  padding:8px 10px;
  border-radius: 999px;
  font-size:12px;
  opacity:0;
  pointer-events:none;
  transition: opacity .18s ease;
  max-width: calc(100vw - 24px);
  white-space:nowrap;
  overflow:hidden;
  text-overflow:ellipsis;
}
.toast.show{ opacity:1; }

@media (max-width: 360px){
  .unitGrid{ gap:5px; }
  .overlayLv, .overlayTreasure{ font-size:13px; }
}

  display:flex;
  gap:10px;
  align-items:center;
  margin: 0 0 10px;
}
  margin: 0 0 10px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid rgba(255, 59, 48, .35);
  background: rgba(255, 59, 48, .10);
  color: rgba(255,255,255,.92);
  font-size: 12px;
  line-height: 1.4;
}
  max-height: 60vh;
  width:100%;
  height:auto;
  display:block;
  border-radius:12px;
  border:1px solid rgba(255,255,255,.10);
}

/* --- screenshot mode --- */
.shotSummary{
  display:none !important;
  padding:10px 12px;
  border:1px solid rgba(255,255,255,.10);
  border-radius:14px;
  background:rgba(255,255,255,.04);
  margin: 8px 0 10px;
}
.shotLine{
  font-size:13px;
  font-weight:800;
  line-height:1.35;
  letter-spacing:.01em;
  color: rgba(255,255,255,.92);
  margin-bottom:6px;
}
.shotLine:last-of-type{ margin-bottom:8px; }
.shotHint{
  font-size:11px;
  color: rgba(255,255,255,.65);
}


body.shotMode #capture .row,
body.shotMode #capture .vaultBlock,
body.shotMode #capture .block__title,
body.shotMode #btnTreasure{
  display:none !important;
}

body.shotMode #unitGrid{
  margin-top: 6px;
}

/* --- shot summary rich formatting --- */
.shotKey{
  font-size:11px;
  font-weight:800;
  color: rgba(255,255,255,.72);
}
.shotVal{
  font-size:13px;
  font-weight:900;
  color: rgba(125, 235, 160, .98);
}
.shotEpic{
  font-size:13px;
  font-weight:900;
}
.shotEpic--on{ color: rgba(255,90,90,.98); }
.shotEpic--off{ color: rgba(255,255,255,.35); }

.shotHint--below{
  display:none;
  margin-top:8px;
  padding-top:6px;
  border-top:1px dashed rgba(255,255,255,.10);
}
body.shotMode #shotHintBelow{ display:block; }


/* In shot mode, hide any modal UI (e.g., treasure modal close button) */
body.shotMode .modal{ display:none !important; }
body.shotMode [data-close]{ display:none !important; }

body.shotMode .shotSummary{ display:block !important; }

/* --- Unit preset action bar --- */
.unitActions{
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.unitActions__row{
  display:flex;
  align-items:center;
  gap: 8px;
  flex-wrap: wrap;
}
.unitActions__label{
  color: rgba(235, 245, 255, .75);
  font-weight: 800;
  font-size: 12px;
  min-width: 132px;
}
.btn--chip{
  padding: 8px 12px;
  border-radius: 999px;
}
.unitActions__row--bottom{
  margin-top: 2px;
}
body.shotMode #unitActions{ display:none !important; }

/* modal footer left actions */
.modal__footer--between{
  display:flex;
  align-items:center;
  justify-content: space-between;
  gap: 10px;
}
.modal__actions{
  display:flex;
  gap: 8px;
  flex-wrap: wrap;
}

/* --- Tap feedback (blink) --- */
@keyframes tapBlink {
  0%   { transform: translateZ(0) scale(1); filter: brightness(1); opacity: 1; }
  45%  { transform: translateZ(0) scale(0.98); filter: brightness(1.25); opacity: 0.92; }
  100% { transform: translateZ(0) scale(1); filter: brightness(1); opacity: 1; }
}
.tapFlash{
  animation: tapBlink 220ms ease-out 1;
}
.btn.tapFlash{
  box-shadow: 0 0 0 2px rgba(120, 255, 210, .45), 0 0 0 6px rgba(120, 255, 210, .12);
}
.unitTile.tapFlash{
  box-shadow: 0 0 0 2px rgba(120, 255, 210, .38), 0 0 0 7px rgba(120, 255, 210, .10);
}

/* reduce perceived tap delay on mobile */
.btn, .unitTile{
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}


/* --- Unit header hint text --- */
.unitHint{
  font-size:12px;
  color:var(--muted);
  line-height:1.2;
  text-align:right;
  max-width: 70%;
}

/* --- Modal spacing --- */
.unitGrid--modal{
  gap:6px;
  margin-top: 8px;
  margin-bottom: 14px;
}
.modal__footer{
  margin-top: 10px;
}

/* --- Note extra block --- */
.note__sep{
  border:0;
  border-top:1px solid var(--line);
  margin: 10px 0;
  opacity: .55;
}
.note__extra{
  font-size:11px;
  color:var(--muted);
  line-height:1.45;
}

