/* sandbox.css: The JRF Economy Model 2026 の画面。暗い海の上に、ガラスの計器を浮かべる。 */
:root {
  --bg: #050914;
  --glass: rgba(14, 22, 44, 0.62);
  --glass-hi: rgba(28, 42, 78, 0.72);
  --line: rgba(140, 170, 230, 0.22);
  --line-hi: rgba(170, 200, 255, 0.45);
  --text: #e6eeff;
  --muted: #93a4c7;
  --dim: #66789c;
  --good: #34d399;
  --bad: #ff4d6d;
  --gold: #ffc94d;
  --a: #2dd4bf; --b: #f59e0b; --c: #a78bfa;
  --font: 'Inter', 'Noto Sans JP', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --left-w: 300px;
  --right-w: 312px;
  --bottom-h: 150px;
  --top-h: 60px;
  --r: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--bg); color: var(--text); font-family: var(--font); font-size: 13px; }
button { font: inherit; color: inherit; cursor: pointer; }
#scene { position: fixed; inset: 0; z-index: 0; }
#scene.noscene { background: radial-gradient(ellipse at 50% 40%, #12305a, #050914 70%); }
.scene-canvas { display: block; }
.scene-labels { position: absolute; inset: 0; }
#vignette { position: fixed; inset: 0; pointer-events: none; z-index: 1;
  background: radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(2, 5, 14, 0.55) 100%); }

