:root {
  color-scheme: dark;
  --bg: #0b0f0d;
  --line: #35423b;
  --text: #f4f1e8;
  --muted: #9da9a2;
  --gold: #e0b862;
  --shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  --tile: clamp(18px, min(31px, calc((100vw - 48px) / 13), calc((100svh - 360px) / 13)), 31px);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  height: 100%;
  margin: 0;
  background:
    radial-gradient(circle at 50% -10%, rgba(181, 139, 65, 0.13), transparent 38%),
    linear-gradient(180deg, #121815 0%, var(--bg) 100%);
  color: var(--text);
  overflow: hidden;
}

body {
  display: flex;
  justify-content: center;
  touch-action: manipulation;
}

button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #26312c, #1b231f);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035), 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 0.12s ease, border-color 0.12s ease, filter 0.12s ease, background 0.12s ease;
}

button:disabled {
  opacity: 0.45;
}

button:active:not(:disabled) {
  transform: translateY(1px);
  filter: brightness(1.12);
}

.app-shell {
  width: min(100vw, 520px);
  height: 100svh;
  padding: max(6px, env(safe-area-inset-top)) 8px max(8px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-rows: auto auto auto auto minmax(0, 1fr) clamp(140px, 20svh, 190px);
  gap: 6px;
  position: relative;
  overflow: hidden;
}

.app-shell.arena-mode {
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: clamp(105px, 15svh, 132px) auto auto minmax(0, 1fr);
  background:
    radial-gradient(circle at 50% 24%, rgba(151, 57, 45, 0.2), transparent 48%),
    linear-gradient(180deg, rgba(25, 18, 15, 0.96), rgba(10, 9, 8, 0.99));
}

.app-shell.dungeon-mode {
  /* 高さ予算: 上部ログ105px + ヘッダー約90px + 操作パッド156px + 余白約40px。
     328px では中背丈端末(667px級)でパッド下段がログに重なった。 */
  --tile: clamp(15px, min(32px, calc((100vw - 42px) / 13), calc((100svh - 390px) / 13)), 32px);
  grid-template-columns: minmax(0, 1fr);
  grid-template-rows: clamp(105px, 15svh, 132px) minmax(0, 1fr);
  background:
    radial-gradient(circle at 50% 26%, rgba(74, 101, 84, 0.2), transparent 48%),
    linear-gradient(180deg, rgba(15, 22, 18, 0.94), rgba(8, 12, 10, 0.98));
}

.app-shell.dungeon-mode .status-bar {
  display: none;
}

.app-shell.dungeon-mode .status-hp {
  display: none;
}

.app-shell.dungeon-mode > .character-strip {
  display: none;
}

.app-shell.dungeon-mode #dungeonView {
  grid-column: 1;
  grid-row: 2;
  padding-bottom: 7px;
  scroll-padding-bottom: 7px;
  overflow: hidden;
}

.app-shell.dungeon-mode .log-panel {
  grid-column: 1 / -1;
  grid-row: 1;
}

.app-shell.dungeon-mode .equipment-strip,
.app-shell.arena-mode .equipment-strip {
  display: none;
}

.app-shell.dungeon-mode .tabs,
.app-shell.arena-mode .tabs {
  display: none;
}

.app-shell.town-mode #dungeonView {
  display: none !important;
}

.app-shell.town-mode {
  background:
    radial-gradient(circle at 50% 18%, rgba(171, 119, 47, 0.18), transparent 48%),
    linear-gradient(180deg, rgba(20, 22, 17, 0.92), rgba(10, 13, 11, 0.98));
}

.app-shell.town-mode .tabs {
  border-color: rgba(214, 174, 84, 0.55);
  background: rgba(52, 42, 27, 0.96);
}

.app-shell.dungeon-mode .equipment-strip,
.app-shell.dungeon-mode .log-panel,
.app-shell.arena-mode .status-bar,
.app-shell.arena-mode .equipment-strip,
.app-shell.arena-mode .log-panel {
  border-color: #4f6048;
  background: rgba(18, 25, 18, 0.97);
}

.app-shell.arena-mode .status-bar,
.app-shell.arena-mode .equipment-strip,
.app-shell.arena-mode .log-panel {
  border-color: rgba(156, 76, 62, 0.62);
  background: rgba(27, 18, 16, 0.97);
}

.status-bar,
.equipment-strip,
.tabs,
.view,
.log-panel,
.floor-line {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(29, 37, 32, 0.97), rgba(18, 24, 20, 0.97));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025), var(--shadow);
}

.status-bar {
  display: grid;
  grid-template-columns: 0.9fr 0.9fr 0.9fr 1fr 0.62fr 54px;
  gap: 1px;
  overflow: hidden;
}

.status-bar > div,
.equipment-strip > div,
.floor-line > div,
.character-strip > div {
  display: grid;
  gap: 2px;
  padding: 5px 6px;
  background: rgba(255, 255, 255, 0.025);
  min-width: 0;
}

.hp-bar {
  display: block;
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08);
}

.hp-bar i,
.mini-hp-bar i {
  display: block;
  height: 100%;
  transition: width 0.18s ease, background-color 0.18s ease;
}

.hp-healthy { background: linear-gradient(90deg, #4f9b55, #89d06d); }
.hp-warning { background: linear-gradient(90deg, #b58a2d, #e4c458); }
.hp-critical { background: linear-gradient(90deg, #9e352f, #e05b4e); }

.character-strip {
  display: grid;
  grid-template-columns: repeat(8, minmax(0, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(27, 35, 30, 0.96), rgba(18, 24, 20, 0.96));
}

.hunger-stat.is-hungry strong,
.dungeon-hunger-stat.is-hungry strong {
  color: #ffd36d;
}

.hunger-stat.is-starving strong,
.dungeon-hunger-stat.is-starving strong {
  color: #ff7369;
  text-shadow: 0 0 8px rgba(255, 60, 45, 0.45);
}

.hunger-stat.is-weakened,
.dungeon-hunger-stat.is-weakened {
  animation: hunger-warning-pulse 1.2s ease-in-out infinite alternate;
}

@keyframes hunger-warning-pulse {
  from { opacity: 0.72; }
  to { opacity: 1; }
}

.audio-button {
  min-height: auto;
  border: 0;
  border-radius: 0;
  display: grid;
  place-items: center;
  gap: 0;
  padding: 5px 3px;
  background: rgba(214, 174, 84, 0.08);
}

.audio-button span {
  color: var(--gold);
  font-size: 18px;
  line-height: 1;
}

.audio-button strong {
  font-size: 10px;
  color: #fff0b8;
}

.audio-button.is-on {
  background: rgba(214, 174, 84, 0.18);
  box-shadow: inset 0 0 18px rgba(214, 174, 84, 0.08);
}

.app-shell:not(.town-mode) .audio-button {
  display: none;
}

span,
.panel-title,
small {
  color: var(--muted);
  font-size: 10px;
  line-height: 1.15;
}

strong {
  min-width: 0;
  font-size: 13px;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.equipment-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  grid-template-rows: repeat(2, auto);
  gap: 1px;
  overflow: hidden;
}

/* 両手持ちの間は、武器欄が左手欄の幅まで伸びて1枠になる。
   `display: grid` が [hidden] を上書きするため、明示的に消す。 */
.equipment-strip > div[hidden] {
  display: none;
}

.equipment-strip > div.slot-two-handed {
  grid-column: span 2;
  background: linear-gradient(180deg, rgba(255, 206, 120, 0.12), rgba(255, 206, 120, 0.03));
  box-shadow: inset 0 0 0 1px rgba(255, 214, 130, 0.35);
}

.equipment-strip > div.slot-two-handed > span {
  color: #ffd782;
}

.tabs {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(2, minmax(32px, auto));
  gap: 4px;
  padding: 4px;
  overflow: hidden;
}

.tabs button {
  border: 0;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  min-height: 32px;
  font-size: 13px;
  white-space: nowrap;
}

.tabs button.locked {
  color: #77736b;
  border-color: rgba(120, 116, 106, 0.28);
  background: #171816;
  filter: saturate(0.35);
}

.tabs button[data-view="dungeon"] {
  padding-inline: 2px;
  font-size: 11px;
}

.tabs button.active {
  color: #fff3c4;
  background: linear-gradient(180deg, #55462a, #352c1e);
  box-shadow: inset 0 0 0 1px rgba(224, 184, 98, 0.28), 0 3px 12px rgba(0, 0, 0, 0.24);
}

.tabs button[data-view="arena"] {
  padding-inline: 2px;
}

.view {
  min-height: 0;
  padding: 7px;
  overflow: auto;
}

#dungeonView {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-shell.arena-mode #arenaView {
  grid-column: 1;
  grid-row: 4;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.app-shell.arena-mode .log-panel {
  grid-column: 1;
  grid-row: 1;
}

.hidden {
  display: none !important;
}

.save-warning {
  position: fixed;
  z-index: 120;
  top: max(8px, env(safe-area-inset-top));
  left: 50%;
  width: min(calc(100vw - 20px), 500px);
  padding: 10px;
  border: 1px solid #db8d78;
  border-radius: 11px;
  background: rgba(78, 25, 20, 0.97);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.55);
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
}

.save-warning p {
  margin: 0;
  line-height: 1.5;
}

.save-warning button {
  border-color: #e5ae72;
}

.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  clip-path: inset(50%) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.town-grid,
.card-list {
  display: grid;
  gap: 8px;
}

.town-card,
.recipe-card,
.research-card {
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 11px;
  padding: 11px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.042), rgba(255, 255, 255, 0.014));
  display: grid;
  gap: 7px;
  box-shadow: inset 3px 0 rgba(224, 184, 98, 0.12), 0 5px 18px rgba(0, 0, 0, 0.18);
}

.town-card h2,
.recipe-card h2,
.research-card h2,
.modal-card h2 {
  margin: 0;
  font-size: 16px;
}

.town-card p,
.recipe-card p,
.research-card p,
.modal-card p {
  margin: 0;
  color: #e5e1d0;
  font-size: 13px;
  line-height: 1.45;
}

.junk-dealer-header {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid rgba(193, 132, 231, 0.46);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(104, 53, 126, 0.28), rgba(38, 28, 48, 0.2));
}

.junk-dealer-header h2,
.junk-dealer-header p {
  margin: 2px 0;
}

.junk-dealer-header > strong {
  color: #efc8ff;
  white-space: nowrap;
}

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

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

.tavern-snack-menu button {
  min-height: 52px;
  padding: 7px;
  text-align: left;
  display: grid;
  gap: 2px;
}

.tavern-snack-menu small {
  color: var(--muted);
}

.job-grid button {
  min-height: 64px;
  padding: 7px;
  text-align: left;
  display: grid;
  gap: 3px;
}

.job-grid button.selected {
  border-color: var(--gold);
  color: #ffe6a5;
}

.choice-grid {
  display: grid;
  gap: 6px;
}

.choice-grid button {
  min-height: 58px;
  padding: 8px;
  text-align: left;
  display: grid;
  gap: 2px;
}

.choice-grid button.selected {
  border-color: var(--gold);
  color: #ffe6a5;
  box-shadow: inset 0 0 0 1px rgba(214, 174, 84, 0.22);
}

.floor-line {
  display: grid;
  grid-template-columns: 1fr 68px;
  gap: 5px;
  align-items: stretch;
  margin-bottom: 5px;
}

.floor-line button {
  margin: 4px 4px 4px 0;
  min-height: 30px;
  font-size: 13px;
}

.floor-line small {
  color: #b9c8ad;
  font-size: 10px;
}

.dungeon-projection {
  position: relative;
  width: fit-content;
  max-width: 100%;
  margin-inline: auto;
}

.dungeon-stats-overlay {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 12;
  width: 66px;
  display: grid;
  gap: 5px;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
  pointer-events: none;
  transform: none;
}

.dungeon-stats-overlay .dungeon-hp-stat {
  grid-template-columns: auto 1fr;
  width: 66px;
  margin-bottom: 2px;
}

.dungeon-hp-stat > strong {
  color: #fff3c4;
  font-size: 11px;
}

.dungeon-hp-stat .hp-bar {
  grid-column: 1 / -1;
  width: 69.3px;
  height: 4px;
}

.dungeon-stats-overlay > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 3px;
  align-items: baseline;
  min-width: 0;
  padding: 1px 0;
}

.dungeon-stats-overlay span {
  color: #a9b8aa;
  font-size: 9px;
  line-height: 1;
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
}

.dungeon-stats-overlay strong {
  color: #fff0b3;
  font-size: 12px;
  line-height: 1;
  text-align: right;
  text-shadow: 0 1px 4px #000;
}

.map {
  position: relative;
  isolation: isolate;
  display: grid;
  grid-template-columns: repeat(13, var(--tile));
  grid-template-rows: repeat(13, var(--tile));
  gap: 0;
  justify-content: center;
  width: fit-content;
  max-width: 100%;
  overflow: hidden;
  padding: 4px;
  border: 1px solid #4b513f;
  border-radius: 12px;
  /* Fractional mobile tile widths can expose a subpixel seam; use the floor
     color underneath so the seam remains visually continuous. */
  background: #1b241c;
  box-shadow: inset 0 0 34px rgba(0, 0, 0, 0.76), 0 8px 24px rgba(0, 0, 0, 0.32);
}

.map::after {
  content: "";
  position: absolute;
  inset: 4px;
  z-index: 8;
  border-radius: 8px;
  pointer-events: none;
  background: radial-gradient(
    circle closest-side at 50% 50%,
    transparent 0 34%,
    rgba(0, 0, 0, 0.08) 46%,
    rgba(0, 0, 0, 0.36) 64%,
    rgba(0, 0, 0, 0.72) 84%,
    rgba(0, 0, 0, 0.91) 97%,
    rgba(0, 0, 0, 0.97) 100%
  );
  box-shadow: inset 0 0 24px 8px rgba(0, 0, 0, 0.78);
}

.map-grid-row {
  display: contents;
}

.cell {
  position: relative;
  z-index: 1;
  /* Slight overlap prevents Safari from exposing hairline gaps when --tile
     resolves to a fractional CSS pixel. The map clips the outer half-pixel. */
  width: calc(var(--tile) + 0.6px);
  height: calc(var(--tile) + 0.6px);
  display: grid;
  place-items: center;
  border-radius: 0;
  background: #11140f;
  color: var(--muted);
  font-size: calc(var(--tile) * 0.48);
  line-height: 1;
  transition: filter 0.16s ease, box-shadow 0.16s ease, color 0.16s ease;
}

.cell.light-near {
  filter: brightness(1.18) saturate(1.08);
}

.cell.light-room {
  z-index: 9;
  filter: brightness(1.18) saturate(1.08);
}

.cell.light-room.tile-floor {
  background: #1b241c;
  box-shadow: none;
}

.cell.light-mid {
  filter: brightness(0.9) saturate(0.9);
}

.cell.light-darkvision {
  filter: brightness(0.86) saturate(0.58) hue-rotate(8deg);
}

.cell.light-far {
  filter: brightness(0.58) saturate(0.68);
}

.tile-wall {
  border: 1px solid rgba(141, 148, 126, 0.22);
  background:
    linear-gradient(145deg, rgba(255, 255, 255, 0.09), transparent 42%),
    repeating-linear-gradient(0deg, #343830 0 4px, #292d27 4px 8px);
  box-shadow: inset 1px 1px rgba(197, 202, 174, 0.08), inset -2px -2px rgba(0, 0, 0, 0.34);
}

.tile-floor,
.tile-chest {
  border: 0;
  background: #1b241c;
  box-shadow: none;
}

.tile-excavated {
  background:
    radial-gradient(circle at 25% 70%, rgba(186, 162, 116, 0.28) 0 1px, transparent 2px),
    radial-gradient(circle at 72% 34%, rgba(162, 145, 108, 0.22) 0 1px, transparent 2px),
    linear-gradient(160deg, #29271f, #1b1c17);
  box-shadow: inset 0 0 0 1px rgba(188, 165, 119, 0.18), inset 0 0 7px rgba(0, 0, 0, 0.28);
}

.cell.room-madness { --special-room-outline-color: rgba(203, 64, 122, 0.7); }
.cell.room-treasureVault { --special-room-outline-color: rgba(247, 202, 83, 0.7); }
.cell.room-thrill { --special-room-outline-color: rgba(137, 210, 255, 0.7); }

/* The outline follows the room's actual boundary, not every tile. */
.cell > .special-room-outline {
  position: absolute;
  inset: 0;
  z-index: 5;
  box-sizing: border-box;
  border: 0 solid var(--special-room-outline-color);
  pointer-events: none;
}
.cell > .special-room-outline.edge-top { border-top-width: 1px; }
.cell > .special-room-outline.edge-bottom { border-bottom-width: 1px; }
.cell > .special-room-outline.edge-left { border-left-width: 1px; }
.cell > .special-room-outline.edge-right { border-right-width: 1px; }

.tile-player {
  z-index: 9;
  background: #1b241c;
  color: #fff4c2;
  font-size: calc(var(--tile) * 0.62);
  font-weight: 400;
  box-shadow: none;
  text-shadow: 0 0 5px #fff5c9, 0 0 12px rgba(238, 198, 94, 0.96);
}

.player-unlit {
  text-shadow: none !important;
}

.capoeira-inverted {
  transform: rotate(180deg);
}

.cell.targetable-ranged {
  z-index: 9;
  cursor: crosshair;
  outline: 2px solid rgba(116, 211, 255, 0.88);
  outline-offset: -2px;
  box-shadow:
    inset 0 0 0 1px rgba(218, 247, 255, 0.46),
    0 0 10px rgba(72, 186, 238, 0.72);
  color: #dff8ff;
}

.combat-projectile-fx,
.combat-impact-fx {
  position: fixed;
  z-index: 150;
  display: block;
  pointer-events: none;
  contain: layout paint;
}

.combat-projectile-fx {
  width: 20px;
  height: 7px;
  border-radius: 999px;
  opacity: 0;
  background: linear-gradient(90deg, transparent, var(--combat-fx-color) 36%, var(--combat-fx-accent));
  box-shadow:
    0 0 5px var(--combat-fx-color),
    0 0 13px color-mix(in srgb, var(--combat-fx-color) 76%, transparent);
  transform: translate(-50%, -50%) rotate(var(--combat-fx-angle));
  transform-origin: center;
  animation: combat-projectile-flight var(--combat-fx-duration) cubic-bezier(0.16, 0.7, 0.2, 1) both;
  will-change: left, top, transform, opacity;
}

.combat-projectile-fx::before,
.combat-projectile-fx::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.combat-projectile-fx::after {
  right: 72%;
  top: 50%;
  width: 34px;
  height: 2px;
  border-radius: 999px;
  opacity: 0.7;
  background: linear-gradient(90deg, transparent, var(--combat-fx-color));
  transform: translateY(-50%);
}

.combat-projectile-player-shot {
  width: 27px;
  height: 4px;
  border-radius: 1px 999px 999px 1px;
  background: linear-gradient(90deg, #8d6635 0 62%, var(--combat-fx-accent) 63% 100%);
  box-shadow: 0 0 7px var(--combat-fx-color);
}

.combat-projectile-player-shot::before {
  right: -5px;
  top: 50%;
  border-top: 5px solid transparent;
  border-bottom: 5px solid transparent;
  border-left: 8px solid var(--combat-fx-accent);
  transform: translateY(-50%);
}

.combat-projectile-enemy-shot {
  width: 18px;
  height: 9px;
  border: 1px solid color-mix(in srgb, var(--combat-fx-accent) 82%, transparent);
  background: radial-gradient(circle at 72% 50%, var(--combat-fx-accent), var(--combat-fx-color) 38%, transparent 72%);
}

.combat-projectile-fx.combat-projectile-enemy-spell {
  width: 22px;
  height: 22px;
  border: 2px solid var(--combat-fx-accent);
  border-radius: 42%;
  clip-path: polygon(50% 0, 88% 18%, 100% 58%, 76% 94%, 32% 100%, 0 68%, 8% 24%);
  background:
    radial-gradient(circle, #fff 0 8%, var(--combat-fx-accent) 14%, transparent 34%),
    conic-gradient(from 30deg, var(--combat-fx-color), transparent 24%, var(--combat-fx-accent) 48%, transparent 72%, var(--combat-fx-color));
  box-shadow: 0 0 10px var(--combat-fx-color), 0 0 24px var(--combat-fx-color);
}

.combat-projectile-fx.combat-projectile-enemy-spell::before {
  inset: -7px;
  border: 1px dashed var(--combat-fx-accent);
  border-radius: 36%;
  animation: combat-projectile-orbit 360ms linear infinite reverse;
}

.combat-projectile-fx.combat-projectile-enemy-spell::after {
  right: 72%;
  width: 42px;
  height: 4px;
  background: linear-gradient(90deg, transparent, var(--combat-fx-color), var(--combat-fx-accent));
  filter: blur(1px);
}

.combat-projectile-job-skill {
  width: 33px;
  height: 9px;
  border-top: 2px solid var(--combat-fx-accent);
  border-bottom: 2px solid var(--combat-fx-color);
  border-radius: 60% 8px 60% 8px;
  background: linear-gradient(90deg, transparent, color-mix(in srgb, var(--combat-fx-color) 72%, transparent));
}

.combat-projectile-job-skill::before {
  inset: -5px 2px;
  border: 1px solid var(--combat-fx-color);
  border-radius: 50%;
  animation: combat-projectile-orbit 260ms linear infinite;
}

.combat-projectile-spell {
  width: 17px;
  height: 17px;
  border: 2px solid var(--combat-fx-accent);
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 12%, var(--combat-fx-accent) 18%, var(--combat-fx-color) 48%, transparent 74%);
  box-shadow: 0 0 8px var(--combat-fx-color), 0 0 20px var(--combat-fx-color);
}

.combat-projectile-spell::before {
  inset: -7px;
  border: 1px solid var(--combat-fx-color);
  border-style: dashed;
  border-radius: 50%;
  animation: combat-projectile-orbit 420ms linear infinite;
}

.combat-projectile-dragon-breath {
  width: 58px;
  height: 34px;
  border: 1px solid color-mix(in srgb, var(--combat-fx-accent) 72%, transparent);
  border-radius: 50% 12% 12% 50%;
  clip-path: polygon(0 39%, 100% 0, 86% 50%, 100% 100%, 0 61%);
  background:
    repeating-linear-gradient(0deg, transparent 0 5px, color-mix(in srgb, var(--combat-fx-accent) 62%, transparent) 6px 8px),
    linear-gradient(90deg, transparent, var(--combat-fx-color) 24%, var(--combat-fx-accent));
  box-shadow: 0 0 12px var(--combat-fx-color), 0 0 28px var(--combat-fx-color);
  animation-name: combat-breath-flight;
  animation-timing-function: cubic-bezier(0.08, 0.58, 0.2, 1);
  mix-blend-mode: screen;
}

.combat-projectile-dragon-breath::after {
  right: 82%;
  width: 48px;
  height: 22px;
  border-radius: 50%;
  filter: blur(4px);
}

.combat-projectile-variant-venom {
  width: 15px;
  height: 13px;
  border-radius: 58% 42% 64% 36%;
  filter: saturate(1.35);
}

.combat-projectile-variant-spark {
  width: 30px;
  height: 12px;
  border: 0;
  border-radius: 0;
  clip-path: polygon(0 43%, 28% 22%, 38% 52%, 65% 8%, 58% 44%, 100% 34%, 73% 61%, 52% 100%, 54% 60%, 22% 78%);
  background: var(--combat-fx-accent);
}

.combat-projectile-variant-ember {
  width: 19px;
  height: 15px;
  border-radius: 55% 45% 55% 45%;
  background: radial-gradient(circle at 70% 50%, #fff 0 9%, var(--combat-fx-accent) 20%, var(--combat-fx-color) 54%, transparent 76%);
}

.combat-projectile-variant-gust {
  width: 29px;
  height: 18px;
  border: 2px solid var(--combat-fx-color);
  border-left-color: transparent;
  border-radius: 50%;
  background: transparent;
}

.combat-projectile-variant-feather {
  width: 28px;
  height: 7px;
  border-radius: 100% 8% 100% 8%;
  background: linear-gradient(170deg, transparent 0 24%, var(--combat-fx-accent) 28% 54%, var(--combat-fx-color) 58% 100%);
}

.combat-projectile-variant-ray {
  width: 42px;
  height: 5px;
  border-radius: 999px;
  background: linear-gradient(90deg, transparent, var(--combat-fx-color) 18%, #fff 72%, var(--combat-fx-accent));
}

.combat-projectile-variant-shard {
  width: 24px;
  height: 12px;
  border-radius: 0;
  clip-path: polygon(0 50%, 74% 0, 100% 50%, 74% 100%);
  background: linear-gradient(145deg, var(--combat-fx-accent), var(--combat-fx-color) 58%, transparent);
}

.combat-projectile-variant-pulse {
  border-radius: 50%;
  background: radial-gradient(circle, #fff 0 8%, var(--combat-fx-accent) 18%, var(--combat-fx-color) 48%, transparent 76%);
}

.combat-impact-fx {
  width: 18px;
  height: 18px;
  border: 3px solid var(--combat-fx-accent);
  border-radius: 50%;
  opacity: 0;
  box-shadow: 0 0 10px var(--combat-fx-color), inset 0 0 8px var(--combat-fx-color);
  transform: translate(-50%, -50%);
  animation: combat-impact-burst 400ms ease-out both;
}

.combat-impact-fx::before,
.combat-impact-fx::after {
  content: "";
  position: absolute;
  inset: 50%;
  width: 28px;
  height: 3px;
  border-radius: 999px;
  background: var(--combat-fx-color);
  box-shadow: 0 0 7px var(--combat-fx-color);
  transform: translate(-50%, -50%) rotate(45deg);
}

.combat-impact-fx::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

/* 希望のロケット: 白い尾を長く引いて飛び、着弾で光が弾ける専用弾。 */
.combat-projectile-hope-rocket {
  width: 46px;
  height: 12px;
  border-radius: 50% 8% 8% 50%;
  clip-path: polygon(0 50%, 24% 0, 100% 34%, 100% 66%, 24% 100%);
  background: linear-gradient(90deg, transparent, #fff8ad 38%, #ffffff);
  box-shadow: 0 0 14px #fff8ad, 0 0 34px rgba(255, 248, 173, 0.85), 0 0 60px rgba(255, 255, 255, 0.5);
  animation-name: combat-projectile-flight;
  animation-timing-function: cubic-bezier(0.12, 0.72, 0.16, 1);
  mix-blend-mode: screen;
}

.combat-projectile-hope-rocket::after {
  content: "";
  position: absolute;
  right: 74%;
  top: 50%;
  width: 130px;
  height: 3px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, transparent, rgba(255, 248, 173, 0.9));
  filter: blur(1.5px);
}

.combat-impact-hope-rocket {
  width: 64px;
  height: 64px;
  border-width: 6px;
  animation-name: combat-breath-impact;
  animation-duration: 640ms;
  mix-blend-mode: screen;
}

.combat-impact-dragon-breath {
  width: 52px;
  height: 52px;
  border-width: 5px;
  animation-name: combat-breath-impact;
  animation-duration: 600ms;
  mix-blend-mode: screen;
}

.combat-impact-enemy-spell {
  width: 30px;
  height: 30px;
  border-width: 2px;
  border-radius: 30%;
  clip-path: polygon(50% 0, 63% 34%, 100% 50%, 63% 66%, 50% 100%, 37% 66%, 0 50%, 37% 34%);
  background: color-mix(in srgb, var(--combat-fx-color) 34%, transparent);
  mix-blend-mode: screen;
}

@keyframes combat-projectile-flight {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--combat-fx-angle)) scaleX(0.28);
  }
  12% { opacity: 1; }
  82% { opacity: 1; }
  100% {
    left: var(--combat-fx-end-x);
    top: var(--combat-fx-end-y);
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--combat-fx-angle)) scaleX(1.08);
  }
}

@keyframes combat-breath-flight {
  0% {
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--combat-fx-angle)) scale(0.12, 0.35);
  }
  14% { opacity: 0.92; }
  72% { opacity: 1; }
  100% {
    left: var(--combat-fx-end-x);
    top: var(--combat-fx-end-y);
    opacity: 0;
    transform: translate(-50%, -50%) rotate(var(--combat-fx-angle)) scale(1.7, 1.22);
  }
}

@keyframes combat-projectile-orbit {
  to { transform: rotate(360deg); }
}

@keyframes combat-impact-burst {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.15); }
  24% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.35); }
}

