/* 暗い地のスマホ向けの見た目。セーフエリア（iPhone の切り欠き・下のバー）の分は余白を空ける */
:root {
  --bg: #0e1116;
  --panel: rgba(22, 27, 34, 0.92);
  --line: #2d333b;
  --text: #e6edf3;
  --sub: #8b949e;
  --accent: #4fc3f7;
  --mod: #f0a63a;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text); overflow: hidden;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Meiryo", sans-serif; font-size: 15px;
  overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
#view { position: fixed; inset: 0; touch-action: none; }
#view canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.hidden { display: none !important; }

#top { position: fixed; left: 0; right: 0; top: 0; z-index: 5; display: flex; gap: 8px; align-items: center;
  padding: calc(var(--safe-t) + 8px) calc(var(--safe-r) + 10px) 8px calc(var(--safe-l) + 10px);
  background: linear-gradient(var(--panel), rgba(22, 27, 34, 0.7)); border-bottom: 1px solid var(--line); }
.tabs { display: flex; background: #161b22; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; flex: none; }
.tab { background: none; color: var(--sub); border: 0; padding: 8px 14px; font-size: 15px; }
.tab.on { background: #253041; color: var(--text); font-weight: 600; }
.cur { flex: 1; min-width: 0; display: flex; align-items: center; justify-content: space-between; gap: 6px;
  background: #161b22; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 8px 12px; font-size: 15px; }
.cur span:first-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chev { color: var(--sub); }

.stats { position: fixed; z-index: 4; right: calc(var(--safe-r) + 10px); top: calc(var(--safe-t) + 62px);
  color: var(--sub); font-size: 12px; text-align: right; pointer-events: none; text-shadow: 0 1px 2px #000; white-space: pre; }

#bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5;
  padding: 10px calc(var(--safe-r) + 12px) calc(var(--safe-b) + 10px) calc(var(--safe-l) + 12px);
  background: linear-gradient(rgba(22, 27, 34, 0.7), var(--panel)); border-top: 1px solid var(--line); }
.ctl { display: flex; flex-direction: column; gap: 8px; max-width: 720px; margin: 0 auto; }
.row { display: flex; align-items: center; gap: 10px; }
.row.btns { justify-content: space-between; }
.lbl { color: var(--sub); flex: none; }
.val { flex: none; min-width: 72px; text-align: right; font-variant-numeric: tabular-nums; }
input[type=range] { flex: 1; min-width: 0; accent-color: var(--accent); height: 32px; }
select { flex: 1; min-width: 0; background: #161b22; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 10px; font-size: 15px; }
.btn { background: #21262d; color: var(--text); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; font-size: 15px; }
.btn:active, .tab:active, .item:active { filter: brightness(1.3); }
.btn.on { border-color: var(--accent); color: var(--accent); }
.btn.sm { padding: 6px 10px; font-size: 13px; }

.sheet { position: fixed; z-index: 10; left: 0; right: 0; bottom: 0; max-height: 72%; display: flex; flex-direction: column;
  background: #12161c; border-top: 1px solid var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -8px 30px rgba(0, 0, 0, 0.5);
  padding-bottom: var(--safe-b); padding-left: var(--safe-l); padding-right: var(--safe-r); }
.sheetHead { display: flex; justify-content: space-between; align-items: center; padding: 12px 14px; border-bottom: 1px solid var(--line); font-weight: 600; }
.close { background: none; border: 0; color: var(--accent); font-size: 15px; padding: 4px 6px; }
.filters { display: flex; gap: 8px; padding: 8px 14px 0; }
.list { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 6px 8px 12px; }
.group { color: var(--sub); font-size: 12px; padding: 10px 8px 4px; }
.item { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; background: none; border: 0; color: var(--text);
  padding: 10px 8px; border-radius: 10px; font-size: 15px; }
.item.on { background: #1d2633; }
.item .t { flex: 1; min-width: 0; }
.item .t b { display: block; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item .t small { color: var(--sub); font-size: 12px; }
.item.off { opacity: 0.35; }
.sw { width: 22px; height: 22px; border-radius: 5px; flex: none; border: 1px solid rgba(255, 255, 255, 0.15); }
.sw.mod { outline: 2px solid var(--mod); outline-offset: 1px; }
.badge { font-size: 11px; color: #111; background: var(--mod); border-radius: 4px; padding: 1px 5px; flex: none; }
.badge.miss { background: #6e7681; color: #fff; }
.cnt { color: var(--sub); font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }

.loading { position: fixed; inset: 0; z-index: 20; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 14px;
  background: rgba(14, 17, 22, 0.72); color: var(--text); }
.spin { width: 38px; height: 38px; border: 4px solid #30363d; border-top-color: var(--accent); border-radius: 50%; animation: sp 0.8s linear infinite; }
@keyframes sp { to { transform: rotate(360deg); } }
.toast { position: fixed; z-index: 30; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 130px);
  background: #30363d; color: var(--text); padding: 10px 14px; border-radius: 10px; font-size: 14px; max-width: 90%; }

@media (orientation: landscape) and (max-height: 500px) {
  /* 横向きのスマホでは、下の操作を右に寄せて画面を広く使う */
  #bottom { left: auto; width: min(420px, 55%); border-left: 1px solid var(--line); border-radius: 14px 0 0 0; }
  .sheet { left: auto; width: min(460px, 70%); max-height: 88%; }
}
