:root {
  color-scheme: dark;
  --bg: #101312;
  --panel: #1b211f;
  --panel-2: #242c29;
  --line: #35413d;
  --text: #f1f4ef;
  --muted: #a8b3ad;
  --accent: #d9b25f;
  --accent-2: #78b7a1;
  --danger: #e06f5f;
  --ok: #8dcf7b;
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  touch-action: manipulation;
}

button,
input {
  font: inherit;
}

button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel-2);
  color: var(--text);
  padding: 10px 14px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  -webkit-user-select: none;
}

button:disabled {
  cursor: not-allowed;
  opacity: .55;
}

button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #1f1708;
  font-weight: 700;
}

button.ghost {
  background: transparent;
}

input {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #111614;
  color: var(--text);
  padding: 12px;
  margin-top: 8px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 26px;
}

h2 {
  font-size: 20px;
  margin-bottom: 12px;
}

h3 {
  font-size: 15px;
  margin: 18px 0 10px;
  color: var(--muted);
}

.app {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.top-actions {
  display: flex;
  gap: 8px;
}

.danger-action {
  border-color: #61423d;
  color: #f0a094;
}

.eyebrow {
  margin-bottom: 4px;
  color: var(--accent-2);
  font-size: 13px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.main-panel {
  height: calc(100vh - 116px);
  min-height: 0;
  overflow: hidden;
}

#dungeonTab {
  position: relative;
  height: calc(100vh - 192px);
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto 76px 112px minmax(120px, 1fr) 112px 148px;
  gap: 8px;
  padding-right: 2px;
}

#dungeonTab.hidden {
  display: none !important;
}

#dungeonTab.combat-mode {
  grid-template-rows: auto 76px minmax(118px, 1fr) minmax(118px, 1fr) 148px;
}

.tab-view {
  height: calc(100vh - 188px);
  overflow: auto;
}

.hidden {
  display: none !important;
}

.setup {
  max-width: 760px;
  margin: 0 auto;
}

.class-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin: 14px 0;
}

.class-card {
  text-align: left;
}

.class-card.active {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}

.class-card strong {
  display: block;
  margin-bottom: 8px;
}

.class-card span {
  color: var(--muted);
  font-size: 14px;
}

.game {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 280px;
  gap: 14px;
  align-items: start;
}

.identity p,
.bodycopy,
.muted {
  color: var(--muted);
}

.meters {
  display: grid;
  gap: 8px;
}

.meters div,
.derived div,
.run-status div {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  border-bottom: 1px solid var(--line);
  padding: 7px 0;
}

.run-status {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.run-status .loot-stat {
  display: block;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a18;
  padding: 9px;
}

.run-status .loot-stat span {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
}

.run-status .loot-stat strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.run-loot-strip {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
  min-height: 20px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.meters span,
.derived span,
.run-status span {
  color: var(--muted);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 16px;
}

.tabs button.active {
  border-color: var(--accent-2);
  color: var(--accent-2);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.section-head span {
  color: var(--accent);
  font-size: 14px;
}

.button-row,
.button-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.camp-home,
.prep-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.camp-card,
.choice-card,
.supply-row {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a18;
  padding: 12px;
}

.camp-card small {
  color: var(--muted);
  line-height: 1.45;
}

.camp-card {
  display: grid;
  align-content: space-between;
  gap: 10px;
  min-height: 118px;
}

.camp-card span,
.choice-card span,
.supply-row small,
.comparison {
  color: var(--muted);
}

.camp-card strong,
.choice-card strong {
  display: block;
  margin-top: 3px;
}

.camp-hero {
  grid-column: span 1;
}

.dungeon-gate-card {
  position: relative;
  grid-column: 1 / -1;
  min-height: 280px;
  overflow: hidden;
  border-color: rgba(217, 178, 95, .55);
  background:
    linear-gradient(90deg, rgba(16, 19, 18, .96) 0%, rgba(16, 19, 18, .68) 46%, rgba(16, 19, 18, .82) 100%),
    linear-gradient(180deg, rgba(16, 19, 18, .10), rgba(16, 19, 18, .94)),
    url("assets/camp-hero.png") center 48% / cover no-repeat;
  align-content: end;
  padding: 18px;
}

.dungeon-gate-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 38% 76%, rgba(217, 178, 95, .28), transparent 34%);
  pointer-events: none;
}

.dungeon-gate-card > * {
  position: relative;
  z-index: 1;
}

.dungeon-gate-card strong {
  font-size: 28px;
  line-height: 1.15;
}

.dungeon-gate-card small {
  max-width: 520px;
  color: #d0d8d2;
}

.dungeon-gate-card button {
  width: min(260px, 100%);
}

.mini-stat-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.mini-stat-grid div {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #101614;
  padding: 8px;
}

.mini-stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 3px;
}

