/*
  VOICE: 作戦卓。静かで硬質、数字ははっきり。
  IDEA: 海図の上に各国の旗色を塗っていく「作戦地図」。UIは地図の縁に置かれた金属の計器盤。
  PICTURE: 画面いっぱいの大陸マップ (canvas) が主役。
  COLOUR: 深い海のティール一色の地 + 計器盤の暗緑 + 珊瑚色のアクセント。戦争=赤、同盟=水色。
  TYPE: Dela Gothic One (見出し・数字) + Zen Kaku Gothic New (本文)。
*/
:root {
  color-scheme: dark;
  --sea: #0b2f37;
  --panel: rgba(9, 27, 31, 0.95);
  --panel-2: #102d33;
  --line: #24505a;
  --ink: #e8f1ee;
  --mute: #93b0ad;
  --accent: #ff7a59;
  --gold: #f2c14e;
  --war: #ff4d3d;
  --ally: #7fe3ff;
  --peace: #8ad97d;
  --menu-w: 360px;
  --disp: 'Dela Gothic One', 'Hiragino Kaku Gothic StdN', sans-serif;
}
* { box-sizing: border-box; min-width: 0; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--sea); color: var(--ink); }
body { font: 15px/1.55 'Zen Kaku Gothic New', 'Hiragino Sans', 'Yu Gothic', system-ui, sans-serif; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
#map { position: fixed; inset: 0; display: block; cursor: crosshair; touch-action: none; }

/* ---------- HUD ---------- */
#hud {
  position: fixed; top: 10px; left: 50%; transform: translateX(-50%);
  display: flex; gap: 6px; align-items: stretch; z-index: 5;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; padding: 6px;
  box-shadow: 0 8px 24px rgba(0,0,0,.35); max-width: calc(100vw - 100px); overflow-x: auto;
}
.hud-nation { display: flex; align-items: center; gap: 8px; padding: 0 12px 0 8px; border-right: 1px solid var(--line); white-space: nowrap; }
.hud-nation b { font-weight: 700; font-size: 15px; }
.stat { display: flex; align-items: baseline; gap: 6px; padding: 4px 10px; white-space: nowrap; }
.stat .k { color: var(--mute); font-size: 12px; }
.stat b { font-family: var(--disp); font-weight: 400; font-size: 18px; font-variant-numeric: tabular-nums; }
#hud-dip { font-family: inherit; font-weight: 700; font-size: 14px; }
.stat small { color: var(--mute); font-size: 12px; }
.stat.gold b { color: var(--gold); }
.sw { width: 14px; height: 14px; border-radius: 4px; flex: none; box-shadow: inset 0 0 0 1px rgba(0,0,0,.4); display: inline-block; }

#banner {
  position: fixed; bottom: 40px; left: 50%; transform: translateX(-50%); z-index: 5;
  background: rgba(255,122,89,.16); border: 1px solid rgba(255,122,89,.5); color: #ffd9cf;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; display: flex; gap: 10px; align-items: center; white-space: nowrap;
}
#banner button { background: var(--accent); color: #2a0d05; border: 0; border-radius: 999px; padding: 2px 12px; font-weight: 700; }

#statusbar {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 8px; z-index: 5;
  font-size: 12px; color: var(--mute); background: rgba(9,27,31,.8); padding: 4px 12px; border-radius: 999px;
  display: flex; align-items: center; gap: 8px; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.dot { width: 8px; height: 8px; border-radius: 50%; background: #888; }
.dot.on { background: var(--peace); box-shadow: 0 0 8px var(--peace); }
.dot.off { background: var(--war); }

/* ---------- 左端メニュー ---------- */
#edge-zone { position: fixed; left: 0; top: 0; bottom: 0; width: 14px; z-index: 8; }
#edge-tab {
  position: fixed; left: 0; top: 50%; transform: translateY(-50%); z-index: 9;
  width: 26px; padding: 14px 0; border: 1px solid var(--line); border-left: 0; border-radius: 0 10px 10px 0;
  background: var(--panel); color: var(--mute); writing-mode: vertical-rl; letter-spacing: .2em; font-size: 11px;
  transition: opacity .2s;
}
#edge-tab:hover { color: var(--ink); }
body.menu-open #edge-tab { opacity: 0; pointer-events: none; }
#edge-tab .badge { position: absolute; top: -6px; right: -6px; writing-mode: horizontal-tb; }

