/*  */
* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;

  color: #fff4d6;
  background: #0b1022;

  font-family:
    Georgia,
    "Times New Roman",
    "Yu Mincho",
    "Hiragino Mincho ProN",
    serif;
}

button {
  font: inherit;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid #fff4d6;
  outline-offset: 4px;
}

/* 隱ｭ縺ｿ荳翫￡逕ｨ縺ｮ隕句�縺� */
.visually-hidden {
  position: absolute;

  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;

  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

/* 蜈ｱ騾壹�隕句�縺� */
.screen-heading {
  margin: 0;
  text-align: center;

  font-size: clamp(22px, 5vw, 36px);
  font-weight: normal;
  line-height: 1.4;

  text-shadow: 0 2px 8px #0008;
}

.screen-heading:focus {
  outline: none;
}

/* 繝｡繝九Η繝ｼ繝懊ち繝ｳ */
.menu-button {
  width: min(320px, 100%);
  min-height: 48px;
  padding: 12px 18px;

  border: 1px solid #dfbd77;
  border-radius: 10px;

  color: #fff0c5;
  background: linear-gradient(#27334fee, #111a30f5);

  font-size: 17px;
  font-weight: bold;
  text-align: center;

  text-shadow: 0 1px 3px #000;
  box-shadow: 0 3px 12px #0008;

  transition:
    transform 0.15s,
    filter 0.15s;
}

.menu-button-primary {
  background: linear-gradient(#a8274bee, #65142ff5);
}

.menu-button:hover {
  filter: brightness(1.15);
  transform: translateY(-2px);
}

.menu-button:active {
  transform: translateY(0);
}

/* 繧ｿ繧､繝医Ν縺ｸ謌ｻ繧九�繧ｿ繝ｳ */
.text-button {
  width: auto;
  min-height: 36px;
  padding: 6px 12px;

  border-color: transparent;
  background: transparent;
  box-shadow: none;

  color: #dfcfaa;
  font-size: 14px;
  font-weight: normal;
}

/* 險隱槫�繧頑崛縺� */
.language-controls {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.language-button {
  min-width: 86px;
  padding: 8px 14px;

  border: 1px solid #c7a566;
  border-radius: 999px;

  color: #fff4d6;
  background: #10172eef;

  font-family: sans-serif;
  font-size: 14px;

  box-shadow: 0 2px 8px #0006;
}

.language-button[aria-pressed="true"] {
  color: #24192b;
  background: #ecd7a0;
}

.language-button:hover {
  border-color: #fff0bb;
}

/* 繧ｿ繧､繝医Ν逕ｻ髱｢�夂判蜒上→髢句ｧ区｡亥�繧貞酔縺俶棧縺ｫ蜿弱ａ繧� */
.app-title {
  min-height: 100vh;
  min-height: 100svh;
}

.intro-screen {
  width: 100%;
  background: #0b1022;
}

/* 隕九◆逶ｮ縺ｯ逕ｻ蜒上□縺後∫判髱｢蜈ｨ菴薙ｒ髢句ｧ九�繧ｿ繝ｳ縺ｨ縺励※謫堺ｽ懊〒縺阪ｋ */
.intro-start {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100vh;
  height: 100svh;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  -webkit-appearance: none;
  appearance: none;
  color: #fff4d6;
  background: #0b1022;
}

/* 01_start.webp 縺ｮ邵ｦ讓ｪ豈斐るｫ倥＆繝ｻ蟷��荳｡譁ｹ縺ｧ逕ｻ髱｢蜀�↓蜿弱ａ繧� */
.intro-stage {
  position: relative;
  display: block;
  width: min(100%, 177.68vh);
  width: min(100%, 177.68svh);
  aspect-ratio: 1672 / 941;
  container-type: inline-size;
}

.intro-image {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-select: none;
  user-select: none;
}

.intro-prompt {
  position: absolute;
  left: 50%;
  bottom: 8%;
  transform: translateX(-50%);
  width: 94%;
  font-family: -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: clamp(12px, 2.8cqw, 34px);
  font-weight: bold;
  line-height: 1.4;
  letter-spacing: 0.04em;
  text-align: center;
  white-space: nowrap;
  color: #fff4d6;
  text-shadow: 0 2px 4px #000, 0 0 12px #000;
  pointer-events: none;
}

.intro-start:focus-visible {
  outline: 3px solid #fff4d6;
  outline-offset: -6px;
}

/* 繝｡繧､繝ｳ繝｡繝九Η繝ｼ逕ｻ髱｢ */
.app-menu {
  min-height: 100vh;
  min-height: 100svh;

  background:
    linear-gradient(#080e2280, #080e22b3),
    url("images/01_start.webp") center / contain no-repeat;

  background-color: #0b1022;
}

.main-menu-screen {
  min-height: 100vh;
  min-height: 100svh;
  padding: 24px 16px;

  display: grid;
  place-items: center;
}

.main-menu-panel {
  width: min(380px, 100%);
  padding: 30px 24px 20px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;

  border: 1px solid #c7a566;
  border-radius: 18px;

  background: #0c1429eb;
  box-shadow: 0 12px 40px #0008;

  -webkit-backdrop-filter: blur(6px);
  backdrop-filter: blur(6px);
}

.main-menu-panel .screen-heading {
  font-size: clamp(22px, 4vw, 28px);
}

.menu-stack {
  width: 100%;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

.menu-stack .menu-button {
  width: 100%;
}

/* 繧ｫ繝ｼ繝我ｸ隕ｧ繝ｻ繝ｫ繝ｼ繝ｫ隱ｬ譏弱↑縺ｩ */
.app-content {
  min-height: 100vh;
  padding: 24px 16px 48px;

  background:
    radial-gradient(
      ellipse at top,
      #303653,
      #111527 70%
    );
}

.content-screen {
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.screen-message {
  margin: 12px 0;

  text-align: center;
  line-height: 1.8;
}

/* 繝ｫ繝ｼ繝ｫ隱ｬ譏� */
.rules-panel {
  width: min(680px, 100%);
  padding: clamp(20px, 4vw, 32px);

  border: 1px solid #b89552;
  border-radius: 14px;

  background: #11192de6;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    sans-serif;
}

.rule-section + .rule-section {
  margin-top: 24px;
  padding-top: 20px;

  border-top: 1px solid #c7a56644;
}

.rule-section h2 {
  margin: 0 0 8px;

  color: #ecd7a0;
  font-size: 20px;
}

.rule-section p {
  margin: 0;

  color: #f0eadb;

  font-size: 18px;
  font-weight: 400;
  line-height: 1.9;

  overflow-wrap: anywhere;
  white-space: pre-line;
}

.card-list {
  width: 100%;

  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  justify-items: center;
  gap: 20px;
}

/* 繧ｫ繝ｼ繝峨�蝨溷床 */
.card {
  position: relative;

  width: min(380px, 100%);
  aspect-ratio: 3 / 4;

  isolation: isolate;
  container-type: inline-size;
}

/* 繧ｫ繝ｼ繝峨�繧､繝ｩ繧ｹ繝� */
.card-art {
  position: absolute;
  z-index: 0;

  left: 8%;
  top: 14%;
  width: 84%;
  height: 57%;

  object-fit: cover;
  object-position: center top;
}

/* 繧ｫ繝ｼ繝峨�譫� */
.card-frame {
  position: absolute;
  z-index: 1;

  inset: 0;
  width: 100%;
  height: 100%;

  pointer-events: none;
}

/* 蟾ｦ荳翫�遞ｮ鬘槭�繝ｼ繧ｯ */
.type-icon {
  position: absolute;
  z-index: 2;

  left: 14%;
  top: 6.1%;
  width: 7%;
  height: 5.25%;

  object-fit: contain;
}

/* 荳贋ｸｭ螟ｮ縺ｮ遞ｮ鬘槫錐 */
.card-header {
  position: absolute;
  z-index: 2;

  left: 25%;
  top: 5.15%;
  width: 50%;
  height: 7%;

  display: flex;
  align-items: center;
  justify-content: center;

  color: #ffe9aa;

  font-size: 6.5cqw;
  font-weight: bold;
  letter-spacing: 0.06em;

  text-shadow: 0 2px 3px #300;
}

/* 蜿ｳ荳翫�繧ｹ繝ｼ繝医�繝ｼ繧ｯ */
.suit-icon {
  position: absolute;
  z-index: 2;

  right: 13.25%;
  top: 5.55%;
  width: 8.5%;
  height: 6.375%;

  object-fit: contain;
}

/* 繧ｫ繝ｼ繝我ｸ矩Κ縺ｮ譁�ｭ励お繝ｪ繧｢ */
.card-text {
  position: absolute;
  z-index: 2;

  left: 14%;
  top: 72.2%;
  width: 72%;
  height: 17%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;

  color: #410b14;
  text-align: center;
}

.card-text h2 {
  margin: 0;

  font-size: 5.6cqw;
  line-height: 1.1;
}

.character-name {
  margin: 0.8cqw 0 1cqw;

  font-size: 3.5cqw;
  line-height: 1.2;
}

.card-rule {
  margin: 0;

  color: #211912;
  font-size: 3.3cqw;
  line-height: 1.3;
}

/* 繧ｭ繝｣繝ｩ繧ｯ繧ｿ繝ｼ驕ｸ謚� */
.character-list {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 16px;
}

.character-choice {
  min-width: 0;
  padding: 0 0 16px;
  overflow: hidden;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;

  border: 1px solid #c7a566;
  border-radius: 14px;

  color: #fff4d6;
  background: #11192d;
}

.character-choice:hover {
  border-color: #fff0bb;
  background: #202b43;
}

.character-portrait {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 4;
  object-fit: cover;
  object-position: center top;
}

.character-choice-name {
  padding: 0 8px;
  font-size: 18px;
  font-weight: bold;
}

.character-choice-style {
  font-family: sans-serif;
  font-size: 14px;
  color: #ecd7a0;
}

@media (pointer: coarse) and (max-width: 1000px)
  and (max-height: 500px) and (orientation: landscape) {

  /* キャラ選択：見出し・操作を残し、一覧だけスクロール */
  .app-character-select {
  height: 100vh;
  height: 100svh;
  min-height: 0;

  padding:
    max(12px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    max(12px, env(safe-area-inset-bottom))
    max(12px, env(safe-area-inset-left));
  }

  .app-character-select .content-screen {
    height: 100%;
    min-height: 0;

    display: grid;
    grid-template-rows: auto auto auto minmax(0, 1fr) auto;
    justify-items: center;
    align-items: center;
    gap: 10px;
  }

  .app-character-select .screen-heading {
    font-size: clamp(20px, 3vw, 30px);
  }

  .app-character-select .screen-message {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
  }

  .app-character-select .character-list {
    height: 100%;
    min-height: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;

    align-content: start;
    align-items: start;
    gap: 12px;
    padding: 6px;
  }

  /* 画像領域をイラストで埋める */
  .app-character-select .character-portrait {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    aspect-ratio: auto;

    object-fit: cover;
    object-position: center top;
  }

  /* 名前・タイプの領域を残す */
  .app-character-select .character-choice {
    height: 100%;
    min-height: 0;
    width: 100%;
    box-sizing: border-box;

    padding: 0 0 6px;
    overflow: hidden;

    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    justify-items: center;
    gap: 4px;
  }

  .app-character-select .character-choice-name,
  .app-character-select .character-choice-style {
    max-width: 100%;
    padding-inline: 6px;
    overflow-wrap: anywhere;
  }

  .app-character-select .character-choice-name {
    font-size: 16px;
  }

  .app-character-select .character-choice-style {
    font-size: 13px;
  }
}

/* 蟇ｾ謌ｦ逕ｻ髱｢ */
.app-battle {
  min-height: 100vh;
  min-height: 100svh;

  background: #080e1c;
}

.battle-screen {
  min-height: 100vh;
  min-height: 100svh;

  display: grid;
  place-items: center;
}

/* 讓ｪ髟ｷ縺ｮ逶､髱｢繧堤判髱｢蜀�↓蜿弱ａ繧� */
.battle-board {
  position: relative;

  width: min(100%, 177.78vh);
  width: min(100%, 177.78svh);
  aspect-ratio: 16 / 9;

  overflow: hidden;
  isolation: isolate;
  container-type: inline-size;

  border: 1px solid #b89552;

  color: #fff4d6;
  background:
    radial-gradient(
      ellipse at center,
      #24324d55,
      transparent 65%
    ),
    radial-gradient(
      ellipse at top left,
      #263656,
      #0b1428 65%
    );

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    sans-serif;
}

/* 蜀��縺ｮ鬟ｾ繧頑棧 */
.battle-board::before {
  content: "";

  position: absolute;
  z-index: -1;
  inset: 1%;

  border: 1px solid #c7a56666;
  border-radius: 12px;

  pointer-events: none;
}

/* 繧ｭ繝｣繝ｩ繧ｯ繧ｿ繝ｼ縺ｨ繝ｩ繧､繝� */
.battle-profile {
  position: absolute;

  width: 29%;
  height: 22%;

  display: flex;
  align-items: center;
  gap: 4%;
}

.battle-profile-cpu {
  top: 3%;
  left: 35%;
}

.battle-profile-player {
  bottom: 3%;
  left: 25%;
}

.battle-portrait {
  display: block;

  width: 42%;
  aspect-ratio: 1;

  object-fit: cover;
  object-position: center 5%;

  border: 2px solid #d6b56e;
  border-radius: 50%;

  background: #15213a;
}

.battle-profile-details {
  flex: 1;
  min-width: 0;
}

.battle-character-name {
  margin: 0 0 8%;

  color: #fff4d6;
  font-size: 1.5cqw;
  line-height: 1.4;
}

.battle-life {
  margin: 0;

  display: flex;
  align-items: center;
  gap: 12%;

  color: #ecd7a0;
  font-size: 1.4cqw;
}

.battle-life strong {
  min-width: 1.6em;

  border: 1px solid #dfbd77;
  border-radius: 8px;

  color: #fff4d6;
  background: #771d39;

  font-size: 3.4cqw;
  font-weight: 600;
  line-height: 1.3;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.battle-profile-cpu .battle-life strong {
  background: #203f75;
}

/* CPU縺ｮ謇区惆 */
.battle-opponent-hand {
  position: absolute;
  top: 4%;
  left: 3%;

  width: 29%;
  height: 25%;

  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 3%;
}

.battle-opponent-hand > .battle-card-back {
  min-width: 0;
  max-width: 30%;
  max-height: 100%;
  flex: 0 1 30%;

  object-fit: contain;
}

/* 螻ｱ譛ｭ繝ｻ謐ｨ縺ｦ譛ｭ */
.battle-piles {
  position: absolute;

  width: 19%;
  height: 28%;

  display: flex;
  justify-content: center;
  gap: 12%;
}

.battle-piles-cpu {
  top: 22%;
  right: 3%;
}

.battle-piles-player {
  bottom: 4%;
  left: 3%;
}

.battle-pile {
  width: 44%;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3%;
}

.battle-pile-visual {
  width: 100%;
  aspect-ratio: 3 / 4;

  border: 1px solid #c7a56688;
  border-radius: 6px;

  background: #0b1226;
}

.battle-pile-visual.is-empty {
  border-style: dashed;
  background: #0b122655;
}

.battle-card-back {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.battle-pile-visual > .card {
  width: 100%;
}

.battle-pile-label {
  max-width: 100%;
  font-size: 1.3cqw;
  line-height: 1.3;
  text-align: center;
  overflow-wrap: anywhere;
}

.battle-pile-count {
  font-size: 2.2cqw;
  line-height: 1.1;
  font-variant-numeric: tabular-nums;
}

/* 荳ｭ螟ｮ縺ｮ蝣ｴ */
.battle-fields {
  position: absolute;
  top: 26%;
  left: 38%;

  width: 22%;
  height: 47%;

  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}

.battle-field {
  width: 100%;
  height: 48%;

  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8%;
}

.battle-field-label {
  width: 40%;
  margin: 0;

  color: #ecd7a0;
  font-size: 1.4cqw;
  font-weight: 400;
  text-align: right;
}

.battle-field-slot {
  height: 100%;
  aspect-ratio: 3 / 4;

  border: 1px solid #c7a56699;
  border-radius: 8px;

  background: #080e2277;
  box-shadow: inset 0 0 20px #0004;
}

/* 閾ｪ蛻��謇区惆 */
.battle-player-hand {
  position: absolute;
  right: 3%;
  bottom: 4%;

  width: 40%;
  height: 29%;

  display: flex;
  align-items: flex-end;
  justify-content: flex-end;
  gap: 2%;
}

/* 謇区惆1譫壹＃縺ｨ縺ｮ謫堺ｽ憺�伜沺 */
.battle-hand-card {
  position: relative;

  width: 28%;
  min-width: 0;
  flex: 0 0 28%;

  border-radius: 8px;

  cursor: pointer;
  touch-action: manipulation;

  transition:
    transform 0.15s,
    filter 0.15s;
}

.battle-hand-card > .card {
  width: 100%;
  pointer-events: none;
}

.battle-hand-card:focus-visible {
  outline: 3px solid #fff4d6;
  outline-offset: 4px;
}

.battle-hand-card.is-locked {
  cursor: default;
}

/* 手札の拡大表示 */
.battle-hover-preview {
  position: fixed;
  z-index: 100;

  top: 50%;
  left: 24%;
  transform: translate(-50%, -50%);

  width: min(300px, 38vw, 65vh);
  width: min(300px, 38vw, 65svh);

  pointer-events: none;
  filter: drop-shadow(0 8px 16px #000b);
}

.battle-hover-preview > .card {
  width: 100%;
}

.battle-hover-preview[hidden] {
  display: none;
}

/* 繧ｫ繝ｼ繝臥｢ｺ隱咲判髱｢ */
.card-preview-dialog {
  width: min(380px, calc(100% - 24px));

  max-height: calc(100vh - 24px);
  max-height: calc(100svh - 24px);

  padding: 0;
  overflow: auto;

  border: 1px solid #c7a566;
  border-radius: 16px;

  color: #fff4d6;
  background: #0c1429;
  box-shadow: 0 12px 40px #0008;
}

.card-preview-dialog::backdrop {
  background: #030817c9;
}

.card-preview-panel {
  padding: 20px;

  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.card-preview-panel .screen-heading {
  font-size: 22px;
}

.card-preview-panel > .card {
  width: min(270px, 100%);
}

.card-preview-panel .menu-button {
  width: 100%;
  min-height: 48px;
}

/* 蝣ｴ縺ｫ繧ｻ繝�ヨ縺輔ｌ縺溘き繝ｼ繝� */
.battle-field-slot.has-card {
  border-color: #dfbd77;
  background: #10192d;
}

.battle-field-slot:focus {
  outline: 2px solid #fff4d6;
  outline-offset: 3px;
}

/* 繧ｿ繝ｼ繝ｳ繝ｻ迥ｶ豕∬｡ｨ遉ｺ */
.battle-turn {
  position: absolute;
  top: 4%;
  right: 4%;

  margin: 0;
  color: #ecd7a0;
  font-size: 1.6cqw;
  font-variant-numeric: tabular-nums;
}

/* 迥ｶ豕∬ｪｬ譏弱→謫堺ｽ懊�繧ｿ繝ｳ縺ｮ蜈ｱ騾壹お繝ｪ繧｢ */
.battle-status {
  position: absolute;

  top: 34%;
  bottom: 34%;
  left: 3%;
  width: 28%;

  overflow: auto;
}

/* 迥ｶ豕∬ｪｬ譏� */
.battle-message {
  margin: 0 0 12px;

  color: #ecd7a0;
  font-size: 1.4cqw;
  line-height: 1.7;
  text-align: center;
  white-space: pre-line;
  overflow-wrap: anywhere;
}

/* 繝｡繝九Η繝ｼ繝懊ち繝ｳ */
.battle-menu-trigger {
  position: absolute;
  top: 10%;
  right: 3%;

  width: 16%;
  min-height: 0;
  padding: 0.6em;

  font-size: 1.5cqw;
}

/* 蟇ｾ謌ｦ荳ｭ縺ｮ繝｡繝九Η繝ｼ */
.battle-menu-dialog {
  width: min(380px, calc(100% - 32px));
  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);

  padding: 0;
  overflow: auto;

  border: 0;

  color: #fff4d6;
  background: transparent;
}

.battle-menu-dialog::backdrop {
  background: #030817b3;
}

.battle-menu-dialog .main-menu-panel {
  width: 100%;
}

/* 蜈ｬ髢九＆繧後◆繧ｫ繝ｼ繝� */
.battle-field-slot > .card {
  width: 100%;
}

.battle-field-slot.is-revealed {
  background: transparent;
}

/* 謫堺ｽ懊�繧ｿ繝ｳ縺ｯ譁�ｫ�縺ｮ荳九∈荳ｦ縺ｹ繧� */
.battle-actions {
  width: 100%;

  display: flex;
  flex-direction: column;
  gap: 10px;
}

.battle-actions .menu-button {
  width: 100%;
  min-height: 44px;

  padding: 10px 12px;
  font-size: clamp(12px, 1.5cqw, 18px);
}

/* 謐ｨ縺ｦ譛ｭ繧呈款縺帙ｋ縺薙→縺後ｏ縺九ｋ隕九◆逶ｮ */
.battle-discard-trigger {
  cursor: pointer;
  touch-action: manipulation;
}

.battle-discard-trigger:focus-visible {
  outline: 3px solid #fff4d6;
  outline-offset: 5px;
  border-radius: 6px;
}

/* 謐ｨ縺ｦ譛ｭ荳隕ｧ */
.discard-dialog {
  width: min(1000px, calc(100% - 32px));

  height: min(760px, calc(100vh - 32px));
  height: min(760px, calc(100svh - 32px));

  max-height: calc(100vh - 32px);
  max-height: calc(100svh - 32px);

  margin: auto;
  padding: 0;
  overflow: hidden;

  border: 1px solid #c7a566;
  border-radius: 16px;

  color: #fff4d6;
  background: #0c1429;
  box-shadow: 0 12px 40px #0008;
}

.discard-dialog::backdrop {
  background: #030817c9;
}

.discard-panel {
  height: 100%;
  min-height: 0;
  padding: clamp(10px, 2vw, 20px);

  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  justify-items: center;
  gap: 10px;
}

.discard-body {
  width: 100%;
  min-width: 0;
  min-height: 0;
  overflow: auto;

  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;

  /* カードの枠やフォーカス表示用の余白 */
  padding: 4px;
}

.discard-body .discard-description {
  margin-bottom: 12px;
}

.discard-panel .screen-heading {
  font-size: clamp(22px, 4vw, 30px);
}

.discard-summary,
.discard-description {
  margin: 0;

  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    sans-serif;

  text-align: center;
  line-height: 1.7;
}

.discard-summary {
  color: #ecd7a0;
  font-size: 16px;
  font-variant-numeric: tabular-nums;
}

.discard-description {
  color: #d6d9e2;
  font-size: 14px;
}

/* 捨て札のカード一覧。スクロールは .discard-body で行う */
.discard-card-grid {
  width: 100%;
  margin: 0;
  padding: 0;

  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 20px;

  list-style: none;
}

.discard-card-item {
  min-width: 0;

  display: flex;
  justify-content: center;
}

.discard-card-item > .card {
  width: min(280px, 100%);
}

.discard-panel > .menu-button {
  min-height: 48px;
}

/* 逕ｻ髱｢蟷��蜈･蜉帶婿豕輔↓蜷医ｏ縺帙◆隱ｿ謨ｴ */

@media (max-width: 800px) {
  .card-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 700px) {
  .discard-card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
}

@media (max-width: 500px) {
  .card-list {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 420px) {
  .discard-card-grid {
    grid-template-columns: 1fr;
  }
}

@media (pointer: coarse) {
  .language-button {
    min-width: 100px;
    min-height: 48px;
    padding: 10px 16px;

    font-size: 16px;
  }

  .language-controls {
    gap: 12px;
  }

  .text-button {
    min-height: 48px;
    padding: 12px 18px;

    font-size: 17px;
  }

  .battle-menu-trigger {
    min-width: 88px;
    min-height: 44px;
    font-size: 14px;
  }
}

@media (hover: hover) and (pointer: fine) {
  .battle-hand-card:not(.is-locked):hover {
    transform: translateY(-8%);
    filter: brightness(1.1);
  }
}

@media (hover: hover) {
  .battle-discard-trigger:hover .battle-pile-visual {
    border-color: #fff0bb;
    filter: brightness(1.15);
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  /* 繝｡繧､繝ｳ繝｡繝九Η繝ｼ縺ｮ螟門� */
  .main-menu-screen {
    min-height: 100vh;
    min-height: 100svh;
    padding: 12px;
  }

  /* 繝｡繝九Η繝ｼ繧貞ｷｦ蜿ｳ2蛻励↓縺吶ｋ */
  .main-menu-panel {
    width: min(620px, 100%);
    padding: 12px 16px;

    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 12px 20px;
  }

  .main-menu-panel > .screen-heading {
    grid-column: 1 / -1;
    font-size: 20px;
    line-height: 1.3;
  }

  /* 蟾ｦ蛛ｴ�壹ご繝ｼ繝�繧ｹ繧ｿ繝ｼ繝医↑縺ｩ */
  .main-menu-panel > .menu-stack {
    grid-column: 1;
    grid-row: 2 / 4;
    gap: 8px;
  }

  /* 蜿ｳ蛛ｴ�壽綾繧九�繧ｿ繝ｳ縲√∪縺溘�BGM繝懊ち繝ｳ */
  .main-menu-panel > .menu-button {
    grid-column: 2;
    grid-row: 2;
    width: 100%;
  }

  /* 蜿ｳ蛛ｴ�夊ｨ隱槫�繧頑崛縺� */
  .main-menu-panel > .language-controls {
    grid-column: 2;
    grid-row: 3;
    flex-wrap: wrap;
    gap: 8px;
  }

  .main-menu-panel .menu-button,
  .card-preview-panel .menu-button {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 15px;
  }

  .main-menu-panel .language-button {
    min-width: 80px;
    min-height: 44px;
    padding: 8px 12px;
    font-size: 14px;
  }

  /* 蟇ｾ謌ｦ荳ｭ縺ｮ繧ｲ繝ｼ繝�繝｡繝九Η繝ｼ */
  .battle-menu-dialog {
    width: min(620px, calc(100% - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100svh - 24px);
  }

  /* 繧ｫ繝ｼ繝臥｢ｺ隱咲判髱｢ */
  .card-preview-dialog {
    width: min(620px, calc(100% - 24px));
    max-height: calc(100vh - 24px);
    max-height: calc(100svh - 24px);
  }

  .card-preview-panel {
    padding: 12px;

    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    justify-items: center;
    gap: 10px 20px;
  }

  .card-preview-panel > .screen-heading {
    grid-column: 1 / -1;
    font-size: 18px;
    line-height: 1.3;
  }

  /* 鬮倥＆縺ｫ蜷医ｏ縺帙※繧ｫ繝ｼ繝峨ｒ邵ｮ繧√ｋ */
  .card-preview-panel > .card {
    grid-column: 1;
    grid-row: 2;

    width: min(190px, calc((100svh - 90px) * 0.75));
    max-width: 100%;
  }

  /* 繧ｫ繝ｼ繝峨�蜿ｳ縺ｫ繧ｻ繝�ヨ繝ｻ謌ｻ繧九�繧ｿ繝ｳ */
  .card-preview-panel > .menu-stack {
    grid-column: 2;
    grid-row: 2;

    width: 100%;
    gap: 12px;
  }

  /* 蟇ｾ謌ｦ荳ｭ縺ｮ繝｡繝九Η繝ｼ繧貞ｱｱ譛ｭ繧医ｊ荳翫∈ */
  .battle-menu-trigger {
    top: 4%;
    right: 3%;

    min-width: 88px;
    min-height: 44px;
    padding: 6px 10px;
    font-size: 14px;
  }

  /* 繧ｿ繝ｼ繝ｳ陦ｨ遉ｺ縺ｯ繝｡繝九Η繝ｼ繝懊ち繝ｳ縺ｮ蟾ｦ縺ｸ */
  .battle-turn {
    top: 5%;
    right: 23%;
  }

  @media (pointer: coarse) and (max-width: 1000px) {
      /* キャラ選択：見出しと言語ボタンを横並びにする */
    .app-character-select .content-screen {
      grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
      grid-template-rows: auto auto minmax(0, 1fr) auto;
      gap: 8px;
    }
  }

  .app-character-select .screen-heading {
    grid-column: 1;
    grid-row: 1;
    font-size: 20px;
    line-height: 1.2;
  }

  .app-character-select .language-controls {
    grid-column: 2;
    grid-row: 1;
    gap: 8px;
  }

  .app-character-select .language-button {
    min-width: 80px;
    min-height: 44px;
    padding: 6px 12px;
    font-size: 14px;
  }

  .app-character-select .screen-message {
    grid-column: 1 / -1;
    grid-row: 2;
    font-size: 13px;
  }

  .app-character-select .character-list {
    grid-column: 1 / -1;
    grid-row: 3;

    grid-template-columns: repeat(4, minmax(0, 1fr));
    grid-auto-rows: 100%;
    gap: 8px;
  }

  /* 各キャラの枠内で、名前を残して画像の高さを調整 */
  .app-character-select .character-choice {
    height: 100%;
    min-height: 0;
    width: 100%;
    padding: 0 0 6px;

    display: grid;
    grid-template-rows: minmax(0, 1fr) auto auto;
    justify-items: center;
    gap: 4px;
  }

  .app-character-select .character-portrait {
    display: block;
    width: 100%;
    height: 100%;
    min-height: 0;
    max-height: none;
    aspect-ratio: auto;
    object-fit: cover;
    object-position: center top;
  }

  .app-character-select .character-choice-name {
    font-size: 14px;
    line-height: 1.2;
  }

  .app-character-select .character-choice-style {
    font-size: 12px;
    line-height: 1.2;
  }

  .app-character-select .content-screen > .menu-button {
    grid-column: 1 / -1;
    grid-row: 4;
    min-height: 44px;
    padding: 6px 12px;
    font-size: 15px;
  }

  /* 捨て札：見出しなどを小さくし、カード用の高さを確保 */
  .discard-panel {
    padding: 10px;
    gap: 8px;
  }

  .discard-panel .screen-heading {
    font-size: 20px;
    line-height: 1.2;
  }

  .discard-summary {
    font-size: 13px;
    line-height: 1.4;
  }

  .discard-body .discard-description {
    display: none;
  }

  /* 横向きでは、カード全体を確認しやすいサイズにする */
  .discard-card-item > .card {
    width: min(180px, max(48px, calc((100svh - 172px) * 0.75)));
    max-width: 100%;
  }

  .discard-card-grid {
    gap: 10px;
  }

  .discard-panel > .menu-button {
    min-height: 44px;
    padding: 6px 12px;
    font-size: 15px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .menu-button,
  .battle-hand-card {
    transition: none;
  }
}

/* スマホ縦向き時の案内 */
.rotate-guide {
  position: fixed;
  inset: 0;

  width: 100%;
  max-width: none;
  height: 100vh;
  height: 100svh;
  max-height: none;

  margin: 0;
  padding: 24px;
  overflow: auto;
  border: 0;

  color: #fff4d6;
  background: #0b1022;
  text-align: center;
  font-family: sans-serif;
}

.rotate-guide[open] {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 20px;
}

.rotate-guide h2 {
  margin: 0;
  font-size: clamp(16px, 4.5vw, 22px);
  line-height: 1.5;
}

.rotate-guide h2:focus {
  outline: none;
}

.rotate-guide p {
  margin: 0;
  color: #dfcfaa;
  font-size: 16px;
  line-height: 1.6;
}

.rotate-guide::backdrop {
  background: #0b1022;
}

/* 長押し時の文字選択・画像メニューを抑える */
.battle-hand-card {
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.battle-hand-card img {
  -webkit-user-drag: none;
}

.battle-field-slot.is-revealed:focus-visible {
  outline: 3px solid #fff4d6;
  outline-offset: 4px;
}

/* 公開済みの場のカード：操作は外側の枠で受け取る */
.battle-field-slot.is-revealed {
  cursor: zoom-in;
  touch-action: manipulation;
  pointer-events: auto;
}

/* 枠とその中身で、Safariの長押しメニュー・選択を抑える */
.battle-field-slot.is-revealed,
.battle-field-slot.is-revealed * {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

/* 画像や文字に触れても、外側の枠で長押しを判定する */
.battle-field-slot.is-revealed * {
  pointer-events: none;
}

.battle-field-slot.is-revealed img {
  -webkit-user-drag: none;
}

.battle-field-slot.is-revealed:focus-visible {
  outline: 3px solid #fff4d6;
  outline-offset: 4px;
}

/* 対戦中のデッキ構成一覧 */
.battle-menu-dialog:has(.deck-composition-panel) {
  width: min(1000px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100svh - 24px);
}

.deck-composition-panel {
  width: 100%;
  min-width: 0;
  box-sizing: border-box;
  padding: 24px;

  display: grid;
  justify-items: center;
  gap: 16px;

  color: #fff4d6;
  background: #0c1428;
  border: 2px solid #c7a566;
  border-radius: 20px;
}

.deck-composition-panel > .screen-heading {
  margin: 0;
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.2;
}

.deck-composition-panel > .screen-heading:focus {
  outline: none;
}

.deck-composition-description {
  margin: 0;
  text-align: center;
  font-size: 14px;
  line-height: 1.4;
}

.deck-composition-scroll {
  width: 100%;
  min-width: 0;
}

.deck-composition-table {
  width: 100%;
  table-layout: fixed;
  border-collapse: collapse;

  color: #fff4d6;
  font-size: clamp(13px, 1.8vw, 18px);
  line-height: 1.4;
}

/* キャラクター名の列を少し広くする */
.deck-composition-table tr > :first-child {
  width: 34%;
}

.deck-composition-table th,
.deck-composition-table td {
  box-sizing: border-box;
  padding: 12px 8px;
  border-bottom: 1px solid #c7a56666;
  text-align: center;
  white-space: normal;
  overflow-wrap: anywhere;
}

.deck-composition-table thead th {
  background: #172039;
  color: #ecd7a0;
}

.deck-composition-table tbody th {
  text-align: left;
}

.deck-composition-table td {
  font-weight: bold;
  font-variant-numeric: tabular-nums;
}

.deck-composition-panel > .menu-button {
  width: min(420px, 100%);
  min-height: 44px;
  margin: 0;
}

/* スマホ横向きなど、高さが少ない画面 */
@media (max-height: 500px) and (orientation: landscape) {
  .battle-menu-dialog:has(.deck-composition-panel) {
    width: min(1000px, calc(100% - 16px));
    max-height: calc(100svh - 16px);
  }

  .deck-composition-panel {
    padding: 10px 16px;
    gap: 6px;
    border-radius: 14px;
  }

  .deck-composition-panel > .screen-heading {
    font-size: 20px;
  }

  .deck-composition-description {
    font-size: 12px;
    line-height: 1.3;
  }

  .deck-composition-table {
    font-size: 13px;
    line-height: 1.25;
  }

  .deck-composition-table th,
  .deck-composition-table td {
    padding: 5px 6px;
  }

  .deck-composition-panel > .menu-button {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 14px;
  }
}

/* カード公開直後のバトル結果 */
.battle-round-result-dialog {
  width: min(720px, calc(100% - 24px));
  max-width: none;
  max-height: calc(100svh - 24px);
  box-sizing: border-box;
  padding: 0;
  overflow: auto;
  border: 2px solid #c7a566;
  border-radius: 20px;
  color: #fff4d6;
  background: #0c1428;
}

.battle-round-result-dialog::backdrop {
  background: #030817b3;
}

.battle-round-result-panel {
  padding: 24px;
  display: grid;
  gap: 16px;
  justify-items: center;
  text-align: center;
}

.battle-round-result-panel > h2,
.battle-round-result-panel > p {
  margin: 0;
}

.battle-round-result-panel > h2 {
  font-size: clamp(22px, 3vw, 30px);
}

.battle-round-result-matchup,
.battle-round-result-life {
  font-size: clamp(14px, 2vw, 20px);
  line-height: 1.5;
}

.battle-round-result-message {
  font-size: clamp(24px, 3.5vw, 36px);
  font-weight: bold;
  line-height: 1.45;
  white-space: pre-line;
}

.battle-round-result-panel[data-outcome="win"] .battle-round-result-message {
  color: #f4dc94;
}

.battle-round-result-panel[data-outcome="lose"] .battle-round-result-message {
  color: #ffb5bb;
}

.battle-round-result-actions {
  width: 100%;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

.battle-round-result-actions > .menu-button {
  flex: 1 1 200px;
  max-width: 360px;
  width: 100%;
  min-height: 44px;
  margin: 0;
}

@media (max-height: 500px) and (orientation: landscape) {
  .battle-round-result-panel {
    padding: 12px 16px;
    gap: 8px;
  }

  .battle-round-result-panel > h2 {
    font-size: 20px;
  }

  .battle-round-result-message {
    font-size: clamp(20px, 3vw, 28px);
    line-height: 1.3;
  }

  .battle-round-result-matchup,
  .battle-round-result-life {
    font-size: 13px;
  }

  .battle-round-result-actions > .menu-button {
    padding: 6px 12px;
    font-size: 14px;
  }
}

/* チュートリアルは表示可能な高さに合わせて、操作ボタンの領域を常に確保する。 */
.app-tutorial {
  padding: 8px max(8px, env(safe-area-inset-right)) 8px max(8px, env(safe-area-inset-left));
  min-height: 100svh;
}
.tutorial-screen {
  width: min(1080px, 100%); height: calc(100svh - 16px); min-height: 0; margin: auto;
  padding: 16px; border: 1px solid #dfbd77; border-radius: 18px;
  background: linear-gradient(135deg, #202e49, #0d1529);
  display: grid;
  grid-template: "top" auto "guide" 140px "content" minmax(0, 1fr) "actions" 48px / minmax(0, 1fr);
  gap: 12px;
}
.tutorial-top { grid-area: top; display: flex; align-items: center; gap: 10px; min-width: 0; }
.tutorial-top h1 { font-size: clamp(20px, 3vw, 28px); margin-right: auto; white-space: nowrap; }
.tutorial-top > .menu-button { width: auto; min-height: 40px; padding: 8px 12px; font-size: 14px; white-space: nowrap; }
.tutorial-top .language-controls { margin: 0; gap: 6px; flex-wrap: nowrap; }
.tutorial-top .language-button { padding: 7px 12px; min-height: 40px; font-size: 14px; }
.tutorial-progress { font-size: 14px; white-space: nowrap; }
.tutorial-guide { grid-area: guide; min-width: 0; min-height: 0; display: flex; align-items: center; gap: 16px; padding: 12px 16px; background: #0b1229d9; border-radius: 12px; }
.tutorial-portrait { width: 64px; height: 64px; object-fit: cover; object-position: top; border-radius: 50%; border: 2px solid #dfbd77; flex-shrink: 0; }
.tutorial-speech { min-width: 0; max-height: 100%; overflow: auto; font-size: clamp(15px, 2vw, 20px); line-height: 1.5; }
.tutorial-speech strong { color: #edcb86; font-size: .85em; }
.tutorial-speech p { margin: 4px 0 0; }
.tutorial-content { grid-area: content; min-height: 0; min-width: 0; container-type: size; display: grid; align-items: center; }
.tutorial-goal, .tutorial-extra { margin: auto; max-width: 760px; max-height: 100%; overflow: auto; font-size: clamp(17px, 2.5vw, 24px); line-height: 1.65; }
.tutorial-relations { display: grid; gap: 10px; padding: 0; list-style: none; margin: auto; width: min(760px, 100%); max-height: 100%; overflow: auto; }
.tutorial-relations li { padding: 10px 14px; border: 1px solid #dfbd77; border-radius: 10px; font-size: clamp(17px, 2.5vw, 24px); }
.tutorial-relations small { display: block; font-size: .66em; margin-top: 3px; opacity: .95; }
.tutorial-arrow { color: #ffe1a0; font-weight: bold; }
.tutorial-type-attack { background: #8b1736; color: #fff4d6; }
.tutorial-type-defence { background: #1a428d; color: #fff4d6; }
.tutorial-type-feint { background: #602a95; color: #fff4d6; }
.tutorial-hand { height: 100%; display: flex; align-items: center; justify-content: center; gap: 12px; }
.tutorial-card-choice { border: 1px solid #c7a566; border-radius: 10px; padding: 4px; background: #0b1229; width: min(29%, 180px, calc((100cqh - 44px) * .75)); color: inherit; }
.tutorial-card-choice .card { width: 100%; pointer-events: none; }
.tutorial-card-choice > span { display: block; padding: 5px 2px; border-radius: 5px; font-weight: bold; font-size: 14px; }
.tutorial-card-choice:hover { outline: 2px solid #dfbd77; }
.tutorial-field { width: 100%; height: 100%; display: grid; grid-template-columns: repeat(2, minmax(0, 190px)); justify-content: center; gap: clamp(12px, 3vw, 36px); }
.tutorial-slot { min-width: 0; min-height: 0; height: 100%; display: grid; grid-template-rows: 48px minmax(0, 1fr); justify-items: center; align-items: start; text-align: center; }
.tutorial-life { margin: 0; height: 44px; display: grid; grid-template-rows: 20px 24px; font-size: 16px; line-height: 20px; }
.tutorial-life-label, .tutorial-life-value { display: block; white-space: nowrap; }
.tutorial-life-value { font-weight: bold; line-height: 24px; }
.tutorial-slot .card, .tutorial-slot .tutorial-card-back { width: min(100%, 170px, calc((100cqh - 52px) * .75)); height: auto; aspect-ratio: 3/4; object-fit: fill; display: block; }
.tutorial-screen > .tutorial-actions { grid-area: actions; align-items: stretch; }
.tutorial-actions { display: flex; justify-content: center; gap: 12px; min-width: 0; min-height: 0; }
.tutorial-actions .menu-button { width: min(300px, 48%); min-height: 40px; padding: 6px 12px; font-size: 16px; }
.tutorial-wait { margin: auto; font-size: 14px; text-align: center; }
/* 横向きの低い画面は、説明を左・カードを右に配置して高さを活用する。 */
@media (max-height: 600px) and (orientation: landscape) {
  .tutorial-screen {
    padding: 10px 12px; gap: 8px;
    grid-template: "top top" 38px "guide content" minmax(0, 1fr) "actions actions" 42px / minmax(0, 34fr) minmax(0, 66fr);
  }
  .tutorial-top { gap: 8px; }
  .tutorial-top h1 { font-size: 20px; }
  .tutorial-progress { font-size: 12px; }
  .tutorial-top > .menu-button, .tutorial-top .language-button { font-size: 13px; min-height: 36px; padding: 6px 10px; }
  .tutorial-guide { flex-direction: column; align-items: flex-start; gap: 4px; padding: 10px; overflow: auto; }
  .tutorial-portrait { width: 40px; height: 40px; }
  .tutorial-speech { font-size: 14px; line-height: 1.4; overflow: visible; max-height: none; }
  .tutorial-goal, .tutorial-extra { font-size: 16px; line-height: 1.5; }
  .tutorial-relations { gap: 5px; }
  .tutorial-relations li { padding: 5px 10px; font-size: 16px; }
  .tutorial-relations small { font-size: 12px; margin-top: 0; }
  .tutorial-actions .menu-button { font-size: 15px; }
  .tutorial-card-choice > span { font-size: 12px; }
  .tutorial-life { font-size: 14px; }
}
@media (max-width: 600px) and (orientation: portrait) {
  .tutorial-top { flex-wrap: wrap; }
  .tutorial-top h1 { width: 100%; }
  .tutorial-screen { padding: 10px; gap: 8px; grid-template-rows: auto 160px minmax(0, 1fr) 48px; }
  .tutorial-portrait { width: 44px; height: 44px; }
  .tutorial-guide { padding: 10px; gap: 10px; }
}

/* 文末の改行は維持し、日本語は指定した文節、英語は空白で折り返す。 */
.tutorial-sentence {
  display: block;
  text-wrap: wrap;
  word-break: normal;
  overflow-wrap: normal;
  line-break: strict;
}
.tutorial-phrase {
  display: inline-block;
  white-space: nowrap;
}