.choice-list {
  display: grid;
  gap: 8px;
}

.choice-card {
  text-align: left;
}

.choice-card.active {
  border-color: var(--accent);
  outline: 1px solid var(--accent);
}

.choice-card small,
.supply-row small {
  display: block;
  line-height: 1.45;
  margin-top: 4px;
}

.supply-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.stepper {
  display: grid;
  grid-template-columns: 38px 28px 38px;
  gap: 4px;
  align-items: center;
  text-align: center;
}

.stepper button {
  min-height: 34px;
  padding: 5px;
}

.formation-choice {
  display: grid;
  gap: 8px;
}

.position-choice-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.position-choice-grid button.active {
  border-color: var(--accent);
  color: var(--accent);
}

.prep-actions {
  margin-top: 12px;
}

.prep-dock {
  position: sticky;
  bottom: 0;
  display: grid;
  grid-template-columns: 1fr 1.4fr;
  gap: 8px;
  margin-top: 12px;
  padding: 10px 0 0;
  background: linear-gradient(180deg, rgba(27, 33, 31, 0), var(--panel) 28%);
}

.comparison {
  border-left: 2px solid var(--line);
  margin: 5px 0;
  padding-left: 8px;
}

.comparison .good {
  color: var(--ok);
}

.comparison .bad {
  color: var(--danger);
}

.score-line {
  color: var(--accent-2);
}

.item.locked {
  border-style: dashed;
}

