/* 旗エディタ / パラメーターパネル / 旗ピッカー (担当B)。クラスは ww- プレフィックス */
.ww-editor, .ww-stats, .ww-picker {
  --ww-bg: #171a2e;
  --ww-panel: #20243d;
  --ww-panel-2: #2a2f4d;
  --ww-line: rgba(255, 255, 255, 0.12);
  --ww-text: #eef1ff;
  --ww-dim: #9aa3c7;
  --ww-accent: #ffd23f;
  --ww-accent-2: #ff5fa2;
  --ww-accent-3: #4fd8ff;
  box-sizing: border-box;
  color: var(--ww-text);
  font-family: "Hiragino Maru Gothic ProN", "Hiragino Sans", "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.4;
  -webkit-tap-highlight-color: transparent;
}
.ww-editor *, .ww-stats *, .ww-picker * { box-sizing: border-box; }

/* ===== エディタ ===== */
.ww-editor { display: flex; flex-direction: column; gap: 10px; outline: none; user-select: none; -webkit-user-select: none; }

.ww-ed-top { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.ww-ed-name { display: flex; align-items: center; gap: 8px; flex: 1 1 180px; min-width: 0; }
.ww-ed-name-label { font-size: 12px; color: var(--ww-dim); white-space: nowrap; }
.ww-ed-name-input {
  flex: 1; min-width: 0; padding: 7px 12px; border-radius: 999px;
  background: var(--ww-panel); color: var(--ww-text); border: 2px solid var(--ww-line);
  font: inherit; font-weight: 700; outline: none; user-select: text; -webkit-user-select: text;
  transition: border-color .15s, box-shadow .15s;
}
.ww-ed-name-input:focus { border-color: var(--ww-accent); box-shadow: 0 0 0 3px rgba(255, 210, 63, .2); }
.ww-ed-hist { display: flex; gap: 6px; }

.ww-btn {
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 11px; border-radius: 999px;
  border: 2px solid var(--ww-line); background: var(--ww-panel); color: var(--ww-text);
  font: inherit; font-size: 13px; font-weight: 700; cursor: pointer;
  transition: transform .1s, background .15s, border-color .15s, opacity .15s;
}
.ww-btn svg { width: 18px; height: 18px; }
.ww-btn:hover:not(:disabled) { background: var(--ww-panel-2); border-color: rgba(255, 255, 255, .3); }
.ww-btn:active:not(:disabled) { transform: scale(.94); }
.ww-btn:disabled { opacity: .35; cursor: default; }
.ww-btn-danger:hover:not(:disabled) { border-color: #ff6b6b; color: #ff9a9a; }

/* 旗の枠: ダークな背景に映える明るいグラデーション縁 + 旗竿 */
.ww-ed-frame {
  position: relative; padding: 8px 8px 8px 14px; border-radius: 14px; margin-left: 8px;
  background: linear-gradient(135deg, #ffd23f, #ff5fa2 55%, #4fd8ff);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, .25) inset, 0 8px 28px rgba(255, 95, 162, .28), 0 0 24px rgba(79, 216, 255, .2);
}
.ww-ed-pole {
  position: absolute; left: -9px; top: -10px; bottom: -14px; width: 8px; border-radius: 4px;
  background: linear-gradient(90deg, #f6f0d8, #c9bd8c 60%, #8a7a45);
  box-shadow: 0 2px 6px rgba(0, 0, 0, .5);
}
.ww-ed-pole::before {
  content: ""; position: absolute; left: -3px; top: -7px; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff6b0, #ffc400 60%, #b98700);
}
.ww-ed-stage {
  position: relative; width: 100%; aspect-ratio: 3 / 2; border-radius: 6px; overflow: hidden; background: #fff;
  box-shadow: 0 2px 10px rgba(0, 0, 0, .35); touch-action: none;
}
.ww-ed-canvas, .ww-ed-overlay { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }
.ww-ed-overlay { pointer-events: none; }
.ww-ed-cursor {
  display: none; position: absolute; pointer-events: none; border-radius: 50%; transform: translate(-50%, -50%);
  border: 1.5px solid #fff; box-shadow: 0 0 0 1px rgba(0, 0, 0, .7), inset 0 0 0 1px rgba(0, 0, 0, .35);
}
.ww-ed-cursor.is-eraser { border-radius: 4px; border-style: dashed; }

/* ツールバー */
.ww-editor { container-type: inline-size; }
.ww-ed-tools { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; }
@container (max-width: 470px) { .ww-ed-tools { grid-template-columns: repeat(5, 1fr); } }
.ww-tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 2px 4px;
  border-radius: 12px; border: 2px solid transparent; background: var(--ww-panel); color: var(--ww-dim);
  font: inherit; font-size: 10.5px; font-weight: 700; cursor: pointer; white-space: nowrap; min-width: 0; transition: transform .12s, background .15s, color .15s, border-color .15s;
}
.ww-tool:hover { color: var(--ww-text); background: var(--ww-panel-2); }
.ww-tool:active { transform: scale(.93); }
.ww-tool.is-active {
  color: #1a1a2e; background: linear-gradient(160deg, #ffe27a, #ffb347); border-color: #fff3b8;
  box-shadow: 0 3px 12px rgba(255, 190, 70, .45); transform: translateY(-2px);
}

.ww-ed-opts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 14px; padding: 6px 10px; border-radius: 12px; background: var(--ww-panel); }
.ww-ed-slider { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--ww-dim); flex: 1 1 150px; min-width: 130px; }
.ww-ed-slider span { white-space: nowrap; }
.ww-ed-slider b { min-width: 30px; text-align: right; color: var(--ww-text); font-variant-numeric: tabular-nums; font-size: 12px; }
.ww-ed-size-dot { flex: none; width: 10px; height: 10px; border-radius: 50%; border: 1px solid rgba(255, 255, 255, .5); display: inline-block; }
.ww-ed-size-val { display: none; }
.ww-editor input[type="range"] { flex: 1; min-width: 60px; height: 22px; accent-color: var(--ww-accent); cursor: pointer; }
.ww-ed-shapemode { display: flex; gap: 4px; transition: opacity .2s; }
.ww-ed-shapemode.is-dim { opacity: .35; }
.ww-chip {
  padding: 4px 11px; border-radius: 999px; border: 2px solid var(--ww-line); background: transparent; color: var(--ww-dim);
  font: inherit; font-size: 12px; font-weight: 700; cursor: pointer;
}
.ww-chip.is-active { background: var(--ww-accent-3); border-color: var(--ww-accent-3); color: #0b1830; }

.ww-ed-palette-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ww-ed-current {
  flex: none; width: 46px; height: 46px; border-radius: 14px; padding: 4px; background: var(--ww-panel);
  border: 2px solid var(--ww-line);
}
.ww-ed-current-sw { display: block; width: 100%; height: 100%; border-radius: 9px; box-shadow: inset 0 0 0 1px rgba(255, 255, 255, .35); }
.ww-ed-palette { display: grid; grid-template-columns: repeat(13, 1fr); gap: 4px; flex: 1 1 260px; min-width: 240px; }
.ww-sw {
  position: relative; aspect-ratio: 1; min-width: 0; border-radius: 8px; border: 2px solid rgba(255, 255, 255, .22);
  background: var(--c); cursor: pointer; padding: 0; transition: transform .1s, border-color .1s;
}
.ww-sw:hover { transform: scale(1.18); z-index: 1; }
.ww-sw.is-active { border-color: #fff; box-shadow: 0 0 0 2px var(--ww-accent-2); transform: scale(1.12); z-index: 1; }
.ww-sw-custom {
  display: grid; place-items: center; overflow: hidden; color: #fff; font-weight: 900; font-size: 15px;
  background: conic-gradient(#f33, #ff3, #3f3, #3ff, #33f, #f3f, #f33);
}
.ww-sw-custom span { text-shadow: 0 1px 3px rgba(0, 0, 0, .8); pointer-events: none; }
.ww-sw-custom input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; cursor: pointer; border: 0; padding: 0; }
.ww-ed-bgfill { flex: none; }

@media (max-width: 520px) {
  .ww-ed-palette { grid-template-columns: repeat(9, 1fr); }
  .ww-btn span { display: none; }
  .ww-btn { padding: 7px 10px; }
  .ww-ed-bgfill span { display: inline; }
}

/* ===== パラメーターパネル ===== */
.ww-stats {
  position: relative; padding: 14px; border-radius: 16px; background: var(--ww-panel);
  border: 2px solid var(--ww-line); box-shadow: 0 6px 22px rgba(0, 0, 0, .3);
}
.ww-st-empty { display: none; padding: 26px 10px; text-align: center; color: var(--ww-dim); font-weight: 700; }
.ww-stats.is-empty .ww-st-empty { display: block; }
.ww-stats.is-empty .ww-st-body { display: none; }

.ww-st-head { display: flex; align-items: center; gap: 14px; margin-bottom: 12px; }
.ww-st-power { position: relative; flex: none; width: 76px; height: 76px; }
.ww-st-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ww-st-ring circle { fill: none; stroke-width: 4.5; }
.ww-st-ring-bg { stroke: rgba(255, 255, 255, .1); }
.ww-st-ring-fg { stroke: var(--ww-accent); stroke-linecap: round; stroke-dasharray: 0 100; filter: drop-shadow(0 0 4px rgba(255, 210, 63, .6)); }
.ww-st-power-num { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.ww-st-power-num b { font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; color: var(--ww-accent); }
.ww-st-power-num small { font-size: 10px; color: var(--ww-dim); margin-top: 2px; }
.ww-st-title { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.ww-st-name { font-size: 17px; font-weight: 900; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ww-st-colors { display: flex; gap: 4px; }
.ww-st-dot { width: 16px; height: 16px; border-radius: 50%; border: 2px solid rgba(255, 255, 255, .6); display: inline-block; }
.ww-st-troops { font-size: 13px; color: var(--ww-dim); }
.ww-st-troops b { font-size: 20px; color: var(--ww-text); font-variant-numeric: tabular-nums; margin: 0 2px; }
.ww-st-troops small { font-size: 11px; }

.ww-st-bars { display: flex; flex-direction: column; gap: 7px; }
.ww-st-row { display: grid; grid-template-columns: 22px 62px 1fr 30px; align-items: center; gap: 6px; font-size: 13px; }
.ww-st-ico { font-style: normal; text-align: center; font-size: 15px; }
.ww-st-label { font-weight: 700; white-space: nowrap; }
.ww-st-bar { position: relative; height: 12px; border-radius: 999px; background: rgba(255, 255, 255, .09); overflow: hidden; }
.ww-st-fill { display: block; height: 100%; width: 0; border-radius: 999px; background: var(--bar, #fff); box-shadow: 0 0 8px var(--bar, #fff); }
.ww-st-mark { position: absolute; left: 50%; top: 0; bottom: 0; width: 2px; background: rgba(255, 255, 255, .35); }
.ww-st-val { text-align: right; font-variant-numeric: tabular-nums; font-weight: 900; }
.ww-st-atk { --bar: linear-gradient(90deg, #ff7a45, #ff3b3b); }
.ww-st-def { --bar: linear-gradient(90deg, #4f9dff, #2d6bff); }
.ww-st-spd { --bar: linear-gradient(90deg, #5cf0c8, #2dd4a8); }
.ww-st-ldr { --bar: linear-gradient(90deg, #ffe66d, #ffb703); }
.ww-st-king { --bar: linear-gradient(90deg, #d37bff, #8f4dff); }
.ww-st-fill { box-shadow: none; }

.ww-st-comp { margin-top: 14px; }
.ww-st-comp-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: rgba(255, 255, 255, .08); gap: 2px; }
.ww-st-seg { display: block; flex: 0 1 0; flex-grow: 0; min-width: 0; }
.ww-st-seg.ww-st-grunt, .ww-st-kind.ww-st-grunt::before { background: #cfd3e6; }
.ww-st-seg.ww-st-blade, .ww-st-kind.ww-st-blade::before { background: #ff8a5c; }
.ww-st-seg.ww-st-gunner, .ww-st-kind.ww-st-gunner::before { background: #4fd8ff; }
.ww-st-seg.ww-st-elite, .ww-st-kind.ww-st-elite::before { background: #ffd23f; }
.ww-st-comp-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 4px 10px; margin-top: 8px; }
.ww-st-kind { display: flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 700; }
.ww-st-kind::before { content: ""; width: 9px; height: 9px; border-radius: 3px; flex: none; }
.ww-st-kind .ww-st-ico { font-size: 13px; }
.ww-st-kind b { margin-left: auto; font-variant-numeric: tabular-nums; font-size: 14px; }

.ww-st-notes { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-direction: column; gap: 5px; }
.ww-st-note {
  position: relative; padding: 6px 10px 6px 26px; border-radius: 10px; background: rgba(255, 255, 255, .06); font-size: 12.5px;
  animation: ww-pop .35s both;
}
.ww-st-note::before { content: "✦"; position: absolute; left: 9px; color: var(--ww-accent); }
.ww-st-dim { color: var(--ww-dim); }
.ww-st-secret { text-align: center; padding-left: 10px; letter-spacing: .3em; color: var(--ww-dim); }
.ww-st-secret::before { content: none; }
@keyframes ww-pop { from { opacity: 0; transform: translateY(6px) scale(.97); } to { opacity: 1; transform: none; } }

.ww-stats.is-hidden .ww-st-name, .ww-stats.is-hidden .ww-st-colors { filter: blur(7px); }
.ww-stats.is-hidden .ww-st-bar { background: repeating-linear-gradient(45deg, rgba(255,255,255,.07) 0 6px, rgba(255,255,255,.14) 6px 12px); }
.ww-stats.is-hidden .ww-st-seg { flex-grow: 1 !important; background: rgba(255, 255, 255, .18) !important; }
.ww-stats.is-hidden .ww-st-mark { display: none; }
.ww-stats.is-hidden b { color: var(--ww-dim) !important; }

.ww-stats.is-compact { padding: 9px; border-radius: 12px; }
.ww-stats.is-compact .ww-st-head { margin-bottom: 7px; gap: 9px; }
.ww-stats.is-compact .ww-st-power { width: 54px; height: 54px; }
.ww-stats.is-compact .ww-st-power-num b { font-size: 18px; }
.ww-stats.is-compact .ww-st-power-num small { display: none; }
.ww-stats.is-compact .ww-st-name { font-size: 14px; }
.ww-stats.is-compact .ww-st-bars { gap: 4px; }
.ww-stats.is-compact .ww-st-row { grid-template-columns: 18px 56px 1fr 26px; font-size: 12px; }
.ww-stats.is-compact .ww-st-bar { height: 9px; }
.ww-stats.is-compact .ww-st-comp { margin-top: 8px; }
.ww-stats.is-compact .ww-st-comp-list { grid-template-columns: repeat(4, auto); }
.ww-stats.is-compact .ww-st-notes { margin-top: 8px; gap: 3px; }
.ww-stats.is-compact .ww-st-note { padding: 3px 8px 3px 22px; font-size: 11.5px; }

/* 特性チップ: 高さ固定(2行分)でレイアウトを揺らさない */
.ww-st-chips { display: flex; flex-wrap: wrap; align-content: flex-start; gap: 5px; height: 58px; overflow: hidden; margin-bottom: 10px; }
.ww-st-chip {
  display: inline-flex; align-items: center; gap: 4px; height: 26px; padding: 0 9px 0 6px; border-radius: 999px; border: 1.5px solid transparent;
  font: inherit; font-size: 12px; font-weight: 800; color: var(--ww-text); cursor: help; white-space: nowrap; animation: ww-pop .3s both;
  background: rgba(255, 255, 255, .08);
}
.ww-st-chip i { font-style: normal; font-size: 14px; }
.ww-st-chip-hi { background: rgba(79, 157, 255, .2); border-color: rgba(79, 157, 255, .6); }
.ww-st-chip-lo { background: rgba(255, 138, 92, .2); border-color: rgba(255, 138, 92, .6); }
.ww-st-chip-sp { background: rgba(255, 210, 63, .2); border-color: rgba(255, 210, 63, .7); }
.ww-st-chip-secret { cursor: default; color: var(--ww-dim); border-color: rgba(255, 255, 255, .15); padding: 0 12px; }
.ww-st-chips-none { align-self: flex-start; font-size: 11.5px; color: var(--ww-dim); line-height: 26px; }
.ww-st-chip:focus-visible { outline: 2px solid var(--ww-accent); outline-offset: 1px; }
.ww-st-tip {
  position: absolute; z-index: 20; max-width: 220px; padding: 6px 10px; border-radius: 10px; background: #0b0d1c; color: var(--ww-text);
  border: 1.5px solid var(--ww-line); font-size: 12px; line-height: 1.4; box-shadow: 0 6px 18px rgba(0, 0, 0, .5); pointer-events: none;
}
.ww-st-tip[hidden] { display: none; }
.ww-stats.is-compact .ww-st-chips { height: 48px; gap: 4px; margin-bottom: 7px; }
.ww-stats.is-compact .ww-st-chip { height: 22px; padding: 0 7px 0 5px; font-size: 11px; }
.ww-stats.is-compact .ww-st-chip i { font-size: 12px; }
.ww-stats.is-compact .ww-st-chips-none { line-height: 22px; font-size: 11px; }

/* ===== 旗ピッカー ===== */
.ww-picker { padding: 12px; border-radius: 16px; background: var(--ww-panel); border: 2px solid var(--ww-line); }
.ww-pk-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.ww-pk-title { margin: 0; font-size: 15px; font-weight: 900; }
.ww-pk-title small { margin-left: 6px; padding: 1px 8px; border-radius: 999px; background: var(--ww-accent); color: #222; font-size: 11px; }
.ww-pk-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 10px; }
.ww-pk-card {
  position: relative; display: flex; flex-direction: column; gap: 5px; padding: 6px; border-radius: 12px; cursor: pointer;
  background: var(--ww-panel-2); border: 2px solid transparent; color: inherit; font: inherit; text-align: left;
  transition: transform .12s, border-color .15s, box-shadow .15s; outline: none;
}
.ww-pk-card:hover, .ww-pk-card:focus-visible { transform: translateY(-3px) rotate(-.6deg); border-color: var(--ww-accent); box-shadow: 0 8px 18px rgba(0, 0, 0, .4); }
.ww-pk-thumb { aspect-ratio: 3 / 2; border-radius: 6px; overflow: hidden; background: #fff; box-shadow: 0 0 0 2px rgba(255, 255, 255, .5); }
.ww-pk-thumb img { width: 100%; height: 100%; display: block; object-fit: cover; }
.ww-pk-meta { display: flex; align-items: center; gap: 6px; padding: 0 2px; }
.ww-pk-name { flex: 1; min-width: 0; font-size: 12.5px; font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ww-pk-power { flex: none; padding: 0 7px; border-radius: 999px; background: rgba(255, 210, 63, .18); color: var(--ww-accent); font-size: 11px; font-weight: 900; }
.ww-pk-del {
  position: absolute; top: 2px; right: 2px; min-width: 24px; height: 24px; padding: 0 6px; border-radius: 999px; border: 0;
  background: rgba(20, 20, 40, .8); color: #fff; font: inherit; font-size: 12px; font-weight: 800; cursor: pointer; opacity: 0;
  transition: opacity .15s, background .15s;
}
.ww-pk-card:hover .ww-pk-del, .ww-pk-card:focus-within .ww-pk-del, .ww-pk-del.is-armed { opacity: 1; }
.ww-pk-del:hover, .ww-pk-del.is-armed { background: #e5484d; }
@media (hover: none) { .ww-pk-del { opacity: .85; } }
.ww-pk-new {
  align-items: center; justify-content: center; min-height: 96px; background: transparent; border: 2px dashed rgba(255, 255, 255, .3);
  color: var(--ww-dim); font-weight: 800; font-size: 13px;
}
.ww-pk-new:hover { color: var(--ww-accent); border-color: var(--ww-accent); }
.ww-pk-plus { font-size: 26px; line-height: 1; }
.ww-pk-empty { margin: 10px 0 0; text-align: center; color: var(--ww-dim); font-size: 12.5px; }

/* 編集画面用: 名前・戦力・5能力だけ。色ドット/兵力/特性チップ/兵種内訳/説明は出さない */
.ww-stats.is-minimal .ww-st-colors,
.ww-stats.is-minimal .ww-st-troops,
.ww-stats.is-minimal .ww-st-chips,
.ww-stats.is-minimal .ww-st-comp,
.ww-stats.is-minimal .ww-st-notes { display: none !important; }

/* 総合戦力は表示しない（旗の強さは戦って分かる。相性しだいで逆転もある） */
.ww-stats .ww-st-power { display: none !important; }