@keyframes combat-breath-impact {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.18) rotate(0); }
  20% { opacity: 0.96; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(2.8) rotate(28deg); }
}

@media (prefers-reduced-motion: reduce) {
  .combat-projectile-fx {
    animation-duration: 90ms !important;
  }

  .combat-impact-fx {
    animation-duration: 120ms !important;
  }
}

.tile-enemy {
  background: #22271f;
  color: #f0a090;
  font-weight: 800;
  text-shadow: 0 1px 3px #000;
}

.tile-enemy,
.tile-unique,
.tile-flower-pet {
  position: relative;
}

.tile-flower-pet {
  background: radial-gradient(circle, rgba(255, 151, 211, 0.3), #1d3322 68%);
  color: #ff9cda !important;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px rgba(255, 143, 207, 0.8), 0 0 9px rgba(116, 236, 137, 0.5);
}

.tile-flower-pet .monster-marker {
  color: #ff9cda !important;
  text-shadow: 0 0 6px #ff5fbd, 0 0 10px #63e77b;
}

.tile-sleeping {
  box-shadow: inset 0 0 0 1px rgba(151, 184, 222, 0.32);
}

.sleep-indicator {
  position: absolute;
  top: 1px;
  right: 2px;
  color: #baddff;
  font-size: calc(var(--tile) * 0.28);
  font-weight: 900;
  text-shadow: 0 0 4px #4e79a8;
  animation: sleep-drift 1.8s ease-in-out infinite alternate;
}

@keyframes sleep-drift {
  from { transform: translateY(1px); opacity: 0.58; }
  to { transform: translateY(-2px); opacity: 1; }
}

.tile-invisible-seen {
  box-shadow: inset 0 0 0 1px rgba(185, 235, 244, 0.42), 0 0 10px rgba(140, 220, 238, 0.24);
}

.tile-invisible-seen > .monster-marker {
  opacity: 0.68;
  animation: invisible-shimmer 1.8s ease-in-out infinite alternate;
}

.tile-phasing-wall {
  background: repeating-linear-gradient(135deg, #222820 0 5px, #35413a 6px 8px) !important;
  opacity: 0.82;
  box-shadow: inset 0 0 0 1px rgba(178, 223, 235, 0.46), 0 0 8px rgba(133, 205, 225, 0.3) !important;
}

@keyframes invisible-shimmer {
  from { filter: contrast(0.82) brightness(0.85); transform: translateX(-1px); }
  to { filter: contrast(1.2) brightness(1.28); transform: translateX(1px); }
}

.monster-tier-white { color: #f4f4f4 !important; text-shadow: 0 1px 3px #000; }
.monster-tier-blue { color: #57a8ff !important; text-shadow: 0 0 5px rgba(40, 116, 255, 0.72); }
.monster-tier-green { color: #62db78 !important; text-shadow: 0 0 5px rgba(31, 157, 69, 0.72); }
.monster-tier-yellow { color: #ffe052 !important; text-shadow: 0 0 6px rgba(205, 154, 0, 0.8); }
.monster-tier-red { color: #ff625e !important; text-shadow: 0 0 6px rgba(210, 42, 37, 0.86); }
.monster-tier-purple { color: #cf79ff !important; text-shadow: 0 0 7px rgba(151, 49, 211, 0.9); }
.monster-tier-rainbow {
  animation: deep-rainbow-text 1.2s steps(6, end) infinite;
}

.monster-tier-white .monster-marker,
.monster-tier-blue .monster-marker,
.monster-tier-green .monster-marker,
.monster-tier-yellow .monster-marker,
.monster-tier-red .monster-marker,
.monster-tier-purple .monster-marker,
.monster-tier-rainbow .monster-marker {
  color: inherit !important;
  text-shadow: inherit;
}

.monster-tier-rainbow .monster-marker {
  animation: deep-rainbow-text 1.2s steps(6, end) infinite;
}

@keyframes deep-rainbow-text {
  0% { color: #ff5252; }
  20% { color: #ffd740; }
  40% { color: #69f0ae; }
  60% { color: #40c4ff; }
  80% { color: #b388ff; }
  100% { color: #ff80ab; }
}

.attr { font-size: inherit; font-weight: 800; }
.attr-fire { color: #ff655e; }
.attr-water { color: #58b8ff; }
.attr-thunder { color: #ffe052; }
.attr-poison { color: #c779ff; }
.attr-ice { color: #9eeeff; }
.attr-curse { color: #d88cff; }
.attr-acid { color: #9bea55; }
.attr-dark { color: #a58acb; }
.attr-light { color: #fff2a8; }
.attr-earth { color: #c89562; }
.attr-wind { color: #7ee8c2; }
.attr-steel { color: #cbd3db; }
.attr-illusion { color: #ff8fd8; }
.attr-slash { color: #ff9b9b; }
.attr-blunt { color: #e0ad78; }

.research-card-details .attr {
  display: inline-block;
  padding: 0 0.08em;
  font-size: 1.15em;
  line-height: 1;
  vertical-align: -0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.78);
}

.research-note-label {
  display: block;
  margin-bottom: 3px;
  color: #e7c772;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.045em;
}

.research-note-label.threat {
  color: #ff8d7b;
}

.research-note-aside {
  color: #aaa58f;
  font-size: 0.92em;
  font-style: normal;
}

.tile-trap {
  color: #ff8a65;
  background: #38241f;
}

.tile-trap.trap-danger-4 {
  color: #ff635f;
  box-shadow: inset 0 0 7px rgba(255, 77, 69, 0.42);
}

.tile-trap.trap-danger-5 {
  color: #fff0b5;
  background: #491b20;
  box-shadow: inset 0 0 8px rgba(255, 44, 62, 0.62), 0 0 5px rgba(255, 44, 62, 0.28);
}

.monster-marker {
  transform: translateY(-1px);
}

.monster-idle-visual {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

.cell.tile-critical-fleeing {
  box-shadow:
    inset 0 0 0 1px rgba(255, 86, 72, 0.76),
    0 0 8px rgba(190, 37, 29, 0.46);
}

.tile-critical-fleeing .monster-marker {
  animation: monster-panic-shiver 0.34s steps(2, end) infinite;
}

.cell.has-monster-scream {
  z-index: 12;
}

.monster-scream {
  position: absolute;
  z-index: 20;
  bottom: 74%;
  left: 50%;
  width: max-content;
  pointer-events: none;
  color: #fff2d0;
  font-size: max(9px, calc(var(--tile) * 0.34));
  font-weight: 900;
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 2px #000, 0 0 7px rgba(255, 65, 52, 0.94);
  animation: monster-scream-burst 0.9s ease-out both;
}

@keyframes monster-panic-shiver {
  0% { transform: translate(-1px, -1px) rotate(-3deg); }
  50% { transform: translate(1px, 0) rotate(3deg); }
  100% { transform: translate(-1px, -1px) rotate(-3deg); }
}

@keyframes monster-scream-burst {
  0% { opacity: 0; transform: translate(-50%, 5px) scale(0.55); }
  22% { opacity: 1; transform: translate(-50%, -3px) scale(1.18); }
  100% { opacity: 0; transform: translate(-50%, -12px) scale(0.94); }
}

.mini-hp-bar {
  position: absolute;
  z-index: 3;
  pointer-events: none;
  right: 2px;
  bottom: 2px;
  left: 2px;
  height: 3px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.72);
}

.tile-unique {
  background: #22271f;
  color: #ffd06f;
  font-weight: 900;
  box-shadow: inset 0 0 0 1px #d6ae54, 0 0 7px rgba(214, 174, 84, 0.45);
}

.tile-unique > .monster-marker > .monster-idle-visual {
  animation: unique-pulse 1.4s ease-in-out infinite alternate;
}

.tile-unique.unique-regal,
.monster-info-heading.unique-regal { border-color: #dcae45; }
.tile-unique.unique-feral,
.monster-info-heading.unique-feral { border-color: #df654f; }
.tile-unique.unique-oracle,
.monster-info-heading.unique-oracle { border-color: #65bfdc; }
.tile-unique.unique-trickster,
.monster-info-heading.unique-trickster { border-color: #dc70c4; }
.tile-unique.unique-warrior,
.monster-info-heading.unique-warrior { border-color: #96a5af; }
.tile-unique.unique-silent,
.monster-info-heading.unique-silent { border-color: #625873; }
.tile-unique.unique-zealot,
.monster-info-heading.unique-zealot { border-color: #edc24f; }
.tile-unique.unique-scholar,
.monster-info-heading.unique-scholar { border-color: #6fbd83; }

.tile-unique.unique-feral > .monster-marker > .monster-idle-visual { animation-duration: 0.58s; }
.tile-unique.unique-silent > .monster-marker > .monster-idle-visual { animation: unique-silent-drift 2.8s ease-in-out infinite alternate; }
.tile-unique.unique-trickster > .monster-marker > .monster-idle-visual { animation: unique-trickster-shift 1.1s steps(3, end) infinite; }

@keyframes unique-silent-drift {
  from { opacity: 0.58; filter: blur(0.35px); }
  to { opacity: 0.96; filter: blur(0); }
}

@keyframes unique-trickster-shift {
  0% { transform: translateX(-1px); filter: hue-rotate(0deg); }
  50% { transform: translateX(1px); filter: hue-rotate(35deg); }
  100% { transform: translateY(-1px); filter: hue-rotate(-25deg); }
}

.enemy-fire { color: #ff8a68; }
.enemy-water { color: #78cfff; }
.enemy-thunder { color: #ffe568; }
.enemy-poison, .enemy-curse { color: #d99aff; }
.enemy-ice { color: #baf6ff; }
.enemy-dark, .enemy-illusion { color: #c2a0ff; }
.enemy-light { color: #fff6c2; }
.enemy-earth, .enemy-blunt { color: #e7b47c; }
.enemy-wind { color: #a9efc0; }
.enemy-slash, .enemy-steel { color: #e3e8ed; }
.enemy-acid { color: #b9f66c; }

@keyframes unique-pulse {
  from { filter: brightness(0.9); }
  to { filter: brightness(1.2); }
}

.equipment-sortbar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 25, 18, 0.94);
}

.equipment-sortbar label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 11px;
}

.equipment-sortbar select {
  min-height: 34px;
  border: 1px solid rgba(214, 174, 84, 0.34);
  border-radius: 6px;
  padding: 4px 28px 4px 8px;
  color: #f1ead5;
  background: #242a20;
}

.monster-info-modal {
  z-index: 80;
}

.monster-info-card {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
}

.monster-info-heading {
  display: grid;
  grid-template-columns: 52px 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(24, 28, 22, 0.94);
}

.monster-info-heading > span {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.28);
  font-size: 25px;
  font-weight: 900;
}

.monster-info-heading h2 {
  margin: 0;
}

.monster-info-heading small {
  margin: 0;
  color: var(--muted);
}

.monster-info-grid {
  display: grid;
  gap: 5px;
}

.monster-detail-hp {
  display: grid;
  grid-template-columns: auto minmax(70px, 1fr) auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  font-size: 12px;
}

.monster-detail-hp .hp-bar {
  height: 8px;
}

.monster-info-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 13px;
}

.monster-info-row span,
.monster-loot-info > span {
  color: var(--muted);
}

.monster-loot-info,
.monster-research-notes,
.unknown-info {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.monster-loot-info p,
.monster-research-notes p {
  margin: 4px 0 0;
}

.shop-wallet {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 8px;
  padding: 10px;
  border: 1px solid rgba(214, 174, 84, 0.45);
  border-radius: 8px;
  background: rgba(80, 61, 24, 0.22);
}

.shop-wallet strong {
  color: #ffe6a5;
  font-size: 18px;
}

.shop-section {
  margin-bottom: 12px;
}

.shop-section h2 {
  margin: 0 0 7px;
  color: #ffe6a5;
  font-size: 15px;
}

.shop-material-list {
  display: grid;
  gap: 5px;
}

.shop-material-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 5px;
  align-items: center;
  padding: 7px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.shop-material-list article div {
  display: grid;
  gap: 3px;
}

.shop-material-list button {
  padding-inline: 8px;
  font-size: 11px;
}

.guild-wallet {
  display: grid;
  grid-template-columns: auto auto 1fr;
  gap: 10px;
  align-items: center;
  margin-bottom: 10px;
  padding: 11px;
  border: 1px solid rgba(129, 173, 211, 0.5);
  border-radius: 8px;
  background: rgba(42, 74, 96, 0.22);
}

.guild-wallet strong {
  color: #bfe4ff;
  font-size: 19px;
}

.guild-section {
  margin-bottom: 14px;
}

.guild-section > h2 {
  margin: 0 0 4px;
  color: #bfe4ff;
  font-size: 16px;
}

.guild-guidance {
  margin: 0 0 8px;
  color: var(--muted);
  font-size: 12px;
}

.guild-bounty-list {
  display: grid;
  gap: 6px;
  max-height: 320px;
  overflow: auto;
}

.guild-bounty-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(211, 151, 94, 0.22);
  border-radius: 7px;
  background: rgba(98, 58, 28, 0.14);
}

.guild-bounty-row div {
  display: grid;
  gap: 3px;
}

.guild-bounty-row small {
  color: var(--muted);
}

.research-bounties {
  margin: 14px 0;
}

.bounty-card.known {
  border-color: rgba(230, 159, 78, 0.45);
}

.guild-reward {
  position: relative;
  padding: 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.025);
}

.guild-exchange-shop {
  display: grid;
  gap: 14px;
}

.guild-product-section {
  display: grid;
  gap: 9px;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 10px;
  background: rgba(10, 16, 20, 0.42);
}

.guild-product-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
}

.guild-product-heading h3 {
  margin: 2px 0 0;
  font-size: 17px;
}

.guild-product-heading > small,
.guild-reward-group summary small {
  color: var(--muted);
}

.guild-product-kicker,
.guild-product-purpose,
.guild-reward-status {
  display: inline-flex;
  width: fit-content;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.04em;
}

.guild-product-kicker {
  color: #bfe4ff;
  background: rgba(76, 142, 184, 0.22);
}

.guild-product-purpose {
  color: #d7efff;
  border: 1px solid rgba(111, 190, 236, 0.3);
  background: rgba(46, 98, 128, 0.18);
}

.guild-consumables .guild-reward h3,
.guild-reward-group .guild-reward h3 {
  margin: 7px 0 4px;
}

.guild-stock {
  margin-bottom: 8px;
  color: #d7efff;
  font-size: 12px;
  font-weight: 800;
}

.guild-reward-groups {
  display: grid;
  gap: 7px;
}

.guild-reward-group {
  overflow: hidden;
  border: 1px solid rgba(111, 190, 236, 0.2);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.018);
}

.guild-reward-group summary {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  cursor: pointer;
  list-style-position: inside;
}

.guild-reward-group summary > span:first-child {
  display: grid;
  gap: 2px;
}

.guild-reward-group[open] summary {
  border-bottom: 1px solid rgba(111, 190, 236, 0.16);
  background: rgba(76, 142, 184, 0.09);
}

.guild-reward-group > .card-list {
  padding: 10px;
}

.guild-reward-count {
  color: #bfe4ff;
  font-size: 11px;
  font-weight: 800;
  text-align: right;
}

.guild-reward-status {
  color: var(--muted);
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
}

.guild-reward-status-ready {
  color: #cdefff;
  border-color: rgba(111, 190, 236, 0.48);
  background: rgba(55, 133, 177, 0.22);
}

.guild-reward-status-incompatible,
.guild-item-job.incompatible {
  color: #ffd28b;
}

.guild-reward-status-short {
  color: #c7c7c7;
}

.guild-reward-status-owned {
  color: #a9d7b0;
  border-color: rgba(107, 183, 117, 0.35);
  background: rgba(53, 114, 61, 0.18);
}

.guild-reward-status-locked {
  color: #ffe9a9;
  border-color: rgba(239, 198, 93, 0.38);
  background: rgba(144, 96, 16, 0.2);
}

.guild-item-job {
  margin: 0 0 7px;
  color: #a9d7b0;
  font-size: 11px;
  font-weight: 800;
}

.guild-reward.available {
  border-color: rgba(111, 190, 236, 0.52);
  box-shadow: inset 3px 0 0 rgba(111, 190, 236, 0.7);
}

.guild-reward.guild-luxury-reward {
  border-color: rgba(239, 198, 93, 0.62);
  background:
    radial-gradient(circle at 12% 0, rgba(255, 229, 144, 0.14), transparent 42%),
    linear-gradient(145deg, rgba(83, 59, 21, 0.34), rgba(26, 22, 18, 0.94));
  box-shadow: inset 3px 0 0 rgba(255, 211, 92, 0.78), 0 0 16px rgba(191, 139, 32, 0.12);
}

.guild-luxury-label {
  display: inline-flex;
  padding: 3px 8px;
  border: 1px solid rgba(255, 218, 120, 0.58);
  border-radius: 999px;
  color: #ffe9a9;
  background: rgba(144, 96, 16, 0.28);
  font-size: 10px;
  font-weight: 900;
  letter-spacing: 0.05em;
}

.guild-cost {
  float: right;
  margin-left: 8px;
  padding: 3px 7px;
  border-radius: 999px;
  color: #d7efff;
  background: rgba(76, 142, 184, 0.24);
  font-size: 12px;
  font-weight: 800;
}

@media (max-width: 520px) {
  .guild-product-heading {
    align-items: start;
    flex-direction: column;
    gap: 4px;
  }

  .guild-reward-group summary {
    grid-template-columns: 1fr;
  }

  .guild-reward-count {
    text-align: left;
  }
}

.arena-intro,
.arena-stage {
  padding: 12px;
  border: 1px solid rgba(194, 80, 68, 0.45);
  border-radius: 9px;
  background: radial-gradient(circle at 50% 0, rgba(141, 48, 39, 0.2), rgba(25, 25, 20, 0.96) 58%);
}

.arena-intro h2 {
  margin: 0 0 8px;
  color: #ffc0a8;
}

.arena-record {
  display: flex;
  justify-content: space-between;
  margin: 12px 0;
  padding: 9px;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.04);
}

.arena-round {
  margin-bottom: 6px;
  color: #ff967f;
  font-size: 13px;
  font-weight: 800;
}

.arena-victory {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
  margin-top: 10px;
}

.arena-tactical-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  justify-items: center;
  margin-top: 10px;
}

.arena-map {
  --arena-cell: clamp(20px, min(36px, 7.5vw, calc((100svh - 430px) / 9)), 36px);
  display: grid;
  grid-template-columns: repeat(9, var(--arena-cell));
  grid-template-rows: repeat(9, var(--arena-cell));
  gap: 2px;
  padding: 6px;
  border: 1px solid rgba(194, 80, 68, 0.48);
  border-radius: 12px;
  background: radial-gradient(circle, #30251e, #100e0c 72%);
  box-shadow: inset 0 0 28px rgba(0, 0, 0, 0.58), 0 8px 24px rgba(0, 0, 0, 0.28);
}

.arena-grid-row,
.arena-gridcell {
  display: contents;
}

.arena-cell {
  display: grid;
  place-items: center;
  width: var(--arena-cell);
  height: var(--arena-cell);
  min-height: 0;
  padding: 0;
  border: 0;
  border-radius: 5px;
  color: #c8b8aa;
  background: rgba(94, 70, 52, 0.18);
  font-size: calc(var(--arena-cell) * 0.46);
  line-height: 1;
}

.arena-floor:nth-child(odd) { background: rgba(120, 83, 55, 0.13); }
.arena-pillar { color: #81756b; background: #302d29; box-shadow: inset 0 0 0 1px #4c4741; }
.arena-player { color: #fff0a5; background: #3b493d; text-shadow: 0 0 9px rgba(255, 222, 113, 0.7); }
.arena-foe {
  color: hsl(var(--arena-marker-hue), 94%, 74%);
  background: rgba(94, 70, 52, 0.18);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.14);
  font-weight: 800;
  -webkit-text-stroke: 0;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.92);
}

.arena-move-pad {
  display: grid;
  grid-template-columns: repeat(3, 44px);
  grid-template-rows: repeat(3, 42px);
  gap: 6px;
  padding: 7px;
  border: 1px solid rgba(224, 184, 98, 0.28);
  border-radius: 12px;
  background: rgba(15, 19, 17, 0.8);
}

.arena-move-pad button {
  min-height: 42px;
  padding: 0;
  font-size: 17px;
  touch-action: none;
  user-select: none;
}

.app-shell.arena-mode .arena-stage {
  display: grid;
  grid-template-rows: auto auto;
  gap: 4px;
  min-height: 100%;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: transparent;
}

.arena-floor-line {
  grid-template-columns: minmax(0, 1fr) auto auto;
  margin-bottom: 0;
}

.arena-floor-line button {
  min-width: 64px;
  white-space: nowrap;
}

.arena-floor-line > div {
  overflow: hidden;
}

.arena-enemy-name,
.arena-compact-status {
  display: block;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.arena-enemy-name {
  color: #ffd2be;
}

.app-shell.arena-mode .arena-round {
  margin: 0;
  font-size: 11px;
}

.app-shell.arena-mode .arena-tactical-layout {
  grid-template-columns: 1fr;
  grid-template-rows: auto auto;
  gap: 8px;
  align-content: start;
  min-height: 0;
  margin-top: 0;
}

.app-shell.arena-mode .arena-map {
  /* Reserve space for the log, status, match header and the full movement pad. */
  --arena-cell: clamp(12px, min(36px, 7.5vw, calc((100svh - 530px) / 9)), 36px);
  align-self: start;
}

.app-shell.arena-mode .arena-move-pad {
  justify-self: end;
  grid-template-columns: repeat(3, 52px);
  grid-template-rows: repeat(3, 44px);
  gap: 7px;
  padding: 8px;
  border-color: rgba(194, 80, 68, 0.48);
  background: linear-gradient(145deg, rgba(47, 28, 23, 0.97), rgba(21, 15, 13, 0.97));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04), 0 12px 34px rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
}

.app-shell.arena-mode .arena-move-pad button {
  width: 52px;
  min-height: 44px;
}

@media (min-width: 600px) {
  .app-shell.arena-mode .arena-tactical-layout {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
  }
}

@media (max-width: 430px) {
  .arena-tactical-layout {
    grid-template-columns: 1fr;
  }

  .arena-move-pad {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 44px);
  }
}

.arena-victory strong,
.arena-victory p,
.arena-victory button {
  grid-column: 1 / -1;
}

.tile-corpse {
  position: relative;
  overflow: hidden;
  background: #292722;
  box-shadow: inset 0 0 0 1px rgba(184, 172, 144, 0.18);
}

.corpse-icon {
  position: relative;
  width: 68%;
  height: 38%;
  margin-top: 18%;
  border-radius: 48% 55% 42% 50%;
  background: #776f60;
  box-shadow:
    inset -3px -3px 4px rgba(0, 0, 0, 0.35),
    0 2px 3px rgba(0, 0, 0, 0.55);
  transform: rotate(-8deg);
}

.corpse-icon::before {
  content: "";
  position: absolute;
  left: -18%;
  top: 10%;
  width: 36%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #918675;
  box-shadow: inset -2px -2px 3px rgba(0, 0, 0, 0.35);
}

.corpse-icon::after {
  content: "";
  position: absolute;
  right: -16%;
  bottom: -12%;
  width: 48%;
  height: 3px;
  border-radius: 2px;
  background: #5e574b;
  transform: rotate(24deg);
  box-shadow: -9px -1px 0 #5e574b;
}

.tile-unique-corpse {
  z-index: 2;
  isolation: isolate;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 48%, rgba(255, 216, 111, 0.16) 0 15%, transparent 48%),
    radial-gradient(circle at 26% 76%, rgba(160, 42, 114, 0.34), transparent 48%),
    linear-gradient(145deg, #28152c, #100d1b 68%, #24131f);
  box-shadow:
    inset 0 0 0 1px rgba(255, 218, 125, 0.72),
    inset 0 0 8px rgba(192, 55, 137, 0.42),
    0 0 5px rgba(239, 177, 82, 0.24);
}

.tile-unique-corpse::after {
  content: "";
  position: absolute;
  z-index: 0;
  inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 235, 166, 0.38), rgba(213, 80, 151, 0.13) 38%, transparent 72%);
  filter: blur(1px);
  animation: unique-corpse-ember 1.9s ease-in-out infinite alternate;
}

.unique-corpse-aura {
  position: absolute;
  z-index: 1;
  inset: 7%;
  border-radius: 50%;
  background: conic-gradient(
    from 12deg,
    transparent 0 9%,
    rgba(255, 224, 139, 0.92) 11% 15%,
    transparent 18% 40%,
    rgba(211, 77, 164, 0.76) 43% 49%,
    transparent 52% 72%,
    rgba(255, 241, 187, 0.88) 75% 80%,
    transparent 83% 100%
  );
  -webkit-mask: radial-gradient(circle, transparent 0 55%, #000 58% 66%, transparent 69%);
  mask: radial-gradient(circle, transparent 0 55%, #000 58% 66%, transparent 69%);
  filter: drop-shadow(0 0 2px rgba(255, 211, 108, 0.82));
  animation: unique-corpse-aura-spin 4.8s linear infinite;
}

.unique-corpse-aura::before,
.unique-corpse-aura::after {
  content: "";
  position: absolute;
  width: 11%;
  aspect-ratio: 1;
  background: linear-gradient(135deg, #fff7ce, #e7ad4f 54%, #a53d94);
  clip-path: polygon(50% 0, 63% 37%, 100% 50%, 63% 63%, 50% 100%, 37% 63%, 0 50%, 37% 37%);
  filter: drop-shadow(0 0 2px rgba(255, 231, 154, 0.96));
}

.unique-corpse-aura::before {
  top: 0;
  left: 44%;
}

.unique-corpse-aura::after {
  right: 3%;
  bottom: 13%;
}

.tile-unique-corpse .corpse-icon {
  z-index: 3;
  width: 72%;
  height: 40%;
  margin-top: 19%;
  border: 1px solid rgba(255, 219, 133, 0.68);
  border-radius: 50% 58% 38% 48%;
  background:
    linear-gradient(116deg, transparent 0 48%, rgba(255, 222, 123, 0.72) 50% 53%, transparent 55%),
    radial-gradient(circle at 38% 30%, #b85b86, #6b294f 46%, #28162d 100%);
  box-shadow:
    inset -3px -3px 4px rgba(18, 4, 24, 0.72),
    inset 2px 1px 2px rgba(255, 189, 169, 0.22),
    0 0 5px rgba(230, 93, 166, 0.58),
    0 2px 3px rgba(0, 0, 0, 0.72);
  transform: rotate(-9deg);
}

.tile-unique-corpse .corpse-icon::before {
  left: -19%;
  top: -2%;
  width: 38%;
  border: 1px solid rgba(255, 221, 139, 0.65);
  border-radius: 52% 48% 45% 40%;
  background:
    radial-gradient(circle at 36% 40%, #ffe8a8 0 5%, transparent 7%),
    radial-gradient(circle at 68% 40%, #ffe8a8 0 5%, transparent 7%),
    linear-gradient(145deg, #c87291, #58213f 72%);
  box-shadow:
    inset -2px -2px 3px rgba(26, 5, 21, 0.64),
    0 0 3px rgba(255, 207, 111, 0.54);
}

.tile-unique-corpse .corpse-icon::after {
  right: -19%;
  bottom: -10%;
  width: 54%;
  height: 4px;
  background: linear-gradient(90deg, #6d2c50, #f2c568);
  box-shadow: -9px -1px 0 rgba(135, 56, 92, 0.92), 0 0 3px rgba(245, 196, 102, 0.62);
}

.unique-corpse-core {
  position: absolute;
  z-index: 5;
  left: 51%;
  top: 31%;
  width: 13%;
  aspect-ratio: 1;
  border: 1px solid rgba(255, 249, 211, 0.92);
  background: #ffd76e;
  box-shadow: 0 0 2px #fff5c5, 0 0 6px #dc4eac;
  transform: rotate(45deg);
  animation: unique-corpse-core-pulse 1.25s ease-in-out infinite alternate;
}

.unique-corpse-crest {
  position: absolute;
  z-index: 4;
  left: 10%;
  top: 18%;
  width: 31%;
  height: 23%;
  background: linear-gradient(180deg, #fff1af, #d99631 58%, #774023);
  clip-path: polygon(0 100%, 8% 25%, 34% 58%, 48% 0, 65% 56%, 94% 22%, 100% 100%);
  filter: drop-shadow(0 0 2px rgba(255, 218, 118, 0.86));
  transform: rotate(-11deg);
}

@keyframes unique-corpse-aura-spin {
  to { transform: rotate(360deg); }
}

@keyframes unique-corpse-core-pulse {
  from { opacity: 0.58; transform: rotate(45deg) scale(0.78); }
  to { opacity: 1; transform: rotate(45deg) scale(1.22); }
}

@keyframes unique-corpse-ember {
  from { opacity: 0.38; transform: scale(0.82); }
  to { opacity: 0.92; transform: scale(1.18); }
}

.tile-stairs {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 18%, rgba(135, 184, 126, 0.2), transparent 42%),
    #1b241d;
  box-shadow: inset 0 0 0 1px rgba(135, 184, 126, 0.24);
}

.stair-icon {
  display: block;
  width: 94%;
  height: 94%;
  background: url("../assets/images/down-stairs.webp") center / contain no-repeat;
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.85));
}

.home-section {
  display: grid;
  gap: 7px;
  margin-bottom: 10px;
}

.home-section > h2 {
  margin: 0;
  color: #ffe6a5;
  font-size: 15px;
}

/* 両手持ちの間は、武器枠と左手枠を1つの枠として囲う。 */
.two-handed-grip {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid rgba(255, 214, 130, 0.55);
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(255, 206, 120, 0.11), rgba(255, 206, 120, 0.03));
}

.two-handed-grip-banner {
  display: grid;
  gap: 3px;
  padding-bottom: 8px;
  border-bottom: 1px dashed rgba(255, 214, 130, 0.4);
}

.two-handed-grip-banner strong {
  color: #ffd782;
  font-size: 14px;
  letter-spacing: 0.1em;
}

.two-handed-grip-banner span {
  font-size: 13px;
}

.two-handed-grip-banner small {
  font-size: 11px;
  opacity: 0.75;
}

.two-handed-grip .home-section {
  margin-bottom: 0;
}

.two-handed-grip-link {
  display: flex;
  align-items: center;
  gap: 8px;
  color: rgba(255, 214, 130, 0.8);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.two-handed-grip-link::before,
.two-handed-grip-link::after {
  content: "";
  flex: 1;
  height: 1px;
  background: rgba(255, 214, 130, 0.35);
}

.two-handed-grip .two-handed-offhand {
  opacity: 0.6;
}

.two-handed-grip-note {
  margin: 0;
  font-size: 12px;
  color: #ffd8a8;
}

.equipment-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.025);
}

.equipment-card p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
}

.equipment-card .equipment-puzzle-effect {
  padding: 6px 8px;
  border-left: 2px solid rgba(116, 190, 222, 0.62);
  color: #ccecff;
  background: rgba(70, 132, 164, 0.08);
}

.equipment-card .equipment-puzzle-effect.active {
  border-left-color: #79e4a5;
  color: #d5ffe4;
  background: rgba(64, 164, 105, 0.1);
}

.equipment-card .equipment-puzzle-effect.inactive {
  opacity: 0.72;
}

.equipment-set-label {
  display: inline-block;
  width: fit-content;
  padding: 2px 6px;
  border: 1px solid rgba(116, 190, 224, 0.42);
  border-radius: 999px;
  color: #bfeaff;
  font-size: 11px;
}

.equipment-set-board {
  margin: 12px 0;
  padding: 11px;
  border: 1px solid rgba(116, 190, 224, 0.28);
  border-radius: 10px;
  background: rgba(28, 55, 70, 0.16);
}

.equipment-set-board h2,
.equipment-set-board p,
.equipment-set-card h3,
.equipment-set-card ul {
  margin: 0;
}

.equipment-set-grid {
  display: grid;
  gap: 7px;
  margin-top: 8px;
}

.equipment-set-card {
  display: grid;
  grid-template-columns: minmax(130px, 0.7fr) minmax(0, 1.3fr);
  gap: 8px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
}

.equipment-set-card.active {
  border-color: rgba(91, 201, 132, 0.48);
  box-shadow: inset 3px 0 rgba(91, 201, 132, 0.6);
}

.equipment-set-card li.inactive { color: var(--muted); }
.equipment-set-card li.active { color: #a9f2bd; }

.equipment-actions {
  display: flex;
  gap: 4px;
}

.equipment-actions button {
  min-height: 30px;
  padding-inline: 7px;
  font-size: 11px;
}

.home-profile {
  margin-bottom: 12px;
  padding: 12px;
  border: 1px solid rgba(214, 174, 84, 0.42);
  border-radius: 11px;
  background:
    radial-gradient(circle at 100% 0, rgba(214, 174, 84, 0.12), transparent 42%),
    linear-gradient(145deg, rgba(44, 43, 30, 0.92), rgba(21, 27, 22, 0.96));
  box-shadow: inset 3px 0 rgba(224, 184, 98, 0.44), 0 7px 22px rgba(0, 0, 0, 0.2);
}

.home-profile-heading {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px 14px;
  align-items: center;
  margin-bottom: 10px;
}

.adventure-objective {
  margin: 12px 0;
  padding: 12px;
  border: 1px solid rgba(205, 89, 102, 0.68);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(72, 24, 37, 0.84), rgba(29, 22, 38, 0.92));
  box-shadow: inset 0 0 18px rgba(126, 35, 70, 0.16);
}

.adventure-objective span { display: block; color: #f1a6ae; font-size: 10px; font-weight: 900; letter-spacing: 0.12em; }
.adventure-objective strong { display: block; margin-top: 5px; color: #fff0c7; font-size: 15px; line-height: 1.4; }
.adventure-objective p { margin: 6px 0 0; color: #d8c9c7; font-size: 11px; line-height: 1.45; }
.adventure-objective.completed { border-color: rgba(111, 195, 124, 0.7); background: linear-gradient(135deg, rgba(25, 65, 43, 0.86), rgba(25, 38, 35, 0.94)); }
.adventure-objective.completed span { color: #91e3a0; }

.home-profile-heading h2,
.inventory-section > h2 {
  margin: 0;
  color: #ffe6a5;
  font-size: 16px;
}

.home-profile-heading p,
.inventory-section > p {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.combat-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(104px, 1fr));
  gap: 6px;
}

.combat-metric {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
  min-height: 58px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.075);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.18);
}

.combat-metric > span {
  color: #aeb9af;
  font-size: 10px;
}

.combat-metric strong {
  color: #fff2c0;
  font-size: 15px;
}

.inventory-section {
  display: grid;
  gap: 7px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(137, 158, 142, 0.24);
  border-radius: 10px;
  background: rgba(24, 31, 26, 0.7);
}

.backstory-editor {
  display: grid;
  gap: 8px;
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid rgba(121, 157, 184, 0.34);
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(33, 48, 58, 0.58), rgba(20, 27, 25, 0.82));
  box-shadow: inset 3px 0 rgba(117, 169, 202, 0.3);
}

.backstory-editor h2,
.backstory-editor p {
  margin: 0;
}

.backstory-editor h2 {
  color: #cae7f6;
  font-size: 16px;
}

.backstory-editor p {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.backstory-editor textarea {
  width: 100%;
  min-height: 126px;
  resize: vertical;
  padding: 9px 10px;
  border: 1px solid rgba(148, 186, 207, 0.32);
  border-radius: 8px;
  color: #edf5f2;
  background: rgba(4, 9, 9, 0.42);
  font: inherit;
  font-size: 13px;
  line-height: 1.65;
}

.inventory-card,
.spell-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px 9px;
  align-items: center;
  min-width: 0;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.028);
}

.inventory-card > div,
.spell-card > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.inventory-card p,
.spell-card p {
  grid-column: 1 / -1;
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.4;
}

.inventory-card button,
.spell-card button {
  min-height: 32px;
  padding-inline: 9px;
  font-size: 11px;
}

.rank-badge,
.artifact-tier,
.cursed-label,
.risque-label,
.reward-tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: max-content;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.2;
}

.risque-label {
  color: #ffd5e8;
  border: 1px solid rgba(240, 125, 176, 0.42);
  background: rgba(145, 48, 93, 0.28);
  box-shadow: 0 0 8px rgba(220, 82, 145, 0.16);
}

.risque-synergy {
  margin: 8px 0 0;
  padding: 7px 8px;
  border: 1px solid rgba(240, 125, 176, 0.32);
  border-radius: 7px;
  color: #ffd5e8;
  background: rgba(145, 48, 93, 0.15);
  font-size: 11px;
  line-height: 1.45;
}


.rank-badge {
  color: #eee2bc;
  border: 1px solid rgba(214, 174, 84, 0.28);
  background: rgba(214, 174, 84, 0.11);
}

.spell-list {
  display: grid;
  gap: 6px;
}

.spell-card {
  border-color: rgba(147, 132, 255, 0.27);
  background: linear-gradient(135deg, rgba(71, 55, 123, 0.18), rgba(24, 22, 39, 0.4));
  box-shadow: inset 3px 0 rgba(147, 132, 255, 0.32);
}

.spell-card strong {
  color: #ddd5ff;
}

.spell-card.selected {
  border-color: rgba(190, 177, 255, 0.72);
  box-shadow: inset 3px 0 #a99cff, 0 0 12px rgba(130, 111, 228, 0.2);
}

.artifact-card {
  position: relative;
  overflow: hidden;
  border-color: rgba(236, 196, 92, 0.52) !important;
  background:
    radial-gradient(circle at 100% 0, rgba(255, 221, 118, 0.16), transparent 38%),
    linear-gradient(145deg, rgba(74, 58, 27, 0.26), rgba(29, 27, 21, 0.84)) !important;
  box-shadow: inset 3px 0 rgba(255, 211, 86, 0.72), 0 5px 18px rgba(0, 0, 0, 0.2) !important;
}

.artifact-card > strong,
.artifact-card h2 {
  color: #ffe39a;
}

.artifact-tier {
  color: #ffe9a8;
  border: 1px solid rgba(255, 214, 95, 0.38);
  background: rgba(153, 109, 25, 0.28);
}

.cursed-label {
  color: #f2c2ff;
  border: 1px solid rgba(207, 111, 235, 0.4);
  background: rgba(116, 42, 137, 0.3);
  box-shadow: 0 0 8px rgba(169, 73, 198, 0.18);
}

.curse-summary {
  grid-column: 1 / -1;
  margin: 2px 0 0;
  padding: 7px 8px;
  border: 1px solid rgba(192, 98, 218, 0.28);
  border-radius: 7px;
  color: #dfc7e7;
  background: rgba(94, 37, 107, 0.16);
  font-size: 11px;
  line-height: 1.45;
}

.research-dashboard {
  display: grid;
  gap: 9px;
  margin-bottom: 12px;
  padding: 11px;
  border: 1px solid rgba(102, 157, 132, 0.34);
  border-radius: 11px;
  background:
    radial-gradient(circle at 0 0, rgba(99, 153, 125, 0.12), transparent 40%),
    rgba(19, 29, 23, 0.88);
  box-shadow: inset 3px 0 rgba(102, 157, 132, 0.38);
}

.research-counts {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(92px, 1fr));
  gap: 6px;
}

.research-count {
  display: grid;
  gap: 3px;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 8px;
  background: rgba(0, 0, 0, 0.17);
}

.research-count span {
  color: #a8b7ad;
  font-size: 10px;
}

.research-count strong {
  color: #d9f0df;
  font-size: 16px;
}

.research-tools {
  display: grid;
  grid-template-columns: minmax(0, 1fr) repeat(2, minmax(108px, auto));
  gap: 7px;
  align-items: end;
  margin-bottom: 9px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: rgba(20, 27, 22, 0.94);
}

.research-tools > * {
  min-width: 0;
}

.research-tools label {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
}

.research-search {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
}

.research-tools select,
.research-search input {
  width: 100%;
  min-height: 36px;
  border: 1px solid rgba(125, 166, 141, 0.34);
  border-radius: 7px;
  padding: 6px 9px;
  color: #eef3ec;
  background: #202a23;
  font: inherit;
  font-size: 12px;
}

.research-search > div {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 5px;
}

.research-search button {
  min-height: 36px;
  padding-inline: 11px;
  font-size: 11px;
}

.research-search input::placeholder {
  color: #7f8d84;
}

.research-progress-track {
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.34);
  box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.44);
}

.research-progress-fill {
  display: block;
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #557f62, #9bc680 70%, #e2c66e);
  box-shadow: 0 0 8px rgba(139, 193, 137, 0.35);
  transition: width 0.2s ease;
}

.research-level-dots {
  display: inline-flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
}

.research-level-dot {
  width: 8px;
  height: 8px;
  border: 1px solid rgba(149, 176, 158, 0.32);
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.32);
}

.research-level-dot.filled {
  border-color: rgba(214, 188, 100, 0.72);
  background: #d2b965;
  box-shadow: 0 0 6px rgba(214, 185, 93, 0.48);
}

.research-card summary {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto auto auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  cursor: pointer;
  list-style: none;
}

.research-monster-graphic {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border: 1px solid rgba(167, 190, 174, 0.3);
  border-radius: 9px;
  background:
    radial-gradient(circle at 50% 38%, rgba(224, 184, 98, 0.13), transparent 52%),
    rgba(4, 8, 6, 0.48);
  box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.34);
  font-size: 24px;
  font-weight: 500;
  text-shadow: 0 2px 4px #000;
}

.research-monster-graphic.unknown {
  color: #687169;
  border-color: rgba(112, 126, 116, 0.18);
  filter: grayscale(1);
}

.research-monster-graphic.unique {
  border-color: rgba(224, 184, 98, 0.62);
  box-shadow: inset 0 0 11px rgba(214, 174, 84, 0.12), 0 0 8px rgba(214, 174, 84, 0.18);
}

.monster-research-title {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.monster-research-title strong,
.monster-research-title small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.research-card summary::-webkit-details-marker {
  display: none;
}

.research-card summary::after {
  content: "+";
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  border: 1px solid rgba(141, 173, 153, 0.28);
  border-radius: 50%;
  color: #c7d8cd;
  background: rgba(255, 255, 255, 0.035);
  font-size: 15px;
  line-height: 1;
}

.research-card-details {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.research-stat-line {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 7px 9px;
  border: 1px solid rgba(201, 184, 126, 0.18);
  border-radius: 8px;
  background: rgba(10, 14, 11, 0.42);
}

.research-stat-line > span {
  color: var(--muted);
}

.research-stat-line strong {
  color: #fff0b3;
}

.research-card[open] {
  display: grid;
  gap: 8px;
}

.research-card[open] summary::after {
  content: "−";
  color: #ffe2a0;
  border-color: rgba(214, 174, 84, 0.38);
}

.research-card[open] summary {
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.reward-tag {
  color: #d9efff;
  border: 1px solid rgba(114, 185, 226, 0.38);
  background: rgba(59, 125, 165, 0.25);
}

.reward-tag.harvest {
  color: #d8ffd0;
  border-color: rgba(126, 205, 104, 0.42);
  background: rgba(66, 130, 52, 0.25);
}

.reward-tag.experience {
  color: #ffe4a8;
  border-color: rgba(224, 178, 76, 0.46);
  background: rgba(143, 98, 31, 0.28);
}

.guild-claims {
  display: grid;
  gap: 7px;
  margin-bottom: 13px;
  padding: 10px;
  border: 1px solid rgba(112, 184, 226, 0.42);
  border-radius: 10px;
  background:
    radial-gradient(circle at 100% 0, rgba(112, 184, 226, 0.12), transparent 44%),
    rgba(35, 61, 78, 0.22);
  box-shadow: inset 3px 0 rgba(112, 184, 226, 0.48);
}

.guild-claim-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.028);
}

.treasure-sell-list {
  display: grid;
  gap: 6px;
}

.treasure-sell-list article {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 6px;
  align-items: center;
  min-width: 0;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.026);
}

.treasure-sell-list article > div {
  display: grid;
  gap: 3px;
  min-width: 0;
}

.treasure-sell-list button {
  min-height: 32px;
  padding-inline: 8px;
  font-size: 11px;
}

.death-effect {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 10px;
  pointer-events: none;
  visibility: hidden;
  opacity: 0;
  color: #e8ddd5;
  background:
    radial-gradient(circle, transparent 0 20%, rgba(45, 0, 0, 0.48) 58%, rgba(0, 0, 0, 0.97) 100%),
    rgba(70, 0, 0, 0.45);
}

.death-review-panel {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(5, 7, 6, 0.9);
  backdrop-filter: blur(10px);
}

.death-review-card {
  width: min(100%, 480px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  display: grid;
  gap: 10px;
  padding: 16px;
  border: 1px solid rgba(154, 70, 59, 0.55);
  border-radius: 14px;
  background: linear-gradient(155deg, #271d1a, #111412);
  box-shadow: inset 3px 0 rgba(154, 51, 40, 0.32), 0 24px 72px rgba(0, 0, 0, 0.62);
}

.death-review-card > span {
  color: #bb8277;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.death-review-card h2,
.death-review-card p {
  margin: 0;
}

.death-review-card h2 {
  color: #dfc8bd;
}

.death-review-log {
  min-height: 132px;
  max-height: min(48dvh, 360px);
  overflow-y: auto;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.28);
}

.death-review-log p {
  margin: 0 0 5px;
  padding: 4px 6px;
  border-left: 2px solid rgba(159, 83, 70, 0.34);
  color: #ddd2c8;
  font-size: 12px;
  line-height: 1.4;
}

.depth-picker-card {
  width: min(100%, 420px);
}

.depth-picker-list {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  max-height: min(56dvh, 440px);
  overflow-y: auto;
}

.depth-picker-list button {
  text-align: center;
}

.level-up-effect {
  position: fixed;
  inset: 0;
  z-index: 90;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 8px;
  padding: 28px;
  visibility: hidden;
  pointer-events: none;
  opacity: 0;
  text-align: center;
  background: radial-gradient(circle, rgba(226, 190, 88, 0.1), rgba(7, 10, 6, 0.78) 62%, rgba(0, 0, 0, 0.86));
}

.level-up-effect.active {
  visibility: visible;
  pointer-events: auto;
  cursor: pointer;
  animation: level-up-screen var(--level-up-duration, 5s) ease-in-out forwards;
}

.level-up-effect.active::after {
  content: "クリックで閉じる";
  margin-top: 18px;
  color: rgba(255, 247, 209, 0.72);
  font-size: 12px;
  letter-spacing: 0.08em;
}

.level-up-effect strong {
  color: #ffe9a0;
  font-family: Georgia, serif;
  font-size: clamp(28px, 8vw, 48px);
  letter-spacing: 0.08em;
  text-shadow: 0 0 12px rgba(255, 214, 91, 0.38);
}

.level-up-effect h2 {
  margin: 0;
  color: #fff7d1;
  font-size: 24px;
}

.level-up-growth {
  display: grid;
  gap: 5px;
  width: min(86vw, 360px);
  max-width: 420px;
  margin: 4px 0 0;
  color: #f2e6ba;
  font-size: 14px;
  line-height: 1.6;
}

.level-up-stat {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto 3.2em;
  gap: 8px;
  align-items: center;
  min-height: 28px;
  padding: 3px 10px;
  border-radius: 5px;
  opacity: 0.34;
  background: rgba(255, 255, 255, 0.035);
  transform: translateY(3px);
  transition: opacity 0.15s ease, transform 0.15s ease, background 0.15s ease;
}

.level-up-stat span:first-child { text-align: left; }
.level-up-stat .stat-before { color: #aaa58f; }
.level-up-stat .stat-arrow { color: #827d68; }
.level-up-stat .stat-after { min-width: 3ch; color: #777363; font-weight: 800; }
.level-up-stat .stat-gain {
  color: #777363;
  font-size: 13px;
  opacity: 0;
  text-align: right;
}

.level-up-stat.revealed {
  opacity: 1;
  transform: none;
}

.level-up-stat.will-rise.revealed {
  background: rgba(255, 221, 112, 0.12);
}

.level-up-stat.unchanged.revealed {
  opacity: 0.72;
}

.level-up-stat.unchanged.revealed .stat-after {
  color: #aaa58f;
}

.level-up-stat.unchanged.revealed .stat-gain {
  color: #777363;
  opacity: 1;
}

.level-up-stat.will-rise.revealed .stat-after {
  color: #fff0a8;
  animation: level-stat-ping 0.36s ease-out;
}

.level-up-stat.will-rise.revealed .stat-gain {
  color: #ffdc65;
  opacity: 1;
  text-shadow: 0 0 8px rgba(255, 213, 78, 0.55);
  animation: level-stat-ping 0.36s ease-out;
}

@keyframes level-stat-ping {
  0% { transform: scale(0.72); filter: brightness(2.2); }
  55% { transform: scale(1.24); filter: brightness(1.45); }
  100% { transform: none; filter: none; }
}

@keyframes level-up-screen {
  0% { opacity: 0; transform: translateY(8px) scale(0.97); filter: brightness(1.12); }
  12% { opacity: 1; transform: none; filter: brightness(1); }
  82% { opacity: 1; transform: none; filter: brightness(1); }
  100% { opacity: 0; transform: translateY(-3px); filter: brightness(0.96); }
}

.title-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  padding: 28px 28px max(24px, env(safe-area-inset-bottom));
  overflow: hidden;
  color: #eee7d2;
  text-align: center;
  background: #050806;
  isolation: isolate;
}

.title-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background:
    linear-gradient(180deg, transparent 72%, rgba(3, 5, 4, 0.22) 84%, rgba(3, 5, 4, 0.78) 100%),
    url("../assets/images/chronicle-dungeon-title-v3.jpg") center / auto 100% no-repeat,
    #050806;
  pointer-events: none;
  transition: opacity 1.6s ease, filter 1.6s ease, transform 1.6s ease;
}

.title-screen.voice-transition::after {
  content: "";
  position: absolute;
  z-index: 10;
  inset: 0;
  background: #000;
  opacity: 1;
  pointer-events: all;
  animation: title-voice-blackout 280ms ease-out both;
}

@keyframes title-voice-blackout {
  from { opacity: 0; }
  to { opacity: 1; }
}

.title-screen > * {
  position: relative;
  max-width: calc(100vw - 56px);
}

.title-screen h1 {
  width: calc(100vw - 56px);
  margin: 0;
  color: #f0d693;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: clamp(36px, 11vw, 68px);
  line-height: 1.02;
  letter-spacing: 0.03em;
  text-shadow: 0 4px 0 #392612, 0 10px 28px #000;
}

.title-screen > .title-kicker,
.title-screen > h1 {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.title-screen > .title-version {
  position: absolute;
  top: 30.6%;
  left: 50%;
  z-index: 1;
  width: auto;
  max-width: none;
  height: auto;
  padding: 0;
  margin: 0;
  overflow: visible;
  clip: auto;
  transform: translate(-50%, -50%);
  border: 0;
  color: #cda665;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: clamp(11px, 1.5vh, 22px);
  font-weight: 400;
  line-height: 1;
  letter-spacing: 0.14em;
  white-space: nowrap;
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.88);
}

.title-kicker,
.title-version,
.title-hint {
  margin: 0;
  color: #9e9d8d;
  font-size: 11px;
  letter-spacing: 0.12em;
}

.title-screen button {
  box-sizing: border-box;
  width: min(280px, 78vw);
  margin: 0;
  padding: 13px 20px;
  border-color: #b9913e;
  color: #fff0b3;
  background: linear-gradient(rgba(87, 71, 34, 0.96), rgba(53, 44, 24, 0.96));
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.62);
}

.title-screen .title-hint {
  color: #b7b2a1;
  text-shadow: 0 2px 5px #000;
}

.title-screen > .title-version,
.title-screen > #titleStartButton,
.title-screen > .title-hint {
  transition: opacity 1.1s ease, visibility 0s linear;
}

.title-screen.chronicle-active::before {
  opacity: 0;
  filter: brightness(0.25) saturate(0.4);
  transform: scale(1.025);
}

.title-screen.chronicle-active > .title-version,
.title-screen.chronicle-active > #titleStartButton,
.title-screen.chronicle-active > .title-hint {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 1.1s ease, visibility 0s linear 1.1s;
}

.title-screen > .title-chronicle {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: grid;
  place-items: center;
  box-sizing: border-box;
  width: 100%;
  max-width: none;
  padding:
    max(30px, env(safe-area-inset-top))
    clamp(22px, 7vw, 80px)
    max(30px, env(safe-area-inset-bottom));
  visibility: hidden;
  overflow-x: hidden;
  overflow-y: auto;
  opacity: 0;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 43%, rgba(138, 112, 61, 0.13), transparent 42%),
    radial-gradient(circle at 50% 50%, transparent 34%, rgba(0, 0, 0, 0.76) 100%),
    linear-gradient(180deg, #080907, #0d0c09 52%, #050605);
  transition: opacity 1.6s ease, visibility 0s linear 1.6s;
}

.title-screen.chronicle-active > .title-chronicle {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
  transition-delay: 0s;
}

.title-chronicle::before,
.title-chronicle::after {
  content: "";
  position: absolute;
  pointer-events: none;
}

.title-chronicle::before {
  inset: clamp(18px, 4vw, 46px);
  border: 1px solid rgba(191, 158, 89, 0.22);
  box-shadow: inset 0 0 70px rgba(0, 0, 0, 0.72);
}

.title-chronicle::after {
  top: 0;
  bottom: 0;
  left: 50%;
  width: min(74vw, 620px);
  transform: translateX(-50%);
  background:
    linear-gradient(90deg, transparent, rgba(219, 187, 116, 0.025) 18%, rgba(219, 187, 116, 0.045) 50%, rgba(219, 187, 116, 0.025) 82%, transparent);
}

.title-chronicle-symbols {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
  pointer-events: none;
}

.title-chronicle-relics {
  position: absolute;
  z-index: 1;
  inset: clamp(14px, 2.5vw, 30px);
  overflow: hidden;
  pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 8%, rgba(0, 0, 0, 0.42) 47%, #000 76%);
  mask-image: radial-gradient(ellipse at center, transparent 8%, rgba(0, 0, 0, 0.42) 47%, #000 76%);
}

.title-chronicle-relics::before {
  content: "";
  position: absolute;
  inset: -12%;
  opacity: 0.34;
  background-image:
    radial-gradient(circle, rgba(236, 205, 132, 0.55) 0 1px, transparent 1.8px),
    radial-gradient(circle, rgba(111, 178, 191, 0.42) 0 0.8px, transparent 1.5px),
    radial-gradient(circle, rgba(225, 170, 88, 0.36) 0 1.2px, transparent 2px);
  background-position: 0 0, 31px 47px, 78px 20px;
  background-size: 109px 97px, 137px 121px, 173px 149px;
  animation: title-chronicle-dust 34s linear infinite;
  animation-play-state: paused;
}

.title-screen.chronicle-active .title-chronicle-relics::before {
  animation-play-state: running;
}

.title-chronicle-relic {
  --relic-opacity: 0.18;
  --relic-rotation: 0deg;
  --relic-drift-x: 20px;
  --relic-duration: 22s;
  --relic-delay: 0s;
  position: absolute;
  display: block;
  width: 70px;
  aspect-ratio: 1;
  color: #bca369;
  opacity: 0;
  filter: drop-shadow(0 0 8px rgba(193, 157, 82, 0.16));
  transform-origin: center;
  animation: title-chronicle-relic-drift var(--relic-duration) ease-in-out infinite;
  animation-delay: var(--relic-delay);
  animation-play-state: paused;
  will-change: opacity, transform;
}

.title-screen.chronicle-active .title-chronicle-relic,
.title-screen.chronicle-active .title-chronicle-relic svg,
.title-screen.chronicle-active .title-chronicle-relic::after {
  animation-play-state: running;
}

.title-chronicle-relic svg {
  display: block;
  width: 100%;
  height: 100%;
  overflow: visible;
  fill: rgba(190, 155, 81, 0.16);
  stroke: currentColor;
  stroke-width: 1.55;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.title-chronicle-relic.relic-sword svg,
.title-chronicle-relic.relic-axe svg {
  fill: rgba(153, 154, 144, 0.14);
  stroke-width: 1.3;
}

.title-chronicle-relic.relic-shield svg {
  fill: rgba(157, 126, 65, 0.13);
}

.title-chronicle-relic.relic-gem {
  color: #70aeb4;
  filter: drop-shadow(0 0 9px rgba(91, 179, 188, 0.23));
}

.title-chronicle-relic.relic-gem svg {
  fill: rgba(72, 148, 158, 0.18);
}

.title-chronicle-relic.relic-gem::after {
  content: "";
  position: absolute;
  top: 9%;
  left: 47%;
  width: 2px;
  height: 82%;
  border-radius: 50%;
  opacity: 0;
  background: linear-gradient(180deg, transparent, rgba(213, 250, 249, 0.72), transparent);
  transform: rotate(43deg);
  animation: title-chronicle-gem-glint 5.8s ease-in-out infinite;
  animation-delay: var(--relic-delay);
  animation-play-state: paused;
}

.title-chronicle-relic.relic-coin {
  color: #c9a44f;
  filter: drop-shadow(0 0 8px rgba(217, 171, 67, 0.2));
}

.title-chronicle-relic.relic-coin svg {
  fill: rgba(195, 145, 40, 0.16);
  animation: title-chronicle-coin-turn 7s ease-in-out infinite;
  animation-delay: var(--relic-delay);
  animation-play-state: paused;
}

.title-chronicle-relic:nth-child(1) {
  top: 6%;
  left: 2%;
  width: clamp(88px, 13vw, 148px);
  --relic-opacity: 0.18;
  --relic-rotation: -18deg;
  --relic-drift-x: 34px;
  --relic-duration: 25s;
  --relic-delay: -7s;
}

.title-chronicle-relic:nth-child(2) {
  top: 19%;
  left: 16%;
  width: clamp(38px, 5vw, 58px);
  --relic-opacity: 0.16;
  --relic-rotation: 12deg;
  --relic-drift-x: -18px;
  --relic-duration: 19s;
  --relic-delay: -12s;
}

.title-chronicle-relic:nth-child(3) {
  top: 57%;
  left: 5%;
  width: clamp(54px, 8vw, 86px);
  --relic-opacity: 0.23;
  --relic-rotation: -9deg;
  --relic-drift-x: 27px;
  --relic-duration: 21s;
  --relic-delay: -4s;
}

.title-chronicle-relic:nth-child(4) {
  top: 76%;
  left: 18%;
  width: clamp(66px, 10vw, 108px);
  --relic-opacity: 0.15;
  --relic-rotation: 8deg;
  --relic-drift-x: -25px;
  --relic-duration: 28s;
  --relic-delay: -18s;
}

.title-chronicle-relic:nth-child(5) {
  top: 6%;
  right: 10%;
  width: clamp(43px, 6vw, 66px);
  --relic-opacity: 0.19;
  --relic-rotation: -7deg;
  --relic-drift-x: 19px;
  --relic-duration: 20s;
  --relic-delay: -14s;
}

.title-chronicle-relic:nth-child(6) {
  top: 25%;
  right: -1%;
  width: clamp(96px, 14vw, 158px);
  --relic-opacity: 0.16;
  --relic-rotation: 21deg;
  --relic-drift-x: -31px;
  --relic-duration: 27s;
  --relic-delay: -9s;
}

.title-chronicle-relic:nth-child(7) {
  top: 48%;
  right: 17%;
  width: clamp(42px, 6vw, 64px);
  color: #9b78b9;
  --relic-opacity: 0.2;
  --relic-rotation: 14deg;
  --relic-drift-x: 16px;
  --relic-duration: 18s;
  --relic-delay: -5s;
}

.title-chronicle-relic:nth-child(8) {
  top: 69%;
  right: 4%;
  width: clamp(57px, 8vw, 88px);
  --relic-opacity: 0.19;
  --relic-rotation: 9deg;
  --relic-drift-x: -28px;
  --relic-duration: 23s;
  --relic-delay: -16s;
}

.title-chronicle-relic:nth-child(9) {
  top: 81%;
  right: 21%;
  width: clamp(76px, 11vw, 116px);
  --relic-opacity: 0.13;
  --relic-rotation: 27deg;
  --relic-drift-x: 25px;
  --relic-duration: 29s;
  --relic-delay: -20s;
}

.title-chronicle-relic:nth-child(10) {
  top: 7%;
  left: 32%;
  width: clamp(31px, 4vw, 46px);
  color: #708fb7;
  --relic-opacity: 0.16;
  --relic-rotation: -13deg;
  --relic-drift-x: -14px;
  --relic-duration: 17s;
  --relic-delay: -8s;
}

.title-chronicle-relic:nth-child(11) {
  top: 12%;
  right: 29%;
  width: clamp(45px, 6vw, 68px);
  --relic-opacity: 0.1;
  --relic-rotation: -11deg;
  --relic-drift-x: 18px;
  --relic-duration: 24s;
  --relic-delay: -15s;
}

.title-chronicle-relic:nth-child(12) {
  top: 87%;
  left: 35%;
  width: clamp(29px, 4vw, 43px);
  --relic-opacity: 0.15;
  --relic-rotation: 18deg;
  --relic-drift-x: -13px;
  --relic-duration: 16s;
  --relic-delay: -6s;
}

.title-chronicle-relic:nth-child(13) {
  top: 35%;
  left: -2%;
  width: clamp(70px, 10vw, 108px);
  --relic-opacity: 0.12;
  --relic-rotation: -28deg;
  --relic-drift-x: 23px;
  --relic-duration: 26s;
  --relic-delay: -22s;
}

.title-chronicle-relic:nth-child(14) {
  top: 87%;
  right: 36%;
  width: clamp(32px, 4vw, 48px);
  color: #6fa483;
  --relic-opacity: 0.17;
  --relic-rotation: 7deg;
  --relic-drift-x: 14px;
  --relic-duration: 19s;
  --relic-delay: -11s;
}

.title-chronicle-frame {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  align-items: center;
  width: min(760px, 100%);
  min-height: min(72svh, 610px);
  color: #dfd5bb;
  font-family: "Yu Mincho", "Hiragino Mincho ProN", Georgia, serif;
}

.title-chronicle-kicker,
.title-chronicle-return {
  margin: 0;
  color: #917d52;
  font-size: clamp(9px, 1.6vw, 12px);
  letter-spacing: 0.24em;
  text-shadow: 0 2px 10px #000;
}

.title-chronicle-kicker::after {
  content: "";
  display: block;
  width: min(280px, 55vw);
  height: 1px;
  margin: 18px auto 0;
  background: linear-gradient(90deg, transparent, rgba(196, 157, 79, 0.72), transparent);
}

.title-chronicle-verse {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: clamp(250px, 43svh, 390px);
  padding: 22px 0;
}

.title-chronicle-verse.is-cycling {
  animation: title-chronicle-verse-cycle var(--title-chronicle-verse-duration, 12000ms) ease both;
}

.title-chronicle-chapter {
  margin: 0 0 clamp(26px, 5svh, 48px);
  color: #bca067;
  font-size: clamp(12px, 2.2vw, 16px);
  letter-spacing: 0.17em;
  animation: title-chronicle-line 1.4s ease both;
}

.title-chronicle-line {
  display: block;
  margin: 0;
  color: #e3dcc9;
  font-size: clamp(14px, min(3.2vw, 3svh), 24px);
  font-weight: 400;
  line-height: 1.95;
  letter-spacing: 0.07em;
  text-wrap: balance;
  text-shadow: 0 2px 12px #000, 0 0 22px rgba(176, 145, 78, 0.08);
  opacity: 0;
  animation: title-chronicle-line 1.65s ease forwards;
  animation-delay: calc(0.45s + var(--chronicle-line-index, 0) * 0.42s);
}

.title-chronicle-return {
  align-self: end;
  color: #71684f;
  letter-spacing: 0.12em;
}

@keyframes title-chronicle-line {
  from {
    opacity: 0;
    filter: blur(3px);
    transform: translateY(11px);
  }
  to {
    opacity: 1;
    filter: none;
    transform: none;
  }
}

@keyframes title-chronicle-verse-cycle {
  0%,
  7% {
    opacity: 0;
  }
  18%,
  84% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

@keyframes title-chronicle-relic-drift {
  0% {
    opacity: 0;
    transform: translate3d(0, 38px, 0) rotate(calc(var(--relic-rotation) - 8deg)) scale(0.9);
  }
  17%,
  70% {
    opacity: var(--relic-opacity);
  }
  48% {
    transform: translate3d(calc(var(--relic-drift-x) * 0.55), -7px, 0) rotate(var(--relic-rotation)) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--relic-drift-x), -45px, 0) rotate(calc(var(--relic-rotation) + 9deg)) scale(1.06);
  }
}

@keyframes title-chronicle-coin-turn {
  0%,
  100% {
    transform: scaleX(1);
    filter: brightness(0.82);
  }
  48% {
    transform: scaleX(0.38);
    filter: brightness(1.45);
  }
  58% {
    transform: scaleX(0.72);
    filter: brightness(1.08);
  }
}

@keyframes title-chronicle-gem-glint {
  0%,
  58%,
  100% {
    opacity: 0;
    transform: translate(-18px, 12px) rotate(43deg);
  }
  70% {
    opacity: 0.8;
  }
  82% {
    opacity: 0;
    transform: translate(18px, -12px) rotate(43deg);
  }
}

@keyframes title-chronicle-dust {
  from {
    transform: translate3d(0, 0, 0);
  }
  to {
    transform: translate3d(48px, -72px, 0);
  }
}

.death-effect.active {
  visibility: visible;
  animation: death-screen 2.8s ease-out forwards;
}

.death-effect strong {
  color: #c9b8af;
  font-family: Georgia, serif;
  font-size: clamp(34px, 10vw, 62px);
  letter-spacing: 0.15em;
  text-shadow: 0 3px 18px #000, 0 0 28px rgba(160, 0, 0, 0.7);
}

.death-effect p {
  margin: 0;
  color: #a99b94;
  font-size: 14px;
}

.death-cry-text {
  max-width: min(82vw, 520px);
  margin: 8px 0 4px;
  color: #ff0000;
  font-family: Georgia, "Yu Mincho", serif;
  font-size: clamp(18px, 5.2vw, 28px);
  font-weight: 700;
  line-height: 1.45;
  text-shadow: 0 2px 8px #000, 0 0 16px rgba(151, 31, 25, 0.45);
}

.death-cry-text::before { content: "「"; }
.death-cry-text::after { content: "」"; }

.death-mark {
  color: #8f1f1f;
  font-family: Georgia, serif;
  font-size: 74px;
  line-height: 1;
  text-shadow: 0 0 24px rgba(220, 0, 0, 0.55);
  animation: death-mark-fall 1.2s cubic-bezier(.2,.8,.2,1) both;
}

@keyframes death-screen {
  0% { opacity: 0; filter: brightness(2.4); }
  12% { opacity: 1; filter: brightness(1.3); }
  70% { opacity: 1; filter: brightness(0.85); }
  100% { opacity: 0; filter: brightness(0.5); }
}

@keyframes death-mark-fall {
  0% { opacity: 0; transform: translateY(-40px) scale(1.7); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.tile-chest {
  color: var(--gold);
}

/* @の下に未開封の宝箱がある状態。箱の記号は隠れるので枠で知らせる。 */
.tile-player-on-chest {
  background: #3a3018;
  outline: 2px solid rgba(255, 215, 130, 0.85);
  outline-offset: -2px;
}

.controls {
  margin-top: 0;
  display: grid;
  grid-template-columns: repeat(3, 54px);
  grid-template-rows: repeat(3, 50px);
  gap: 5px;
  justify-content: center;
  position: static;
  z-index: 1;
  padding: 6px;
  border: 0;
  border-radius: 13px;
  background: linear-gradient(145deg, rgba(24, 31, 27, 0.42), rgba(12, 17, 14, 0.5));
  box-shadow: none;
  backdrop-filter: blur(4px);
  transform: translateY(-3px);
}

.controls button {
  width: 54px;
  min-height: 50px;
  font-size: 21px;
  cursor: pointer;
  touch-action: none;
  user-select: none;
  pointer-events: auto;
  border-color: rgba(214, 174, 84, 0.34);
  border-radius: 11px;
  background: linear-gradient(180deg, rgba(50, 61, 53, 0.98), rgba(27, 36, 31, 0.98));
}

.controls button.has-action {
  border-color: #d6ae54;
  color: #fff0b3;
  background: #55451f;
  box-shadow: 0 0 10px rgba(214, 174, 84, 0.32);
}

/* 足元の宝箱を開ける時だけ、中央ボタンをさらに強く光らせる。 */
.controls button.chest-action {
  border-color: #ffd782;
  color: #fff8dc;
  background: #6b5322;
  box-shadow: 0 0 14px rgba(255, 215, 130, 0.55);
}

/* The convenience button keeps its normal size while showing the actual target. */
.controls #waitButton {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3px;
  overflow: hidden;
}

.wait-action-graphic {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 86%;
  height: 86%;
  min-width: 0;
  min-height: 0;
  pointer-events: none;
}

.controls #waitButton.chest-action .wait-action-graphic {
  width: 78%;
  height: 78%;
}

.wait-corpse-graphic { isolation: isolate; }

/* Rotate only the @ glyph when the capoeira stance is active. */
.wait-player-glyph { display: inline-block; position: relative; top: -0.08em; font: inherit; color: inherit; }

.magic-move-controls {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  align-content: start;
  grid-auto-rows: max-content;
  gap: 6px;
  width: auto;
  min-width: 0;
  margin: 0;
  padding: 6px;
  border: 1px solid rgba(132, 119, 239, 0.48);
  border-radius: 14px;
  background: linear-gradient(145deg, rgba(41, 31, 75, 0.96), rgba(20, 17, 42, 0.96));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.04), 0 8px 22px rgba(0, 0, 0, 0.32);
  transform: translateY(-4px) scale(0.9);
  transform-origin: right center;
}

.magic-move-controls button {
  min-width: 0;
  min-height: 38px;
  white-space: normal;
  overflow-wrap: anywhere;
  line-height: 1.25;
  padding: 5px;
  border-color: rgba(147, 132, 255, 0.42);
  background: rgba(55, 42, 99, 0.92);
  font-size: 12px;
}

.magic-move-controls button.selected {
  color: #fff;
  border-color: #c4b8ff;
  box-shadow: 0 0 12px rgba(154, 131, 255, 0.45);
}

.dungeon-action-dock {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  align-items: stretch;
  width: 100%;
  margin-top: 7px;
}

.resistance-board {
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(214, 174, 84, 0.35);
  border-radius: 9px;
  background: rgba(214, 174, 84, 0.055);
}

.resistance-board h2 {
  margin: 0 0 5px;
}

.resistance-board p {
  margin: 0 0 5px;
  color: var(--muted);
  font-size: 11px;
}

.resistance-total-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 5px;
}

.resistance-total {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px;
  overflow: hidden;
  padding: 5px 6px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 14px;
}

.resistance-total strong {
  font-size: inherit;
}

.resistance-total i {
  position: absolute;
  inset: auto 0 0;
  height: 2px;
  background: linear-gradient(90deg, #8ea960 calc(var(--tier) * 20%), transparent 0);
}

.resistance-total.tier-5 {
  color: #fff1a8;
  background: rgba(214, 174, 84, 0.17);
}

.log-panel {
  min-height: 140px;
  max-height: none;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 4px;
  overflow: hidden;
  padding: 5px 6px;
}

.log-panel-toolbar {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 7px;
}

.log-panel-toolbar > span {
  overflow: hidden;
  color: #91a397;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.log-panel-toolbar button {
  min-height: 25px;
  padding: 3px 8px;
  border-color: rgba(214, 174, 84, 0.34);
  border-radius: 8px;
  color: #e8ddb9;
  background: rgba(71, 58, 34, 0.62);
  font-size: 10px;
  white-space: nowrap;
}

.log-panel-toolbar button:disabled {
  opacity: 0.46;
}

.log-history-count {
  display: inline-grid;
  min-width: 18px;
  min-height: 18px;
  place-items: center;
  margin-left: 3px;
  padding: 0 4px;
  border-radius: 999px;
  color: #fff1bd;
  background: rgba(214, 174, 84, 0.2);
}

.log-list {
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.log-list::-webkit-scrollbar {
  display: none;
}

.app-shell.dungeon-mode .log-panel,
.app-shell.arena-mode .log-panel {
  min-height: 140px;
  max-height: none;
  padding: 8px 9px;
  overflow: hidden;
  border-color: rgba(105, 136, 116, 0.52);
  background: linear-gradient(180deg, rgba(17, 25, 21, 0.98), rgba(10, 16, 13, 0.98));
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025), 0 -8px 28px rgba(0, 0, 0, 0.18);
}

.app-shell.dungeon-mode .log-panel {
  min-height: 105px;
  padding: 6px 8px;
  gap: 3px;
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.025), 0 8px 28px rgba(0, 0, 0, 0.18);
}

.app-shell.arena-mode .log-panel {
  min-height: 0;
  padding: 6px 8px;
}

.app-shell.dungeon-mode .log-panel-toolbar > span {
  font-size: 8px;
}

.app-shell.dungeon-mode .log-panel-toolbar button {
  min-height: 20px;
  padding: 1px 6px;
  font-size: 9px;
}

.app-shell.dungeon-mode .log-panel p {
  margin-bottom: 1px;
  padding-block: 1px;
  font-size: 11px;
  line-height: 1.15;
}

.app-shell.dungeon-mode .log-list,
.app-shell.arena-mode .log-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.app-shell.dungeon-mode .log-list::-webkit-scrollbar,
.app-shell.arena-mode .log-list::-webkit-scrollbar {
  display: none;
}

.log-panel p {
  margin: 0 0 3px;
  padding: 2px 5px 3px 7px;
  border-left: 2px solid rgba(127, 157, 137, 0.22);
  border-radius: 2px;
  color: #e8e4d5;
  font-size: 12px;
  line-height: 1.25;
}

.log-panel p:first-child {
  color: #fff5cf;
  border-left-color: var(--gold);
  background: linear-gradient(90deg, rgba(224, 184, 98, 0.09), transparent 82%);
}

.log-history-card {
  width: min(100%, 520px);
  max-height: calc(100dvh - 32px);
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.log-history-heading {
  display: grid;
  gap: 4px;
}

.log-history-heading > span {
  color: #9ab0a1;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
}

.log-history-heading h2,
.log-history-heading p {
  margin: 0;
}

.log-history-heading p {
  color: var(--muted);
  font-size: 11px;
}

.log-history-list {
  min-height: 0;
  max-height: min(62dvh, 540px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 9px;
  background: rgba(0, 0, 0, 0.28);
  scrollbar-color: rgba(214, 174, 84, 0.42) transparent;
}

.log-history-list p {
  margin: 0 0 5px;
  padding: 5px 7px;
  border-left: 2px solid rgba(127, 157, 137, 0.26);
  border-radius: 2px;
  color: #dddacf;
  font-size: 12px;
  line-height: 1.4;
}

.log-history-list p.latest {
  border-left-color: var(--gold);
  color: #fff5cf;
  background: linear-gradient(90deg, rgba(224, 184, 98, 0.09), transparent 82%);
}

.log-history-list p.empty {
  border-left: 0;
  color: var(--muted);
  text-align: center;
}

.log-list p.log-death-cry,
.log-history-list p.log-death-cry,
.death-review-log p.log-death-cry {
  color: #ff0000;
  border-left-color: #ff0000;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(4, 7, 6, 0.78);
  backdrop-filter: blur(9px);
}

.modal-card {
  width: min(100%, 480px);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 14px;
  background: linear-gradient(155deg, #202923, #111713);
  box-shadow: inset 0 1px rgba(255, 255, 255, 0.035), 0 22px 64px rgba(0, 0, 0, 0.54);
  display: grid;
  gap: 10px;
}

.setup-card {
  width: min(100%, 560px);
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.setup-selectors {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.name-entry {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 12px;
}

.name-entry input {
  width: 100%;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid rgba(214, 174, 84, 0.4);
  border-radius: 7px;
  color: #fff;
  background: rgba(0, 0, 0, 0.3);
  font-size: 16px;
}

.setup-selector {
  display: grid;
  gap: 3px;
  min-height: 82px;
  text-align: left;
}

.setup-selector span,
.setup-selector small {
  color: var(--muted);
  font-size: 11px;
}

.setup-selector strong {
  color: #ffe6a5;
  font-size: 18px;
}

.setup-picker-modal {
  z-index: 70;
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible,
.log-history-list:focus-visible,
.cell[role="button"]:focus-visible,
.research-card summary:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

@media (max-width: 420px) {
  .tabs {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: repeat(2, minmax(38px, auto));
  }

  .tabs button {
    min-height: 38px;
    padding-inline: 2px;
    font-size: 11px;
  }

  .home-profile-heading {
    grid-template-columns: 1fr;
  }

  .combat-metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .research-tools {
    grid-template-columns: 1fr;
  }

  .guild-claim-row {
    grid-template-columns: 1fr;
  }

  .treasure-sell-list article {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .treasure-sell-list article > div {
    grid-column: 1 / -1;
  }

  .treasure-sell-list button {
    width: 100%;
  }
}

.setup-picker-card {
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.setup-picker-list {
  overflow-y: auto;
  max-height: min(62dvh, 520px);
  /* ボタン内の説明文はグリッド行の自動サイズ計算へ寄与しないことがあるため、
     行を内容量で確実に伸ばして説明の見切れを防ぐ。 */
  grid-auto-rows: max-content;
}

.setup-picker-list.race-picker-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 7px;
}

.setup-picker-list.race-picker-grid button {
  align-content: start;
  min-width: 0;
  min-height: 76px;
}

.setup-picker-list.race-picker-grid small {
  overflow-wrap: anywhere;
  line-height: 1.35;
}

.setup-summary {
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.03);
  color: #efe8d0;
  font-size: 13px;
  line-height: 1.5;
}

.stat-row {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 8px;
  align-items: start;
  font-size: 13px;
  line-height: 1.4;
}

.list-pager {
  position: sticky;
  top: 0;
  z-index: 4;
  display: grid;
  grid-template-columns: auto auto 1fr auto;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(20, 25, 18, 0.96);
  font-size: 12px;
}

.list-pager span {
  color: var(--muted);
}

.danger {
  color: #ffb0a0;
}

.ok {
  color: #cde9a8;
}

@media (min-width: 980px) {
  .app-shell {
    width: min(100vw, 1180px);
    padding: 12px 16px;
    gap: 9px;
  }

  .tabs {
    /* 10列に並ぶ幅ではタブは1行で足りる。基礎ルールの2行分確保を
       引き継ぐと空の2行目(約40px)がタブ下の死帯になるため、1行へ畳む。
       浮いた高さはグリッドの1frである表示ビューが受け取る。 */
    grid-template-columns: repeat(10, minmax(0, 1fr));
    grid-template-rows: minmax(42px, auto);
  }

  .tabs button {
    min-height: 42px;
    font-size: 12px;
  }

  .view {
    padding: 12px;
  }

  .town-grid,
  .card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .app-shell.dungeon-mode {
    --tile: clamp(18px, min(36px, calc((100svh - 480px) / 13)), 36px);
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: clamp(105px, 15svh, 150px) minmax(0, 1fr);
    gap: 12px;
  }

  .app-shell.dungeon-mode #dungeonView {
    grid-column: 1;
    grid-row: 2;
    padding: 10px;
  }

  .app-shell.dungeon-mode .log-panel {
    grid-column: 1;
    grid-row: 1;
    min-height: 0;
    max-height: none;
    padding: 12px;
    gap: 8px;
  }

  .app-shell.dungeon-mode .log-panel-toolbar > span {
    font-size: 11px;
  }

  .app-shell.dungeon-mode .log-panel-toolbar button {
    min-height: 32px;
    padding: 5px 10px;
    font-size: 11px;
  }

  .app-shell.dungeon-mode .log-panel p {
    margin-bottom: 5px;
    padding: 5px 7px 6px 9px;
    font-size: 13px;
    line-height: 1.35;
  }

  .dungeon-action-dock {
    max-width: 700px;
    margin: 10px auto 0;
  }

  .magic-move-controls {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}

@media (max-width: 380px) {
  :root {
    --tile: clamp(17px, min(27px, calc((100vw - 42px) / 13), calc((100svh - 342px) / 13)), 27px);
  }

  .controls {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 46px);
    gap: 4px;
    padding: 5px;
  }

  .controls button {
    width: 48px;
    min-height: 46px;
    font-size: 16px;
  }

  .dungeon-action-dock {
    gap: 5px;
  }

  .magic-move-controls {
    grid-template-columns: minmax(0, 1fr);
    gap: 4px;
    padding: 5px;
  }

  .magic-move-controls button {
    min-height: 34px;
    padding: 3px;
    font-size: 11px;
  }

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

  .app-shell.arena-mode .log-panel {
    min-height: 0;
    max-height: none;
    padding-right: 9px;
  }

  .app-shell.dungeon-mode .log-panel {
    min-height: 105px;
    max-height: 132px;
    padding: 6px 8px;
  }

  .app-shell.arena-mode .status-bar {
    grid-template-columns: repeat(5, minmax(0, 1fr)) 42px;
  }

  .app-shell.arena-mode .character-strip {
    grid-template-columns: repeat(8, minmax(0, 1fr));
  }

  .app-shell.dungeon-mode {
    /* 高さ予算390px = ヘッダー+操作パッド+ログ+余白。320pxでは667px級の
       端末で操作パッド下段がログに重なり、下移動が押せなかった。 */
    --tile: clamp(15px, min(29px, calc((100vw - 42px) / 13), calc((100svh - 390px) / 13)), 29px);
    grid-template-columns: minmax(0, 1fr);
  }

  .dungeon-stats-overlay {
    left: 6px;
    width: 66px;
  }

  .app-shell.arena-mode .status-bar > div,
  .app-shell.arena-mode .character-strip > div {
    padding: 3px;
  }

  .app-shell.arena-mode .status-bar strong,
  .app-shell.arena-mode .character-strip strong {
    font-size: 10px;
  }

  .app-shell.arena-mode .status-bar span,
  .app-shell.arena-mode .character-strip span {
    font-size: 8px;
  }

  .app-shell.arena-mode .arena-move-pad {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 44px);
    gap: 6px;
  }

  .app-shell.arena-mode .arena-move-pad button {
    width: 48px;
  }

  .status-bar {
    grid-template-columns: 1fr 1fr 1fr 54px;
  }

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

  .setup-selectors {
    grid-template-columns: 1fr;
  }
}

/* 背の低いスマートフォンでは、街の装備帯を自宅へ譲り、施設の閲覧領域を守る。 */
@media (max-width: 600px) and (max-height: 700px) {
  .app-shell.town-mode {
    grid-template-rows: auto auto auto minmax(180px, 1fr) 78px;
    gap: 4px;
  }

  .app-shell.town-mode .equipment-strip {
    display: none;
  }

  .app-shell.town-mode .character-strip {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }

  .app-shell.town-mode .character-strip > div {
    padding: 2px 4px;
  }

  .app-shell.town-mode .character-strip strong {
    font-size: 10px;
  }

  .app-shell.town-mode .character-strip span {
    font-size: 8px;
  }

  .app-shell.town-mode .tabs {
    grid-template-rows: repeat(2, minmax(28px, auto));
    gap: 2px;
    padding: 3px;
  }

  .app-shell.town-mode .tabs button {
    min-height: 28px;
    padding: 2px;
    font-size: 9px;
  }

  .app-shell.town-mode .log-panel {
    min-height: 0;
    padding: 4px 5px;
  }

  .app-shell.town-mode .log-panel-toolbar button {
    min-height: 22px;
    padding: 2px 6px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }

  .level-up-effect.active {
    animation: none !important;
    opacity: 1;
    transform: none;
    filter: none;
  }

  .title-chronicle-verse.is-cycling,
  .title-chronicle-chapter,
  .title-chronicle-line {
    animation: none !important;
    opacity: 1;
    filter: none;
    transform: none;
  }

  .title-chronicle-relics::before,
  .title-chronicle-relic,
  .title-chronicle-relic svg,
  .title-chronicle-relic::after {
    animation: none !important;
  }

  .title-chronicle-relic {
    opacity: 0.09;
    transform: rotate(var(--relic-rotation));
  }

}

.gm-crown {
  display: inline-block;
  margin-right: 3px;
  animation: gm-crown-glow 2.4s ease-in-out infinite;
}

.gm-rainbow-name {
  font-weight: 800;
  animation: deep-rainbow-text 1.8s steps(6, end) infinite;
}

@keyframes gm-crown-glow {
  0%, 100% { filter: drop-shadow(0 0 2px rgba(255, 215, 64, 0.55)); }
  50% { filter: drop-shadow(0 0 6px rgba(255, 215, 64, 0.95)); }
}

.clear-trophy {
  display: inline-block;
  margin-right: 3px;
  filter: drop-shadow(0 0 3px rgba(255, 213, 79, 0.7));
}

.clear-gold-name {
  font-weight: 800;
  color: #ffd54f;
  text-shadow: 0 0 6px rgba(255, 213, 79, 0.45);
}

/* ---- エンディング: 白の@とピンクの@、恋の舞台 ---- */
.ending-screen {
  position: fixed; inset: 0; z-index: 400; background: #000;
  opacity: 1; transition: opacity 1.4s ease;
}
.ending-screen.hidden { display: none; }
.ending-screen.is-fading { opacity: 0; }
.ending-stage { position: absolute; inset: 0; overflow: hidden; opacity: 1; transition: opacity 4s ease; }
.ending-stage.is-dimming { opacity: 0; }
.ending-actor {
  position: absolute; left: 0; top: 0; line-height: 1;
  font-family: Georgia, "Yu Mincho", serif;
  font-weight: 400;
  font-size: clamp(48px, 10vmin, 96px);
  transition-property: left, top;
  transition-duration: 900ms, 900ms;
  transition-timing-function: cubic-bezier(0.45, 0.05, 0.35, 1);
  will-change: left, top, transform;
}
.ending-actor-white { color: var(--text); text-shadow: 0 0 3px #f4f1e8, 0 0 15px rgba(244, 241, 232, 0.6), 0 2px 3px #000; }
.ending-actor-pink { color: #ff85b8; text-shadow: 0 0 3px #ff85b8, 0 0 15px rgba(255, 133, 184, 0.6), 0 2px 3px #000; }
.ending-actor.is-lean-left { transform: rotate(-13deg); transition: left 900ms, top 900ms, transform 700ms ease; }
.ending-actor.is-lean-right { transform: rotate(13deg); transition: left 900ms, top 900ms, transform 700ms ease; }
.ending-actor.is-fainted { transform: rotate(94deg) translateY(0.6vmin); transition: left 500ms, top 500ms, transform 600ms cubic-bezier(0.4, 0, 0.8, 1); }
.ending-actor.anim-hop { animation: ending-hop 0.55s ease; }
.ending-actor.anim-hop2 { animation: ending-hop 0.45s ease 2; }
.ending-actor.anim-twirl { animation: ending-twirl 1.1s cubic-bezier(0.4, 0.1, 0.3, 1); }
.ending-actor.anim-bigjump { animation: ending-bigjump 1.25s cubic-bezier(0.35, 0.5, 0.35, 1); }
.ending-actor.anim-shy { animation: ending-shy 0.85s ease; }
.ending-actor.anim-skid { animation: ending-skid 0.75s ease-out; }
.ending-actor.anim-springup { animation: ending-springup 0.7s cubic-bezier(0.3, 0.9, 0.4, 1.2); }
.ending-actor.anim-waltz { animation: ending-waltz 1.9s ease-in-out infinite; }
.ending-actor.anim-waltz.is-offbeat { animation-delay: -0.95s; }
@keyframes ending-hop { 40% { transform: translateY(-2.4vmin); } }
@keyframes ending-twirl { to { transform: rotate(360deg); } }
@keyframes ending-bigjump { 45% { transform: translateY(-9vmin) rotate(180deg); } 100% { transform: translateY(0) rotate(360deg); } }
@keyframes ending-shy { 40% { transform: rotate(-15deg) translateX(-1vmin); } }
@keyframes ending-skid { 30% { transform: rotate(20deg) translateX(1vmin); } 65% { transform: rotate(-9deg); } }
@keyframes ending-springup { 0% { transform: rotate(94deg); } 55% { transform: rotate(-14deg) translateY(-2.4vmin); } 100% { transform: none; } }
@keyframes ending-waltz { 0%, 100% { transform: translateY(0) rotate(-9deg); } 50% { transform: translateY(-1.8vmin) rotate(9deg); } }
.ending-spark {
  position: absolute; pointer-events: none; line-height: 1;
  font-size: clamp(18px, 3.2vmin, 28px); color: #ff85b8;
  text-shadow: 0 0 12px rgba(255, 133, 184, 0.6);
  opacity: 0; animation: ending-spark-rise 2.6s ease-out forwards;
}
.ending-spark.is-white { color: #f2efe6; text-shadow: 0 0 12px rgba(242, 239, 230, 0.5); }
.ending-spark.is-big { font-size: clamp(34px, 7vmin, 62px); animation-duration: 3.8s; }
@keyframes ending-spark-rise {
  0% { opacity: 0; transform: translateY(1.2vmin) scale(0.6); }
  16% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-10vmin) scale(1.18); }
}
.ending-gift {
  position: absolute; pointer-events: none; line-height: 1;
  font-size: clamp(22px, 4.4vmin, 38px); color: #ffd75e;
  text-shadow: 0 0 14px rgba(255, 215, 94, 0.55);
  transition: left 900ms ease, top 900ms ease, transform 600ms ease, opacity 600ms ease;
}
.ending-gift.is-dropped { transform: rotate(74deg); }
.ending-gift.is-claimed { opacity: 0; transform: scale(0.5); }
.ending-credit {
  position: absolute; left: 0; width: 100%; top: -12%;
  margin: 0; text-align: center; pointer-events: none;
  color: var(--text); letter-spacing: 0.14em;
  font-size: clamp(16px, 3vmin, 24px);
  line-height: 1.7; white-space: pre-line;
  text-shadow: 0 0 12px rgba(244, 241, 232, 0.4);
  transition: top 2.6s cubic-bezier(0.2, 0.7, 0.3, 1), transform 1.6s ease;
}
.ending-credit.is-falling {
  transition: top 1.5s cubic-bezier(0.5, 0, 0.9, 0.4), transform 1.5s ease-in;
  transform: rotate(9deg);
}
.ending-skip-hint {
  position: absolute; bottom: 4%; left: 0; width: 100%; margin: 0;
  text-align: center; color: #8a857a; font-size: 12px;
  opacity: 0; transition: opacity 1s ease; pointer-events: none;
}
.ending-skip-hint.is-visible { opacity: 0.85; }

/* 鍛冶レシピ: 必要素材、所持数、産出先を小画面でも一続きで読ませる。 */
.smithy-recipe-card {
  align-content: start;
}

.monster-heart-workshop label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.monster-heart-workshop select {
  width: 100%;
  min-width: 0;
}

.monster-heart-preview {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(214, 174, 84, 0.45);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.18);
  overflow-wrap: anywhere;
}

.monster-heart-preview h3 {
  margin: 0 0 8px;
  color: var(--gold);
  font-size: 14px;
}

.monster-heart-preview dl {
  display: grid;
  gap: 6px;
  margin: 0;
}

.monster-heart-preview dl > div {
  padding: 8px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.035);
}

.monster-heart-preview dt {
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 11px;
}

.monster-heart-preview dd,
.monster-heart-preview p {
  margin: 0;
  font-size: 12px;
  line-height: 1.6;
}

.monster-heart-preview p {
  margin-top: 8px;
  color: var(--muted);
}

.monster-heart-preview .heart-preview-caution {
  border-left: 3px solid #e4a76a;
  color: #ffe0b5;
}

.monster-heart-preview .heart-preview-warning {
  margin: 0 0 8px;
  padding: 8px;
  border: 1px solid #d39467;
  border-radius: 6px;
  color: #ffe0b5;
  background: rgba(141, 51, 32, 0.22);
}

.smithy-material-needs {
  display: grid;
  gap: 5px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.smithy-material-needs li {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 2px 8px;
  align-items: baseline;
  padding: 6px 8px;
  border-radius: 7px;
  background: rgba(0, 0, 0, 0.18);
  font-size: 12px;
}

.smithy-material-options {
  min-width: 0;
  overflow-wrap: anywhere;
}

.smithy-material-options summary {
  cursor: pointer;
  padding-block: 5px;
}

.smithy-material-options small {
  display: block;
  margin-block: 4px;
}

.smithy-material-needs li strong {
  min-width: 0;
  overflow-wrap: anywhere;
}

.smithy-material-needs li small {
  grid-column: 1 / -1;
  color: rgba(255, 255, 255, 0.64);
}

.smithy-material-needs li.ready {
  color: #9fe6a8;
}

.smithy-material-needs li.short {
  color: #ffd8a8;
}

/* 旧セーブの説明資料と比較するため残す、従来の進捗カード表現。 */
.craft-progress-list {
  display: grid;
  gap: 8px;
}

.craft-progress {
  display: grid;
  gap: 6px;
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.03);
}

.craft-progress > div {
  display: grid;
  gap: 2px;
}

.craft-progress small {
  color: rgba(255, 255, 255, 0.62);
  font-size: 11px;
}

.craft-progress ul {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 3px;
}

.craft-progress li {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: baseline;
  font-size: 12px;
}

.craft-progress li.ready {
  color: #9fe6a8;
}

.craft-progress li.short {
  color: #ffd8a8;
}

/* 珍しい素材を要求する装備は、棚の上でも格が見えるようにする。 */
.craft-tier {
  display: inline-block;
  margin-left: 7px;
  padding: 1px 7px;
  border-radius: 999px;
  font-size: 10px;
  letter-spacing: 0.06em;
  vertical-align: middle;
}

.craft-tier-rare {
  color: #a9d8ff;
  border: 1px solid rgba(169, 216, 255, 0.5);
  background: rgba(169, 216, 255, 0.1);
}

.craft-tier-super {
  color: #ffd782;
  border: 1px solid rgba(255, 215, 130, 0.62);
  background: rgba(255, 215, 130, 0.13);
  text-shadow: 0 0 6px rgba(255, 215, 130, 0.5);
}

.craft-tier-ultra {
  color: #fff3c4;
  border: 1px solid rgba(255, 236, 150, 0.85);
  background: linear-gradient(120deg, rgba(255, 214, 130, 0.28), rgba(255, 120, 220, 0.24), rgba(140, 200, 255, 0.28));
  text-shadow: 0 0 8px rgba(255, 240, 180, 0.9);
  animation: craft-tier-ultra-glow 2.4s ease-in-out infinite;
}

@keyframes craft-tier-ultra-glow {
  0%, 100% { box-shadow: 0 0 6px rgba(255, 230, 150, 0.45); }
  50% { box-shadow: 0 0 16px rgba(255, 230, 150, 0.9); }
}

.recipe-card.craft-tier-card-super {
  border-color: rgba(255, 215, 130, 0.45);
}

.recipe-card.craft-tier-card-ultra {
  border-color: rgba(255, 236, 150, 0.7);
  background: linear-gradient(180deg, rgba(255, 224, 150, 0.09), rgba(255, 255, 255, 0.02));
  box-shadow: 0 0 14px rgba(255, 226, 150, 0.22);
}

/* 確認ダイアログの本文は改行を活かす。ギルドの査定明細を1行ずつ読ませるため。 */
#confirmText {
  white-space: pre-line;
}

/* 生涯のスコアと、このブラウザの冒険記録。 */
.title-screen > #titleRankingButton {
  width: min(200px, 64vw);
  padding: 7px 18px;
  border-color: rgba(185, 145, 62, 0.65);
  background: rgba(11, 18, 14, 0.88);
  font-size: 13px;
}
.title-screen.chronicle-active > #titleRankingButton {
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
}
.ranking-card {
  width: min(640px, calc(100vw - 24px));
  max-height: calc(100dvh - 32px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 12px;
  overflow: hidden;
}
.ranking-card h2 { margin: 4px 0 8px; }
.ranking-card > div > p { color: var(--muted); font-size: 12px; line-height: 1.5; }
.ranking-kicker { color: var(--gold); letter-spacing: 0.14em; font-size: 10px; }
.ranking-list {
  list-style: none;
  min-height: 100px;
  overflow-y: auto;
  overscroll-behavior: contain;
  margin: 0;
  padding: 0 3px 0 0;
}
.ranking-row {
  padding: 12px;
  margin-bottom: 9px;
  border: 1px solid rgba(160, 174, 135, 0.2);
  border-radius: 8px;
  background: linear-gradient(125deg, rgba(92, 94, 50, 0.13), rgba(8, 17, 13, 0.5));
  overflow-wrap: anywhere;
}
.ranking-row:nth-child(-n+3) { border-color: rgba(224, 184, 98, 0.5); }
.ranking-row-heading { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; }
.ranking-place { color: var(--gold); font-weight: 700; }
.ranking-row-heading strong { color: #fff0bb; font-variant-numeric: tabular-nums; font-size: 23px; }
.ranking-row-heading small { font-size: 11px; font-weight: 400; }
.ranking-row h3 { margin: 6px 0; font-size: 16px; }
.ranking-row p { margin: 5px 0; font-size: 12px; line-height: 1.5; }
.ranking-depth { display: flex; flex-wrap: wrap; gap: 6px 12px; font-weight: 700; color: #eee7d2; }
.ranking-status { color: #e3a598; }
.ranking-status.cleared { color: #dbc574; }
.ranking-row time { color: var(--muted); font-size: 10px; }
.ranking-empty { color: var(--muted); padding: 28px 14px; line-height: 1.8; text-align: center; }
.play-score-summary {
  margin: 10px 0;
  padding: 16px;
  border: 1px solid rgba(224, 184, 98, 0.36);
  border-radius: 8px;
  text-align: center;
  background: linear-gradient(135deg, rgba(123, 96, 46, 0.13), rgba(0, 0, 0, 0.2));
  overflow-wrap: anywhere;
}
.play-score-summary > span { display: block; color: var(--gold); font-size: 10px; letter-spacing: 0.18em; }
.play-score-summary > strong { display: block; margin: 5px 0 8px; font-size: clamp(28px, 9vw, 42px); color: #ffe5a2; font-variant-numeric: tabular-nums; }
.play-score-summary p { margin: 5px 0; font-size: 12px; line-height: 1.6; }
.score-cause { color: #f3a69c; overflow-wrap: anywhere; }
.score-result-card { width: min(440px, calc(100vw - 28px)); max-height: calc(100dvh - 32px); overflow-y: auto; }
.score-result-card > button { width: 100%; }
.death-review-card { max-height: calc(100dvh - 24px); overflow-y: auto; }
.death-review-card:has(.play-score-summary) .death-review-log { max-height: min(30dvh, 240px); }


/* Steam vanilla: centered title and menu over the wide illustration. */
@media (min-width: 760px) and (orientation: landscape) {
  .title-screen {
    align-items: center;
    justify-content: center;
    gap: clamp(10px, 1.8vh, 20px);
    padding: clamp(24px, 5vh, 64px) clamp(40px, 6.5vw, 160px) clamp(72px, 21vh, 240px);
    text-align: center;
  }

  .title-screen::before {
    background:
      linear-gradient(90deg, rgba(3, 8, 6, 0.12), rgba(3, 8, 6, 0.42) 50%, rgba(3, 8, 6, 0.12)),
      url("../assets/images/chronicle-dungeon-title-pc-v1.webp") center / cover no-repeat,
      #050806;
  }

  .title-screen > .title-kicker,
  .title-screen > h1 {
    position: relative;
    width: min(90vw, 1500px);
    max-width: none;
    height: auto;
    padding: 0;
    margin: 0;
    overflow: visible;
    clip: auto;
    white-space: nowrap;
  }

  .title-screen > .title-kicker {
    color: #bcae86;
    font-size: clamp(11px, 0.95vw, 16px);
    letter-spacing: 0.26em;
    text-transform: uppercase;
  }

  .title-screen > h1 {
    font-family: "Yu Mincho", "Hiragino Mincho ProN", "Noto Serif CJK JP", serif;
    font-size: clamp(42px, min(5.1vw, 9vh), 100px);
    font-weight: 700;
    line-height: 1.3;
    letter-spacing: 0.07em;
    color: #e7cb8b;
    text-shadow: 0 2px 0 #614722, 0 6px 24px #000;
  }

  .title-screen > .title-version {
    position: relative;
    top: auto;
    left: auto;
    transform: none;
    font-size: clamp(11px, 1.1vw, 16px);
    line-height: 1.4;
    margin: 0 0 clamp(12px, 3vh, 40px);
  }

  .title-screen > button {
    width: clamp(260px, 24vw, 370px);
    max-width: 42vw;
    min-height: 48px;
    padding: 14px 28px;
    font-size: clamp(16px, 1.2vw, 21px);
    border: 1px solid #b9913e;
    border-radius: 3px;
    transition: background 160ms ease, border-color 160ms ease, box-shadow 160ms ease;
  }

  .title-screen > #titleRankingButton {
    width: clamp(260px, 24vw, 370px);
    max-width: 42vw;
    color: #d8cbaa;
    border-color: #6e654c;
    background: rgba(13, 22, 18, 0.84);
    font-size: clamp(14px, 1vw, 18px);
  }

  /* Keep the title in place; lower only the menu and its caption. */
  .title-screen > #titleStartButton,
  .title-screen > #titleRankingButton,
  .title-screen > .title-hint {
    top: clamp(70px, calc(30vh - 65px), 265px);
  }

  .title-screen > button:hover {
    border-color: #eed49b;
    background: rgba(103, 82, 39, 0.96);
  }

  .title-screen > button:focus-visible {
    outline: 2px solid #ffe6a7;
    outline-offset: 5px;
  }

  .title-screen > .title-hint {
    max-width: 42vw;
    margin-top: 8px;
    font-size: clamp(11px, 0.9vw, 15px);
    line-height: 1.8;
    letter-spacing: 0.08em;
  }

  .title-screen > .title-kicker,
  .title-screen > h1 {
    transition: opacity 1.1s ease, visibility 0s linear;
  }

  .title-screen.chronicle-active > .title-kicker,
  .title-screen.chronicle-active > h1 {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
    transition: opacity 1.1s ease, visibility 0s linear 1.1s;
  }
}


/* Steam vanilla: Unity material art and transparent in-world HUD; actors stay text. */
@media (min-width: 980px) and (min-height: 500px) {
  .app-shell.dungeon-mode {
    --tile: min(88px, calc((100svh - 24px) / 13), calc((100vw - 350px) / 13));
    display: block;
    width: 100vw;
    height: 100svh;
    padding: 0;
    background: #02060b;
    isolation: isolate;
  }
  .app-shell.dungeon-mode #dungeonView:not(.hidden),
  .app-shell.dungeon-mode .dungeon-projection { display: contents; }
  .app-shell.dungeon-mode .map {
    position: absolute;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    padding: 0; border: 0; border-radius: 0;
    max-width: none;
    background: #02060b;
    box-shadow: none;
    overflow: hidden;
    z-index: 1;
  }
  .app-shell.dungeon-mode .map::after {
    inset: 0;
    border-radius: 0;
    background: none;
    box-shadow: inset 0 0 80px 20px rgba(1, 4, 8, 0.64);
  }
  .app-shell.dungeon-mode .cell {
    isolation: isolate;
    border: 0;
    border-radius: 0;
    background: transparent;
    filter: none;
    box-shadow: none;
    transition: none;
    font-family: Georgia, "Yu Mincho", serif;
    text-shadow: 0 2px 5px #000, 0 0 8px #000;
  }
  .app-shell.dungeon-mode .cell::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: #182020;
    transform: rotate(var(--stone-turn, 0deg));
    filter: brightness(var(--stone-light, 0.5)) saturate(0.78);
    box-shadow: inset 0 0 0 1px rgba(1, 4, 8, 0.48), inset 0 0 12px rgba(0, 0, 0, 0.35);
  }
  /* Three quiet stone materials with faint white cracks and blue mineral accents. */
  .app-shell.dungeon-mode .cell[data-terrain="floor"][data-stone="0"]::before {
    background-image: url("../assets/images/dungeon/dungeon_floor_crystal_v2_1.webp");
    background-size: cover;
    background-position: center;
  }
  .app-shell.dungeon-mode .cell[data-terrain="floor"][data-stone="2"]::before {
    background-image: url("../assets/images/dungeon/dungeon_floor_crystal_v2_3.webp");
    background-size: cover;
    background-position: center;
  }
  .app-shell.dungeon-mode .cell[data-terrain="floor"][data-stone="3"]::before {
    background-image: url("../assets/images/dungeon/dungeon_floor_crystal_v2_4.webp");
    background-size: cover;
    background-position: center;
  }
  .app-shell.dungeon-mode .cell[data-terrain="wall"]::before {
    background-image: url("../assets/images/dungeon/dungeon_wall_blue_marble_veins_v23.webp");
    background-size: var(--wall-size) var(--wall-size);
    background-position: var(--wall-x) var(--wall-y);
    transform: none;
    filter: brightness(calc(var(--stone-light, 0.5) * 0.78)) saturate(0.75);
    box-shadow: inset 0 -6px 9px rgba(0, 0, 0, 0.8);
  }
  .app-shell.dungeon-mode .cell[data-terrain="wall"]::after {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 24%;
    z-index: 0;
    pointer-events: none;
    background: url("../assets/images/dungeon/dungeon_wall_top_edge_v21.webp") var(--edge-x) center / 400% 100% no-repeat;
    filter: brightness(var(--stone-light, 0.5));
    opacity: 0.7;
  }
  .app-shell.dungeon-mode .tile-player {
    color: #ffebae;
    font-size: calc(var(--tile) * 0.56);
    text-shadow: 0 0 3px #fff6d3, 0 0 15px #b99242, 0 2px 3px #000;
  }
  .app-shell.dungeon-mode .tile-player-on-chest {
    outline: 1px solid rgba(224, 184, 98, 0.7);
    outline-offset: -4px;
  }
  .app-shell.dungeon-mode .floor-line {
    position: absolute;
    top: 12px; left: 50%;
    transform: translateX(-50%);
    z-index: 30;
    width: min(60vw, 1000px);
    min-height: 54px;
    margin: 0;
    border: 0;
    border-bottom: 1px solid rgba(189, 157, 83, 0.6);
    border-radius: 0;
    background: linear-gradient(90deg, rgba(1, 7, 10, 0.94), rgba(1, 7, 10, 0.68));
    box-shadow: none;
    grid-template-columns: minmax(0, 1fr) 74px;
  }
  .app-shell.dungeon-mode .floor-line > div {
    grid-template-columns: auto minmax(0, 1fr);
    gap: 3px 12px;
    align-items: baseline;
    padding: 7px 12px;
    background: transparent;
  }
  .app-shell.dungeon-mode .floor-line small {
    grid-column: 1 / -1;
    font-size: 11px;
    line-height: 1.4;
    color: #b4bba6;
  }
  .app-shell.dungeon-mode .floor-line button {
    border: 1px solid rgba(154, 132, 81, 0.5);
    border-radius: 1px;
    font-size: 13px;
    background: rgba(15, 20, 21, 0.65);
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay {
    position: absolute;
    left: 24px; top: 88px;
    z-index: 20;
    width: clamp(175px, 16vw, 270px);
    padding: 10px 16px;
    gap: clamp(5px, 1vh, 11px);
    border: 0;
    border-left: 1px solid rgba(111, 196, 204, 0.65);
    border-radius: 0;
    background: linear-gradient(90deg, rgba(0, 6, 10, 0.88), rgba(0, 6, 10, 0.1));
    box-shadow: none;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay::before {
    content: "▪ 冒険者";
    margin-bottom: 8px;
    color: #dfbd6f;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: 0.06em;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay .dungeon-hp-stat {
    width: auto;
    margin: 0 0 8px;
    gap: 8px;
  }
  .app-shell.dungeon-mode .dungeon-hp-stat .hp-bar { width: 100%; height: 5px; border-radius: 0; }
  .app-shell.dungeon-mode .dungeon-stats-overlay > div { padding: 2px 0; }
  .app-shell.dungeon-mode .dungeon-stats-overlay span { font-size: clamp(12px, 0.9vw, 15px); line-height: 1.2; color: #d7d1b8; }
  .app-shell.dungeon-mode .dungeon-stats-overlay strong { font-size: clamp(14px, 1.1vw, 19px); line-height: 1.2; color: #e5c378; }
  .app-shell.dungeon-mode .dungeon-hp-stat strong { color: #8cf29e; }
  .app-shell.dungeon-mode .log-panel {
    position: absolute;
    right: 24px; bottom: 24px;
    z-index: 20;
    width: clamp(290px, 32vw, 530px);
    height: clamp(160px, 29svh, 290px);
    min-height: 0; max-height: none;
    padding: 8px 10px;
    gap: 8px;
    border: 0;
    border-top: 1px solid rgba(111, 196, 204, 0.6);
    border-left: 1px solid rgba(111, 196, 204, 0.6);
    border-radius: 0;
    background: linear-gradient(90deg, rgba(0, 6, 10, 0.84), rgba(0, 6, 10, 0.64));
    box-shadow: none;
  }
  .app-shell.dungeon-mode .log-panel-toolbar > span { color: #dfbd6f; font-size: 16px; font-weight: 600; }
  .app-shell.dungeon-mode .log-panel-toolbar button { min-height: 27px; padding: 2px 8px; border-radius: 0; font-size: 11px; background: rgba(10, 20, 23, 0.8); }
  .app-shell.dungeon-mode .log-panel p { padding: 7px 9px; margin: 0 0 6px; font-size: clamp(12px, 0.9vw, 15px); line-height: 1.6; background: transparent; }
  .app-shell.dungeon-mode .dungeon-action-dock {
    position: absolute;
    left: 24px; bottom: 24px;
    z-index: 20;
    width: clamp(210px, 20vw, 300px);
    max-width: none;
    margin: 0;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
  }
  .app-shell.dungeon-mode .magic-move-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    max-height: clamp(88px, calc(100svh - 530px), 160px);
    min-height: 0;
    overflow-y: auto;
    padding: 5px;
    border: 1px solid rgba(111, 196, 204, 0.28);
    border-radius: 0;
    background: rgba(0, 7, 12, 0.8);
    box-shadow: none;
    transform: none;
  }
  .app-shell.dungeon-mode .magic-move-controls button {
    min-height: 34px;
    padding: 5px;
    border-color: rgba(132, 147, 145, 0.34);
    border-radius: 1px;
    background: rgba(19, 31, 36, 0.85);
    font-size: 12px;
  }
  .app-shell.dungeon-mode .controls {
    grid-template-columns: repeat(3, 48px);
    grid-template-rows: repeat(3, 40px);
    gap: 5px;
    justify-content: start;
    padding: 0;
    background: transparent;
    border-radius: 0;
    backdrop-filter: none;
    transform: none;
  }
  .app-shell.dungeon-mode .controls button {
    width: 48px; min-height: 40px;
    border: 1px solid rgba(154, 132, 81, 0.6);
    border-radius: 1px;
    background: rgba(10, 20, 24, 0.82);
    font-size: 18px;
  }
}


/* Full-viewport stone field. Information floats above it without a side gutter. */
@media (min-width: 980px) and (min-height: 500px) {
  .app-shell.dungeon-mode { --tile: calc(100svh / 13); }
  .app-shell.dungeon-mode .map {
    grid-template-columns: repeat(var(--map-columns, 25), var(--tile));
    height: 100svh;
  }
  .app-shell.dungeon-mode .dungeon-action-dock { left: auto; right: 24px; }
  .app-shell.dungeon-mode .controls { justify-content: end; }
  .app-shell.dungeon-mode .log-panel { right: auto; left: 24px; }
  .app-shell.dungeon-mode .monster-marker {
    font-size: calc(var(--tile) * 0.48);
    line-height: 1;
    font-weight: 500;
    transform: none;
  }
}


/* Ordinary remains: provisional approved art. Unique remains are unchanged. */
.tile-corpse:not(.tile-unique-corpse) > .corpse-icon,
.wait-corpse-graphic:not(.tile-unique-corpse) > .corpse-icon {
  width: 98%;
  height: 98%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: url("../assets/images/corpse-normal-v1.webp") center / contain no-repeat;
  box-shadow: none;
  transform: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7));
  z-index: 2;
}
.tile-corpse:not(.tile-unique-corpse) > .corpse-icon::before,
.tile-corpse:not(.tile-unique-corpse) > .corpse-icon::after,
.wait-corpse-graphic:not(.tile-unique-corpse) > .corpse-icon::before,
.wait-corpse-graphic:not(.tile-unique-corpse) > .corpse-icon::after { content: none; }


/* Approved unique remains v4: the artwork contains its own bone and soul glow. */
.tile-unique-corpse {
  background: #1b2023;
  box-shadow: none;
}
.tile-unique-corpse > .corpse-icon {
  width: 98%;
  height: 98%;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: url("../assets/images/corpse-unique-v4.webp") center / contain no-repeat;
  box-shadow: none;
  transform: none;
  filter: drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7));
  z-index: 2;
}
.tile-unique-corpse > .corpse-icon::before,
.tile-unique-corpse > .corpse-icon::after,
.tile-unique-corpse::after { content: none; }
.tile-unique-corpse .unique-corpse-aura,
.tile-unique-corpse .unique-corpse-core,
.tile-unique-corpse .unique-corpse-crest { display: none; }


/* Kikirukurusu alone uses the approved serpent remains with its luminous heart. */
.tile-kikirukurusu-corpse > .corpse-icon {
  background-image: url("../assets/images/corpse-kikirukurusu-v2.webp");
}


/* Dungeon HUD: quiet older messages and clearly phased actors, without framing lines. */
.app-shell.dungeon-mode .log-list > p { border-left: 0; transition: opacity 180ms ease; }
.app-shell.dungeon-mode .log-list > p:first-child { opacity: 1; }
.app-shell.dungeon-mode .log-list > p:nth-child(2) { opacity: 0.72; }
.app-shell.dungeon-mode .log-list > p:nth-child(n+3) { opacity: 0.48; }
.app-shell.dungeon-mode .log-list > p:nth-child(n+5) { opacity: 0.3; }
.app-shell.dungeon-mode .cell.tile-phasing-wall:is(.tile-enemy, .tile-unique, .tile-flower-pet) {
  opacity: 1;
  background: transparent !important;
  box-shadow: none !important;
}
.app-shell.dungeon-mode .tile-phasing-wall .monster-marker,
.app-shell.dungeon-mode .tile-phasing-wall .sleep-indicator { opacity: 0.4; }

@media (min-width: 980px) and (min-height: 500px) {
  .app-shell.dungeon-mode .dungeon-stats-overlay,
  .app-shell.dungeon-mode .log-panel,
  .app-shell.dungeon-mode .magic-move-controls { border: 0; }
  .app-shell.dungeon-mode .controls {
    --move-key: clamp(56px, 5.8svh, 76px);
    grid-template-columns: repeat(3, var(--move-key));
    grid-template-rows: repeat(3, var(--move-key));
    gap: 6px;
  }
  .app-shell.dungeon-mode .controls button {
    width: var(--move-key);
    min-height: var(--move-key);
    font-size: clamp(24px, 2.7svh, 34px);
  }
}


.dungeon-player-name { display: none; }
.app-shell.town-mode .log-list > p {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
  padding: 2px 5px;
  font-size: 12px;
  line-height: 18px;
}
.app-shell.dungeon-mode .tile-phasing-wall .monster-marker,
.app-shell.dungeon-mode .tile-phasing-wall .sleep-indicator { opacity: 0.22; }

@media (min-width: 980px) and (min-height: 500px) {
  .app-shell.dungeon-mode .dungeon-action-dock { right: clamp(64px, 7vw, 128px); }
  .app-shell.dungeon-mode .dungeon-hp-stat .hp-bar { width: 147.08739591%; max-width: none; }
  .app-shell.dungeon-mode .dungeon-stats-overlay::before { content: none; }
  .app-shell.dungeon-mode .dungeon-player-name {
    display: block;
    margin: 0 0 8px;
    color: var(--text);
    font-size: 17px;
    font-weight: 600;
    line-height: 1.5;
    letter-spacing: 0.04em;
    overflow-wrap: anywhere;
  }
}
@media (min-width: 980px) and (min-height: 600px) {
  .app-shell.town-mode { grid-template-rows: auto auto auto auto minmax(0, 1fr) 110px; }
  .app-shell.town-mode .log-panel { min-height: 0; padding: 5px 8px; gap: 3px; }
}


/* Keep the town log compact while retaining all saved entries for scrolling. */
.app-shell.town-mode .log-list { overflow-y: auto; }
@media (min-width: 980px) {
  .app-shell.town-mode .equipment-strip {
    grid-template-columns: repeat(6, minmax(0, 1fr));
    grid-template-rows: auto;
  }
  .app-shell.town-mode .equipment-strip strong {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}


@media (min-width: 980px) {
  #arenaView .arena-intro { font-size: 13px; line-height: 1.5; }
  #arenaView .arena-intro h2 { font-size: 16px; }
  #arenaView .arena-intro button,
  .app-shell.arena-mode .arena-floor-line button { font-size: 14px; }
  .app-shell.arena-mode .arena-round,
  .app-shell.arena-mode .arena-compact-status { font-size: 13px; line-height: 1.5; }
  .app-shell.arena-mode .arena-enemy-name { font-size: 16px; }
  .app-shell.arena-mode .status-bar > div > span,
  .app-shell.arena-mode .character-strip > div > span { font-size: 11px; }
  .app-shell.arena-mode .status-bar strong,
  .app-shell.arena-mode .character-strip strong { font-size: 14px; }
}

/* Let the arena use the full remaining PC play area. */
@media (min-width: 980px) and (min-height: 600px) {
  .app-shell.arena-mode .arena-stage {
    height: 100%;
    min-height: 0;
    grid-template-rows: auto minmax(0, 1fr);
  }
  .app-shell.arena-mode .arena-floor-line { align-items: center; }
  .app-shell.arena-mode .arena-tactical-layout {
    container-type: size;
    height: 100%;
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: minmax(0, 1fr);
    align-items: center;
  }
  .app-shell.arena-mode .arena-map {
    --arena-cell: min(calc((100cqh - 32px) / 9), calc((100cqw - 240px) / 9));
    align-self: center;
  }
}

/* Mouse entry feedback: town controls and the dungeon return button only. */
@media (hover: hover) and (pointer: fine) {
  .interaction-hover:not(:disabled):not([aria-disabled="true"]) {
    background: linear-gradient(180deg, #66552e, #3f3c27) !important;
    color: #fff1c9 !important;
    border-color: #dfbd6f !important;
    box-shadow: inset 0 0 0 1px rgba(255, 225, 153, 0.22), 0 0 10px rgba(224, 184, 98, 0.22) !important;
    cursor: pointer;
  }
}

/* Match the strong gold hover treatment used by the dungeon return button. */
@media (hover: hover) and (pointer: fine) {
  .app-shell.dungeon-mode .controls button:not(:disabled):hover,
  .app-shell.dungeon-mode .magic-move-controls button:not(:disabled):hover {
    background: linear-gradient(180deg, #66552e, #3f3c27);
    color: #fff1c9;
    border-color: #dfbd6f;
    box-shadow: inset 0 0 0 1px rgba(255, 225, 153, 0.22), 0 0 10px rgba(224, 184, 98, 0.22);
  }
}

/* Shared 0.7-second reveal for rankings and entry from town into the dungeon. */
body.ranking-open-flash::after,
body.dungeon-entry-flash::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100000;
  background: #000;
  pointer-events: none;
  animation: ranking-open-reveal 700ms ease-out both;
}
@keyframes ranking-open-reveal {
  0%, 25% { opacity: 1; }
  100% { opacity: 0; }
}
body.dungeon-entry-flash::after {
  animation-duration: 1100ms;
}


/* Keep the return journey hidden while the ascending footsteps play. */
body.return-stairs-transition::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100001;
  background: #000;
  pointer-events: auto;
  animation: return-stairs-reveal 1000ms ease-out 1800ms both;
}
@keyframes return-stairs-reveal {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Home entry: 0.38s fully black, then 1s ease-out reveal. */
body.home-entry-blackout::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100002;
  background: #000;
  opacity: 1;
  pointer-events: auto;
  animation: return-stairs-reveal 1000ms ease-out 380ms both;
}


/* The objective card uses the same neutral palette as town windows. */
body.home-theme #homeView .adventure-objective:not(.completed) {
  border-color: var(--line);
  background: linear-gradient(180deg, rgba(29, 37, 32, 0.97), rgba(18, 24, 20, 0.97));
  box-shadow: none;
}
body.home-theme #homeView .adventure-objective:not(.completed) span { color: #a9c9ee; }
body.home-theme #homeView .adventure-objective:not(.completed) strong { color: #e2edf9; }
body.home-theme #homeView .adventure-objective:not(.completed) p { color: #bfcee2; }

/* Rainbow applies only to the final boss name in the home objective. */
body.home-theme #homeView .adventure-objective span.objective-boss-name {
  display: inline;
  font: inherit;
  letter-spacing: inherit;
  color: #f6dc90;
  text-shadow: none;
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  body.home-theme #homeView .adventure-objective span.objective-boss-name {
    background: linear-gradient(90deg, #ff929c 0%, #ffbf80 17%, #f7e789 33%, #8bdfac 50%, #89c9f6 67%, #b9a4f4 83%, #f0a9df 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    -webkit-text-fill-color: transparent;
  }
}

@keyframes objective-boss-rainbow-flow {
  from { background-position: 0% 50%; }
  to { background-position: 200% 50%; }
}
@supports ((background-clip: text) or (-webkit-background-clip: text)) {
  body.home-theme #homeView .adventure-objective span.objective-boss-name {
    background-image: linear-gradient(90deg, #ff929c 0%, #ffbf80 14%, #f7e789 28%, #8bdfac 42%, #89c9f6 56%, #b9a4f4 70%, #f0a9df 84%, #ff929c 100%);
    background-size: 200% 100%;
    animation: objective-boss-rainbow-flow 6s linear infinite;
  }
}
@media (prefers-reduced-motion: reduce) {
  body.home-theme #homeView .adventure-objective span.objective-boss-name { animation: none; }
}

/* Leaving home: 0.2s fully black, followed by the shared 1s reveal. */
body.home-exit-blackout::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 100002;
  background: #000;
  opacity: 1;
  pointer-events: auto;
  animation: return-stairs-reveal 1000ms ease-out 200ms both;
}

/* スコア内訳 */
.score-breakdown { color: var(--muted); font-size: 11px; line-height: 1.5; }

.online-send { margin: 10px 0 0; padding: 10px; border: 1px solid rgba(224, 184, 98, 0.35); border-radius: 8px; display: grid; gap: 8px; text-align: left; }
.online-send label { display: flex; align-items: center; gap: 8px; font-size: 12px; }
.online-send input { flex: 1; min-width: 0; padding: 6px 8px; font-size: 14px; background: rgba(0, 0, 0, 0.35); color: inherit; border: 1px solid rgba(255, 255, 255, 0.25); border-radius: 6px; }
.online-send-status { margin: 0; font-size: 11px; line-height: 1.5; color: var(--muted); }
.online-send-status a, .online-ranking-link { color: var(--gold); }
.online-ranking-link { display: block; margin: 10px 0; text-align: center; font-size: 13px; }
.online-send-comment { flex-wrap: wrap; }
.online-send-comment input { flex-basis: 100%; }
/* Score submission: clear field labels and responsive results layout. */
.online-send { padding: 16px; gap: 14px; background: rgba(0,0,0,.18); min-width: 0; }
.online-send label { display: grid; grid-template-columns: minmax(0,1fr); gap: 7px; align-items: start; line-height: 1.5; }
.online-send label small { color: var(--muted); font-size: 12px; }
.online-send input { box-sizing: border-box; width: 100%; min-width: 0; min-height: 42px; padding: 10px 12px; font-size: 16px; }
.online-send button { width: 100%; min-height: 44px; padding: 10px 12px; line-height: 1.5; white-space: normal; }
.online-send-status { overflow-wrap: anywhere; line-height: 1.8; }
.online-send-status a { display: inline-block; margin-inline-start: 8px; }
#deathReviewScore, #scoreResultSummary, #demoClearScore { min-width: 0; }
.death-review-card, .score-result-card { box-sizing: border-box; width: min(820px, calc(100vw - 32px)); padding: clamp(16px,3vw,26px); }
#deathReviewScore .play-score-summary, #scoreResultSummary .play-score-summary, #demoClearScore .play-score-summary { margin: 0; }
.death-review-card:has(.play-score-summary) .death-review-log { min-height: 72px; max-height: min(18dvh,150px); }
@media (min-width: 720px) {
  #deathReviewScore, #scoreResultSummary, #demoClearScore { display: grid; grid-template-columns: minmax(0,.9fr) minmax(0,1.1fr); gap: 18px; align-items: start; }
  #deathReviewScore > .online-send, #scoreResultSummary > .online-send, #demoClearScore > .online-send { margin-top: 0; }
}

/* 天軸の雷槍は予告された一マスに落ちる。 */
.cell.tile-metatron-target { outline: 2px solid #ffe49a; outline-offset: -3px; }

/* Dedicated art stays within its original cell and inherits all actor state effects. */
.game-art { position: relative; display: inline-flex; align-items: center; justify-content: center; width: 100%; height: 100%; vertical-align: middle; line-height: 1; }
.game-art-image { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; user-select: none; }
.game-art-fallback { display: none; }
.art-load-failed > .game-art-fallback { display: inline; }
.cell > .monster-marker:has(.game-art) { display: flex; align-items: center; justify-content: center; width: 92%; height: 92%; z-index: 2; }
.game-art-monster, .game-art-object { filter: drop-shadow(0 1px 1px rgba(0,0,0,.75)); }
.cell > .game-art-object { width: 84%; height: 84%; z-index: 2; }
.cell > .game-art-corpse { width: 96%; height: 96%; z-index: 2; }
.cell.has-dedicated-corpse::after { display: none; }
.research-monster-graphic:has(.game-art) { width: 68px; height: 68px; font-size: 0; flex-shrink: 0; }
.monster-info-art:has(.game-art) { display: block; width: 104px; height: 104px; flex-shrink: 0; }
.monster-heart-preview > .art-context-heart { float: right; width: 110px; height: 110px; margin: 0 0 12px 16px; }
.monster-heart-preview { display: flow-root; }
.arena-foe > .game-art { width: 94%; height: 94%; }
.tile-critical-fleeing .game-art-image { filter: sepia(.35) saturate(1.3) drop-shadow(0 0 2px rgba(255,70,50,.65)); }
/* The monster-marker wrapper still shakes, fades in walls, and carries sleep/HP/scream overlays. */
.title-screen > .title-online-ranking-link {
  box-sizing: border-box; display: block; width: min(260px, 76vw); margin: 0; padding: 8px 12px;
  color: #e6dfcf; background: rgba(11,18,14,.88); border: 1px solid #6e654c;
  border-radius: 3px; text-align: center; text-decoration: none; font-size: 13px;
  transition: background 160ms ease, border-color 160ms ease, opacity 1.1s ease;
}
.title-screen.chronicle-active > .title-online-ranking-link { visibility: hidden; opacity: 0; pointer-events: none; }
.title-screen > .title-online-ranking-link:is(:hover, :focus-visible, .interaction-hover) { color: #fff4d1; background: #675227; border-color: #eed49b; }
.ranking-online-link { display: inline-block; padding: 10px 0; color: #ded8c8; }
@media (min-width: 760px) and (orientation: landscape) {
  .title-screen > .title-online-ranking-link { top: clamp(70px, calc(30vh - 65px), 265px); width: clamp(260px,24vw,370px); max-width: 42vw; }
}
@media (min-width: 760px) and (orientation: landscape) and (max-height: 400px) {
  .title-screen { gap: 6px; padding-top: 10px; padding-bottom: 48px; }
  .title-screen > :is(#titleStartButton, #titleRankingButton, .title-online-ranking-link, .title-hint) {
    top: clamp(30px, calc(100vh - 335px), 70px);
  }
}
@media (min-width: 760px) and (orientation: landscape) and (max-height: 330px) {
  .title-screen { gap: 4px; padding-top: 6px; padding-bottom: 25px; }
  .title-screen > h1 { font-size: clamp(30px, 8vh, 42px); line-height: 1.15; }
  .title-screen > .title-version { margin-bottom: 4px; }
  .title-screen > button { min-height: 38px; padding: 7px 18px; }
  .title-screen > .title-hint { margin-top: 0; line-height: 1.2; }
  .title-screen > :is(#titleStartButton, #titleRankingButton, .title-online-ranking-link, .title-hint) { top: 15px; }
}
@media (max-width: 599px) {
  .monster-heart-preview > .art-context-heart { width: 80px; height: 80px; }
  .research-monster-graphic:has(.game-art) { width: 54px; height: 54px; }
}
.research-card summary:has(.game-art) { grid-template-columns: 72px minmax(0,1fr) auto auto auto; }
.monster-info-heading:has(.game-art) { grid-template-columns: 104px minmax(0,1fr); }
@media (max-width: 599px) { .research-card summary:has(.game-art) { grid-template-columns: 58px minmax(0,1fr) auto auto auto; } }
/* Grid intrinsic sizing must not enlarge a tall sprite beyond its map cell. */
.game-art, .game-art-image { min-width: 0; min-height: 0; max-width: 100%; max-height: 100%; }
.cell > .monster-marker:has(.game-art) { position: absolute; inset: 4%; width: auto; height: auto; }
.cell > .monster-marker > .monster-idle-visual:has(.game-art) { position: absolute; inset: 0; }
.cell > .game-art-object { position: absolute; inset: 8%; width: auto; height: auto; }
.cell > .game-art-corpse { position: absolute; inset: 2%; width: auto; height: auto; }
.cell > .monster-marker:has(.game-art)::after { content: ""; position: absolute; bottom: 7%; right: 7%; width: 4px; height: 4px; border-radius: 50%; background: currentColor; box-shadow: 0 0 1px #000; }
.game-art-fallback { font-size: 24px; }
.art-context-dungeon .game-art-fallback { font-size: calc(var(--tile) * .48); }

/* Dungeon monsters have no square enclosure. Research cards retain their existing frames. */
.app-shell.dungeon-mode .cell:is(.tile-enemy, .tile-unique, .tile-flower-pet) {
  border: 0 !important;
  box-shadow: none !important;
}
.app-shell.dungeon-mode .cell:is(.tile-enemy, .tile-unique, .tile-flower-pet):not(.tile-metatron-target):not(:focus-visible) {
  outline: none !important;
}
.app-shell.dungeon-mode .cell:is(.tile-enemy, .tile-unique, .tile-flower-pet)[data-terrain="floor"] {
  background: #1b241c !important;
}
@media (min-width: 980px) and (min-height: 500px) {
  .app-shell.dungeon-mode .cell:is(.tile-enemy, .tile-unique, .tile-flower-pet)[data-terrain="floor"] {
    background: transparent !important;
  }
}

/* The frontal luxury chest fills its cell, while trap sizes remain unchanged. */
.cell > .game-art-object.art-object-chest { inset: 14%; width: auto; height: auto; }

.shop-bulk-sales { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 10px 0 16px; }
.shop-bulk-sales button { min-height: 44px; white-space: normal; line-height: 1.5; }
@media (max-width: 599px) { .shop-bulk-sales { grid-template-columns: minmax(0, 1fr); } }

/* Corpses use the same floor as neighboring cells without an enclosing frame. */
.app-shell.dungeon-mode .cell.tile-corpse {
  border: 0 !important;
  box-shadow: none !important;
  outline: none !important;
  background: #1b241c !important;
}
@media (min-width: 980px) and (min-height: 500px) {
  .app-shell.dungeon-mode .cell.tile-corpse { background: transparent !important; }
}

/* Keep arena controls together on narrow touch screens; allow short screens to scroll. */
@media (max-width: 599px) {
  .app-shell.arena-mode .arena-stage { min-height: 0; overflow: visible; }
  .app-shell.arena-mode .arena-tactical-layout {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-rows: auto;
    gap: 4px;
    align-items: center;
    justify-items: center;
  }
  .app-shell.arena-mode .arena-map {
    --arena-cell: clamp(12px, min(21px, calc((100vw - 190px) / 9), calc((100svh - 360px) / 9)), 21px);
    align-self: center;
    gap: 1px;
    padding: 3px;
  }
  .app-shell.arena-mode .arena-move-pad {
    grid-template-columns: repeat(3, 42px);
    grid-template-rows: repeat(3, 44px);
    gap: 3px;
    padding: 4px;
  }
  .app-shell.arena-mode .arena-move-pad button { width: 42px; min-height: 44px; }
  .app-shell.town-mode .log-list > p {
    white-space: normal;
    overflow: visible;
    text-overflow: clip;
    overflow-wrap: anywhere;
    line-height: 1.35;
  }
  .app-shell.town-mode .log-list { -webkit-overflow-scrolling: touch; }
}
@media (max-height: 500px) and (orientation: landscape) {
  .app-shell.arena-mode { grid-template-rows: 64px auto auto minmax(0, 1fr); gap: 3px; }
  .app-shell.arena-mode .status-bar > div,
  .app-shell.arena-mode .character-strip > div { padding: 2px 3px; }
  .app-shell.arena-mode .status-bar strong,
  .app-shell.arena-mode .character-strip strong { font-size: 10px; }
  .app-shell.arena-mode .status-bar span,
  .app-shell.arena-mode .character-strip span { font-size: 8px; }
  .app-shell.arena-mode .arena-stage { min-height: 0; overflow: visible; }
  .app-shell.arena-mode .arena-map { --arena-cell: clamp(12px, calc((100svh - 245px) / 9), 20px); gap: 1px; padding: 3px; }
  .app-shell.arena-mode .arena-move-pad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 40px); gap: 3px; padding: 4px; }
  .app-shell.arena-mode .arena-move-pad button { width: 44px; min-height: 40px; }
}
@media (max-height: 500px) and (max-width: 979px) and (orientation: landscape) {
  .app-shell.town-mode { grid-template-rows: auto auto auto auto minmax(180px, 1fr) 90px; overflow-y: auto; -webkit-overflow-scrolling: touch; }
  .app-shell.town-mode .log-panel { min-height: 0; }
}

/* Keep every dungeon control reachable on small mobile viewports. */
@media (max-width: 979px) {
  .app-shell.dungeon-mode #dungeonView {
    overflow-x: hidden;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
    scroll-padding-bottom: max(10px, env(safe-area-inset-bottom));
  }
}

/* Short portrait screens need more space for the map and the full move pad. */
@media (max-width: 599px) and (max-height: 620px) and (orientation: portrait) {
  .app-shell.dungeon-mode {
    --tile: clamp(11px, min(29px, calc((100vw - 42px) / 13), calc((100svh - 360px) / 13)), 29px);
    grid-template-rows: clamp(42px, 10svh, 60px) minmax(0, 1fr);
  }
  .app-shell.dungeon-mode .log-panel {
    min-height: 0;
    max-height: none;
    padding: 4px 8px;
  }
}

@media (max-width: 979px) {
  .app-shell.dungeon-mode .magic-move-controls {
    max-height: 172px;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
  }
}
@media (max-width: 380px) {
  .app-shell.dungeon-mode .magic-move-controls { max-height: 156px; }
}

/* Put the map and controls side by side when a phone is held sideways. */
@media (max-width: 979px) and (max-height: 500px) and (orientation: landscape) {
  .app-shell.dungeon-mode {
    width: 100vw;
    --tile: clamp(11px, min(22px, calc((100svh - 170px) / 13)), 22px);
    grid-template-rows: 60px minmax(0, 1fr);
    gap: 4px;
  }
  .app-shell.dungeon-mode .log-panel { min-height: 0; max-height: none; padding: 4px 8px; }
  .app-shell.dungeon-mode #dungeonView {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(300px, 1fr);
    grid-template-rows: auto auto;
    align-content: start;
    column-gap: 8px;
  }
  .app-shell.dungeon-mode .floor-line { grid-column: 1 / -1; }
  .app-shell.dungeon-mode .dungeon-projection { grid-column: 1; }
  .app-shell.dungeon-mode .dungeon-action-dock { grid-column: 2; align-self: start; margin: 0; }
}

/* Arena: keep the opponent readable and group actions with movement. */
.app-shell.arena-mode .arena-floor-line {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: start;
  gap: 6px;
}
.app-shell.arena-mode .arena-floor-line > .arena-opponent {
  display: grid;
  gap: 3px;
  overflow: visible;
  padding: 7px 9px;
}
.app-shell.arena-mode .arena-enemy-name,
.app-shell.arena-mode .arena-compact-status {
  overflow: visible;
  white-space: normal;
  text-overflow: clip;
  overflow-wrap: anywhere;
}
.app-shell.arena-mode .arena-enemy-name { line-height: 1.3; }
.app-shell.arena-mode .arena-compact-status { line-height: 1.35; }
.arena-enemy-health {
  display: flex;
  align-items: center;
  gap: 8px;
  color: #f2e9dc;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}
.arena-enemy-health-bar {
  display: block;
  width: min(180px, 35vw);
  height: 6px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.65);
}
.arena-enemy-health-bar i { display: block; height: 100%; }
.app-shell.arena-mode .arena-floor-line > button { align-self: start; min-height: 40px; }
.arena-map-area { display: grid; justify-items: center; align-content: center; min-width: 0; }
.arena-move-hint {
  margin: 5px 0 0;
  color: #d9cfc4;
  font-size: 12px;
  line-height: 1.35;
  text-align: center;
}
.arena-command-panel {
  display: grid;
  align-content: center;
  justify-items: stretch;
  width: 192px;
  max-width: 100%;
  gap: 6px;
}
.arena-action-hint { margin: 0; color: #e9beac; font-size: 12px; line-height: 1.35; }
.arena-action-hint.is-ready { color: #bfe5a9; }
.arena-action-buttons { display: grid; gap: 5px; }
.arena-action-buttons button { width: 100%; min-height: 40px; padding: 5px 7px; line-height: 1.25; overflow-wrap: anywhere; }
.arena-action-buttons button small { margin-left: 4px; }
.app-shell.arena-mode .arena-move-pad { justify-self: stretch; justify-content: center; }
.arena-intro-guide { display: grid; gap: 6px; margin: 12px 0; }
.arena-intro-guide p { margin: 0; line-height: 1.5; }
.arena-intro-guide strong { color: #ffd5b4; }
.arena-victory { grid-template-columns: minmax(0, 1fr); align-content: start; }
.arena-victory > strong, .arena-victory > p { padding: 9px; margin: 0; }
.arena-victory > button { min-height: 44px; }
@media (min-width: 980px) and (min-height: 600px) {
  .app-shell.arena-mode { grid-template-rows: clamp(80px, 12svh, 100px) auto auto minmax(0, 1fr); }
  /* Keep the PC arena HP bar at 95% of its previous length. */
  .app-shell.arena-mode .status-bar { grid-template-columns: .9fr .9fr .9fr calc(25.2893515% - 16.0307px) .62fr 54px; }
  .app-shell.arena-mode .arena-tactical-layout {
    grid-template-columns: minmax(0, max-content) 192px;
    justify-content: center;
    column-gap: clamp(24px, 4vw, 64px);
  }
  .app-shell.arena-mode .arena-map { --arena-cell: min(calc((100cqh - 44px) / 9), calc((100cqw - 280px) / 9)); }
}
@media (max-width: 599px) {
  .app-shell.arena-mode .status-bar { grid-template-columns: 1fr .8fr 1.2fr 1.15fr .45fr; }
  .app-shell.arena-mode .status-bar strong { overflow-wrap: anywhere; line-height: 1.15; }
  .app-shell.arena-mode .character-strip { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .app-shell.arena-mode .character-strip strong { white-space: nowrap; }
  .app-shell.arena-mode .arena-tactical-layout { grid-template-columns: minmax(0, 1fr) 144px; align-items: start; }
  .app-shell.arena-mode .arena-command-panel { width: 144px; gap: 4px; }
  .app-shell.arena-mode .arena-map { --arena-cell: clamp(12px, min(23px, calc((100vw - 190px) / 9), calc((100svh - 400px) / 9)), 23px); }
  .arena-action-hint, .arena-move-hint { font-size: 11px; }
  .arena-action-buttons button { min-height: 42px; font-size: 12px; }
  .app-shell.arena-mode .arena-move-pad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); gap: 3px; padding: 3px; }
  .app-shell.arena-mode .arena-move-pad button { width: 44px; min-height: 44px; }
}
@media (max-width: 359px) {
  .app-shell.arena-mode .arena-map { --arena-cell: clamp(12px, calc((100vw - 210px) / 9), 20px); }
}
@media (max-width: 599px) and (max-height: 680px) and (orientation: portrait) {
  .app-shell.arena-mode { grid-template-rows: 64px auto auto minmax(0, 1fr); gap: 4px; }
}
@media (max-width: 979px) and (max-height: 500px) and (orientation: landscape) {
  .app-shell.arena-mode .arena-tactical-layout { grid-template-columns: minmax(0, 1fr) 300px; gap: 4px; align-items: start; }
  .app-shell.arena-mode .arena-command-panel {
    width: 300px;
    grid-template-columns: minmax(0, 1fr) 140px;
    grid-template-rows: auto 1fr;
    column-gap: 6px;
    align-items: start;
  }
  .arena-action-hint { grid-column: 1; grid-row: 1; }
  .arena-action-buttons { grid-column: 1; grid-row: 2; }
  .app-shell.arena-mode .arena-move-pad { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
  .app-shell.arena-mode .arena-map { --arena-cell: clamp(12px, calc((100svh - 270px) / 9), 20px); }
  .arena-move-hint { display: none; }
}


/* Compact the stat overlay and log when vertical room is scarce. */
@media (max-width: 599px) and (max-height: 520px) and (orientation: portrait) {
  .app-shell.dungeon-mode .dungeon-stats-overlay { top: 4px; gap: 2px; }
}
@media (max-width: 979px) and (max-height: 360px) and (orientation: landscape) {
  .app-shell.dungeon-mode { grid-template-rows: 48px minmax(0, 1fr); }
  .app-shell.dungeon-mode .dungeon-stats-overlay { top: 4px; gap: 2px; }
}

/* スマホ縦画面では、ログの行数だけでなく枠自体も小さくして操作領域を確保する。 */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode {
    grid-template-rows: clamp(68px, 10svh, 80px) minmax(0, 1fr);
  }
  .app-shell.dungeon-mode .log-panel {
    min-height: 0;
    max-height: none;
    padding: 4px 8px;
  }
}
@media (max-width: 599px) and (max-height: 843px) and (orientation: portrait) {
  .app-shell.arena-mode .arena-move-hint { display: none; }
}

/* 特に背の低い画面では既存の小さいログ枠を維持する。 */
@media (max-width: 599px) and (max-height: 620px) and (orientation: portrait) {
  .app-shell.dungeon-mode {
    grid-template-rows: clamp(42px, 10svh, 60px) minmax(0, 1fr);
  }
}


/* 心を画像と一緒に選ぶ。画像のない個体は文字を表示する。 */
.heart-picker-label { margin-bottom: 6px; }
.heart-picker { width: 100%; min-width: 0; }
.heart-picker summary, .heart-choice {
  box-sizing: border-box; display: flex; align-items: center; gap: 12px;
  width: 100%; min-width: 0; min-height: 62px; padding: 7px 12px;
  color: #e6dfcf; background: #171c18; border: 1px solid #6e654c;
  border-radius: 5px; cursor: pointer; text-align: left;
}
.heart-picker summary { list-style: none; }
.heart-picker summary::-webkit-details-marker { display: none; }
.heart-picker-selection { display: flex; align-items: center; gap: 12px; flex: 1; min-width: 0; }
.heart-picker-arrow { margin-left: auto; font-size: 13px; color: #d7bd7c; }
.heart-picker[open] .heart-picker-arrow { transform: rotate(180deg); }
.heart-choice-art { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 44px; width: 44px; height: 44px; font-size: 27px; color: #eee8d9; }
.heart-choice-label { display: flex; flex-direction: column; gap: 3px; min-width: 0; overflow-wrap: anywhere; }
.heart-choice-label small { color: #c7bfae; line-height: 1.35; }
.heart-picker-options { max-height: 294px; overflow-y: auto; padding: 4px; background: #101612; border: 1px solid #6e654c; border-radius: 0 0 5px 5px; }
.heart-choice { min-height: 60px; border-color: transparent; border-radius: 3px; background: transparent; }
.heart-choice:is(:hover,:focus-visible), .heart-picker summary:is(:hover,:focus-visible) { background: #574b2b; border-color: #d2b76f; }
.heart-choice.is-selected { background: #353322; }
@media (max-width: 599px) { .heart-choice-art { flex-basis: 38px; width: 38px; height: 38px; } .heart-picker summary, .heart-choice { min-height: 56px; } }

/* Monster-art visibility: ambient light also affects actors and objects. */
.app-shell.dungeon-mode .cell > :is(.monster-marker, .game-art-object, .game-art-corpse, .sleep-indicator, .monster-scream) {
  filter: brightness(var(--actor-light, 1));
}
.app-shell.dungeon-mode .cell.tile-sleeping > .monster-marker {
  filter: brightness(calc(var(--actor-light, 1) * 0.78)) saturate(0.62);
}
.app-shell.dungeon-mode .cell > .game-art-object {
  filter: brightness(var(--actor-light, 1)) drop-shadow(0 1px 1px rgba(0,0,0,.75));
}
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode {
    --tile: clamp(11px, min(36px, calc((100vw - 42px) / 11), calc((100svh - 390px) / 11)), 36px);
  }
  .app-shell.dungeon-mode .map {
    grid-template-columns: repeat(var(--map-columns, 11), var(--tile));
    grid-template-rows: repeat(var(--map-columns, 11), var(--tile));
  }
}
@media (max-width: 599px) and (max-height: 620px) and (orientation: portrait) {
  .app-shell.dungeon-mode {
    --tile: clamp(11px, min(36px, calc((100vw - 42px) / 11), calc((100svh - 376px) / 11)), 36px);
  }
}
/* Use the same floor color for occupied and empty floor cells on mobile. */
@media (max-width: 979px) {
  .app-shell.dungeon-mode .cell:is(.tile-enemy, .tile-unique, .tile-flower-pet, .tile-corpse)[data-terrain="floor"] {
    background: #1b241c !important;
    box-shadow: none;
  }
  /* Keep all stats visible above the map instead of covering dungeon tiles. */
  .app-shell.dungeon-mode .dungeon-projection { display: flex; flex-direction: column; }
  .app-shell.dungeon-mode .dungeon-stats-overlay {
    position: static; width: 100%; box-sizing: border-box; display: flex;
    flex-wrap: wrap; align-items: baseline; justify-content: space-between;
    column-gap: 4px; row-gap: 3px; padding: 0 3px 5px;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay .dungeon-hp-stat {
    flex: 0 0 100%; width: 100%; margin: 0; display: grid;
    grid-template-columns: auto auto minmax(0,1fr); gap: 4px; align-items: center;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay .dungeon-hp-stat .hp-bar {
    grid-column: auto; width: 100%; max-width: none;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay > div:not(.dungeon-hp-stat) {
    display: flex; align-items: baseline; gap: 2px; padding: 0; white-space: nowrap;
  }
}

/* Reserve the mobile stat strip when the phone is horizontal. */
@media (max-width: 979px) and (max-height: 500px) and (orientation: landscape) {
  .app-shell.dungeon-mode { --tile: clamp(11px, min(22px, calc((100svh - 202px) / 13)), 22px); }
}

/* In portrait, give the battlefield its own row and use the space below for actions. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.arena-mode .arena-tactical-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto auto;
    align-content: start;
    justify-items: center;
    gap: 6px;
  }
  .app-shell.arena-mode .arena-map {
    --arena-cell: clamp(12px, min(28px, calc((100vw - 50px) / 9), calc((100svh - 560px) / 9)), 28px);
  }
  .app-shell.arena-mode .arena-command-panel {
    width: 100%;
    max-width: 360px;
    grid-template-columns: minmax(0, 1fr) 146px;
    grid-template-rows: auto 1fr;
    align-items: start;
    gap: 4px 8px;
  }
  .app-shell.arena-mode .arena-action-hint { grid-column: 1; grid-row: 1; }
  .app-shell.arena-mode .arena-action-buttons { grid-column: 1; grid-row: 2; }
  .app-shell.arena-mode .arena-move-pad { grid-column: 2; grid-row: 1 / span 2; align-self: start; }
}
@media (max-width: 599px) and (max-height: 680px) and (orientation: portrait) {
  .app-shell.arena-mode .arena-map {
    --arena-cell: clamp(12px, min(25px, calc((100vw - 50px) / 9), calc((100svh - 470px) / 9)), 25px);
  }
}
@media (max-width: 599px) and (max-height: 600px) and (orientation: portrait) {
  .app-shell.arena-mode { grid-template-rows: 52px auto auto minmax(0, 1fr); }
}

/* Portrait dungeon: keep status on the map and use the reclaimed space for larger controls. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode .dungeon-projection {
    display: block;
    position: relative;
    width: fit-content;
    max-width: 100%;
    margin-inline: auto;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay {
    position: absolute;
    top: 5px;
    left: 5px;
    z-index: 12;
    width: 76px;
    box-sizing: border-box;
    display: grid;
    gap: 2px;
    padding: 4px;
    border: 0;
    background: rgba(2, 9, 10, 0.72);
    pointer-events: none;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay .dungeon-hp-stat {
    width: auto;
    margin: 0 0 2px;
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 2px 4px;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay .dungeon-hp-stat .hp-bar {
    grid-column: 1 / -1;
    width: 100%;
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay > div:not(.dungeon-hp-stat) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    align-items: baseline;
    gap: 2px;
    padding: 0;
  }
  .app-shell.dungeon-mode .controls {
    --mobile-move-key: clamp(48px, min(72px, 9svh, calc((100vw - 160px) / 3)), 72px);
    --mobile-move-key-height: clamp(48px, 10svh, 90px);
    grid-template-columns: repeat(3, var(--mobile-move-key));
    grid-template-rows: repeat(3, var(--mobile-move-key-height));
  }
  .app-shell.dungeon-mode .controls button {
    width: var(--mobile-move-key);
    min-height: var(--mobile-move-key-height);
    font-size: clamp(18px, 3svh, 25px);
  }
  .app-shell.dungeon-mode .magic-move-controls { max-height: clamp(156px, 25svh, 230px); }
  .app-shell.dungeon-mode .magic-move-controls #jobSkillButton {
    grid-column: 1 / -1;
  }
}

/* The convenience button uses the same @ as the dungeon player, at button size. */
.controls #waitButton:not(:has(.wait-action-graphic)),
.app-shell.arena-mode .arena-move-pad [data-arena-wait] {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  font-size: clamp(27px, 4.5svh, 42px);
  font-weight: 400;
  line-height: 1;
  color: #fff4c2;
  text-shadow: 0 0 5px #fff5c9, 0 0 12px rgba(238, 198, 94, 0.96);
}

@media (min-width: 980px) and (min-height: 600px) {
  .controls #waitButton:not(:has(.wait-action-graphic)),
  .app-shell.arena-mode .arena-move-pad [data-arena-wait] {
    font-family: Georgia, "Yu Mincho", serif;
    color: #ffebae;
    text-shadow: 0 0 3px #fff6d3, 0 0 15px #b99242, 0 2px 3px #000;
  }
}

@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode .dungeon-stats-overlay .dungeon-hp-stat .hp-bar {
    width: 110%;
    max-width: none;
  }
}
@media (max-width: 599px) and (min-height: 621px) and (max-height: 700px) and (orientation: portrait) {
  .app-shell.dungeon-mode .controls {
    --mobile-move-key-height: clamp(48px, calc((100svh - 515px) / 3), 65px);
  }
}
@media (max-width: 599px) and (min-height: 701px) and (max-height: 820px) and (orientation: portrait) {
  .app-shell.dungeon-mode .controls {
    --mobile-move-key-height: clamp(56px, calc(38svh - 229px), 74px);
  }
}
@media (max-width: 599px) and (min-height: 690px) and (max-height: 700px) and (orientation: portrait) {
  .app-shell.dungeon-mode .controls {
    --mobile-move-key-height: clamp(48px, calc((100svh - 527px) / 3), 65px);
  }
}

/* Fit the map to the actual space left by the header and controls. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode {
    padding-left: max(2px, env(safe-area-inset-left));
    padding-right: max(2px, env(safe-area-inset-right));
  }
  .app-shell.dungeon-mode #dungeonView {
    display: grid;
    grid-template-rows: auto minmax(0, 1fr) auto;
    overflow: hidden;
    padding-left: 0;
    padding-right: 0;
  }
  .app-shell.dungeon-mode .dungeon-projection {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
    min-height: 0;
    container-type: size;
  }
  .app-shell.dungeon-mode .dungeon-projection .map {
    --tile: max(0px, min(44px, calc((100cqw - 10px) / 11), calc((100cqh - 10px) / 11)));
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay {
    left: calc((100% - min(100cqw, 100cqh, 494px)) / 2 + 5px);
    top: calc((100% - min(100cqw, 100cqh, 494px)) / 2 + 5px);
  }
  .app-shell.dungeon-mode .controls {
    --mobile-move-key: clamp(48px, min(72px, 9svh, calc((100vw - 160px) / 3), calc((100svh - 550px) / 3)), 72px);
    --mobile-move-key-height: var(--mobile-move-key);
  }
  .app-shell.dungeon-mode .controls button {
    width: var(--mobile-move-key);
    height: var(--mobile-move-key);
    min-height: var(--mobile-move-key);
  }
}

/* The dungeon player keeps its white color and original glow. */
.app-shell.dungeon-mode .tile-player { color: var(--text); }
/* Keep arena and convenience-button glyphs readable without a glow. */
.app-shell.arena-mode .arena-player,
.controls #waitButton:not(:has(.wait-action-graphic)),
.app-shell.arena-mode .arena-move-pad [data-arena-wait] {
  color: var(--text);
  text-shadow: none;
}
.app-shell.arena-mode .arena-move-pad [data-arena-wait] {
  font-size: 24px;
}

/* Give the arena movement buttons a little more room on portrait phones. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.arena-mode {
    --arena-move-key: clamp(46px, 12.5vw, 50px);
  }
  .app-shell.arena-mode .arena-command-panel {
    grid-template-columns: minmax(0, 1fr) calc(var(--arena-move-key) + var(--arena-move-key) + var(--arena-move-key) + 14px);
  }
  .app-shell.arena-mode .arena-move-pad {
    grid-template-columns: repeat(3, var(--arena-move-key));
    grid-template-rows: repeat(3, var(--arena-move-key));
  }
  .app-shell.arena-mode .arena-move-pad button {
    width: var(--arena-move-key);
    height: var(--arena-move-key);
    min-height: var(--arena-move-key);
  }
}
@media (max-width: 599px) and (min-height: 721px) and (max-height: 839px) and (orientation: portrait) {
  .app-shell.arena-mode .arena-map {
    --arena-cell: clamp(12px, min(27px, calc((100vw - 50px) / 9), calc((100svh - 569px) / 9)), 27px);
  }
}

/* Arena movement keys are square, retaining their existing width on PC. */
@media (min-width: 600px) and (min-height: 501px) {
  .app-shell.arena-mode .arena-move-pad {
    grid-template-columns: repeat(3, 52px);
    grid-template-rows: repeat(3, 52px);
  }
  .app-shell.arena-mode .arena-move-pad button {
    width: 52px;
    height: 52px;
    min-height: 52px;
  }
}
@media (max-height: 500px) and (orientation: landscape) {
  .app-shell.arena-mode .arena-move-pad {
    grid-template-columns: repeat(3, 40px);
    grid-template-rows: repeat(3, 40px);
  }
  .app-shell.arena-mode .arena-move-pad button {
    width: 40px;
    height: 40px;
    min-height: 40px;
  }
}
@media (min-width: 600px) and (min-height: 501px) and (max-height: 680px) {
  .app-shell.arena-mode .arena-move-pad { grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(3, 44px); }
  .app-shell.arena-mode .arena-move-pad button { width: 44px; height: 44px; min-height: 44px; }
}
@media (max-height: 380px) and (orientation: landscape) {
  .app-shell.arena-mode .arena-move-pad { grid-template-columns: repeat(3, 38px); grid-template-rows: repeat(3, 38px); }
  .app-shell.arena-mode .arena-move-pad button { width: 38px; height: 38px; min-height: 38px; }
}
@media (min-width: 980px) and (min-height: 600px) and (max-height: 620px) {
  .app-shell.arena-mode .arena-move-pad { grid-template-columns: repeat(3, 36px); grid-template-rows: repeat(3, 36px); }
  .app-shell.arena-mode .arena-move-pad button { width: 36px; height: 36px; min-height: 36px; }
}
/* Four lines of combat log on portrait phones. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode { grid-template-rows: 96px minmax(0, 1fr); }
  .app-shell.arena-mode { grid-template-rows: 96px auto auto minmax(0, 1fr); }
  .app-shell.dungeon-mode .log-panel,
  .app-shell.arena-mode .log-panel { min-height: 0; max-height: none; padding: 4px 8px; gap: 2px; }
  .app-shell.dungeon-mode .log-panel-toolbar button,
  .app-shell.arena-mode .log-panel-toolbar button { min-height: 20px; padding: 1px 6px; font-size: 9px; }
  .app-shell.dungeon-mode .log-panel p,
  .app-shell.arena-mode .log-panel p { font-size: 11px; line-height: 1.15; padding-block: 1px; margin-bottom: 1px; }
}
@media (max-width: 599px) and (max-height: 680px) and (orientation: portrait) {
  .app-shell.arena-mode .arena-map {
    --arena-cell: clamp(8px, min(25px, calc((100vw - 50px) / 9), calc((100svh - 499px) / 9)), 25px);
  }
}

/* Expand the square battlefield by reducing unused spacing on portrait phones. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode {
    padding-left: env(safe-area-inset-left);
    padding-right: env(safe-area-inset-right);
  }
  .app-shell.dungeon-mode #dungeonView {
    padding-top: 2px;
    padding-bottom: max(4px, env(safe-area-inset-bottom));
  }
  .app-shell.dungeon-mode .floor-line { margin-bottom: 2px; }
  .app-shell.dungeon-mode .floor-line > div {
    grid-template-columns: auto minmax(0, 1fr);
    align-items: center;
    column-gap: 5px;
    padding: 3px 5px;
  }
  .app-shell.dungeon-mode #actionPaceText {
    grid-column: 1 / -1;
    line-height: 1.15;
    overflow-wrap: anywhere;
  }
  .app-shell.dungeon-mode .dungeon-action-dock { margin-top: 2px; }
  .app-shell.dungeon-mode .controls { padding: 4px; gap: 3px; }
}

/* On portrait phones, reserve the system safe area once and place controls lower. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode { height: 100dvh; }
  .app-shell.dungeon-mode #dungeonView { padding-bottom: 4px; }
  .app-shell.dungeon-mode .dungeon-action-dock { margin-top: 8px; }
  .app-shell.dungeon-mode .controls { transform: none; }
  .app-shell.dungeon-mode .magic-move-controls { transform: scale(0.9); }
}

/* Slightly inset the square dungeon map on portrait phones. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode .dungeon-projection .map {
    --tile: max(0px, calc((min(97cqw, 97cqh, 479.18px) - 10px) / 11));
  }
  .app-shell.dungeon-mode .dungeon-stats-overlay {
    left: calc((100% - min(97cqw, 97cqh, 479.18px)) / 2 + 5px);
    top: calc((100% - min(97cqw, 97cqh, 479.18px)) / 2 + 5px);
  }
}

/* Align the rightmost movement key with the dungeon map on portrait phones. */
@media (max-width: 599px) and (orientation: portrait) {
  .app-shell.dungeon-mode .dungeon-action-dock {
    padding-right: var(--dungeon-control-inset, 0px);
  }
}

/* Shared direction icons for dungeon and arena. */
:is(.controls, .arena-move-pad) .movement-arrow {
  position: relative;
  display: inline-block;
  flex: none;
  width: 1.08em;
  height: 1.08em;
  color: inherit;
  font: inherit;
  line-height: 1;
  pointer-events: none;
}
.movement-arrow::before {
  content: "";
  position: absolute;
  inset: 10%;
  background: currentColor;
  clip-path: polygon(50% 5%, 95% 90%, 5% 90%);
}
:is(.movement-nw, .movement-ne, .movement-sw, .movement-se)::before {
  inset: 5%;
  clip-path: polygon(50% 5%, 91% 47%, 62% 47%, 62% 93%, 38% 93%, 38% 47%, 9% 47%);
}
.movement-ne { transform: rotate(45deg); }
.movement-e  { transform: rotate(90deg); }
.movement-se { transform: rotate(135deg); }
.movement-s  { transform: rotate(180deg); }
.movement-sw { transform: rotate(225deg); }
.movement-w  { transform: rotate(270deg); }
.movement-nw { transform: rotate(315deg); }

@media (hover: hover) and (pointer: fine) {
  .app-shell.arena-mode .arena-move-pad button:not(:disabled):hover {
    color: #fff1c9;
    border-color: #dfbd6f;
    background: linear-gradient(180deg, #66552e, #3f3c27);
    box-shadow: inset 0 0 0 1px rgba(255, 225, 153, 0.22), 0 0 10px rgba(224, 184, 98, 0.22);
  }
}

/* Keep the PC HUD usable when the browser window is short. */
@media (min-width: 980px) and (min-height: 500px) and (max-height: 599px) {
  .app-shell.dungeon-mode .dungeon-stats-overlay {
    top: 74px;
    padding: 6px 12px;
    gap: 2px;
  }
  .app-shell.dungeon-mode .dungeon-player-name { margin-bottom: 3px; }
  .app-shell.dungeon-mode .dungeon-stats-overlay .dungeon-hp-stat { margin-bottom: 3px; gap: 3px; }
  .app-shell.dungeon-mode .dungeon-stats-overlay > div { padding: 1px 0; }
  .app-shell.dungeon-mode .log-panel { height: 130px; bottom: 12px; }
  .app-shell.dungeon-mode .dungeon-action-dock { bottom: 12px; }
  .app-shell.dungeon-mode .controls #waitButton:not(:has(.wait-action-graphic)) {
    font-family: Georgia, "Yu Mincho", serif;
    color: #ffebae;
    text-shadow: 0 0 3px #fff6d3, 0 0 15px #b99242, 0 2px 3px #000;
  }
}

/* Match the PC @ glyph on phones while preserving each control's glow. */
.app-shell.dungeon-mode .tile-player {
  font-family: Georgia, "Yu Mincho", serif;
  text-shadow: 0 0 3px #fff6d3, 0 0 15px #b99242, 0 2px 3px #000;
}
.controls #waitButton:not(:has(.wait-action-graphic)),
.app-shell.arena-mode .arena-move-pad [data-arena-wait],
.app-shell.dungeon-mode .controls #waitButton:not(:has(.wait-action-graphic)) {
  font-family: Georgia, "Yu Mincho", serif;
  color: var(--text);
  text-shadow: none;
}

/* 文字版: 遺体が中央ボタンにも画像として表示される。 */
.wait-corpse-graphic.tile-unique-corpse { background: transparent; }

/* 文字表示版：共通spanの10px指定を避ける。 */
.app-shell.dungeon-mode .cell > .monster-marker { font-size: calc(var(--tile) * 0.56); line-height: 1; }
.app-shell.dungeon-mode .cell > .monster-marker > .monster-idle-visual { font-size: inherit; color: inherit; line-height: inherit; }