#menu {
  position: fixed; left: 0; top: 0; bottom: 0; width: var(--menu-w); max-width: 92vw; z-index: 10;
  background: var(--panel); border-right: 1px solid var(--line); box-shadow: 12px 0 32px rgba(0,0,0,.4);
  display: flex; flex-direction: column;
  transform: translateX(-102%); transition: transform .22s cubic-bezier(.2,.8,.2,1);
}
body.menu-open #menu { transform: none; }
@media (prefers-reduced-motion: reduce) { #menu { transition: none; } }
.menu-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 8px 16px; }
.logo { font-family: var(--disp); font-size: 26px; line-height: 1; letter-spacing: .02em; }
.logo small { display: block; font-family: inherit; font-size: 11px; color: var(--mute); letter-spacing: .1em; margin-top: 4px; }
.pin { background: transparent; border: 1px solid var(--line); border-radius: 8px; padding: 6px 12px; color: var(--mute); }
.pin.on { background: var(--accent); color: #2a0d05; border-color: var(--accent); font-weight: 700; }
.tabs { display: flex; gap: 2px; padding: 0 10px; border-bottom: 1px solid var(--line); }
.tabs button { flex: 1; background: none; border: 0; padding: 10px 2px; color: var(--mute); border-bottom: 2px solid transparent; position: relative; font-size: 14px; }
.tabs button.on { color: var(--ink); border-bottom-color: var(--accent); font-weight: 700; }
.panels { flex: 1; overflow-y: auto; padding: 12px 14px 24px; }
.panels section { display: none; }
.panels section.on { display: block; }
.badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--accent); color: #2a0d05; font-size: 11px; font-style: normal; font-weight: 700; margin-left: 4px; }
h3 { font-size: 13px; color: var(--mute); font-weight: 500; margin: 18px 0 8px; }
.hint { font-size: 13px; color: var(--mute); margin: 0 0 12px; }
.empty { color: var(--mute); font-size: 13px; text-align: center; padding: 16px 0; }