/* ---------------------------------------------------------------- 上の帯 */
#top { position: fixed; left: 0; right: 0; top: 0; height: var(--top-h); z-index: 5; display: flex; align-items: center; gap: 18px;
  padding: 0 16px; background: linear-gradient(180deg, rgba(5, 9, 20, 0.85), rgba(5, 9, 20, 0)); }
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand h1 { margin: 0; font-size: 17px; font-weight: 800; letter-spacing: 0.02em; white-space: nowrap;
  background: linear-gradient(90deg, #fff, #b8d4ff 60%, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.brand .sub { font-size: 11px; color: var(--muted); letter-spacing: 0.08em; }
.logo, .boot-logo { position: relative; width: 34px; height: 34px; flex: none; }
.logo span, .boot-logo span { position: absolute; width: 14px; height: 14px; border-radius: 50%; box-shadow: 0 0 12px currentColor; }
.logo span:nth-child(1), .boot-logo span:nth-child(1) { left: 0; bottom: 2px; background: var(--a); color: var(--a); }
.logo span:nth-child(2), .boot-logo span:nth-child(2) { right: 0; bottom: 2px; background: var(--b); color: var(--b); }
.logo span:nth-child(3), .boot-logo span:nth-child(3) { left: 10px; top: 0; background: var(--c); color: var(--c); }
.views { display: flex; gap: 4px; padding: 4px; background: var(--glass); border: 1px solid var(--line); border-radius: 999px; backdrop-filter: blur(14px); }
.views button { border: 0; background: none; padding: 6px 14px; border-radius: 999px; color: var(--muted); font-weight: 600; }
.views button.on { background: linear-gradient(135deg, rgba(90, 140, 255, 0.35), rgba(160, 110, 255, 0.3)); color: #fff; box-shadow: inset 0 0 0 1px var(--line-hi); }
.yearbox { margin-left: auto; display: flex; align-items: baseline; gap: 8px; }
.ylab { color: var(--muted); font-size: 12px; letter-spacing: 0.1em; }
.ynum { font-family: var(--mono); font-size: 30px; font-weight: 600; text-shadow: 0 0 18px rgba(140, 190, 255, 0.6); min-width: 3ch; text-align: right; }
.topright { display: flex; align-items: center; gap: 10px; }
.ledger { display: flex; align-items: center; gap: 7px; padding: 6px 12px; border-radius: 999px; background: var(--glass); border: 1px solid var(--line);
  font-size: 12px; backdrop-filter: blur(14px); cursor: help; }
.ledger .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--good); box-shadow: 0 0 10px var(--good); animation: breathe 2.4s ease-in-out infinite; }
.ledger.bad .dot { background: var(--bad); box-shadow: 0 0 12px var(--bad); }
@keyframes breathe { 50% { opacity: 0.55; } }
.lang { display: flex; border: 1px solid var(--line); border-radius: 999px; overflow: hidden; background: var(--glass); backdrop-filter: blur(14px); }
.lang button { border: 0; background: none; padding: 6px 11px; color: var(--muted); font-size: 12px; }
.lang button.on { background: rgba(120, 160, 255, 0.28); color: #fff; }
.icon { width: 32px; height: 32px; border-radius: 50%; border: 1px solid var(--line); background: var(--glass); backdrop-filter: blur(14px); display: grid; place-items: center; padding: 0; }
button svg { width: 16px; height: 16px; fill: currentColor; display: block; pointer-events: none; }
.dice svg { width: 26px; height: 26px; }
.tb-buttons > button { display: grid; place-items: center; }
.icon:hover, .views button:hover, .lang button:hover { color: #fff; }

/* ---------------------------------------------------------------- 左右の板 */
.panel { position: fixed; z-index: 4; top: calc(var(--top-h) + 6px); bottom: calc(var(--bottom-h) + 14px); overflow-y: auto; overflow-x: hidden;
  background: var(--glass); border: 1px solid var(--line); border-radius: var(--r); backdrop-filter: blur(18px) saturate(1.2);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.06); scrollbar-width: thin; scrollbar-color: rgba(140, 170, 230, 0.3) transparent; }
#left { left: 12px; width: var(--left-w); padding: 12px; }
#right { right: 12px; width: var(--right-w); padding: 10px; }
.panel-title { display: flex; justify-content: space-between; align-items: center; font-size: 11px; letter-spacing: 0.14em; color: var(--muted); text-transform: uppercase; margin: 2px 4px 8px; }
#countries { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin-bottom: 10px; }
.ctry { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 4px; border-radius: 10px; border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03); transition: all 0.2s; }
.ctry-flag { width: 26px; height: 16px; border-radius: 3px; background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 50%, #000)); box-shadow: 0 0 10px var(--accent); }
.ctry-name { font-weight: 700; font-size: 12px; }
.ctry small { color: var(--dim); font-size: 9.5px; text-align: center; line-height: 1.2; }
.ctry.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 16%, transparent); box-shadow: 0 0 0 1px var(--accent), 0 0 22px color-mix(in srgb, var(--accent) 40%, transparent); }
.lever-group { border-top: 1px solid var(--line); padding: 4px 2px; }
.lever-group summary { cursor: pointer; list-style: none; padding: 8px 2px; font-weight: 700; font-size: 12px; letter-spacing: 0.04em; color: #cfe0ff; display: flex; }
.lever-group summary::before { content: '▸'; margin-right: 8px; color: var(--muted); transition: transform 0.2s; }
.lever-group[open] summary::before { transform: rotate(90deg); }
.lever { padding: 6px 4px 8px; }
.lever-head { display: flex; justify-content: space-between; gap: 8px; font-size: 12px; color: #d6e2fa; }
.lever-val { font-family: var(--mono); color: var(--gold); font-size: 12px; white-space: nowrap; }
.lever-nb { font-size: 10px; color: var(--dim); margin-top: 2px; }
.lever-same { font-size: 11px; color: var(--muted); display: block; margin-top: 3px; }
.lever-select { width: 100%; margin-top: 5px; padding: 5px 8px; border-radius: 8px; background: rgba(8, 14, 30, 0.8); color: var(--text); border: 1px solid var(--line); }
input[type=range] { -webkit-appearance: none; appearance: none; width: 100%; height: 22px; background: transparent; margin: 2px 0 0; }
input[type=range]::-webkit-slider-runnable-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, rgba(90, 140, 255, 0.6), rgba(170, 110, 255, 0.6)); }
input[type=range]::-moz-range-track { height: 4px; border-radius: 4px; background: linear-gradient(90deg, rgba(90, 140, 255, 0.6), rgba(170, 110, 255, 0.6)); }
input[type=range]::-webkit-slider-thumb { -webkit-appearance: none; width: 15px; height: 15px; margin-top: -5.5px; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(120, 160, 255, 0.45), 0 0 12px rgba(150, 190, 255, 0.8); }
input[type=range]::-moz-range-thumb { width: 15px; height: 15px; border: 0; border-radius: 50%; background: #fff; box-shadow: 0 0 0 3px rgba(120, 160, 255, 0.45), 0 0 12px rgba(150, 190, 255, 0.8); }
input[type=range]:disabled { opacity: 0.35; }

#cards { display: grid; grid-template-columns: 1fr 1fr; gap: 7px; }
.card { position: relative; padding: 8px 9px 4px; border-radius: 11px; background: linear-gradient(160deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.015));
  border: 1px solid var(--line); cursor: pointer; transition: transform 0.15s, border-color 0.15s; overflow: hidden; }
