[hidden] { display: none !important; }
:root {
  --bg: #15121f; --panel: #221d33; --panel2: #2d2742; --line: #4a4068; --ink: #efe9d9; --muted: #a79fbd;
  --gold: #ffd24a; --red: #ff6b6b; --green: #7dff8f; --blue: #7cc4ff; --warn: #ff9b3d; --accent: #ffb347;
  --r1: #ff6b57; --r2: #ffae42; --r3: #8fce6b; --r4: #6fa8dc;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--ink); font-family: 'DotGothic16', 'Yu Gothic', 'Hiragino Sans', sans-serif; font-size: 16px; line-height: 1.5; }
h3 { font-size: 18px; color: var(--accent); margin-bottom: 6px; }
button { font: inherit; color: inherit; }
select { font: inherit; background: var(--bg); color: var(--ink); border: 2px solid var(--line); padding: 2px 4px; min-height: 30px; max-width: 100%; }
.screen { display: none; min-height: 100vh; }
.screen.active { display: flex; flex-direction: column; }
.muted { color: var(--muted); } .small { font-size: 14px; }
.row { display: flex; gap: 8px; align-items: center; } .wrap { flex-wrap: wrap; } .center { justify-content: center; }
.spacer { flex: 1; }
.btn { background: var(--panel2); border: 2px solid var(--line); padding: 6px 14px; cursor: pointer; min-height: 38px; box-shadow: 0 3px 0 #0a0812; }
.btn:hover { background: #3a3256; }
.btn:active { transform: translateY(2px); box-shadow: 0 1px 0 #0a0812; }
.btn:focus-visible, .cell:focus-visible, select:focus-visible { outline: 3px solid var(--gold); outline-offset: 1px; }
.btn.primary { background: #c8502e; border-color: #ffb347; color: #fff5dc; }
.btn.primary:hover { background: #dd6239; }
.btn.big { font-size: 20px; padding: 10px 26px; }
.btn.on { background: var(--gold); color: #21180a; border-color: #fff0a8; }
.chip { background: var(--bg); border: 2px solid var(--line); padding: 2px 10px; white-space: nowrap; }
.chip.gold { color: var(--gold); } .chip.warn { color: var(--warn); }
.bar { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--panel); border-bottom: 2px solid var(--line); flex-wrap: wrap; }
.bar h2 { font-size: 20px; }
.panel { background: var(--panel); border: 2px solid var(--line); padding: 12px; }
.spr { display: inline-block; image-rendering: pixelated; background-repeat: no-repeat; vertical-align: middle; flex: none; }
/* 準備 */
.setup-body { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; padding: 12px; align-items: start; }
.side-col { display: flex; flex-direction: column; gap: 12px; }
.panel-head { margin-bottom: 8px; }
.preset-row { margin-bottom: 10px; }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; }
th { font-weight: normal; }
.th-job { padding: 2px; font-size: 13px; line-height: 1.15; min-width: 44px; text-align: center; }
.th-job .spr { display: block; margin: 0 auto 2px; }
.hero-cell { text-align: left; padding: 6px 8px 6px 0; min-width: 190px; white-space: nowrap; }
.hero-line { display: flex; align-items: center; gap: 6px; }
.hero-name { font-size: 17px; }
.hero-meta { font-size: 13px; color: var(--muted); }
.mini { background: var(--panel2); border: 2px solid var(--line); min-width: 30px; min-height: 30px; cursor: pointer; padding: 0 5px; font-size: 13px; }
.mini:hover { background: #3a3256; }
.cell { width: 100%; height: 40px; min-width: 40px; border: 2px solid #171324; background: #171324; color: var(--muted); cursor: pointer; font-size: 19px; }
.cell[data-v="1"] { background: var(--r1); color: #2a0c07; }
.cell[data-v="2"] { background: var(--r2); color: #2e1b00; }
.cell[data-v="3"] { background: var(--r3); color: #12260a; }
.cell[data-v="4"] { background: var(--r4); color: #0b1a2c; }
.cell:hover { border-color: #fff; }
td { padding: 1px; }
.rules-row td { padding: 2px 0 14px; }
.rule-grid { display: flex; flex-wrap: wrap; gap: 6px 12px; font-size: 14px; color: var(--muted); }
.rule-grid label { display: flex; align-items: center; gap: 4px; }
.shop-line { display: flex; align-items: center; gap: 6px; padding: 3px 0; }
.shop-line .nm { flex: 1; }
.shop-line .pr { color: var(--gold); font-size: 14px; }
.shop-line b { font-weight: normal; min-width: 22px; text-align: center; }
.total { margin-top: 6px; text-align: right; }
.form-line { display: flex; flex-direction: column; gap: 2px; margin-bottom: 8px; }
/* ゲーム */
#game.active { height: 100vh; }
.hud { padding: 5px 10px; gap: 8px; }
.hud-bag { display: flex; gap: 8px; align-items: center; }
.hud-bag span.it { display: inline-flex; align-items: center; gap: 2px; }
.speed { display: flex; gap: 2px; }
.speed .btn { padding: 2px 8px; min-width: 40px; }
.game-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 310px; }
#stage { position: relative; background: #000; min-height: 0; min-width: 0; overflow: hidden; }
#cv { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
#bubbles { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.bubble { position: absolute; transform: translate(-50%, -100%); background: #fffdf2; color: #1c1626; padding: 3px 9px; border: 2px solid #1c1626; font-size: 16px; line-height: 1.3; max-width: 240px; width: max-content; text-align: center; box-shadow: 0 2px 0 #0007; }
.bubble::after { content: ''; position: absolute; left: 50%; bottom: -8px; margin-left: -4px; border: 4px solid transparent; border-top-color: #1c1626; }
#pausedMark { display: none; position: absolute; top: 12px; left: 50%; transform: translateX(-50%); background: #000c; border: 2px solid var(--gold); color: var(--gold); padding: 3px 14px; }
#stage.paused #pausedMark { display: block; }
#sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--panel); border-left: 2px solid var(--line); }
#cards { display: flex; flex-direction: column; gap: 4px; padding: 6px; }
.card { background: var(--panel2); padding: 4px 6px; border-left: 5px solid var(--c, #fff); display: grid; grid-template-columns: 34px 1fr; gap: 0 6px; }
.card.down { background: #3d1f2a; }
.card.dead { opacity: .5; }
.card .line1 { overflow: hidden; display: flex; justify-content: space-between; gap: 6px; font-size: 15px; white-space: nowrap; }
.card .lv { color: var(--muted); font-size: 13px; }
.card .doing { font-size: 14px; color: #ffe9b0; display: flex; align-items: center; gap: 3px; min-height: 21px; }
.bars { display: grid; grid-template-columns: 1fr 44px; gap: 3px; margin: 2px 0; }
.meter { height: 7px; background: #120f1c; border: 1px solid #000; }
.meter i { display: block; height: 100%; background: var(--green); }
.meter.low i { background: var(--red); }
.meter.food i { background: #e8b65a; }
.log-head { padding: 2px 8px 0; }
.key-hint { padding: 0 8px 4px; font-size: 13px; color: var(--muted); }
.edict-note { color: var(--gold); margin-bottom: 2px; }
#log { flex: 1; min-height: 0; overflow-y: auto; padding: 0 8px 8px; font-size: 14px; line-height: 1.4; }
#log div { padding: 2px 0; border-bottom: 1px solid #ffffff10; }
#log .bad { color: #ffb0a8; } #log .good { color: #b6f5c0; } #log .info { color: var(--muted); }
#log .floor { color: var(--gold); text-align: center; }
#log .caseline { color: #ffc27a; background: #ff9b3d1f; padding: 3px 5px; }
#log .caseline.goodcase { color: #b6f5c0; background: #7dff8f1f; }
#log small { display: block; font-size: 13px; opacity: .85; }
/* 結果 */
#result.active { align-items: center; padding: 18px 12px 90px; }
.result-box { width: min(860px, 100%); display: flex; flex-direction: column; gap: 12px; }
#resTitle { font-size: 38px; color: var(--gold); text-align: center; }
#resSub { text-align: center; }
.stat { background: var(--panel); border: 2px solid var(--line); padding: 4px 14px; text-align: center; min-width: 96px; }
.stat b { display: block; font-size: 24px; font-weight: normal; color: var(--gold); }
.sticky-actions { position: fixed; left: 0; right: 0; bottom: 0; padding: 10px; background: #15121ff0; border-top: 2px solid var(--line); }

/* モーダル */
.modal { display: none; position: fixed; inset: 0; background: #000b; z-index: 10; padding: 16px; overflow-y: auto; }
.modal.open { display: flex; align-items: flex-start; justify-content: center; }
.modal-box { background: var(--panel); border: 3px solid var(--line); width: min(1000px, 100%); padding-bottom: 12px; }
/* ===== 若き王の建国記 ===== */
:root { --rN: #e8e2d0; --rR: #6fb8ff; --rSR: #c27bff; --rUR: #ffcf3a; --rLR: #ff5fa2; }
input { font: inherit; background: var(--bg); color: var(--ink); border: 2px solid var(--line); padding: 4px 8px; min-height: 34px; }
.hint { color: var(--gold); margin-top: 8px; min-height: 1.5em; }
.chip.lootchip { color: var(--rSR); }

/* タイトル */
#title.active { align-items: center; justify-content: center; padding: 24px 16px; background: radial-gradient(ellipse at 50% 120%, #4a3a1c 0%, var(--bg) 60%); }
.title-box { max-width: 680px; text-align: center; display: flex; flex-direction: column; gap: 16px; }
.kicker { color: var(--accent); letter-spacing: .15em; font-size: 15px; }
h1 { line-height: 1.1; color: var(--gold); text-shadow: 0 4px 0 #7a3b12; }
h1 span { display: block; white-space: nowrap; }
h1 .t1 { font-size: min(8vw, 44px); }
h1 .t2 { font-size: min(16vw, 92px); letter-spacing: .1em; }
.lead { font-size: 18px; }
.title-scene { display: flex; justify-content: center; align-items: flex-end; gap: 10px; min-height: 76px; }

/* 物語 */
#story.active { position: fixed; inset: 0; min-height: 0; background: #000; overflow: hidden; cursor: pointer; z-index: 6; }
#storyCv { position: absolute; left: 0; top: 0; image-rendering: pixelated; }
.story-title { position: absolute; top: 18%; left: 0; right: 0; text-align: center; font-size: clamp(26px, 5vw, 56px); color: var(--gold); text-shadow: 3px 3px 0 #1d0f1a, -3px -3px 0 #1d0f1a, 3px -3px 0 #1d0f1a, -3px 3px 0 #1d0f1a; animation: pop .4s steps(4); }
.story-box { position: absolute; left: 50%; bottom: max(14px, 3vh); transform: translateX(-50%); width: min(92vw, 860px); min-height: 110px; background: #0c0a18ee; border: 3px solid var(--gold); padding: 10px 18px 14px; font-size: clamp(17px, 2.6vw, 24px); line-height: 1.5; box-shadow: 0 4px 0 #000; }
.story-box .who { display: block; color: var(--gold); font-size: .8em; min-height: 1.2em; }
.story-next { position: absolute; right: 12px; bottom: 6px; color: var(--gold); animation: blink 1s steps(2) infinite; }
.story-skip { position: absolute; top: 10px; right: 10px; z-index: 3; }
@keyframes blink { 50% { opacity: 0; } }
@keyframes pop { from { transform: translateY(12px); } to { transform: none; } }

/* 町 */
.town-body { display: grid; grid-template-columns: minmax(0, 1fr) 400px; gap: 12px; padding: 12px; align-items: start; }
.town-scene { position: relative; height: clamp(260px, 46vh, 460px); background: linear-gradient(#7ec8f0 0 30%, #b8e3a0 30% 33%, #5f9e48 33%); border: 3px solid var(--line); overflow: hidden; }
.town-scene.night { background: linear-gradient(#1b2347 0 30%, #3b5a3a 30% 33%, #2d4f26 33%); }
.town-scene .sky-sun { position: absolute; right: 8%; top: 6%; width: 38px; height: 38px; background: #ffe680; box-shadow: 0 0 0 6px #ffe68044; }
.town-scene .thing { position: absolute; transform: translate(-50%, -100%); display: flex; flex-direction: column; align-items: center; }
.town-scene .thing .lbl { font-size: 12px; background: #0009; color: #fff; padding: 0 4px; white-space: nowrap; margin-top: 2px; }
.town-scene .thing.empty { opacity: .4; filter: grayscale(1); }
.town-scene .walker { position: absolute; transform: translate(-50%, -100%); transition: left 4s linear; }
.town-scene .deco { position: absolute; transform: translate(-50%, -100%); }
.town-actions { margin-top: 10px; }
.town-actions .btn.big { font-size: 18px; padding: 8px 16px; }
.town-build { max-height: calc(100vh - 90px); overflow-y: auto; }
.bld { display: grid; grid-template-columns: 44px 1fr; gap: 4px 8px; padding: 8px 0; border-bottom: 1px solid #ffffff14; align-items: center; }
.bld .ic { grid-row: span 3; display: flex; justify-content: center; }
.bld .nm { font-size: 17px; }
.bld .nm small { color: var(--gold); margin-left: 6px; font-size: 13px; }
.bld .ds { font-size: 14px; color: var(--muted); }
.bld .act { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.bld.locked { opacity: .55; }
.lvdots { display: inline-flex; gap: 2px; margin-left: 4px; vertical-align: middle; }
.lvdots i { width: 8px; height: 8px; background: #120f1c; border: 1px solid var(--line); }
.lvdots i.on { background: var(--gold); }

/* 出撃準備 */
.start-floor { display: flex; align-items: center; gap: 6px; }
.skill-pick { display: flex; flex-wrap: wrap; gap: 4px; font-size: 13px; align-items: center; color: var(--muted); }
.skill-pick .mini.on { background: var(--gold); color: #21180a; }
.syn { padding: 4px 8px; margin: 3px 0; background: var(--panel2); border-left: 4px solid var(--gold); font-size: 14px; }
.syn.off { opacity: .45; border-left-color: var(--line); }
.bonus-line { font-size: 14px; display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; border-bottom: 1px dashed #ffffff14; }
.bonus-line b { font-weight: normal; color: var(--green); }

/* 迷宮 */
#toast { position: absolute; left: 12px; right: 12px; bottom: 12px; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 4px; }
.toast { background: #120f1cf0; border: 3px solid var(--c, var(--gold)); padding: 5px 14px; display: flex; gap: 8px; align-items: center; animation: pop .18s steps(3); font-size: 17px; }
.toast .rk { color: var(--c); font-size: 14px; }
#log .rareline { color: #ffd76a; background: #ffcf3a1a; padding: 3px 5px; }
.card .eqrow { display: flex; gap: 4px; align-items: center; min-height: 18px; font-size: 12px; color: var(--muted); }
.card .eqrow .spr { box-shadow: 0 2px 0 var(--c2, transparent); }
.card .sk { font-size: 12px; color: #d9b8ff; }

/* レアの演出 */
#rare { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: #000c; cursor: pointer; overflow: hidden; }
.rare-rays { position: absolute; left: 50%; top: 50%; width: 220vmax; height: 220vmax; transform: translate(-50%, -50%); background: repeating-conic-gradient(from 0deg, var(--c, #ffcf3a) 0deg 8deg, transparent 8deg 20deg); opacity: .32; animation: spin 6s linear infinite; }
#rare.lr .rare-rays { background: repeating-conic-gradient(from 0deg, #ff5fa2 0deg 6deg, #ffcf3a 6deg 12deg, #6fb8ff 12deg 18deg, #7dff8f 18deg 24deg, transparent 24deg 30deg); opacity: .45; animation-duration: 3s; }
.rare-box { position: relative; text-align: center; background: #120f1cf2; border: 4px solid var(--c, #ffcf3a); padding: 18px 28px; max-width: min(92vw, 560px); animation: rareIn .5s steps(6); box-shadow: 0 0 0 6px #000, 0 0 60px var(--c, #ffcf3a); }
.rare-kicker { font-size: clamp(22px, 4vw, 40px); color: var(--c, #ffcf3a); letter-spacing: .2em; text-shadow: 3px 3px 0 #000; }
.rare-icon { display: flex; justify-content: center; margin: 10px 0; min-height: 70px; align-items: center; }
.rare-name { font-size: clamp(22px, 3.6vw, 34px); color: #fff; }
.rare-text { color: #ffe9b0; font-size: 16px; margin: 6px 0 10px; }
.rare-text div { margin: 1px 0; }
#rare.flash::after { content: ''; position: absolute; inset: 0; background: #fff; animation: flashOut .5s steps(5) forwards; pointer-events: none; }
@keyframes spin { to { transform: translate(-50%, -50%) rotate(360deg); } }
@keyframes rareIn { 0% { transform: scale(3); opacity: 0; } 60% { transform: scale(.9); opacity: 1; } 100% { transform: scale(1); } }
@keyframes flashOut { from { opacity: 1; } to { opacity: 0; } }

/* 結果 */
.loot-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 4px; max-height: 40vh; overflow-y: auto; }
.loot { display: flex; gap: 6px; align-items: center; background: var(--panel2); padding: 3px 6px; border-left: 4px solid var(--c); font-size: 14px; }
.loot .v { margin-left: auto; color: var(--gold); white-space: nowrap; }
.new-list { display: flex; flex-wrap: wrap; gap: 6px; }
.new-item { background: var(--panel2); padding: 4px 8px; display: flex; gap: 6px; align-items: center; border: 2px solid var(--c, var(--line)); font-size: 14px; }

/* モーダル共通 */
.modal-box h3 { margin: 10px 12px 4px; }
.grid-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 6px; padding: 0 12px; }
.gitem { background: var(--panel2); padding: 6px 8px; display: grid; grid-template-columns: 40px 1fr; gap: 2px 8px; align-items: center; border-left: 4px solid var(--c, var(--line)); font-size: 14px; }
.gitem .ic { grid-row: span 3; display: flex; justify-content: center; }
.gitem .nm { font-size: 15px; color: #fff; }
.gitem .ds { color: var(--muted); font-size: 13px; }
.gitem .ac { display: flex; gap: 4px; flex-wrap: wrap; align-items: center; }
.gitem.unknown { opacity: .45; }
.gitem.on { background: #3a3256; border-left-color: var(--gold); }
#colTabs { padding: 8px 12px 0; }
#colTabs .btn { min-height: 32px; padding: 2px 10px; font-size: 14px; }
#colList { padding: 10px 0; }
.col-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 4px; padding: 0 12px; }
.col-cell { background: var(--panel2); padding: 4px 6px; display: flex; gap: 6px; align-items: center; border-left: 4px solid var(--c, var(--line)); font-size: 13px; min-height: 40px; }
.col-cell.unknown { opacity: .4; }
.col-row-head { padding: 8px 12px 2px; color: var(--accent); }

/* 家 */
.house-room { margin: 10px 12px; height: 200px; position: relative; background: linear-gradient(#5a3d2a 0 55%, #8a5a36 55%); border: 3px solid #2a1a0c; }
.house-room .f { position: absolute; bottom: 18px; transform: translateX(-50%); }

/* 酒場 */
.tavern-talk { margin: 8px 12px; min-height: 80px; background: #0c0a18; border: 2px solid var(--gold); padding: 8px 12px; display: flex; gap: 10px; align-items: center; }
.tavern-talk .who { color: var(--gold); display: block; font-size: 14px; }
#tavernPeople { padding: 0 12px; }
.love-meter { height: 8px; background: #120f1c; border: 1px solid #000; }
.love-meter i { display: block; height: 100%; background: #ff7aa8; }

/* カジノ */
.casino .modal-box { background: #1c0f26; border-color: #c27bff; }
.slot-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 12px; padding: 12px; }
.slot-machine { background: linear-gradient(#5b1530, #2a0a18); border: 4px solid #ffcf3a; padding: 12px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.slot-top { display: flex; gap: 12px; align-items: center; min-height: 32px; }
.slot-lamp { padding: 2px 12px; border: 3px solid #555; color: #555; background: #111; font-size: 18px; }
.slot-lamp.on { color: #fff; background: #ff2d55; border-color: #ffe680; box-shadow: 0 0 18px #ff2d55; }
.slot-cv { width: min(100%, 480px); aspect-ratio: 80 / 72; image-rendering: pixelated; border: 4px solid #000; background: #fff; }
.slot-win { min-height: 1.6em; font-size: 22px; color: #ffe680; text-shadow: 2px 2px 0 #000; }
.stopb { min-width: 64px; }
.pay-table { margin: 0; padding: 0 0 0 18px; font-size: 14px; }
.slot-side .grid-list { padding: 0; grid-template-columns: 1fr; }
.slot-side h3 { margin: 8px 0 4px; }

@media (max-width: 1100px) {
  .setup-body { grid-template-columns: 1fr; }
  .side-col { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
}
@media (max-width: 1000px) {
  .town-body { grid-template-columns: 1fr; }
  .town-build { max-height: none; }
  .slot-wrap { grid-template-columns: 1fr; }
}
@media (max-width: 860px) {
  #game.active { height: auto; min-height: 100vh; }
  .game-body { grid-template-columns: 1fr; grid-template-rows: 62vh auto; }
  #sidebar { border-left: 0; border-top: 2px solid var(--line); }
  #cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); }
  #log { max-height: 40vh; }
  .bubble { font-size: 14px; max-width: 170px; }
  .hero-cell { min-width: 150px; }
}

/* スマホで横にはみ出さない */
.setup-body > *, .side-col > *, .game-body > *, .town-body > *, .card > div { min-width: 0; }
.card .line1 span:first-child { overflow: hidden; text-overflow: ellipsis; }
@media (max-width: 600px) {
  .card .lv { font-size: 11px; }
  .bar { padding: 6px 8px; gap: 6px; }
  .speed .btn { min-width: 34px; padding: 2px 4px; }
  .grid-list { grid-template-columns: 1fr; }
}

#log .item { color: #e8e2d0; }
.toast.small { font-size: 14px; padding: 2px 10px; border-width: 2px; }
/* 命令のマス：パソコンでは数字だけ、スマホでは仕事名つき */
.cell .cell-job { display: none; }
.dojo-member { background: var(--panel2); padding: 6px 8px; margin: 6px 0; display: flex; flex-direction: column; gap: 4px; }
.preset-row .btn.on { background: var(--gold); color: #21180a; }

@media (max-width: 860px) {
  /* 迷宮：地図・記録・仲間を1画面に収める */
  #game.active { height: 100vh; height: 100dvh; min-height: 0; }
  .game-body { grid-template-rows: minmax(0, 1fr) auto; }
  #sidebar { display: flex; flex-direction: column; }
  .log-head, .key-hint { display: none; }
  #log { order: -1; flex: none; height: 19vh; max-height: none; padding: 2px 8px; font-size: 13px; border-bottom: 2px solid var(--line); }
  #cards { gap: 3px; padding: 4px; }
  .card { padding: 2px 4px; grid-template-columns: 26px 1fr; }
  .card .line1 { font-size: 13px; }
  .card .doing { font-size: 12px; min-height: 17px; }
  .card .sk { font-size: 11px; }
  /* カードの高さを一定に（文字の折り返しで地図の大きさが変わり、画面がチラついた） */
  .card .doing { height: 17px; white-space: nowrap; overflow: hidden; }
  .card .doing > * { flex: none; }
  .card .sk, .card .eqrow { height: 16px; min-height: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
}
@media (max-width: 600px) {
  /* 命令の表を縦に並べる（横にはみ出さない） */
  .table-wrap { overflow: visible; }
  #prioTable, #prioTable tbody { display: block; width: 100%; }
  #prioTable thead { display: none; }
  #prioTable tr { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 3px; }
  #prioTable tr:not(.rules-row) { margin-top: 10px; padding-top: 8px; border-top: 2px solid var(--line); }
  #prioTable th.hero-cell { grid-column: 1 / -1; min-width: 0; white-space: normal; padding: 0 0 4px; display: flex; flex-direction: column; gap: 4px; }
  #prioTable td { padding: 0; min-width: 0; }
  #prioTable .rules-row td { grid-column: 1 / -1; padding: 6px 0 4px; }
  .cell { min-width: 0; height: 44px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0; line-height: 1.1; padding: 0; }
  .cell .cell-job { display: block; font-size: 11px; white-space: nowrap; overflow: hidden; max-width: 100%; }
  .cell .cell-v { font-size: 16px; }
  .rule-grid label { flex-wrap: wrap; }
  .rule-grid select { max-width: 100%; }
}
.bug-list { white-space: pre-wrap; word-break: break-all; font-size: 13px; background: #0d0b14; padding: 8px; max-height: 60vh; overflow: auto; margin: 8px 12px 0; }
#btnBugs { margin-top: 8px; font-size: 13px; }

@media (max-width: 860px) {
  /* 迷宮の上の帯：行の数を固定（「装備 1個（最高 ふつう）」が伸びて折り返すたびに地図の大きさが変わり、画面がチラついた） */
  .hud { display: grid; grid-template-columns: auto auto minmax(0, 1fr); gap: 4px 6px; align-items: center; }
  .hud > * { min-width: 0; }
  #hudFloor { grid-column: 1 / -1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #hudLoot { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; justify-self: start; max-width: 100%; }
  #hudBag { grid-row: 3; grid-column: 1 / 3; white-space: nowrap; overflow: hidden; height: 22px; }
  .hud .spacer { display: none; }
  .hud #btnBgm { grid-row: 3; grid-column: 3; justify-self: end; padding: 2px 8px; }
  .hud .speed { grid-row: 4; grid-column: 1 / 3; display: flex; flex-wrap: nowrap; }
  .hud #btnAbort { grid-row: 4; grid-column: 3; justify-self: end; }
}

/* iPhone：ボタンの2回たたきで拡大しない・ホーム画面追加の案内 */
button, .btn, .cell, a { touch-action: manipulation; }
.ios-hint { margin: 10px auto 0; max-width: 340px; font-size: 14px; line-height: 1.6; background: rgba(255,255,255,.06); border: 2px solid var(--line); padding: 6px 10px; }