.card { background: var(--panel-2); border: 1px solid var(--line); border-radius: 12px; padding: 12px; margin-bottom: 10px; }
.card .row { display: flex; align-items: center; gap: 8px; }
.card.me .row b { font-weight: 700; font-size: 18px; }
.empty-card { text-align: center; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; margin: 10px 0; font-size: 14px; }
.kv dt { color: var(--mute); }
.kv dd { margin: 0; font-variant-numeric: tabular-nums; }
.kv small { color: var(--mute); }
.bar { height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: linear-gradient(90deg, #ffb39e, var(--accent)); width: 0; transition: width .3s; }
.btnrow { display: flex; gap: 8px; margin-top: 10px; flex-wrap: wrap; }
.btnrow > button { flex: 1; }

button.primary, button.ghost, .card button, .btnrow button {
  min-height: 36px; border-radius: 9px; border: 1px solid var(--line); background: #17404a; color: var(--ink); padding: 6px 10px; font-size: 13px;
}
.card button small, .btnrow button small { display: block; font-size: 11px; color: var(--mute); }
button.primary { background: var(--accent); border-color: var(--accent); color: #2a0d05; font-weight: 700; }
button.ghost { background: transparent; }
button.wide { width: 100%; margin-top: 16px; }
button:disabled { opacity: .4; cursor: not-allowed; }
button.armed { background: var(--war) !important; border-color: var(--war) !important; color: #fff !important; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--ally); outline-offset: 2px; }
.card button:not(:disabled):hover, .btnrow button:not(:disabled):hover { border-color: var(--mute); }

table.rank { width: 100%; border-collapse: collapse; font-size: 13px; }
.rank th { text-align: left; color: var(--mute); font-weight: 500; padding: 4px; border-bottom: 1px solid var(--line); }
.rank td { padding: 5px 4px; border-bottom: 1px solid rgba(36,80,90,.5); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.rank .num { text-align: right; font-variant-numeric: tabular-nums; }
.rank tr.mine td { color: #fff; font-weight: 700; }
.rank tr { cursor: pointer; }
.rank tr:hover td { background: rgba(255,255,255,.04); }
.tag { font-size: 11px; border-radius: 4px; padding: 0 5px; margin-left: 4px; border: 1px solid var(--line); color: var(--mute); }
.tag.on { color: var(--peace); border-color: rgba(138,217,125,.5); }
.help { padding-left: 18px; margin: 0; font-size: 13px; color: #c4d6d3; }
.help li { margin: 3px 0; }

/* 外交カード */
.dcard { cursor: pointer; }
.dcard.sel { border-color: #fff; }
.dc-head { display: flex; align-items: center; gap: 8px; }
.dc-head b { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.st { font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--mute); white-space: nowrap; }
.st.war { color: #fff; background: var(--war); border-color: var(--war); }
.st.alliance { color: #062a33; background: var(--ally); border-color: var(--ally); }
.st.truce { color: var(--peace); border-color: rgba(138,217,125,.5); }
.rel { display: flex; align-items: center; gap: 8px; margin: 8px 0 4px; font-size: 12px; color: var(--mute); }
.relbar { flex: 1; height: 6px; background: rgba(255,255,255,.08); border-radius: 3px; position: relative; }
.relbar::after { content: ''; position: absolute; left: 50%; top: -2px; bottom: -2px; width: 1px; background: var(--mute); }
.relbar i { position: absolute; top: 0; bottom: 0; border-radius: 3px; }
.relval { width: 34px; text-align: right; font-variant-numeric: tabular-nums; }
.dc-stats, .dc-ties { font-size: 12px; color: var(--mute); }
.dc-ties { margin-top: 2px; }
.dc-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-top: 8px; }
.dc-support { display: flex; gap: 6px; align-items: center; margin-top: 6px; font-size: 12px; color: var(--mute); }
.dc-support button { flex: 1; min-height: 32px; padding: 4px; }

/* 通知・ログ */
.prop { border-left: 3px solid var(--accent); }
.prop p { margin: 0 0 8px; font-size: 14px; }
.prop .left { font-size: 12px; color: var(--mute); }
.chk { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--mute); margin-bottom: 8px; }
#log-list, #hall { list-style: none; margin: 0; padding: 0; }
#log-list li { font-size: 13px; padding: 6px 0 6px 10px; border-left: 3px solid var(--line); margin-bottom: 4px; }
#log-list li .t { color: var(--mute); font-size: 11px; margin-right: 6px; font-variant-numeric: tabular-nums; }
#log-list li.war { border-color: var(--war); }
#log-list li.peace { border-color: var(--peace); }
#log-list li.alliance { border-color: var(--ally); }
#log-list li.support { border-color: var(--gold); }
#log-list li.capital, #log-list li.elim, #log-list li.season { border-color: var(--accent); font-weight: 700; }
#hall li { display: flex; gap: 8px; align-items: center; font-size: 13px; padding: 6px 0; border-bottom: 1px solid rgba(36,80,90,.5); }
#hall li .s { color: var(--mute); width: 34px; }
#hall li b { flex: 1; }

/* ツールチップ・トースト */
#tip {
  position: fixed; z-index: 20; pointer-events: none; background: rgba(6,20,24,.96); border: 1px solid var(--line);
  border-radius: 10px; padding: 8px 10px; font-size: 13px; max-width: 280px; box-shadow: 0 8px 20px rgba(0,0,0,.4);
}
#tip .h { font-weight: 700; display: flex; gap: 6px; align-items: center; }
#tip .m { color: var(--mute); }
#tip .a { margin-top: 4px; color: #b9ffa9; }
#tip .a.no { color: #ffb0a8; }
#tip .a.atk { color: #ffd0c8; }
#toasts { position: fixed; right: 12px; bottom: 40px; z-index: 30; display: flex; flex-direction: column; gap: 8px; align-items: flex-end; pointer-events: none; }
.toast {
  pointer-events: auto; background: rgba(9,27,31,.97); border: 1px solid var(--line); border-left: 4px solid var(--mute);
  border-radius: 10px; padding: 10px 12px; max-width: 340px; font-size: 13px; box-shadow: 0 8px 20px rgba(0,0,0,.4);
  animation: tin .2s ease-out;
}
.toast.error { border-left-color: var(--war); }
.toast.ok { border-left-color: var(--peace); }
.toast.war { border-left-color: var(--war); }
.toast.alliance { border-left-color: var(--ally); }
.toast.peace { border-left-color: var(--peace); }
.toast.support { border-left-color: var(--gold); }
.toast.prop, .toast.season, .toast.capital, .toast.elim { border-left-color: var(--accent); }
.toast .btnrow { margin-top: 8px; }
@keyframes tin { from { opacity: 0; transform: translateY(6px); } }
@media (prefers-reduced-motion: reduce) { .toast { animation: none; } }

/* オーバーレイ */
.overlay { position: fixed; inset: 0; z-index: 40; display: grid; place-items: center; padding: 16px;
  background: radial-gradient(ellipse at 50% 40%, rgba(11,47,55,.75), rgba(3,14,17,.94)); }
.sheet { width: min(440px, 100%); background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 28px; box-shadow: 0 20px 60px rgba(0,0,0,.5); }
.sheet.small { width: min(320px, 100%); text-align: center; }
.title { font-family: var(--disp); font-weight: 400; font-size: 52px; line-height: 1.05; margin: 0 0 8px; }
.title span { display: block; font-size: 15px; color: var(--mute); letter-spacing: .12em; margin-top: 6px; }
.sheet h2 { font-weight: 700; font-size: 32px; margin: 0 0 6px; }
.lead { color: #c4d6d3; margin: 0 0 20px; }
.fine { font-size: 12px; color: var(--mute); margin: 18px 0 0; }
.msg { min-height: 1.4em; font-size: 13px; color: #ffb0a8; margin: 10px 0 0; }
/* 引き継ぎ (サーバータブ) */
.xfer { display: grid; gap: 8px; margin-bottom: 8px; }
.xfer-row { display: flex; gap: 6px; align-items: center; }
.xfer-row code { flex: 1; min-width: 0; font-size: 12px; letter-spacing: .02em; padding: 8px 10px; border-radius: 8px; background: #06171b; border: 1px solid var(--line); overflow-wrap: anywhere; user-select: all; }
.xfer-row button { flex: none; min-height: 36px; padding: 4px 10px; font-size: 13px; }
.xfer-row input { flex: 1; min-width: 0; min-height: 36px; font-size: 13px; padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: #06171b; }
.xfer .msg { margin: 0; }
.field input { flex: 1; min-height: 44px; font-size: 16px; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--line); background: #06171b; }
.field { display: grid; gap: 6px; margin: 0 0 16px; border: 0; padding: 0; font-size: 13px; color: var(--mute); }
.field legend { padding: 0; margin-bottom: 6px; }
.swatches { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.swatches button { aspect-ratio: 1; border-radius: 10px; border: 2px solid transparent; min-height: 40px; position: relative; }
.swatches button.on { border-color: #fff; box-shadow: 0 0 0 2px var(--sea), 0 0 0 4px #fff; }
.swatches button:disabled { opacity: .18; }
.spinner { width: 34px; height: 34px; margin: 0 auto 12px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--accent); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

@media (max-width: 700px) {
  #hud { top: 6px; padding: 4px; gap: 2px; max-width: calc(100vw - 40px); }
  .hud-nation b, .stat small { display: none; }
  .stat { padding: 2px 6px; }
  .stat b { font-size: 15px; }
  #banner { font-size: 12px; white-space: normal; max-width: 92vw; }
  .title { font-size: 40px; }
}