.rarity-border-common { border-left: 3px solid #d9ddd8; }
.rarity-border-magic { border-left: 3px solid #75b9ff; }
.rarity-border-rare { border-left: 3px solid #d6b45e; }
.rarity-border-epic { border-left: 3px solid #c28cff; }
.rarity-border-legendary { border-left: 3px solid #ff8a5c; }

.button-grid {
  display: grid;
  gap: 8px;
  min-height: 148px;
  max-height: 148px;
  align-content: start;
  overflow: auto;
}

.button-grid button,
.action-group button {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.action-group {
  display: grid;
  gap: 6px;
}

.action-group h3 {
  margin: 0;
  color: var(--accent-2);
  font-size: 12px;
}

.action-group-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.action-group-extract h3 {
  color: var(--accent);
}

.action-group-extract button {
  border-color: var(--accent);
}

.combat-hud {
  position: relative;
  display: grid;
  gap: 10px;
  margin: 12px 0;
  height: 112px;
  overflow: hidden;
}

#dungeonTab.combat-mode .combat-hud {
  height: 100%;
  overflow: visible;
}

.combat-hud.hidden {
  display: grid !important;
  visibility: hidden;
}

.combat-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.combat-formation {
  display: grid;
  grid-template-rows: 1fr 1fr;
  gap: 6px;
  height: 100%;
}

.formation-row {
  display: grid;
  gap: 8px;
  align-items: stretch;
}

.formation-back {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.formation-front {
  grid-template-columns: repeat(2, minmax(0, .72fr));
  justify-content: center;
}

.player-hud {
  margin: 0;
}

.combat-card {
  position: relative;
  height: 112px;
  min-height: 76px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #151a18;
  padding: 10px;
}

#dungeonTab.combat-mode .combat-card {
  height: 100%;
}

.combat-card[data-target-enemy] {
  cursor: pointer;
}

.combat-card.targeted {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px rgba(217, 178, 95, .55), 0 0 18px rgba(217, 178, 95, .18);
}

.combat-card.targeted::after {
  content: "目標";
  position: absolute;
  top: 6px;
  right: 7px;
  color: var(--accent);
  font-size: 10px;
  font-weight: 800;
}

.combat-card.empty {
  opacity: .38;
}

.combat-card.enemy {
  border-color: #61423d;
}

.combat-card.player {
  border-color: #3b5b50;
}

.combat-card.fx-melee {
  animation: player-card-charge .52s ease-out;
}

.combat-card.fx-monster {
  animation: enemy-card-charge .52s ease-out;
}

.combat-card.fx-hit {
  animation: hit-flash .48s ease-out;
}

.combat-card.fx-heal {
  animation: heal-glow .72s ease-out;
}

.combat-card.fx-shield {
  animation: shield-glow .75s ease-out;
}

.combat-card.fx-smoke {
  animation: smoke-glow .75s ease-out;
}

.combat-fx-layer {
  position: absolute;
  inset: 0;
  z-index: 3;
  pointer-events: none;
}

.combat-fx-layer span {
  position: absolute;
  display: block;
}

.combat-scene-fx {
  position: absolute;
  z-index: 12;
  top: 104px;
  right: 0;
  bottom: 160px;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.combat-log-toggle {
  position: absolute;
  top: 158px;
  right: 0;
  z-index: 24;
  min-height: 42px;
  width: 38px;
  padding: 5px 4px;
  border-radius: 8px 0 0 8px;
  writing-mode: vertical-rl;
  letter-spacing: 0;
}

.combat-log-toggle.active {
  border-color: var(--accent);
  color: var(--accent);
}

.scene-fireball {
  position: absolute;
  left: 50%;
  bottom: 36px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: radial-gradient(circle, #fff0b8 0%, #ff9b38 42%, rgba(255, 72, 0, 0) 72%);
  box-shadow: 0 0 22px rgba(255, 122, 50, .96), 0 0 42px rgba(255, 72, 0, .36);
  transform: translateX(-50%);
  animation: scene-fireball-flight .72s cubic-bezier(.18, .72, .28, 1) forwards;
}

.scene-fireball::after {
  content: "";
  position: absolute;
  left: 6px;
  top: 12px;
  width: 6px;
  height: 72px;
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(255, 238, 184, .8), rgba(255, 122, 50, .52), rgba(255, 122, 50, 0));
  filter: blur(1px);
}

.scene-damage {
  position: absolute;
  left: 50%;
  z-index: 14;
  color: #ffd0c8;
  font-weight: 800;
  font-size: 20px;
  text-shadow: 0 2px 0 rgba(0, 0, 0, .55), 0 0 14px rgba(224, 111, 95, .85);
  transform: translateX(-50%);
  animation: damage-float .95s ease-out forwards;
}

.scene-damage-enemy {
  top: 22px;
}

.scene-damage-player {
  bottom: 30px;
}

.fx-layer-projectile span {
  left: 50%;
  top: 82px;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: radial-gradient(circle, #ffd28a 0%, #ff7a32 45%, rgba(255, 72, 0, 0) 72%);
  box-shadow: 0 0 18px rgba(255, 122, 50, .9);
  animation: fireball-up .62s ease-out forwards;
}

.fx-layer-melee span,
.fx-layer-monster span {
  left: 50%;
  top: 50%;
  width: 104px;
  height: 4px;
  background: linear-gradient(90deg, transparent, #fff3bd, var(--accent), transparent);
  box-shadow: 0 0 14px rgba(217, 178, 95, .8);
  transform-origin: center;
  animation: slash-flash .42s ease-out forwards;
}

.fx-layer-heal span {
  left: calc(50% - 42px);
  bottom: 10px;
  width: 84px;
  height: 42px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(141, 207, 123, .42), rgba(141, 207, 123, 0) 68%);
  animation: pulse-fade .72s ease-out forwards;
}

.fx-layer-shield span {
  left: calc(50% - 44px);
  bottom: 7px;
  width: 88px;
  height: 54px;
  border: 1px solid rgba(120, 183, 161, .9);
  border-radius: 999px 999px 10px 10px;
  box-shadow: 0 0 18px rgba(120, 183, 161, .34);
  animation: pulse-fade .75s ease-out forwards;
}

.fx-layer-smoke span {
  left: 16%;
  right: 16%;
  bottom: 8px;
  height: 54px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(174, 185, 178, .35), rgba(174, 185, 178, 0) 70%);
  filter: blur(4px);
  animation: smoke-rise .85s ease-out forwards;
}

@keyframes player-lunge {
  0% { transform: translateY(0); }
  34% { transform: translateY(-28px) scale(1.05); box-shadow: 0 0 22px rgba(217, 178, 95, .45); }
  62% { transform: translateY(4px) scale(.99); }
  100% { transform: translateY(0); }
}

@keyframes player-card-charge {
  0% { transform: translateY(0) scale(1); z-index: 2; }
  42% { transform: translateY(-86px) scale(1.04); box-shadow: 0 0 24px rgba(217, 178, 95, .52); border-color: var(--accent); z-index: 8; }
  62% { transform: translateY(-74px) scale(1.01); }
  100% { transform: translateY(0) scale(1); z-index: 2; }
}

@keyframes enemy-lunge {
  0% { transform: translateY(0); }
  34% { transform: translateY(22px) scale(1.05); box-shadow: 0 0 22px rgba(224, 111, 95, .4); }
  62% { transform: translateY(-3px) scale(.99); }
  100% { transform: translateY(0); }
}

@keyframes enemy-card-charge {
  0% { transform: translateY(0) scale(1); z-index: 2; }
  42% { transform: translateY(86px) scale(1.04); box-shadow: 0 0 24px rgba(224, 111, 95, .48); border-color: var(--danger); z-index: 8; }
  62% { transform: translateY(74px) scale(1.01); }
  100% { transform: translateY(0) scale(1); z-index: 2; }
}

@keyframes cast-pulse {
  0%, 100% { transform: scale(1); box-shadow: none; }
  35% { transform: scale(1.04); box-shadow: 0 0 22px rgba(255, 122, 50, .45); border-color: #ffb15d; }
}

@keyframes hit-flash {
  0%, 100% { filter: none; }
  35% { filter: brightness(1.7) saturate(1.25); box-shadow: 0 0 18px rgba(224, 111, 95, .45); }
}

@keyframes heal-glow {
  0%, 100% { box-shadow: none; }
  35% { box-shadow: 0 0 20px rgba(141, 207, 123, .55); border-color: var(--ok); }
}

@keyframes shield-glow {
  0%, 100% { box-shadow: none; }
  35% { box-shadow: 0 0 20px rgba(120, 183, 161, .58); border-color: var(--accent-2); }
}

@keyframes smoke-glow {
  0%, 100% { filter: none; }
  40% { filter: brightness(1.25) contrast(.95); }
}

@keyframes fireball-up {
  0% { transform: translate(-50%, 0) scale(.7); opacity: 0; }
  20% { opacity: 1; }
  100% { transform: translate(-50%, -96px) scale(1.2); opacity: 0; }
}

@keyframes scene-fireball-flight {
  0% { bottom: 30px; transform: translateX(-50%) scale(.72); opacity: 0; }
  12% { opacity: 1; }
  78% { opacity: 1; }
  100% { bottom: calc(100% - 42px); transform: translateX(-50%) scale(1.18); opacity: 0; }
}

@keyframes damage-float {
  0% { transform: translate(-50%, 8px) scale(.82); opacity: 0; }
  18% { opacity: 1; }
  100% { transform: translate(-50%, -28px) scale(1.08); opacity: 0; }
}

@keyframes slash-flash {
  0% { transform: translate(-50%, -50%) rotate(-24deg) scaleX(.15); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: translate(-50%, -50%) rotate(-24deg) scaleX(1.35); opacity: 0; }
}

@keyframes pulse-fade {
  0% { transform: scale(.76); opacity: 0; }
  35% { opacity: 1; }
  100% { transform: scale(1.18); opacity: 0; }
}

@keyframes smoke-rise {
  0% { transform: translateY(12px) scale(.8); opacity: 0; }
  35% { opacity: .85; }
  100% { transform: translateY(-24px) scale(1.18); opacity: 0; }
}

.combat-name {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.combat-name strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.combat-name span {
  color: var(--muted);
  font-size: 12px;
}

.action-orbs {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-bottom: 8px;
}

.action-orb {
  width: 10px;
  height: 10px;
  border: 1px solid var(--accent);
  border-radius: 50%;
  background: transparent;
  opacity: .55;
}

.action-orb.filled {
  background: var(--accent);
  opacity: 1;
}

.action-orbs strong {
  margin-left: 3px;
  color: var(--accent);
  font-size: 12px;
}

.bar-line {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) 64px;
  gap: 8px;
  align-items: center;
  margin-top: 6px;
  font-size: 12px;
}

.bar-track {
  height: 8px;
  overflow: hidden;
  border-radius: 999px;
  background: #0d1110;
  border: 1px solid #26302d;
}

.bar-fill {
  height: 100%;
  width: var(--fill);
  background: var(--bar);
}

.bar-line.hp .bar-fill {
  --bar: var(--danger);
}

.bar-line.mp .bar-fill {
  --bar: var(--accent-2);
}

.bar-line.ap .bar-fill {
  --bar: var(--accent);
}

.event-box {
  height: auto;
  min-height: 0;
  background: #111614;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  margin: 0;
  white-space: pre-line;
  line-height: 1.65;
  overflow: auto;
}

.event-box.combat-log {
  position: absolute;
  top: 108px;
  right: 42px;
  bottom: 154px;
  z-index: 22;
  width: min(360px, calc(100% - 62px));
  max-width: 360px;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .38);
  transform: translateX(calc(100% + 48px));
  transition: transform .22s ease, opacity .22s ease;
  opacity: .98;
}

.event-box.combat-log.open {
  transform: translateX(0);
}

.list {
  display: grid;
  gap: 8px;
}

.item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px;
  background: #151a18;
}

.item-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 6px;
}

.item small {
  color: var(--muted);
  display: block;
  line-height: 1.45;
}

.rarity-common { color: #d9ddd8; }
.rarity-magic { color: #75b9ff; }
.rarity-rare { color: #d6b45e; }
.rarity-epic { color: #c28cff; }
.rarity-legendary { color: #ff8a5c; }

.inventory-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.log {
  display: flex;
  flex-direction: column-reverse;
  gap: 8px;
  max-height: calc(100vh - 190px);
  overflow: auto;
}

.log p {
  margin: 0;
  color: var(--muted);
  border-bottom: 1px solid var(--line);
  padding-bottom: 8px;
  line-height: 1.45;
}

@media (max-width: 980px) {
  .game {
    grid-template-columns: 1fr;
  }

  .log {
    max-height: 220px;
  }
}

@media (max-width: 820px) {
  :root {
    --mobile-app-height: 100dvh;
    --mobile-combat-hud-height: 92px;
    --mobile-actions-height: 132px;
  }

  html,
  body {
    height: 100%;
    overflow: hidden;
  }

  .app {
    height: var(--mobile-app-height);
    padding: max(4px, env(safe-area-inset-top)) max(4px, env(safe-area-inset-right)) max(4px, env(safe-area-inset-bottom)) max(4px, env(safe-area-inset-left));
    overflow: hidden;
  }

  .topbar {
    display: none;
  }

  .game {
    height: 100%;
    display: block;
  }

  .stats,
  .log-panel {
    display: none;
  }

  .panel {
    padding: 6px;
  }

  .main-panel {
    height: calc(var(--mobile-app-height) - 8px);
    min-height: 0;
    overflow: hidden;
  }

  .tabs {
    gap: 4px;
    margin-bottom: 6px;
  }

  .tabs button {
    min-height: 32px;
    padding: 5px 4px;
    font-size: 12px;
  }

  .tab-view {
    height: calc(var(--mobile-app-height) - 58px);
    overflow: auto;
  }

  #dungeonTab {
    position: relative;
    min-height: 0;
    height: calc(var(--mobile-app-height) - 58px);
    overflow: hidden;
    display: grid;
    grid-template-rows: 22px 60px var(--mobile-combat-hud-height) minmax(0, 1fr) var(--mobile-combat-hud-height) var(--mobile-actions-height);
    gap: 4px;
    padding-right: 0;
  }

  .combat-scene-fx {
    top: 90px;
    bottom: calc(var(--mobile-actions-height) + 12px);
  }

  .combat-log-toggle {
    top: 92px;
    width: 34px;
    min-height: 40px;
    font-size: 11px;
  }

  .scene-fireball {
    bottom: 30px;
  }

  #dungeonTab.hidden {
    display: none !important;
  }

  #dungeonTab.combat-mode {
    grid-template-rows: 22px 60px minmax(0, 1fr) minmax(0, 1fr) var(--mobile-actions-height);
  }

  .section-head {
    display: flex;
    align-items: baseline;
    min-height: 22px;
  }

  .section-head h2 {
    font-size: 14px;
    margin-bottom: 0;
  }

  .section-head span {
    font-size: 11px;
  }

  .class-grid,
  .inventory-layout,
  .camp-home,
  .prep-layout,
  .run-status {
    grid-template-columns: 1fr;
  }

  .camp-home {
    gap: 6px;
  }

  .camp-card {
    min-height: 0;
    padding: 8px;
    gap: 7px;
  }

  .dungeon-gate-card {
    min-height: 260px;
    padding: 12px;
    background:
      linear-gradient(180deg, rgba(16, 19, 18, .28), rgba(16, 19, 18, .96)),
      url("assets/camp-hero.png") center / cover no-repeat;
  }

  .dungeon-gate-card strong {
    font-size: 24px;
  }

  .dungeon-gate-card button {
    width: 100%;
  }

  .mini-stat-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
  }

  .mini-stat-grid div {
    padding: 5px;
  }

  .mini-stat-grid span {
    font-size: 10px;
    margin-bottom: 1px;
  }

  .mini-stat-grid strong {
    font-size: 11px;
  }

  .supply-row {
    grid-template-columns: 1fr;
    padding: 8px;
  }

  .stepper {
    grid-template-columns: 42px 1fr 42px;
  }

  .market-row {
    grid-template-columns: 1fr auto;
  }

  .prep-dock {
    padding: 8px 0 0;
  }

  .run-status {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(68px, 1fr);
    grid-template-columns: none;
    gap: 4px;
    margin-bottom: 0;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 2px;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .run-status .loot-stat {
    min-width: 68px;
    padding: 6px 5px;
  }

  .run-status .loot-stat span {
    font-size: 10px;
    margin-bottom: 2px;
  }

  .run-status .loot-stat strong {
    font-size: 12px;
    line-height: 1.2;
  }

  .run-status::-webkit-scrollbar {
    display: none;
  }

  .run-loot-strip {
    display: none;
  }

  .combat-hud {
    height: var(--mobile-combat-hud-height);
    margin: 0;
  }

  .combat-row {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .combat-card.empty {
    display: none;
  }

  .combat-card {
    height: var(--mobile-combat-hud-height);
    padding: 7px 8px;
  }

  #dungeonTab.combat-mode .combat-card {
    height: 100%;
    min-height: 0;
  }

  .combat-name {
    gap: 6px;
    margin-bottom: 5px;
  }

  .combat-name strong {
    font-size: 12px;
  }

  .combat-name span {
    display: inline;
    flex: 0 0 auto;
    font-size: 10px;
  }

  .action-orbs {
    gap: 4px;
    margin-bottom: 5px;
  }

  .action-orb {
    width: 8px;
    height: 8px;
  }

  .bar-line {
    grid-template-columns: 34px minmax(0, 1fr) 48px;
    gap: 5px;
    margin-top: 3px;
    font-size: 10px;
  }

  .bar-track {
    height: 6px;
  }

  .bar-line span:last-child {
    display: inline;
    overflow: hidden;
    text-align: right;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .event-box {
    height: auto;
    min-height: 0;
    margin: 0;
    padding: 8px;
    font-size: 11px;
    line-height: 1.34;
  }

  .event-box.combat-log {
    top: 86px;
    right: 36px;
    bottom: calc(var(--mobile-actions-height) + 10px);
    width: min(300px, calc(100% - 48px));
    padding: 8px;
    font-size: 10.5px;
    line-height: 1.28;
  }

  .player-hud {
    margin: 0;
  }

  .button-grid {
    min-height: var(--mobile-actions-height);
    max-height: var(--mobile-actions-height);
    gap: 4px;
    padding-bottom: 2px;
  }

  .button-grid button {
    min-height: 36px;
    padding: 5px 7px;
    font-size: 11px;
  }

  .action-group {
    gap: 3px;
  }

  .action-group h3 {
    font-size: 10px;
    line-height: 1;
  }

  .action-group-buttons {
    gap: 4px;
  }
}

@media (max-width: 820px) and (max-height: 700px) {
  :root {
    --mobile-combat-hud-height: 86px;
    --mobile-actions-height: 116px;
  }

  .run-status {
    height: 56px;
  }

  .combat-card {
    padding: 6px 7px;
  }

  .combat-name {
    margin-bottom: 4px;
  }

  .action-orbs {
    margin-bottom: 4px;
  }

  .bar-line {
    margin-top: 2px;
  }

  .action-group h3 {
    display: none;
  }
}

@media (max-width: 360px) and (max-height: 680px) {
  :root {
    --mobile-combat-hud-height: 82px;
    --mobile-actions-height: 108px;
  }

  .combat-name span {
    display: none;
  }

  .bar-line {
    grid-template-columns: 32px minmax(0, 1fr) 42px;
    font-size: 9px;
  }

  .action-group-buttons {
    gap: 3px;
  }
}
