:root {
  color-scheme: dark;
  --bg: #0b0b0e;
  --panel: rgba(20, 22, 28, 0.94);
  --panel2: rgba(32, 34, 42, 0.92);
  --line: rgba(220, 220, 230, 0.22);
  --lineStrong: rgba(245, 232, 190, 0.52);
  --text: #f3f1e8;
  --muted: #a7a9b4;
  --gold: #d4b46c;
  --hp: #c94a44;
  --mp: #4a82d1;
  --ok: #9ac77b;
  --warn: #d0a64f;
  --danger: #cf5959;
  --gameW: min(100vw, calc(100svh * 0.5625));
}

* { box-sizing: border-box; }
.game, .memberSlot, .memberPortraitWrap, .memberPortraitWrap img, .card, .card img, .sceneObject, .sceneObject img {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}
img { -webkit-user-drag: none; }
html, body { height: 100%; }
body {
  margin: 0;
  min-height: 100svh;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 12%, rgba(117, 98, 64, 0.20), transparent 42%),
    linear-gradient(160deg, #08080b, #12131a 46%, #07070a);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

button, input { font: inherit; }
button { color: inherit; }

#appShell {
  width: var(--gameW);
  height: min(100svh, calc(100vw * 1.7777778));
  display: grid;
  place-items: center;
}

.game {
  width: 100%;
  aspect-ratio: 9 / 16;
  container-type: inline-size;
  max-height: 100svh;
  display: grid;
  grid-template-rows: 5fr 56.25fr 18.75fr 20fr;
  background: linear-gradient(#101118, #08090d);
  border: 1px solid rgba(255,255,255,0.15);
  box-shadow: 0 22px 80px rgba(0,0,0,0.54), inset 0 0 34px rgba(255,255,255,0.035);
  overflow: hidden;
  position: relative;
}

.topBar {
  min-height: 0;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 2.2%;
  padding: 0 2.5%;
  background: linear-gradient(180deg, rgba(30,30,36,0.98), rgba(14,15,20,0.98));
  border-bottom: 1px solid var(--line);
}

.iconButton, .subButton {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.055);
  border-radius: 0;
  min-width: 2.3em;
  min-height: 2.1em;
  display: inline-grid;
  place-items: center;
}

.subButton {
  padding: 0 0.7em;
  color: var(--muted);
  font-size: clamp(10px, 2.7vw, 14px);
}

.scenarioTitle {
  min-width: 0;
  font-size: clamp(13px, 3.4vw, 18px);
  letter-spacing: 0.04em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
}

.mainFrame {
  min-height: 0;
  padding: 1.4%;
  background:
    linear-gradient(90deg, rgba(255,255,255,0.06), transparent 8%, transparent 92%, rgba(255,255,255,0.06)),
    linear-gradient(#181922, #0c0d12);
}

.sceneArea {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 0;
  border: 2px solid rgba(225, 196, 126, 0.25);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), inset 0 0 55px rgba(0,0,0,0.42);
  background: radial-gradient(circle at 50% 44%, #30323d, #11131b 70%);
  background-size: cover;
  background-position: center;
}

.objectLayer, .sceneObject, .sceneHit, .sceneObjectImage, .sceneObjectFallback {
  position: absolute;
}

.objectLayer { inset: 0; }

.sceneObject {
  display: grid;
  place-items: center;
  pointer-events: none;
  border: 1px solid rgba(232, 207, 145, 0.42);
  background:
    radial-gradient(circle at 50% 24%, rgba(255,255,255,0.12), transparent 36%),
    linear-gradient(180deg, rgba(34, 32, 28, 0.88), rgba(11, 12, 16, 0.88));
  box-shadow:
    0 14px 20px rgba(0,0,0,0.42),
    0 3px 6px rgba(0,0,0,0.42),
    inset 0 0 0 1px rgba(255,255,255,0.05);
  transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.15s ease;
}

.sceneObject.interactiveHint {
  border-color: rgba(244, 213, 130, 0.76);
  box-shadow:
    0 16px 22px rgba(0,0,0,0.48),
    0 0 14px rgba(234, 204, 124, 0.32),
    inset 0 0 0 1px rgba(244, 213, 130, 0.18);
}
.sceneObject.hiddenObject { display: none; }

.sceneObjectImage {
  inset: 7%;
  width: 86%;
  height: 86%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 7px 9px rgba(0,0,0,0.34));
}

.sceneObjectFallback {
  inset: 7%;
  border: 1px solid rgba(245,235,197,0.42);
  background: rgba(21,22,27,0.50);
  border-radius: 0;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 4px;
  font-size: clamp(10px, 2.6vw, 14px);
  color: #f6e8b8;
}

.sceneHit {
  border: 1px dashed rgba(255, 236, 165, 0.0);
  border-radius: 0;
  pointer-events: auto;
}
.sceneHit.debugHit { border-color: rgba(255, 236, 165, 0.36); }
.sceneHit.dropHover { background: rgba(255, 236, 165, 0.08); border-color: rgba(255, 236, 165, 0.55); }

@keyframes objectShake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-8px); }
  36% { transform: translateX(7px); }
  54% { transform: translateX(-5px); }
  72% { transform: translateX(4px); }
}
@keyframes hitShakeStrong {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  10% { transform: translate(-14px, 2px) rotate(-1.2deg); }
  22% { transform: translate(13px, -2px) rotate(1.1deg); }
  34% { transform: translate(-11px, -1px) rotate(-0.9deg); }
  46% { transform: translate(10px, 2px) rotate(0.8deg); }
  58% { transform: translate(-8px, 1px) rotate(-0.6deg); }
  72% { transform: translate(6px, -1px) rotate(0.4deg); }
  86% { transform: translate(-3px, 0) rotate(-0.2deg); }
}
.sceneObject.shake, .memberSlot.shake, .card.shake, .battleEnemy.shake { animation: objectShake 0.22s ease both; }
.memberSlot.hitShake, .battleEnemy.hitShake { animation: hitShakeStrong 0.34s cubic-bezier(.2,.9,.25,1) both; }
.battleEnemy.enemyAction { animation: enemyActionDip 0.28s ease both; }

@keyframes enemyActionDip {
  0%, 100% { transform: translateY(0); }
  42% { transform: translateY(9px); }
  70% { transform: translateY(-2px); }
}