.card:hover { transform: translateY(-1px); border-color: var(--line-hi); }
.card-head { display: flex; justify-content: space-between; align-items: center; }
.card-label { font-size: 10.5px; color: var(--muted); letter-spacing: 0.03em; }
.card-delta { font-size: 9px; }
.card-delta.up { color: var(--good); } .card-delta.down { color: var(--bad); }
.card-val { font-family: var(--mono); font-size: 18px; font-weight: 600; margin-top: 1px; letter-spacing: -0.02em; }
.card-spark { height: 34px; margin: 0 -9px; }
.legend { margin-top: 10px; padding: 8px 6px 2px; border-top: 1px solid var(--line); color: var(--dim); font-size: 10.5px; line-height: 1.5; }
.legend p { margin: 0 0 6px; }

/* ---------------------------------------------------------------- 下の帯 */
#bottom { position: fixed; z-index: 5; left: 12px; right: 12px; bottom: 10px; height: var(--bottom-h); display: flex; flex-direction: column; gap: 8px; }
.row-events { display: flex; gap: 10px; height: 52px; }
.events { display: flex; align-items: center; gap: 6px; padding: 6px 10px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(16px); }
.ev-title { font-size: 10px; color: var(--muted); max-width: 90px; line-height: 1.25; }
.ev { display: flex; align-items: center; gap: 6px; padding: 7px 11px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-weight: 600; font-size: 12px; white-space: nowrap; transition: all 0.15s; }
.ev i { font-style: normal; font-size: 14px; }
.ev:hover { transform: translateY(-1px); }
.ev-disaster:hover { border-color: #ff6b6b; box-shadow: 0 0 18px rgba(255, 90, 90, 0.4); }
.ev-local:hover { border-color: #6bb6ff; box-shadow: 0 0 18px rgba(90, 160, 255, 0.4); }
.ev-halve:hover { border-color: #b8c2d6; box-shadow: 0 0 18px rgba(200, 210, 230, 0.3); }
.ev-hike:hover { border-color: #a78bfa; box-shadow: 0 0 18px rgba(167, 139, 250, 0.45); }
.ev-euphoria:hover { border-color: var(--gold); box-shadow: 0 0 18px rgba(255, 201, 77, 0.5); }
.ev.pulse { animation: pulse 0.6s ease-out; }
@keyframes pulse { 0% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.6); } 100% { box-shadow: 0 0 0 16px rgba(255, 255, 255, 0); } }
.news { flex: 1; min-width: 0; display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-radius: var(--r); background: var(--glass); border: 1px solid var(--line); backdrop-filter: blur(16px); overflow: hidden; }
.news-title { font-family: 'Noto Sans JP', serif; font-weight: 900; font-size: 13px; letter-spacing: 0.1em; color: var(--gold); writing-mode: horizontal-tb; flex: none; }
#news-list { list-style: none; margin: 0; padding: 0; display: flex; gap: 14px; overflow: hidden; white-space: nowrap; mask-image: linear-gradient(90deg, #000 85%, transparent); }
#news-list li { font-size: 12px; padding-left: 9px; border-left: 3px solid var(--accent); }
#news-list li b { font-family: var(--mono); font-weight: 400; color: var(--muted); margin-right: 4px; font-size: 11px; }
#news-list li.cmd { color: #cbd7f0; font-style: italic; }

#timebar { flex: 1; display: flex; align-items: center; gap: 14px; padding: 8px 14px; border-radius: var(--r); background: var(--glass-hi); border: 1px solid var(--line-hi);
  backdrop-filter: blur(18px); box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 255, 255, 0.08); }