.objectResourcePanel {
  position: absolute;
  z-index: 3;
  left: 6%;
  right: 6%;
  top: 5%;
  display: grid;
  gap: 2px;
  padding: 3px 4px;
  background: rgba(6, 7, 10, 0.78);
  border: 1px solid rgba(242, 225, 173, 0.38);
  box-shadow: 0 2px 8px rgba(0,0,0,0.42);
  pointer-events: none;
}
.objectResourceRow {
  display: grid;
  grid-template-columns: auto minmax(20px, 1fr);
  align-items: center;
  gap: 4px;
  min-width: 0;
}
.objectResourceLabel {
  color: #f3e7c1;
  font-size: clamp(7px, 1.8vw, 10px);
  line-height: 1;
  white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0,0,0,0.9);
}
.objectResourceBar {
  display: block;
  height: clamp(3px, 0.9vw, 5px);
  overflow: hidden;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.16);
}
.objectResourceBar > span {
  display: block;
  height: 100%;
  min-width: 0;
}
.objectResourceRow.hp .objectResourceBar > span { background: linear-gradient(90deg, #8b2528, #db5c62); }
.objectResourceRow.mp .objectResourceBar > span { background: linear-gradient(90deg, #294f92, #5b8fdd); }

.objectStatusBadges {
  position: absolute;
  left: 6%;
  right: 6%;
  bottom: 5%;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  pointer-events: none;
}
.objectStatusBadge {
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 0.25em;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(244, 213, 130, 0.55);
  background: rgba(8, 9, 13, 0.82);
  color: #f2e1ad;
  font-size: clamp(9px, 2.4vw, 12px);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.88);
  box-shadow: 0 2px 8px rgba(0,0,0,0.42);
}
.objectStatusBadge.status-immobile { color: #c9ff57; border-color: rgba(201,255,87,0.58); }
.objectStatusBadge.status-continuous { color: #b6ff8d; border-color: rgba(182,255,141,0.58); }
.objectStatusBadge.status-confusion { color: #e3a1ff; border-color: rgba(227,161,255,0.58); }
.objectStatusBadge.status-down { color: #ff8585; border-color: rgba(255,133,133,0.58); }
.objectStatusBadge.status-stealth { color: #c6d2e8; border-color: rgba(198,210,232,0.58); }

.messageWindow {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 3.5%;
  z-index: 20;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px;
  padding: 3.2%;
  border-radius: 0;
  border: 1px solid rgba(242, 225, 173, 0.32);
  background: rgba(7, 8, 11, 0.78);
  backdrop-filter: blur(8px);
  box-shadow: 0 12px 28px rgba(0,0,0,0.38);
}

.messageWindow.dragMuted { opacity: 0.34; }
.messageWindow.hidden { display: none; }
.messageWindow.choiceMode {
  grid-template-columns: 1fr;
  align-items: start;
  background: #000;
  backdrop-filter: none;
}
.messageHeader {
  min-width: 0;
}
.messageHeader.hasSpeakerGraphic {
  display: grid;
  grid-template-columns: clamp(72px, 22vw, 104px) minmax(0, 1fr);
  align-items: start;
  gap: clamp(8px, 2.4vw, 13px);
}
.speakerGraphicFrame {
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 4px 6px;
  border: 1px solid rgba(242, 225, 173, 0.28);
  background: #000;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.035);
  overflow: hidden;
}
.speakerGraphicFrame.hidden { display: none; }
.speakerGraphicImage {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
  object-position: center;
}
.messageText {
  white-space: pre-wrap;
  line-height: 1.55;
  font-size: clamp(12px, 3.3vw, 17px);
}
.messageNext {
  border: 1px solid rgba(242, 225, 173, 0.34);
  border-radius: 0;
  background: rgba(255,255,255,0.08);
  padding: 0.45em 0.7em;
  font-size: clamp(11px, 2.8vw, 14px);
}

.cardPanel {
  min-height: 0;
  background: linear-gradient(180deg, rgba(20,21,28,0.98), rgba(11,12,17,0.98));
  border-top: 1px solid var(--line);
  padding: 1.8% 2.2%;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2.5%;
}
.actorInfo {
  min-height: 1.65em;
  color: var(--muted);
  font-size: clamp(11px, 2.9vw, 14px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.actorInfoSummary {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cardPager {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}
.cardPageButton {
  width: 2.2em;
  height: 1.7em;
  display: grid;
  place-items: center;
  border: 1px solid rgba(242, 225, 173, 0.34);
  background: rgba(255,255,255,0.055);
  color: var(--text);
  border-radius: 0;
  font-size: clamp(12px, 3.4vw, 16px);
  padding: 0;
  touch-action: manipulation;
}
.cardPageButton:disabled {
  opacity: 0.28;
}
.cardPageLabel {
  color: var(--gold);
  font-size: clamp(10px, 2.6vw, 12px);
}
.cardList {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 1.25%;
  overflow: hidden;
  padding: 0 0 2px;
  scrollbar-width: none;
}
.cardList::-webkit-scrollbar { display: none; }
.card {
  position: relative;
  min-width: 0;
  height: 100%;
  border: 1px solid rgba(228, 207, 150, 0.34);
  border-radius: 0;
  background:
    radial-gradient(circle at 50% 26%, rgba(255,255,255,0.12), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025)),
    rgba(36, 32, 27, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.04), 0 8px 18px rgba(0,0,0,0.25);
  padding: clamp(4px, 1.1vw, 7px);
  display: grid;
  place-items: center;
  touch-action: none;
  cursor: grab;
  user-select: none;
}
.card:active { cursor: grabbing; }
.cardArt {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 8px 12px rgba(0,0,0,0.32));
}
.cardFallbackSymbol {
  width: 64%;
  aspect-ratio: 1;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 1px solid rgba(244, 213, 130, 0.44);
  background: rgba(0,0,0,0.24);
  color: var(--gold);
  font-size: clamp(22px, 8vw, 48px);
}
.cardUses {
  position: absolute;
  right: 6px;
  bottom: 5px;
  min-width: 1.55em;
  height: 1.55em;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: rgba(8, 9, 13, 0.78);
  border: 1px solid rgba(244, 213, 130, 0.45);
  color: var(--gold);
  font-weight: 700;
  font-size: clamp(9px, 2.5vw, 12px);
}
.cardPassiveMark {
  position: absolute;
  left: 6px;
  top: 5px;
  color: rgba(244, 213, 130, 0.9);
  font-size: clamp(10px, 2.6vw, 13px);
  text-shadow: 0 1px 4px rgba(0,0,0,0.7);
}
.card.basicAction {
  border-color: rgba(204, 226, 255, 0.42);
  background:
    radial-gradient(circle at 50% 26%, rgba(180,215,255,0.13), transparent 32%),
    linear-gradient(180deg, rgba(255,255,255,0.075), rgba(255,255,255,0.025)),
    rgba(26, 33, 43, 0.84);
}
.cardBasicMark {
  position: absolute;
  left: 5px;
  top: 5px;
  min-width: 1.45em;
  height: 1.45em;
  display: grid;
  place-items: center;
  border: 1px solid rgba(207,229,255,0.42);
  background: rgba(8, 12, 18, 0.72);
  color: #cfe5ff;
  font-size: clamp(8px, 2.1vw, 11px);
  font-weight: 800;
}

.inputLockOverlay {
  position: absolute;
  inset: 0;
  z-index: 15;
  background: rgba(0,0,0,0.001);
  pointer-events: auto;
  cursor: default;
}
.inputLockOverlay.hidden { display: none; }
body.messageLocked .card,
body.messageLocked .memberSlot,
body.messageLocked .sceneHit,
body.messageLocked .iconButton,
body.messageLocked .subButton {
  cursor: default;
}
body.marketLocked .sceneHit,
body.marketLocked .cardPanel .card,
body.marketLocked .topBar .iconButton,
body.marketLocked .topBar .subButton {
  pointer-events: none;
  cursor: default;
}
body.marketLocked .marketPanel,
body.marketLocked .marketPanel .card,
body.marketLocked .partyBar .memberSlot {
  pointer-events: auto;
}

.dragGhost {
  position: fixed;
  z-index: 1000;
  width: min(34vw, 150px);
  height: min(22svh, 150px);
  transform: translate(-50%, -50%) rotate(-2deg);
  pointer-events: none;
  opacity: 0.94;
}
.dragGhost.hidden { display: none; }
.dragGhost .card { width: 100%; height: 100%; }

.cardInfoModal {
  position: absolute;
  inset: 0;
  z-index: 32;
  display: grid;
  place-items: start center;
  padding: 6.5% 5% 4%;
  pointer-events: auto;
}
.cardInfoModal.hidden { display: none; }
.cardInfoBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.30);
  backdrop-filter: blur(2px);
}
.cardInfoPanel {
  position: relative;
  width: min(84%, 380px);
  max-height: calc(100% - 18px);
  overflow: auto;
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 10px;
  padding: 14px;
  border-radius: 0;
  border: 1px solid rgba(242, 225, 173, 0.34);
  background:
    radial-gradient(circle at 50% 10%, rgba(244, 213, 130, 0.10), transparent 36%),
    rgba(12, 13, 18, 0.95);
  box-shadow: 0 18px 38px rgba(0,0,0,0.56), inset 0 0 0 1px rgba(255,255,255,0.04);
  color: var(--text);
}
.cardInfoArt {
  height: clamp(128px, 24svh, 170px);
  border-radius: 0;
  border: 1px solid rgba(228, 207, 150, 0.25);
  background: rgba(255,255,255,0.035);
  padding: 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.cardInfoArt .card {
  pointer-events: none;
}
.cardInfoBody { display: grid; gap: 8px; min-height: 0; }
.cardInfoTitle {
  margin: 0;
  color: var(--gold);
  font-size: clamp(18px, 5vw, 24px);
  letter-spacing: 0.04em;
}
.cardInfoDesc {
  margin: 0;
  white-space: pre-wrap;
  line-height: 1.6;
  color: #e7e0d0;
  font-size: clamp(13px, 3.5vw, 16px);
}
.cardInfoMeta {
  min-height: 1.4em;
  color: var(--muted);
  font-size: clamp(11px, 2.8vw, 13px);
}
.cardInfoClose {
  justify-self: end;
  border: 1px solid rgba(242, 225, 173, 0.34);
  border-radius: 0;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0.55em 1.1em;
  font-size: clamp(12px, 3vw, 15px);
}


.partyBar {
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 1.2%;
  padding: 1.2% 1.6% 2.0%;
  background: linear-gradient(180deg, rgba(18,19,25,0.98), rgba(7,8,11,1));
  border-top: 1px solid var(--line);
}
.memberSlot {
  min-width: 0;
  display: block;
  padding: 0;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 0;
  background: rgba(255,255,255,0.035);
  position: relative;
  overflow: hidden;
  touch-action: none;
  isolation: isolate;
}
.memberSlot::after {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: 38%;
  z-index: 2;
  pointer-events: none;
  background: linear-gradient(180deg, transparent, rgba(0,0,0,0.66) 62%, rgba(0,0,0,0.86));
}
.memberSlot.empty { opacity: 0.28; }
.memberSlot.selected {
  border-color: rgba(244, 213, 130, 0.76);
  box-shadow: 0 0 18px rgba(221, 184, 100, 0.15), inset 0 0 0 1px rgba(244, 213, 130, 0.30);
}
.memberPortraitWrap {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  overflow: hidden;
  background: radial-gradient(circle at 50% 35%, #393f4a, #17191f 70%);
  border: 0;
  z-index: 1;
}
.memberPortraitWrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center bottom;
  display: block;
}
.memberFallback {
  width: 100%; height: 100%; display: grid; place-items: center;
  font-size: clamp(22px, 7vw, 42px);
  color: rgba(242,225,173,0.92);
  background: radial-gradient(circle at 50% 35%, #3d4350, #17191f 72%);
}
.memberVitalsOverlay {
  position: absolute;
  left: 7%;
  right: 7%;
  bottom: 6%;
  z-index: 3;
  display: grid;
  gap: 3px;
  pointer-events: none;
}
.memberStatusBadges {
  min-height: 1.2em;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
}
.memberStatusBadge {
  min-width: 1.35em;
  height: 1.35em;
  padding: 0 0.25em;
  display: inline-grid;
  place-items: center;
  border-radius: 999px;
  border: 1px solid rgba(244, 213, 130, 0.58);
  background: rgba(8,9,13,0.82);
  color: #f2e1ad;
  font-size: clamp(8px, 2.1vw, 11px);
  font-weight: 800;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.88);
  box-shadow: 0 2px 8px rgba(0,0,0,0.42);
}
.memberStatusBadge.status-defense { color: #ffe59b; border-color: rgba(255,229,155,0.70); }
.memberStatusBadge.status-evade { color: #cfe5ff; border-color: rgba(207,229,255,0.70); }
.memberStatusBadge.status-stealth { color: #c9ff57; border-color: rgba(201,255,87,0.58); }
.bar {
  height: 5px;
  border-radius: 99px;
  background: rgba(255,255,255,0.17);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.55);
}
.bar > span { display: block; height: 100%; width: 0; }
.hpBar > span { background: linear-gradient(90deg, #8b2528, var(--hp)); }
.mpBar > span { background: linear-gradient(90deg, #294f92, var(--mp)); }
.statusLine {
  height: 1.25em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: #d8c47f;
  font-size: clamp(9px, 2.3vw, 12px);
  white-space: nowrap;
}

.drawer {
  position: fixed;
  z-index: 900;
  top: 0;
  right: 0;
  width: min(86vw, 390px);
  height: 100svh;
  padding: 18px;
  display: grid;
  grid-template-rows: auto auto auto 1fr;
  gap: 12px;
  background: rgba(13,14,19,0.96);
  border-left: 1px solid var(--line);
  box-shadow: -18px 0 54px rgba(0,0,0,0.48);
  backdrop-filter: blur(10px);
}
.drawer.hidden { display: none; }
.drawerHeader { display: flex; align-items: center; justify-content: space-between; }
.drawerButton {
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255,255,255,0.06);
  padding: 11px 12px;
  text-align: left;
}
.drawerDetails {
  min-height: 0;
  overflow: hidden;
}
.logView {
  margin-top: 10px;
  max-height: 62svh;
  overflow: auto;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 0;
  background: rgba(255,255,255,0.035);
  font-size: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
  color: #c9cbd2;
}

.hidden { display: none !important; }
@media (max-aspect-ratio: 9/16) {
  #appShell { width: 100vw; height: calc(100vw * 1.7777778); }
}
@media (min-aspect-ratio: 9/16) {
  #appShell { height: 100svh; width: calc(100svh * 0.5625); }
}

.effectPopup {
  position: fixed;
  z-index: 1150;
  transform: translate(-50%, -50%);
  pointer-events: none;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: #c9ff57;
  font-weight: 900;
  font-size: clamp(19px, 5.6vw, 30px);
  line-height: 1;
  text-align: center;
  letter-spacing: 0.02em;
  text-shadow:
    0 2px 4px rgba(0,0,0,0.92),
    0 0 10px rgba(201,255,87,0.34);
  box-shadow: none;
  animation: effectPopupFloat 0.88s ease-out both;
}
.effectPopup.hp,
.effectPopup.mp,
.effectPopup.status {
  color: #c9ff57;
  text-shadow:
    0 2px 4px rgba(0,0,0,0.92),
    0 0 10px rgba(201,255,87,0.38);
}
.effectPopup.damage,
.effectPopup.statusRemove {
  color: #ff3f3f;
  text-shadow:
    0 2px 4px rgba(0,0,0,0.92),
    0 0 10px rgba(255,63,63,0.36);
}

@keyframes effectPopupFloat {
  0% { opacity: 0; transform: translate(-50%, -36%) scale(0.82); }
  16% { opacity: 1; transform: translate(-50%, -58%) scale(1.08); }
  72% { opacity: 1; transform: translate(-50%, -96%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -125%) scale(0.96); }
}

.messageChoices {
  display: grid;
  gap: 8px;
  box-sizing: border-box;
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(242, 225, 173, 0.22);
  background: transparent;
}
.messageChoices.hidden { display: none; }
.messageChoiceButton {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 0;
  background: #000;
  color: var(--text);
  padding: 10px 12px;
  text-align: left;
  font: inherit;
  white-space: normal;
  line-height: 1.45;
}
.messageChoiceButton:active {
  transform: translateY(1px);
  background: #151515;
}

.actorInfoModal {
  position: absolute;
  inset: 0;
  z-index: 33;
  display: grid;
  place-items: start center;
  padding: 6.5% 5% 4%;
  pointer-events: auto;
}
.actorInfoModal.hidden { display: none; }
.actorInfoBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.30);
  backdrop-filter: blur(2px);
}
.actorInfoPanel {
  position: relative;
  width: min(88%, 420px);
  max-height: calc(100% - 18px);
  overflow: auto;
  display: grid;
  grid-template-columns: minmax(86px, 32%) 1fr;
  gap: 12px;
  padding: 14px;
  border-radius: 0;
  border: 1px solid rgba(242, 225, 173, 0.34);
  background:
    radial-gradient(circle at 50% 10%, rgba(244, 213, 130, 0.10), transparent 36%),
    rgba(12, 13, 18, 0.95);
  box-shadow: 0 18px 38px rgba(0,0,0,0.56), inset 0 0 0 1px rgba(255,255,255,0.04);
  color: var(--text);
}
.actorInfoPortrait {
  min-height: 120px;
  border: 1px solid rgba(228, 207, 150, 0.25);
  background: rgba(255,255,255,0.035);
  display: grid;
  place-items: center;
  overflow: hidden;
}
.actorInfoPortraitInner,
.actorInfoPortraitInner img,
.actorInfoPortraitInner .memberFallback { width: 100%; height: 100%; }
.actorInfoPortraitInner img { object-fit: cover; display: block; }
.actorInfoBody { min-width: 0; display: grid; gap: 8px; }
.actorInfoTitle { margin: 0; color: var(--gold); font-size: clamp(18px, 5vw, 24px); letter-spacing: 0.04em; }
.actorInfoProfile { margin: 0; white-space: pre-wrap; line-height: 1.55; color: #e7e0d0; font-size: clamp(12px, 3.2vw, 15px); }
.actorInfoStats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px 8px; font-size: clamp(11px, 2.9vw, 13px); }
.actorInfoStats div { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; border-bottom: 1px solid rgba(255,255,255,0.08); padding-bottom: 2px; line-height: 1.25; }
.actorInfoStats b { color: var(--muted); font-weight: 500; }
.actorInfoStats span { display: inline-flex; align-items: baseline; gap: 3px; min-width: 0; line-height: 1.25; }
.actorLevelInlineUp {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  border: 1px solid rgba(242, 225, 173, 0.34);
  border-radius: 0;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0;
  min-width: 1.22em;
  width: 1.22em;
  height: 1.18em;
  line-height: 1;
  font-size: 0.72em;
  transform: translateY(-0.02em);
}
.actorLevelInlineUp:disabled { opacity: 0.32; }
.actorInfoCards { grid-column: 1 / -1; color: var(--muted); font-size: clamp(11px, 2.9vw, 13px); line-height: 1.45; }
.actorInfoClose {
  grid-column: 1 / -1;
  justify-self: end;
  border: 1px solid rgba(242, 225, 173, 0.34);
  border-radius: 0;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0.55em 1.1em;
  font-size: clamp(12px, 3vw, 15px);
}

.battleLayer {
  position: absolute;
  inset: 0;
  z-index: 5;
  pointer-events: none;
}
.battleLayer.hidden { display: none; }
.battleHeader {
  --battleHeaderSize: clamp(48px, 12.8vw, 64px);
  position: absolute;
  left: 3.5%;
  right: 3.5%;
  top: 3.5%;
  height: var(--battleHeaderSize);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 2fr) auto;
  align-items: stretch;
  gap: 7px;
  z-index: 8;
  pointer-events: auto;
}
.battleTitle {
  min-width: 0;
  height: 100%;
  display: grid;
  align-content: center;
  gap: 2px;
  padding: 0.38em 0.68em;
  border: 1px solid rgba(242, 225, 173, 0.28);
  background: rgba(7, 8, 11, 0.62);
  color: var(--gold);
  font-size: clamp(10px, 2.8vw, 14px);
  letter-spacing: 0.04em;
  line-height: 1.08;
  backdrop-filter: blur(4px);
  overflow: hidden;
}
.battleTitleName {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-weight: 700;
}
.battleTitleTurn {
  color: rgba(242, 225, 173, 0.82);
  font-size: 0.9em;
}
.battleEscape {
  height: 100%;
  min-width: var(--battleHeaderSize);
  border: 1px solid rgba(242, 225, 173, 0.48);
  background: rgba(0, 0, 0, 0.58);
  color: var(--gold);
  padding: 0.35em 0.65em;
  font-size: clamp(11px, 3vw, 15px);
  font-weight: 700;
  letter-spacing: 0.06em;
  border-radius: 0;
  display: grid;
  place-items: center;
  text-shadow: 0 1px 2px rgba(0,0,0,0.95);
  box-shadow: inset 0 0 0 1px rgba(0,0,0,0.55), 0 4px 12px rgba(0,0,0,0.36);
  backdrop-filter: blur(3px);
}
.battleEnemy {
  position: absolute;
  display: grid;
  grid-template-rows: 1fr auto auto auto auto;
  gap: 3px;
  place-items: stretch;
  padding: 5px;
  border: 1px solid rgba(230, 191, 119, 0.42);
  background:
    radial-gradient(circle at 50% 24%, rgba(255,255,255,0.12), transparent 36%),
    linear-gradient(180deg, rgba(34, 32, 28, 0.84), rgba(11, 12, 16, 0.86));
  box-shadow: 0 14px 22px rgba(0,0,0,0.44), inset 0 0 0 1px rgba(255,255,255,0.04);
  pointer-events: none;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.battleEnemy.interactiveHint {
  border-color: rgba(244, 213, 130, 0.78);
  box-shadow: 0 16px 24px rgba(0,0,0,0.50), 0 0 14px rgba(234,204,124,0.34), inset 0 0 0 1px rgba(244,213,130,0.18);
}
.battleEnemyImage {
  width: 100%;
  height: 100%;
  min-height: 0;
  object-fit: contain;
  filter: drop-shadow(0 10px 12px rgba(0,0,0,0.40));
  pointer-events: none;
}
.battleEnemyName {
  color: #f2e1ad;
  text-align: center;
  font-size: clamp(10px, 2.8vw, 14px);
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.battleMiniBar {
  width: 100%;
  height: 5px;
}
.battleEnemyStatus {
  height: 1.2em;
  color: #d8c47f;
  text-align: center;
  font-size: clamp(9px, 2.2vw, 12px);
  line-height: 1.2;
}
.battleEnemyHit {
  position: absolute;
  z-index: 7;
  pointer-events: auto;
  border: 1px dashed rgba(255,236,165,0);
}
.battleEnemyHit.dropHover {
  background: rgba(255, 236, 165, 0.08);
  border-color: rgba(255, 236, 165, 0.55);
}

/* Engine 0.19: active battle actor/enemy emphasis */
.memberSlot {
  transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease, background .16s ease;
}
.memberSlot.acting {
  transform: translateY(-8px);
  border-color: rgba(255, 231, 154, 0.92);
  background: rgba(244, 213, 130, 0.08);
  box-shadow: 0 0 20px rgba(244, 213, 130, 0.30), 0 10px 18px rgba(0,0,0,0.32), inset 0 0 0 1px rgba(244,213,130,0.30);
  z-index: 2;
}
.battleEnemy.acting {
  transform: translateY(-10px);
  border-color: rgba(255, 231, 154, 0.96);
  box-shadow: 0 0 22px rgba(244, 213, 130, 0.36), 0 20px 28px rgba(0,0,0,0.52), inset 0 0 0 1px rgba(244,213,130,0.30);
  z-index: 6;
}
.battleQueue {
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: stretch;
  gap: 4px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 0;
  border: 1px solid rgba(242, 225, 173, 0.18);
  background: rgba(7, 8, 11, 0.46);
  color: rgba(242, 225, 173, 0.72);
  backdrop-filter: blur(4px);
  scrollbar-width: none;
  overscroll-behavior-x: contain;
  scroll-snap-type: x proximity;
  cursor: grab;
}
.battleQueue::-webkit-scrollbar { display: none; }
.battleQueue.dragging { cursor: grabbing; }
.battleQueueItem {
  position: relative;
  flex: 0 0 var(--battleHeaderSize);
  width: var(--battleHeaderSize);
  height: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.14);
  background:
    radial-gradient(circle at 50% 28%, rgba(255,255,255,0.10), transparent 46%),
    rgba(10, 11, 15, 0.84);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.03);
  transition: transform .14s ease, border-color .14s ease, box-shadow .14s ease;
  scroll-snap-align: start;
}
.battleQueueItem.actor {
  border-style: double;
  border-width: 3px;
  border-color: rgba(159, 199, 238, 0.68);
}
.battleQueueItem.enemy {
  border-color: rgba(235, 151, 139, 0.70);
}
.battleQueueImage {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  object-position: center;
  pointer-events: none;
}
.battleQueueItem.actor .battleQueueImage { object-position: center 22%; }
.battleQueueFallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  color: #f3e4b5;
  font-size: clamp(18px, 5vw, 28px);
  font-weight: 800;
  text-shadow: 0 2px 5px rgba(0,0,0,0.75);
}
.battleQueueItem.active {
  border-color: rgba(255, 231, 154, 0.98);
  box-shadow:
    0 0 0 1px rgba(255,255,255,0.30),
    0 0 15px rgba(244, 213, 130, 0.50),
    0 8px 12px rgba(0,0,0,0.40),
    inset 0 0 0 1px rgba(244,213,130,0.30);
  z-index: 2;
}
.battleQueueItem.active::after {
  content: "";
  position: absolute;
  inset: 2px;
  border: 2px solid rgba(255, 235, 170, 0.90);
  pointer-events: none;
}
.battleQueueEmpty {
  flex: 1 1 auto;
  min-width: 0;
  display: grid;
  place-items: center;
  color: rgba(242, 225, 173, 0.58);
  font-size: clamp(18px, 5vw, 26px);
}

/* R53.13.58: 販売/ガチャ価格はカード枠外の直下中央へ出す。 */
.marketCard {
  position: relative;
  overflow: visible;
}
.marketPriceBadge {
  position: absolute;
  left: 50%;
  right: auto;
  top: calc(100% + 2px);
  bottom: auto;
  transform: translateX(-50%);
  min-width: 3.2em;
  height: var(--pc-market-price-h, clamp(14px, 3.2vw, 18px));
  padding: 0 0.45em;
  display: grid;
  place-items: center;
  text-align: center;
  border: 1px solid rgba(244, 213, 130, 0.68);
  background: rgba(8, 9, 13, 0.90);
  color: #f3dfa3;
  font-size: clamp(9px, 2.2vw, 12px);
  line-height: 1;
  font-weight: 800;
  white-space: nowrap;
  pointer-events: none;
  z-index: 8;
}
.moneyDistributionModal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.58);
}
.moneyDistributionPanel {
  width: min(92vw, 420px);
  max-height: 88vh;
  overflow: auto;
  border: 1px solid rgba(244, 213, 130, 0.48);
  background: rgba(18, 19, 25, 0.98);
  padding: 14px;
  box-shadow: 0 18px 60px rgba(0,0,0,0.6);
}
.moneyDistributionPanel h2 { margin: 0 0 8px; font-size: 1.1rem; }
.moneyDistributionRows { display: grid; gap: 8px; }
.moneyDistributionRow {
  display: grid;
  grid-template-columns: 1fr 7em;
  align-items: center;
  gap: 8px;
  border: 1px solid rgba(255,255,255,0.10);
  padding: 7px;
  background: rgba(255,255,255,0.04);
}
.moneyDistributionRow input {
  width: 100%;
  color: var(--text);
  background: rgba(0,0,0,0.22);
  border: 1px solid var(--line);
  padding: 0.35em;
}
.moneyDistributionActions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.moneyDistributionActions button {
  border: 1px solid var(--line);
  background: rgba(255,255,255,0.08);
  padding: 0.45em 0.7em;
}
.moneyDistributionActions button:disabled { opacity: 0.45; }
.moneyDistributionError { color: var(--muted); min-height: 1.4em; }

/* 0.26.1: 販売/ガチャ枠は所持カード欄ではなくメイン画面へ表示する */
.marketPanel {
  position: absolute;
  left: 3%;
  right: 3%;
  bottom: 3%;
  z-index: 22;
  border: 1px solid rgba(244, 213, 130, 0.42);
  background: rgba(12, 13, 18, 0.90);
  box-shadow: 0 10px 34px rgba(0,0,0,0.42);
  padding: 6px;
  display: grid;
  gap: 5px;
  backdrop-filter: blur(6px);
}
.marketPanel.hidden { display: none; }
.marketHeader {
  display: flex;
  align-items: center;
  gap: 6px;
  justify-content: space-between;
  min-height: 1.8em;
  font-size: clamp(10px, 2.6vw, 13px);
}
.marketTitle {
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: #f3dfa3;
  font-weight: 800;
}
.marketList {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 5px;
  min-height: 0;
}
.marketList .card {
  min-height: 0;
}

.scenarioClearModal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(0,0,0,0.58);
}
.scenarioClearPanel {
  width: min(92vw, 420px);
  padding: 16px;
  border-radius: 14px;
  background: var(--panel, #1f2430);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 12px 40px rgba(0,0,0,0.45);
}
.scenarioClearPanel h2 { margin: 0 0 8px; font-size: 1.1rem; }
.scenarioClearActions { display: grid; gap: 8px; margin-top: 12px; }
.scenarioClearActions button { min-height: 38px; }

/* 0.27.1: シナリオ正規終了前の共通リザルト画面 */
.scenarioResultModal {
  position: fixed;
  inset: 0;
  z-index: 1300;
  display: grid;
  place-items: center;
  padding: 14px;
  background: rgba(0,0,0,0.66);
}
.scenarioResultPanel {
  width: min(94vw, 480px);
  max-height: 88vh;
  overflow: auto;
  padding: 16px;
  border-radius: 16px;
  background: var(--panel, #1f2430);
  border: 1px solid rgba(255,255,255,0.18);
  box-shadow: 0 16px 48px rgba(0,0,0,0.52);
}
.scenarioResultPanel h2 { margin: 0 0 10px; font-size: 1.18rem; }
.scenarioResultBody { display: grid; gap: 8px; }
.resultLine {
  display: grid;
  grid-template-columns: 8em 1fr;
  gap: 8px;
  align-items: start;
  padding: 6px 0;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.resultLine b { color: #f3dfa3; }
.resultLine.muted { opacity: 0.78; }
.resultMessage {
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 10px;
  background: rgba(0,0,0,0.20);
  line-height: 1.55;
}
.resultExtra { display: grid; gap: 4px; }
.resultWarning {
  margin: 4px 0 0;
  padding: 10px;
  border-radius: 10px;
  border: 1px solid rgba(244, 213, 130, 0.38);
  background: rgba(244, 213, 130, 0.12);
  color: #f3dfa3;
}
.scenarioResultActions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 14px;
}
.scenarioResultActions button { min-height: 40px; }
.scenarioResultActions button:disabled { opacity: 0.45; }

/* 0.28.0 title / scenario preview / character make */
.systemPanel {
  position: absolute;
  inset: 5%;
  z-index: 8;
  display: flex;
  flex-direction: column;
  gap: 0.7em;
  padding: 5%;
  overflow: auto;
  border: 1px solid rgba(242, 225, 173, 0.36);
  background: rgba(7, 8, 12, 0.82);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 40px rgba(0,0,0,0.45);
}
.systemPanel h1 { margin: 0; color: var(--gold); font-size: clamp(18px, 5vw, 28px); }
.systemPanel h3 { margin: 0.45em 0 0; color: #f5e4ad; font-size: clamp(12px, 3.2vw, 16px); }
.systemPanel p { margin: 0; color: var(--text); line-height: 1.55; font-size: clamp(11px, 3vw, 14px); }
.systemMeta, .systemNote { color: var(--muted) !important; }
.systemButtonGrid { display: grid; gap: 0.7em; margin-top: 0.4em; }
.systemButtonGrid.two { grid-template-columns: 1fr 1fr; }
.systemButtonGrid button, .characterMakeActions button, .characterMakePanel button {
  border: 1px solid rgba(242, 225, 173, 0.34);
  background: rgba(255,255,255,0.07);
  padding: 0.75em 0.8em;
  color: var(--text);
}
.systemOk { color: var(--ok) !important; font-weight: 700; }
.systemWarn { color: var(--warn) !important; font-weight: 700; }
.scenarioDescription { color: var(--text); line-height: 1.55; font-size: clamp(11px, 3vw, 14px); }
.titleEmptySlot { width: 100%; height: 100%; display: grid; place-items: center; color: var(--muted); font-size: clamp(10px, 2.6vw, 13px); border: 1px dashed rgba(242,225,173,0.24); }
.titleSlotLabel { position: absolute; left: 2px; right: 2px; bottom: 2px; padding: 1px 2px; background: rgba(0,0,0,0.62); color: #f6e8b8; font-size: clamp(8px, 2.2vw, 11px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.titleMemberSlot { position: relative; }
.characterMakeModal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  background: rgba(0,0,0,0.58);
}
.characterMakePanel {
  width: min(94vw, 520px);
  max-height: 92svh;
  overflow: auto;
  padding: 18px;
  border: 1px solid rgba(242, 225, 173, 0.4);
  background: rgba(13,14,19,0.96);
  box-shadow: 0 20px 80px rgba(0,0,0,0.55);
}
.characterMakePanel h2 { margin: 0 0 12px; color: var(--gold); }
.makeGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.makeGrid.stats { margin-top: 10px; }
.characterMakePanel label { display: grid; gap: 4px; font-size: 12px; color: var(--muted); }
.characterMakePanel input, .characterMakePanel select, .characterMakePanel textarea {
  min-width: 0;
  border: 1px solid rgba(255,255,255,0.18);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0.55em;
}
.characterMakePanel textarea { min-height: 70px; resize: vertical; }
.makeProfile { margin-top: 10px; }
.makePreview { color: #f4e5af; min-height: 1.4em; }
.characterMakeActions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
@media (max-width: 420px) { .makeGrid { grid-template-columns: 1fr; } .systemButtonGrid.two { grid-template-columns: 1fr; } }
.titleRemoveSlot {
  position: absolute;
  right: 3px;
  top: 3px;
  z-index: 4;
  padding: 2px 5px;
  border: 1px solid rgba(255,255,255,0.26);
  background: rgba(10,10,14,0.76);
  color: #f7e9b5;
  font-size: clamp(8px, 2.1vw, 11px);
  line-height: 1.2;
  pointer-events: auto;
}
.makeImageBox {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 12px;
}
.makeImageActions { display: flex; gap: 8px; flex-wrap: wrap; }
.makeStepperGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}
.makeStepper {
  display: grid;
  grid-template-columns: 1fr auto 68px auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.makeStepper input { text-align: center; }
.makeStepper button { padding: 0.45em 0.65em; }
.titleRemoveSlot {
  position: absolute;
  right: 3px;
  top: 3px;
  z-index: 4;
  padding: 2px 5px;
  border: 1px solid rgba(255,255,255,0.26);
  background: rgba(10,10,14,0.76);
  color: #f7e9b5;
  font-size: clamp(8px, 2.1vw, 11px);
  line-height: 1.2;
  pointer-events: auto;
}
.makeImageBox {
  display: grid;
  gap: 6px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  color: var(--muted);
  font-size: 12px;
}
.makeImageActions { display: flex; gap: 8px; flex-wrap: wrap; }
.makeStepperGrid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 10px;
}
.makeStepper {
  display: grid;
  grid-template-columns: 1fr auto 68px auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 12px;
}
.makeStepper input { text-align: center; }
.makeStepper button { padding: 0.45em 0.65em; }

.makePointStatus {
  margin-top: 10px;
  padding: 8px 10px;
  border: 1px solid rgba(242,225,173,0.22);
  background: rgba(242,225,173,0.07);
  color: #f4e5af;
  font-size: 12px;
  font-weight: 700;
}

.poolButton {
  min-width: 9.5em;
  white-space: nowrap;
}
.poolButton:disabled {
  opacity: 0.55;
}

.cardInfoActions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 4px;
}
.cardInfoActionButton {
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255,255,255,0.1);
  color: var(--text, #f5f2e8);
  font-weight: 700;
  touch-action: manipulation;
}
.cardInfoActionButton.danger {
  border-color: rgba(255,130,120,0.5);
}

.scenarioPreviewCover {
  width: 100%;
  min-height: min(28svh, 220px);
  aspect-ratio: 16 / 9;
  border: 1px solid rgba(242, 225, 173, 0.32);
  border-radius: 10px;
  background-color: rgba(0,0,0,0.32);
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.05);
}

.actorLevelControls {
  grid-column: 1 / -1;
  display: grid;
  gap: 8px;
  margin-top: 4px;
  padding: 9px;
  border: 1px solid rgba(242, 225, 173, 0.22);
  background: rgba(242, 225, 173, 0.055);
}
.actorLevelHead {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  color: #f4e5af;
  font-size: clamp(11px, 2.9vw, 13px);
}
.actorLevelUpButton,
.actorGrowthStepper button {
  border: 1px solid rgba(242, 225, 173, 0.34);
  border-radius: 0;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  padding: 0.45em 0.75em;
  font-size: clamp(11px, 2.8vw, 13px);
}
.actorLevelUpButton:disabled,
.actorGrowthStepper button:disabled {
  opacity: 0.38;
}
.actorGrowthStepperGrid {
  display: grid;
  gap: 6px;
}
.actorGrowthStepper {
  display: grid;
  grid-template-columns: 1fr 54px auto;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: clamp(11px, 2.9vw, 13px);
}
.actorGrowthStepper strong {
  text-align: center;
  color: var(--text);
}


/* R41 Porta Carta title / legal */
.titleLogoWrap { width: 100%; display: grid; place-items: center; margin: 0 auto 0.25em; }
.titleLogo { display: block; width: min(100%, 760px); height: auto; object-fit: contain; image-rendering: auto; }
.drawer { grid-template-rows: auto; align-content: start; overflow-y: auto; }
.legalModal { position: fixed; inset: 0; z-index: 1300; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,0.72); }
.legalPanel { width: min(92vw, 520px); max-height: 88svh; display: grid; grid-template-rows: auto minmax(0,1fr) auto; border: 1px solid rgba(242,225,173,0.44); background: rgba(13,14,19,0.98); box-shadow: 0 24px 80px rgba(0,0,0,0.65); }
.legalHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.legalHeader h2 { margin: 0; color: var(--gold); font-size: 18px; }
.legalBody { overflow-y: auto; padding: 16px; color: var(--text); font-size: 13px; line-height: 1.75; }
.legalBody p { margin: 0 0 1em; }
.legalCloseButton { margin: 0 14px 14px; min-height: 42px; border: 1px solid var(--line); background: rgba(255,255,255,0.07); color: var(--text); }
.copyrightMark { margin: 1em 0; color: #f5e4ad; font-weight: 700; }

.resumeNoticeOverlay {
  position: fixed;
  inset: 0;
  z-index: 1250;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0, 0, 0, 0.30);
  pointer-events: auto;
}
.resumeNoticePanel {
  width: min(86vw, 360px);
  display: grid;
  gap: 10px;
  padding: 16px 16px 14px;
  border: 1px solid rgba(242,225,173,0.48);
  background: linear-gradient(180deg, rgba(28,29,36,0.98), rgba(10,11,16,0.98));
  box-shadow: 0 18px 56px rgba(0,0,0,0.62), inset 0 0 0 1px rgba(255,255,255,0.04);
  text-align: center;
}
.resumeNoticeTitle {
  color: var(--text);
  font-weight: 700;
  letter-spacing: 0.02em;
  font-size: clamp(13px, 3.6vw, 16px);
  line-height: 1.65;
}
.resumeNoticeBody {
  color: var(--text);
  font-size: clamp(12px, 3.2vw, 14px);
  line-height: 1.65;
}
.resumeNoticeBody[hidden] { display: none; }
.resumeNoticeButton {
  min-height: 42px;
  border: 1px solid var(--lineStrong);
  background: rgba(255,255,255,0.075);
  color: var(--text);
}

/* R53.13.26 audio settings */
.settingsModal { position: fixed; inset: 0; z-index: 1320; display: grid; place-items: center; padding: 16px; background: rgba(0,0,0,0.62); }
.settingsBackdrop { position: absolute; inset: 0; }
.settingsPanel { position: relative; width: min(90vw, 420px); border: 1px solid rgba(242,225,173,0.44); background: rgba(13,14,19,0.98); box-shadow: 0 24px 80px rgba(0,0,0,0.65); }
.settingsHeader { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 14px; border-bottom: 1px solid var(--line); }
.settingsHeader h2 { margin: 0; color: var(--gold); font-size: 18px; }
.settingsBody { display: grid; gap: 16px; padding: 16px; }
.settingsSliderRow { display: grid; gap: 8px; }
.settingsSliderRow span { color: #f5e4ad; font-size: 14px; }
.settingsSliderRow input[type="range"] { width: 100%; accent-color: var(--gold); }
.settingsNote { color: var(--muted); font-size: 12px; line-height: 1.55; }


.makeImagePreview {
  width: 100%;
  min-height: 180px;
  border: 1px solid rgba(242,225,173,0.24);
  background-color: rgba(0,0,0,0.22);
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  display: grid;
  place-items: center;
  color: var(--muted);
  font-size: 12px;
}
.makeImagePreview[data-has-image="1"] {
  min-height: 240px;
}
.makeImageBox select {
  width: 100%;
  margin-top: 4px;
}


.bootGate {
  display: grid;
  gap: 1.1em;
  place-items: center;
  text-align: center;
  padding: min(7vh, 48px) 0;
}
.bootGateTitle {
  letter-spacing: 0.18em;
  font-size: clamp(28px, 9vw, 56px);
  color: var(--gold);
  text-shadow: 0 0 18px rgba(242,225,173,0.22);
}
.bootGatePhrase {
  margin: 0;
  color: var(--text);
  font-size: clamp(15px, 4.2vw, 22px);
}
.bootGate .systemButtonGrid {
  width: min(72vw, 280px);
}
.bootGate .systemButtonGrid button {
  font-size: clamp(15px, 4vw, 20px);
  padding: 0.9em 1em;
}

.resultPenalties {
  display: grid;
  gap: 4px;
  padding: 8px 10px;
  border: 1px solid rgba(194, 70, 70, 0.42);
  border-radius: 10px;
  background: rgba(120, 20, 20, 0.16);
}
.resultPenaltyHead {
  font-weight: 700;
  color: #d65a5a;
}
.resultPenaltyLine {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: #d65a5a;
}
.resultPenaltyLine b {
  white-space: nowrap;
}
.resultCharacterExp {
  display: grid;
  gap: 2px;
  padding: 8px 10px;
  border: 1px solid rgba(212, 180, 108, 0.30);
  border-radius: 10px;
  background: rgba(212, 180, 108, 0.07);
}
.resultCharacterExp .resultPenaltyHead { color: #f3dfa3; }
.resultCharacterExp .resultLine:last-child { border-bottom: 0; }
.resultLine.repeatClearExp { opacity: 0.82; }


.cutInLayer {
  position: absolute;
  inset: 0;
  z-index: 18;
  overflow: hidden;
  pointer-events: auto;
  background: transparent;
}
.cutInLayer.waitUntilEnd {
  cursor: default;
}
.cutInLayer.tapToSkip {
  cursor: pointer;
}
.cutInImage {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  will-change: left, top, transform;
}


.cutInCaption {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 4%;
  z-index: 2;
  padding: 3.2%;
  border: 1px solid rgba(242, 225, 173, 0.32);
  background: rgba(7, 8, 11, 0.78);
  color: var(--text);
  font-size: clamp(12px, 3.3vw, 17px);
  line-height: 1.55;
  white-space: pre-wrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  box-shadow: 0 12px 28px rgba(0,0,0,0.38);
  pointer-events: none;
}


/* R53.13.48: カットインは常時カード枠付き。
   left/top/width/height は画像本体基準。枠は疑似要素で外側に追従するだけ。 */
.cutInFrame {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  pointer-events: none;
  user-select: none;
  will-change: left, top, transform;
  background:
    radial-gradient(circle at 50% 24%, rgba(255,255,255,0.12), transparent 36%),
    linear-gradient(180deg, rgba(34, 32, 28, 0.88), rgba(11, 12, 16, 0.88));
}
.cutInFrame::before {
  content: "";
  position: absolute;
  inset: -4px;
  z-index: 2;
  border: 1px solid rgba(232, 207, 145, 0.42);
  box-shadow:
    0 14px 20px rgba(0,0,0,0.42),
    0 3px 6px rgba(0,0,0,0.42),
    inset 0 0 0 1px rgba(255,255,255,0.05);
  pointer-events: none;
}
.cutInImage {
  position: absolute;
  display: block;
  max-width: none;
  max-height: none;
  object-fit: fill;
  pointer-events: none;
  user-select: none;
  will-change: auto;
}
.cutInCaption {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 4%;
  z-index: 3;
  padding: 3.2%;
  border: 1px solid rgba(242, 225, 173, 0.32);
  background: rgba(7, 8, 11, 0.78);
  color: var(--text);
  font-size: clamp(12px, 3.3vw, 17px);
  line-height: 1.55;
  white-space: pre-wrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  box-shadow: 0 12px 28px rgba(0,0,0,0.38);
  pointer-events: none;
}


/* R53.13.49: カットイン内メッセージは枠内ではなく、通常メッセージ窓に準じた位置に出す。
   通常メッセージ処理は使わず、cutInLayer内の専用字幕としてカットインと同時に消える。 */
.cutInCaption {
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 3.5%;
  z-index: 6;
  display: block;
  padding: 3.2%;
  border-radius: 0;
  border: 1px solid rgba(242, 225, 173, 0.32);
  background: rgba(7, 8, 11, 0.78);
  color: var(--text);
  font-size: clamp(12px, 3.3vw, 17px);
  line-height: 1.55;
  white-space: pre-wrap;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  box-shadow: 0 12px 28px rgba(0,0,0,0.38);
  pointer-events: none;
}


/* R53.13.50: 大きいカットイン画像の縮小前フラッシュ防止。
   サイズ・座標が確定するまで専用レイヤー内の表示物を隠す。 */
.cutInLayer.pending .cutInFrame,
.cutInLayer.pending .cutInCaption {
  visibility: hidden;
  opacity: 0;
}
.cutInLayer.ready .cutInFrame,
.cutInLayer.ready .cutInCaption {
  visibility: visible;
  opacity: 1;
}


/* R53.13.51: エンジン側カード識別オーバーレイ。
   既存JSONだけを使い、カード名・レア度★・残回数の視認性を上げる。 */
.cardNameBadge {
  position: absolute;
  left: 2px;
  right: 2px;
  top: 2px;
  z-index: 5;
  min-width: 0;
  padding: 1px 3px 2px;
  border: 1px solid rgba(242, 225, 173, 0.20);
  background: rgba(5, 6, 9, 0.70);
  color: #f5ebd0;
  font-size: clamp(6px, 1.55vw, 10px);
  line-height: 1.15;
  font-weight: 700;
  letter-spacing: -0.04em;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-shadow: 0 1px 2px rgba(0,0,0,0.85);
  pointer-events: none;
}
.card.basicAction .cardNameBadge,
.card.passiveCard .cardNameBadge {
  left: 1.9em;
  text-align: left;
}
.cardRarityBadge {
  position: absolute;
  left: 4px;
  bottom: 4px;
  z-index: 5;
  max-width: calc(100% - 2.2em);
  padding: 1px 4px 2px;
  border: 1px solid rgba(244, 213, 130, 0.34);
  background: rgba(8, 9, 13, 0.74);
  color: #f3dfa3;
  font-size: clamp(7px, 1.9vw, 10px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: -0.12em;
  white-space: nowrap;
  overflow: hidden;
  pointer-events: none;
  text-shadow: 0 1px 3px rgba(0,0,0,0.8);
}
.cardUses {
  z-index: 6;
}
.cardPassiveMark,
.cardBasicMark,
.marketPriceBadge {
  z-index: 7;
}
.marketList .cardNameBadge {
  font-size: clamp(6px, 1.45vw, 9px);
}
.marketList .cardRarityBadge {
  font-size: clamp(6px, 1.65vw, 9px);
}
.dragGhost .cardNameBadge,
.dragGhost .cardRarityBadge {
  opacity: 0.92;
}


/* R53.13.52: ★は裸表示。R53.13.56でカード比率指定は撤回。 */
.cardRarityBadge {
  border: 0 !important;
  background: transparent !important;
  padding: 0 !important;
  color: #f3dfa3;
  text-shadow:
    0 1px 2px rgba(0,0,0,0.95),
    0 0 5px rgba(244,213,130,0.30);
  box-shadow: none !important;
}


/* R53.13.73: 固定9:16座標空間を保ったまま、所持カード欄の実セルを共通カード規格にする。
   最低118px固定を廃止し、カード欄からはみ出して下端が切れる問題を根本解消する。
   実セル寸法はapp.jsが計測して同じ変数へ反映し、販売・入手・受け渡し・ガチャ・詳細・ドラッグ表示も同寸法に揃える。 */
:root {
  --pc-owned-card-slot-w: calc(var(--gameW) * 0.185);
  --pc-owned-card-slot-h: calc(var(--gameW) * 0.250);
  --pc-market-price-h: clamp(14px, 3.2vw, 18px);
  --pc-market-price-gap: 2px;
  --pc-card-grid-gap: calc(var(--gameW) * 0.0125);
}

.cardList {
  align-items: stretch !important;
  grid-template-rows: minmax(0, 1fr) !important;
  grid-auto-rows: minmax(0, 1fr) !important;
}
.cardList .card {
  width: 100% !important;
  height: 100% !important;
  min-height: 0 !important;
  aspect-ratio: auto !important;
  align-self: stretch !important;
}

/* R53.13.74: 販売・入手・受け渡し・ガチャも、所持カードの実測幅・高さ・列間隔をそのまま使う。
   市場枠固有の狭い列幅へ押し込んで縦長に見える問題を解消する。 */
.marketPanel {
  left: 0 !important;
  right: 0 !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
.marketHeader {
  padding-left: 6px;
  padding-right: 6px;
}
.marketList {
  align-items: start !important;
  grid-template-columns: repeat(5, var(--pc-owned-card-slot-w)) !important;
  column-gap: var(--pc-card-grid-gap) !important;
  row-gap: 5px !important;
  justify-content: center !important;
  grid-auto-rows: calc(var(--pc-owned-card-slot-h) + var(--pc-market-price-h) + var(--pc-market-price-gap)) !important;
  min-height: calc(var(--pc-owned-card-slot-h) + var(--pc-market-price-h) + var(--pc-market-price-gap)) !important;
  overflow: visible !important;
}
.marketList .card,
.marketList .marketCard {
  width: var(--pc-owned-card-slot-w) !important;
  height: var(--pc-owned-card-slot-h) !important;
  min-width: var(--pc-owned-card-slot-w) !important;
  min-height: var(--pc-owned-card-slot-h) !important;
  aspect-ratio: auto !important;
  align-self: start !important;
  overflow: visible !important;
}

.cardInfoArt {
  height: calc(var(--pc-owned-card-slot-h) + 22px) !important;
}
.cardInfoArt .card {
  width: var(--pc-owned-card-slot-w) !important;
  height: var(--pc-owned-card-slot-h) !important;
  min-height: var(--pc-owned-card-slot-h) !important;
  aspect-ratio: auto !important;
}

.dragGhost {
  width: var(--pc-owned-card-slot-w) !important;
  height: var(--pc-owned-card-slot-h) !important;
}



/* R53.13.73: PCのブラウザ幅ではなく固定9:16ゲーム枠を基準にカード周辺UIを拡縮する。 */
@supports (font-size: 1cqw) {
  .game .actorInfo { font-size: clamp(11px, 2.9cqw, 14px); }
  .game .cardPageButton { font-size: clamp(12px, 3.4cqw, 16px); }
  .game .cardPageLabel { font-size: clamp(10px, 2.6cqw, 12px); }
  .game .card { padding: clamp(4px, 1.1cqw, 7px); }
  .game .cardUses { font-size: clamp(9px, 2.5cqw, 12px); }
  .game .cardPassiveMark { font-size: clamp(10px, 2.6cqw, 13px); }
  .game .cardBasicMark { font-size: clamp(8px, 2.1cqw, 11px); }
  .game .marketList .cardNameBadge { font-size: clamp(6px, 1.45cqw, 9px); }
  .game .marketList .cardRarityBadge { font-size: clamp(6px, 1.65cqw, 9px); }
}