.tb-buttons { display: flex; align-items: center; gap: 5px; }
.tb-buttons > button, .speeds button { height: 32px; min-width: 32px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); font-size: 12px; }
.tb-buttons > button:hover, .speeds button:hover { border-color: var(--line-hi); background: rgba(255, 255, 255, 0.1); }
.play { width: 44px !important; height: 40px !important; border-radius: 50% !important; font-size: 15px !important;
  background: radial-gradient(circle at 35% 30%, #8fb6ff, #4b66ff 60%, #3a2fbf) !important; border: 0 !important; box-shadow: 0 0 22px rgba(90, 120, 255, 0.7); }
.speeds { display: flex; gap: 2px; margin-left: 6px; }
.speeds button { font-family: var(--mono); padding: 0 7px; color: var(--muted); }
.speeds button.on { color: #fff; background: rgba(120, 160, 255, 0.3); border-color: var(--line-hi); }
.dice { width: 40px !important; height: 40px !important; font-size: 20px !important; border-radius: 11px !important; margin-left: 6px;
  background: linear-gradient(145deg, #fff3c4, #ffc94d) !important; border: 0 !important; box-shadow: 0 0 18px rgba(255, 201, 77, 0.55); }
.dice span { display: inline-block; }
.dice.roll span { animation: roll 0.7s cubic-bezier(.2, .8, .2, 1); }
@keyframes roll { 0% { transform: rotate(0) scale(1); } 40% { transform: rotate(400deg) scale(1.3); } 100% { transform: rotate(720deg) scale(1); } }
#bar { position: relative; flex: 1; height: 54px; cursor: pointer; touch-action: none; }
#bar-track { position: absolute; left: 0; right: 0; top: 22px; height: 10px; border-radius: 6px; background: rgba(0, 0, 0, 0.45); box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.6); overflow: hidden; }
#bar-done { position: absolute; left: 0; top: 0; bottom: 0; background: repeating-linear-gradient(90deg, rgba(120, 150, 210, 0.35) 0 6px, rgba(120, 150, 210, 0.22) 6px 12px); }
#bar-played { position: absolute; left: 0; top: 0; bottom: 0; background: linear-gradient(90deg, #3d7bff, #a06bff 70%, #ffc94d); box-shadow: 0 0 14px rgba(140, 120, 255, 0.8); }
#bar-knob { position: absolute; top: 15px; width: 24px; height: 24px; margin-left: -12px; border-radius: 50%; background: #fff; pointer-events: none;
  box-shadow: 0 0 0 4px rgba(140, 150, 255, 0.45), 0 0 20px rgba(180, 190, 255, 0.95); transition: left 0.08s linear; }
#bar-flags { position: absolute; left: 0; right: 0; top: 0; height: 20px; pointer-events: none; }
.flag { position: absolute; top: 2px; transform: translateX(-50%); color: var(--accent); filter: drop-shadow(0 0 4px var(--accent)); pointer-events: auto; }
.flag svg { width: 13px; height: 13px; display: block; }
.flag-dice { color: var(--gold); }
.flag.fork { color: #fff; font-size: 13px; }
.flag.broken { color: var(--bad); }
#bar-ticks { position: absolute; left: 0; right: 0; top: 36px; height: 14px; pointer-events: none; }
#bar-ticks span { position: absolute; transform: translateX(-50%); font-family: var(--mono); font-size: 9.5px; color: var(--dim); }
.tb-right { display: flex; align-items: center; gap: 10px; }
.years { font-family: var(--mono); display: flex; align-items: baseline; gap: 4px; }
.years b { font-size: 22px; font-weight: 600; }
.years small { color: var(--muted); }
#tries { display: flex; gap: 4px; max-width: 260px; overflow-x: auto; scrollbar-width: none; }
.try { white-space: nowrap; padding: 4px 9px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); font-size: 11px; color: var(--muted); }
.try.cur { color: #fff; border-color: var(--line-hi); background: rgba(120, 160, 255, 0.3); }
.try.ghost { border-style: dashed; color: #c8d3e6; }

/* ---------------------------------------------------------------- 島の名札 */
.island-label { pointer-events: auto; cursor: pointer; text-align: center; padding: 6px 12px 7px; border-radius: 12px; background: rgba(6, 12, 28, 0.62);
  border: 1px solid color-mix(in srgb, var(--accent) 55%, transparent); backdrop-filter: blur(8px); box-shadow: 0 0 22px color-mix(in srgb, var(--accent) 25%, transparent);
  transform: translateY(-10px); transition: box-shadow 0.2s; }
.island-label.sel { box-shadow: 0 0 0 2px var(--accent), 0 0 30px color-mix(in srgb, var(--accent) 60%, transparent); }
.il-name { font-weight: 800; font-size: 14px; color: var(--accent); text-shadow: 0 0 10px color-mix(in srgb, var(--accent) 60%, transparent); }
.il-cur { font-size: 10px; color: var(--muted); }
.il-stats { display: flex; gap: 8px; font-family: var(--mono); font-size: 10.5px; color: #dbe6ff; margin-top: 2px; }

/* ---------------------------------------------------------------- 浮かぶもの */
.popover { position: fixed; z-index: 20; display: none; padding: 14px; border-radius: var(--r); background: rgba(12, 20, 42, 0.92); border: 1px solid var(--line-hi);
  backdrop-filter: blur(20px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.6); }
.popover.open { display: block; animation: pop 0.18s ease-out; }
@keyframes pop { from { opacity: 0; transform: translateY(6px); } }
#savebox { right: 16px; bottom: calc(var(--bottom-h) + 18px); width: 380px; }
.slot { display: grid; grid-template-columns: auto 1fr auto auto; gap: 8px; align-items: center; padding: 6px 0; border-bottom: 1px solid var(--line); }
.slot small { color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.popover button { padding: 6px 10px; border-radius: 8px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); font-size: 12px; }
.popover button:disabled { opacity: 0.35; cursor: default; }
.popover button.primary { background: linear-gradient(135deg, #4b66ff, #8b5cf6); border: 0; font-weight: 700; margin-top: 10px; width: 100%; padding: 9px; }
.pop-row { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
#settings { right: 16px; top: calc(var(--top-h) + 4px); width: 300px; }
#settings label { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin: 8px 0; font-size: 12px; }
#settings select { padding: 5px 8px; border-radius: 8px; background: rgba(8, 14, 30, 0.8); color: var(--text); border: 1px solid var(--line); max-width: 170px; }
.seg { display: flex; gap: 3px; }
.seg button.on { background: rgba(120, 160, 255, 0.35); }
#helpbox { right: 60px; top: calc(var(--top-h) + 4px); width: 360px; font-size: 12.5px; line-height: 1.7; }
#helpbox h3 { margin: 0 0 6px; font-size: 14px; }
.modal { position: fixed; inset: 0; z-index: 30; display: none; place-items: center; background: rgba(2, 5, 14, 0.6); backdrop-filter: blur(6px); }
.modal.open { display: grid; }
.modal-box { width: min(980px, 92vw); height: min(560px, 76vh); display: flex; flex-direction: column; border-radius: 18px; background: rgba(12, 20, 42, 0.95); border: 1px solid var(--line-hi); box-shadow: 0 40px 100px rgba(0, 0, 0, 0.7); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-close { border: 0; background: none; font-size: 16px; }
.modal-chart { flex: 1; }
.soon { position: fixed; z-index: 15; left: 50%; top: 45%; transform: translate(-50%, -50%); display: none; padding: 22px 28px; border-radius: 16px;
  background: rgba(12, 20, 42, 0.9); border: 1px solid var(--line-hi); backdrop-filter: blur(16px); font-size: 14px; max-width: 420px; text-align: center; }
.soon.show { display: block; }
.broken { position: fixed; z-index: 14; left: 50%; top: 22%; transform: translateX(-50%); display: none; padding: 14px 20px; border-radius: 14px; max-width: 520px;
  background: rgba(60, 8, 20, 0.85); border: 1px solid var(--bad); box-shadow: 0 0 40px rgba(255, 60, 90, 0.4); font-size: 13px; line-height: 1.6; }
.broken.show { display: block; }
.toast { position: fixed; z-index: 40; left: 50%; bottom: calc(var(--bottom-h) + 26px); transform: translateX(-50%) translateY(10px); opacity: 0; pointer-events: none;
  padding: 8px 16px; border-radius: 999px; background: rgba(20, 30, 60, 0.92); border: 1px solid var(--line-hi); font-size: 12px; transition: all 0.25s; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.boot { position: fixed; inset: 0; z-index: 50; display: grid; place-content: center; justify-items: center; gap: 18px; background: radial-gradient(ellipse at 50% 40%, #13244d, #050914 70%); transition: opacity 0.8s; }
.boot.done { opacity: 0; pointer-events: none; }
.boot-logo { width: 60px; height: 60px; animation: spin 2.4s linear infinite; }
.boot-logo span { width: 24px; height: 24px; }
.boot-logo span:nth-child(3) { left: 18px; }
.boot-title { font-weight: 800; font-size: 20px; letter-spacing: 0.04em; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------------------------------------------------------------- 狭い画面 */
@media (max-width: 1100px) {
  :root { --left-w: 260px; --right-w: 270px; }
  .ev span { display: none; }
}

.overview { text-transform: none; letter-spacing: 0; font-size: 11px; padding: 3px 9px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.05); color: var(--text); }
.overview:hover { border-color: var(--line-hi); }
.undo { width: 34px !important; height: 34px !important; margin-left: 6px; }
.undo svg { width: 18px; height: 18px; }
.pop-close { float: right; border: 0 !important; background: none !important; font-size: 14px !important; padding: 0 0 6px 10px !important; color: var(--muted); }

/* ---------------------------------------------------------------- 分析の画面 */
.analysis { position: fixed; z-index: 6; display: none; left: calc(var(--left-w) + 24px); right: 12px; top: calc(var(--top-h) + 6px); bottom: calc(var(--bottom-h) + 14px);
  flex-direction: column; padding: 12px 14px; border-radius: var(--r); background: rgba(10, 17, 36, 0.86); border: 1px solid var(--line-hi);
  backdrop-filter: blur(18px); box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); }
body.view-analysis .analysis { display: flex; }
body.view-analysis #right { display: none; }
.atabs { display: flex; gap: 6px; margin-bottom: 10px; }
.atabs button { padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.04); color: var(--muted); font-weight: 600; }
.atabs button.on { color: #fff; background: linear-gradient(135deg, rgba(90, 140, 255, 0.35), rgba(160, 110, 255, 0.3)); border-color: var(--line-hi); }
.apane { display: none; flex: 1; flex-direction: column; min-height: 0; }
.apane.on { display: flex; }
.actl { display: flex; flex-wrap: wrap; gap: 10px 14px; align-items: flex-end; margin-bottom: 8px; }
.actl label { display: flex; flex-direction: column; gap: 3px; font-size: 11px; color: var(--muted); }
.actl select { padding: 5px 8px; border-radius: 8px; background: rgba(8, 14, 30, 0.85); color: var(--text); border: 1px solid var(--line); min-width: 120px; }
.actl .primary, .life .primary { padding: 8px 16px; border-radius: 10px; border: 0; font-weight: 700; color: #fff; background: linear-gradient(135deg, #4b66ff, #8b5cf6); box-shadow: 0 0 18px rgba(110, 100, 255, 0.45); }
.achart { flex: 1; min-height: 200px; }
.asum { font-size: 12px; color: #cbd7f0; padding: 6px 4px 0; line-height: 1.6; min-height: 1.6em; }

/* ---------------------------------------------------------------- 一人の暮らし */
#life-left, #life-right { display: none; }
body.view-life #left, body.view-life #right { display: none; }
body.view-life #life-left { display: block; left: 12px; width: var(--left-w); padding: 12px; }
body.view-life #life-right { display: block; right: 12px; width: 360px; padding: 12px; }
body.view-life.iron #dice, body.view-life.iron #btn-undo { opacity: 0.25; pointer-events: none; }
.life-who { font-size: 12px; color: #cbd7f0; margin: 0 4px 8px; line-height: 1.5; }
.life-mix { margin: 2px 4px 10px; }
.mix-bar { display: flex; height: 10px; border-radius: 6px; overflow: hidden; background: rgba(0, 0, 0, 0.4); }
.mx-n { background: linear-gradient(90deg, #5fae4f, #e3c55a); } .mx-l { background: linear-gradient(90deg, #ff7ad9, #a78bfa); }
.mix-leg { font-size: 10.5px; color: var(--muted); margin-top: 3px; }
.life .primary { width: 100%; margin: 6px 0 2px; }
.life .primary:disabled { opacity: 0.35; box-shadow: none; cursor: default; }
.life-iron { display: block; margin-top: 12px; font-size: 11.5px; color: var(--muted); }
.life-head { font-weight: 800; font-size: 15px; color: var(--gold); margin-bottom: 6px; }
.life-hungry { font-size: 11px; color: #fff; background: var(--bad); padding: 2px 7px; border-radius: 999px; margin-left: 6px; }
.life-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.life-grid div { padding: 6px 8px; border-radius: 9px; background: rgba(255, 255, 255, 0.04); border: 1px solid var(--line); }
.life-grid small { display: block; font-size: 10px; color: var(--muted); }
.life-grid b { font-family: var(--mono); font-size: 13px; font-weight: 600; }
.life-sub { margin: 12px 2px 4px; font-size: 11px; letter-spacing: 0.08em; color: var(--muted); }
.life-chart { height: 120px; }
.life-tree { display: flex; flex-direction: column; align-items: stretch; }
.gen { display: grid; grid-template-columns: auto 1fr auto; gap: 2px 8px; padding: 6px 9px; border-radius: 10px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.03); font-size: 11.5px; }
.gen.now { border-color: var(--accent); box-shadow: 0 0 14px color-mix(in srgb, var(--accent) 35%, transparent); }
.gen-n { font-weight: 800; color: var(--accent); } .gen-y { color: var(--muted); font-family: var(--mono); font-size: 10.5px; } .gen-w { font-family: var(--mono); color: var(--gold); }
.gen-c { grid-column: 1 / -1; color: #cbd7f0; font-size: 10.5px; }
.gen-link { width: 2px; height: 8px; margin-left: 18px; background: var(--line-hi); }
.vote-bar { display: flex; height: 22px; border-radius: 8px; overflow: hidden; font-size: 10.5px; font-weight: 700; }
.vb-hi { background: linear-gradient(90deg, #3d7bff, #6aa1ff); display: flex; align-items: center; padding-left: 6px; white-space: nowrap; overflow: hidden; }
.vb-lo { background: linear-gradient(90deg, #ffb340, #ffc94d); color: #2a1a00; display: flex; align-items: center; justify-content: flex-end; padding-right: 6px; white-space: nowrap; overflow: hidden; }
.vote-info { font-size: 11px; color: #cbd7f0; margin-top: 5px; line-height: 1.5; }
#helpbox a { color: var(--gold); }
#helpbox small { color: var(--dim); }

.il-rev { color: #ff9a8a; } .il-up { color: #7ff6ff; }
.ev-workshop:hover { border-color: #7ff6ff; box-shadow: 0 0 18px rgba(127, 246, 255, 0.45); }

/* ---------------------------------------------------------------- 小さな画面(電話の縦と横、小さな窓)
   左右の板は引き出しにする(上の帯のボタンで開く)。分析の画面は幅いっぱいで、すべらせられる。
   JRF: 縦持ちの直しが、横持ち(幅は広く、高さが低い)に効いていなかった。高さでも判じる */
.compact-only { display: none !important; }
@media (max-width: 820px), (max-height: 540px) {
  .compact-only { display: grid !important; }
  html, body { overflow: hidden; }
  #left, #right, body.view-life #life-left, body.view-life #life-right { display: none; }
  body.drawer-left #left, body.drawer-left.view-life #life-left, body.drawer-right #right, body.drawer-right.view-life #life-right { display: block; }
  body.drawer-left.view-life #left, body.drawer-right.view-life #right { display: none; }
  .panel, body.view-life #life-left, body.view-life #life-right {
    position: fixed; top: calc(var(--top-h) + 4px) !important; bottom: calc(var(--bottom-h) + 10px) !important; max-height: none !important;
    width: min(340px, 92vw) !important; z-index: 9; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
    box-shadow: 0 20px 80px rgba(0, 0, 0, 0.7); }
  #left, body.view-life #life-left { left: 8px !important; right: auto !important; }
  #right, body.view-life #life-right { right: 8px !important; left: auto !important; }
  .analysis { left: 8px; right: 8px; top: calc(var(--top-h) + 4px); bottom: calc(var(--bottom-h) + 10px); padding: 10px;
    overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
  .apane.on { display: block; }
  .atabs { flex-wrap: wrap; }
  .actl label { flex: 1 1 140px; }
  .actl select { min-width: 0; width: 100%; }
  .actl .primary { flex: 1 1 100%; }
  .achart { height: 320px; min-height: 0; }
  .news { display: none; }
  #bottom { left: 8px; right: 8px; }
  .views button, .drawer-btn, .lang button { white-space: nowrap; }
  .drawer-btn { height: 30px; padding: 0 10px; border-radius: 999px; border: 1px solid var(--line); background: var(--glass); color: var(--text); font-size: 12px; place-items: center; }
  body.drawer-left .drawer-btn[data-drawer=left], body.drawer-right .drawer-btn[data-drawer=right], body.drawer-events .drawer-btn[data-drawer=events] { background: rgba(120, 160, 255, 0.35); border-color: var(--line-hi); }
}
/* 縦持ち: 上の帯は折り返す */
@media (max-width: 820px) and (min-height: 541px) {
  :root { --top-h: 140px; --bottom-h: 176px; }
  #top { flex-wrap: wrap; height: auto; padding: 8px 12px; gap: 8px; }
  .yearbox { margin-left: 0; }
  .row-events { flex-direction: column; height: auto; }
  .ev-title { display: none; }
  #timebar { flex-wrap: wrap; gap: 8px; }
  #bar { flex-basis: 100%; order: 3; }
}
/* 横持ち(高さが低い): 上の帯を一行に縮め、出来事の列は引き出しに */
@media (max-height: 540px) {
  :root { --top-h: 46px; --bottom-h: 62px; }
  #top { height: var(--top-h); padding: 0 10px; gap: 8px; }
  .brand { display: none; }                         /* 題は起動の画面と窓の題にあるので、低い画面では帯から外す */
  .ledger-text { display: none; }
  .views button, .drawer-btn, .lang button { white-space: nowrap; }
  .views button { padding: 4px 9px; font-size: 12px; }
  .ynum { font-size: 22px; }
  .lang button { padding: 4px 8px; }
  .row-events { display: none; position: fixed; left: 8px; right: 8px; bottom: calc(var(--bottom-h) + 16px); height: auto; z-index: 10; }
  body.drawer-events .row-events { display: flex; }
  #timebar { padding: 4px 10px; gap: 8px; }
  #bar { height: 44px; }
  .tb-buttons > button, .speeds button { height: 28px; min-width: 28px; }
  .play { width: 36px !important; height: 34px !important; }
  .dice { width: 34px !important; height: 34px !important; }
  #tries { display: none; }
  .achart { height: 260px; }
}

/* 島の上のものの説明 */
.scene-tip { position: absolute; z-index: 3; pointer-events: none; display: none; width: 270px; padding: 9px 11px; border-radius: 11px;
  background: rgba(8, 14, 32, 0.92); border: 1px solid var(--line-hi); box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5); font-size: 11.5px; line-height: 1.5; }
.scene-tip.show { display: block; }
.scene-tip b { font-size: 12.5px; color: #fff; } .scene-tip small { color: var(--muted); margin-left: 4px; }
.scene-tip p { margin: 3px 0 5px; color: #cbd7f0; }
.scene-tip div { display: flex; justify-content: space-between; gap: 8px; } .scene-tip div span { color: var(--muted); }
.scene-tip em { font-style: normal; font-family: var(--mono); color: var(--gold); }
.scene-tip .warn { color: #ff8a8a; display: block; }
.life-move-btn { margin-top: 6px; width: 100%; padding: 6px 10px; border-radius: 9px; border: 1px solid var(--line); background: rgba(255, 255, 255, 0.06); color: var(--text); }

/* 音のボタン(押すまでは、押すと鳴るという合図に明滅) */
#btn-sound.off { color: var(--dim); }
#btn-sound.wait { animation: breathe 1.6s ease-in-out infinite; box-shadow: 0 0 0 2px rgba(255, 201, 77, 0.6); }
#settings input[type=range] { width: 150px; }
/* 大きな札(革命、格上げ、代替わり) */
.banner { position: fixed; z-index: 25; left: 50%; top: 34%; transform: translate(-50%, -50%) scale(0.85); opacity: 0; pointer-events: none; text-align: center;
  transition: opacity 0.5s, transform 0.6s cubic-bezier(.2, 1.4, .4, 1); }
.banner.show { opacity: 1; transform: translate(-50%, -50%) scale(1); }
.banner-big { font-family: 'Noto Sans JP', sans-serif; font-weight: 900; font-size: clamp(34px, 7vw, 76px); letter-spacing: 0.06em; color: #fff;
  text-shadow: 0 0 30px var(--bc, #9fb3ff), 0 0 60px var(--bc, #9fb3ff), 0 4px 0 rgba(0, 0, 0, 0.4); }
.banner-sub { margin-top: 6px; font-size: clamp(13px, 2vw, 18px); color: #e6eeff; text-shadow: 0 2px 12px rgba(0, 0, 0, 0.8); }
.banner.rev { --bc: #ff3b3b; } .banner.res { --bc: #ffb340; } .banner.up { --bc: #33e0ff; } .banner.gen { --bc: #ffe08a; }
