:root {
  color-scheme: light;
  --ink: #2b2320;
  --ink-soft: #5f493a;
  --paper: #fffaf0;
  --paper-deep: #f4dfbf;
  --line: #c99965;
  --red: #a64235;
  --gold: #d99c39;
  --green: #487a5a;
  --blue: #566f96;
  --violet: #67507d;
  --shadow: 0 18px 40px rgba(54, 32, 18, 0.18);
  --panel-shadow: 0 12px 24px rgba(50, 31, 19, 0.14), inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  --battle-bg: url("../images/bg01.webp");
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

html {
  width: 100%;
  min-height: 100%;
}

body {
  width: 100%;
  min-height: 100vh;
  height: 100vh;
  overflow: auto;
  color: var(--ink);
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  /*background:
    radial-gradient(ellipse at 20% 8%, rgba(217, 156, 57, 0.18), transparent 30rem),
    linear-gradient(135deg, #f8e8c9 0%, #f6efdf 46%, #dfebec 100%);
  background-size: auto, auto;*/
  background-image: url("../images/bg_main.webp");
  background-repeat: no-repeat;
  background-size: cover;
  background-color: rgba(255,255,255,0.4);
  background-blend-mode: lighten;
}

button {
  font: inherit;
}

[hidden] {
  display: none !important;
}

.visually-hidden {
  position: absolute !important;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

.game-shell {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  gap: 8px;
  width: 1280px;
  height: 775px;
  margin: 15px auto 0;
  padding: 8px 0;
}

.device-notice {
  display: none;
}

.command-board,
.battle-info {
  border: 2px solid rgba(124, 79, 42, 0.28);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 246, 224, 0.46)),
    rgba(255, 250, 240, 0.9);
  box-shadow: var(--panel-shadow);
  backdrop-filter: blur(8px);
}

.top-bar {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  height: 75px;
  padding: 0 18px;
  /*min-height: 64px;
  padding: 8px 18px 8px 22px;*/
  /*border-radius: 4px;
  overflow: hidden;
  background: linear-gradient(180deg, #fff8e8 0%, #f3e6c9 100%);
  box-shadow: 0 2px 6px rgba(80, 50, 30, 0.12);*/
  border-radius: 4px;
  background-image: url("../images/title_bar.webp");
  background-repeat: no-repeat;
  background-size: cover;
}

.top-bar > div {
  position: relative;
  display: flex;
  align-items: center;
  gap: 14px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  display: none;
  position: relative;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", "Hiragino Kaku Gothic ProN", system-ui, sans-serif;
  font-size: 1.85rem;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 0 1px 0 rgba(255,255,255,.8), 0 2px 3px rgba(90,50,30,.18);
}

.setup-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
  min-height: 0;
  margin-top: 10px;
  padding: 14px;
  overflow: hidden;
  border: 2px solid rgba(124, 79, 42, 0.28);
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.58), rgba(255, 246, 224, 0.46)),
    rgba(255, 250, 240, 0.9);
  box-shadow: var(--panel-shadow);
}

.setup-heading {
  padding: 8px 12px 8px 8px;
  border: 1px solid rgba(124, 79, 42, 0.25);
  border-radius: 4px;
  background: rgba(255, 247, 229, 0.86);
}

.setup-title {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
}

.setup-heading h2 {
  color: #3b2921;
  font-size: 1.18rem;
}

.setup-heading p {
  margin-top: 4px;
  color: var(--ink-soft);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.35;
}

.setup-actions {
  display: grid;
  grid-template-columns: 120px 328px 216px 240px 178px;
  justify-content: end;
  align-items: end;
  column-gap: 24px;
  min-width: 0;
}

.setup-bar-title {
  position: relative;
  align-self: end;
  display: flex;
  align-items: center;
  min-height: 72px;
  padding: 4px 0 7px;
  color: #6b4f3e;
  font-size: 1.2rem;
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
}

.setup-control {
  position: relative;
  display: grid;
  align-content: end;
  justify-items: start;
  gap: 8px;
  min-width: 0;
  min-height: 72px;
  padding: 4px 0;
  border: 0;
  background: transparent;
}

.setup-control::before {
  content: "";
  position: absolute;
  left: -12px;
  top: 8px;
  bottom: 8px;
  width: 1px;
  background: rgba(124, 79, 42, 0.22);
}

.control-label,
.selection-count {
  display: inline-grid;
  align-items: center;
  justify-items: start;
  width: fit-content;
  min-height: 22px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #6c5342;
  font-size: 0.76rem;
  font-weight: 900;
  line-height: 1;
  text-align: left;
}

.difficulty-control .control-label {
  background: rgba(222, 214, 198, 0.55);
}

.opponent-control .selection-count {
  background: rgba(196, 211, 221, 0.42);
}

.player-control .selection-count {
  background: rgba(217, 179, 170, 0.34);
}

.control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 6px;
}

.control-row .control-label {
  margin-bottom: 0;
}

.random-tools {
  display: flex;
  align-items: center;
  gap: 6px;
}

.random-label {
  color: #6b5b73;
}

.difficulty-picker {
  display: block;
  padding: 0;
  border: 0;
  border-radius: 0;
  color: var(--ink-soft);
  background: transparent;
  font-size: 0.8rem;
  font-weight: 900;
}

.difficulty-buttons {
  display: flex;
  gap: 8px;
}

.difficulty-button,
.mode-button,
.compact-button {
  width: 104px;
  min-height: 34px;
  padding: 6px 10px;
  cursor: pointer;
  border: 1px solid rgba(43, 35, 32, 0.22);
  border-radius: 4px;
  color: #3b2921;
  background: #fffaf0;
  box-shadow: 0 4px 0 rgba(89, 57, 30, 0.16);
  font: inherit;
  font-size: 0.82rem;
  font-weight: 800;
  line-height: 1;
}

.difficulty-button:hover,
.mode-button:hover,
.compact-button:hover {
  transform: translateY(-1px);
}

.difficulty-button:active,
.mode-button:active,
.compact-button:active {
  box-shadow: 0 2px 0 rgba(89, 57, 30, 0.16);
  transform: translateY(1px);
}

.difficulty-button[data-difficulty="normal"] {
  background: #fffaf0;
}

.difficulty-button[data-difficulty="hard"] {
  background: #fffaf0;
}

.difficulty-button[data-difficulty="hashira"] {
  background: #fffaf0;
}

.difficulty-button.selected {
  color: #3b2921;
  border-color: rgba(166, 66, 53, 0.42);
  background:
    linear-gradient(135deg, rgba(166, 66, 53, 0.1), transparent 58%),
    #fff0e9;
}

.mode-button.selected {
  color: #3b2921;
  border-color: rgba(166, 66, 53, 0.42);
  background:
    linear-gradient(135deg, rgba(166, 66, 53, 0.1), transparent 58%),
    #fff0e9;
}

.enemy-random-button[aria-pressed="true"] {
  border-color: rgba(166, 66, 53, 0.42);
  background:
    linear-gradient(135deg, rgba(166, 66, 53, 0.1), transparent 58%),
    #fff0e9;
}

.compact-actions {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.selection-count.complete {
  color: #3b2921;
}

.setup-footer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: stretch;
  gap: 12px;
  padding-top: 2px;
}

.team-comment {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 38px;
  padding: 7px 12px;
  border: 1px solid rgba(153, 103, 49, 0.46);
  border-radius: 7px;
  color: #4b3126;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.62), rgba(255, 247, 229, 0.42)),
    rgba(255, 250, 240, 0.82);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.54), 0 6px 14px rgba(76, 48, 26, 0.08);
}

.team-comment.complete {
  border-color: rgba(166, 66, 53, 0.46);
  background:
    linear-gradient(135deg, rgba(217, 156, 57, 0.16), rgba(255, 247, 229, 0.42)),
    rgba(255, 248, 232, 0.92);
}

.team-comment-label {
  display: inline-grid;
  place-items: center;
  min-height: 22px;
  padding: 4px 10px;
  border-radius: 999px;
  color: #fffaf0;
  background: rgba(125, 78, 42, 0.84);
  font-size: 0.74rem;
  font-weight: 900;
  line-height: 1;
}

.team-comment-text {
  min-width: 0;
  color: #4b3126;
  font-size: 0.9rem;
  font-weight: 900;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.setup-sound-actions {
  display: flex;
  align-items: stretch;
  justify-content: flex-end;
  gap: 8px;
}

.roster-list {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  min-height: 0;
  margin-top: 12px;
  align-content: start;
  overflow: auto;
  padding: 6px 4px 0 0;
}

.roster-card {
  position: relative;
  display: grid;
  grid-template-rows: auto auto auto;
  justify-items: center;
  gap: 6px;
  min-height: 212px;
  padding: 9px;
  border: 2px solid rgba(152, 88, 48, 0.22);
  border-radius: 4px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(217, 156, 57, 0.12), transparent 48%),
    rgba(255, 249, 232, 0.96);
  box-shadow: 0 12px 24px rgba(43, 35, 32, 0.12);
  transition: transform 140ms ease, border-color 140ms ease, opacity 140ms ease, box-shadow 140ms ease;
}

.roster-card:hover {
  border-color: rgba(166, 66, 53, 0.5);
  box-shadow: 0 16px 30px rgba(43, 35, 32, 0.18);
  transform: translateY(-4px);
}

.roster-card[aria-disabled="true"]:not(.active-team-selected) {
  cursor: not-allowed;
  opacity: 0.62;
}

.roster-card[aria-disabled="true"]:not(.active-team-selected):hover {
  border-color: rgba(152, 88, 48, 0.22);
  box-shadow: 0 12px 24px rgba(43, 35, 32, 0.12);
  transform: none;
}

.roster-card.selected {
  border-color: rgba(154, 69, 56, 0.72);
  background:
    linear-gradient(135deg, rgba(183, 82, 72, 0.15), transparent 48%),
    rgba(255, 241, 235, 0.98);
  box-shadow: 0 16px 28px rgba(108, 65, 22, 0.2), inset 0 0 0 2px rgba(255, 255, 255, 0.66);
}

.roster-card.enemy-selected {
  border-color: rgba(86, 111, 150, 0.5);
  background:
    linear-gradient(135deg, rgba(86, 111, 150, 0.12), transparent 48%),
    rgba(242, 249, 252, 0.96);
}

.roster-card.player-selected.enemy-selected {
  border-color: #8c536f;
  background:
    linear-gradient(135deg, rgba(166, 66, 53, 0.14), transparent 42%),
    linear-gradient(225deg, rgba(86, 111, 150, 0.14), transparent 46%),
    rgba(255, 249, 232, 0.96);
}

.roster-card img {
  align-self: center;
  width: 100%;
  max-width: 126px;
  justify-self: center;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(155, 91, 43, 0.38);
  border-radius: 4px;
  background: linear-gradient(145deg, #f7d79e, #d9a965);
  box-shadow: inset 0 0 0 4px rgba(255, 250, 240, 0.58);
}

.roster-card strong {
  width: 100%;
  text-align: center;
  font-size: 0.9rem;
  font-weight: 900;
}

.roster-card small {
  width: 100%;
  color: var(--ink-soft);
  font-size: 0.68rem;
  font-weight: 800;
  text-align: center;
}

.pick-mark {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 1;
  padding: 4px 9px;
  border-radius: 999px;
  color: #fffaf0;
  background: rgba(86, 111, 150, 0.88);
  font-size: 0.66rem;
  font-weight: 900;
}

.roster-card.selected .pick-mark {
  background: rgba(154, 69, 56, 0.94);
}

.roster-card.enemy-selected .pick-mark {
  background: rgba(86, 111, 150, 0.92);
}

.roster-card.player-selected.enemy-selected .pick-mark {
  background: #8c536f;
}

.start-button,
.random-button,
.sound-toggle-button {
  flex: 0 0 auto;
  min-width: 156px;
  padding: 10px 14px;
  cursor: pointer;
  border: 1px solid rgba(43, 35, 32, 0.22);
  border-radius: 4px;
  color: #fffaf0;
  background: linear-gradient(135deg, #b94b3b, #8f2d2a);
  box-shadow: 0 4px 0 rgba(89, 57, 30, 0.16);
  font-weight: 900;
}

.random-button {
  min-width: 0;
  color: #3b2921;
  background: #fffaf0;
}

.compact-button {
  min-height: 34px;
  padding: 6px 10px;
  font-size: 0.82rem;
}

.player-random-button {
  width: 128px;
  min-height: 38px;
  background: linear-gradient(135deg, #fff6dd, #e6c26f);
  font-size: 0.88rem;
}

.enemy-random-button {
  border-color: rgba(166, 66, 53, 0.42);
  background:
    linear-gradient(135deg, rgba(166, 66, 53, 0.1), transparent 58%),
    #fff0e9;
}

.setup-screen.opponent-open .enemy-random-button {
  border-color: rgba(43, 35, 32, 0.22);
  background: #fffaf0;
}

.start-control {
  display: grid;
  align-content: end;
}

.start-control .start-button {
  width: 100%;
  min-width: 0;
  min-height: 60px;
  padding: 12px 14px;
  font-size: 1.12rem;
  line-height: 1.35;
}

.sound-toggle-button {
  min-width: 86px;
  min-height: 38px;
  width: 100px;
  padding: 7px 10px;
  color: #3b2921;
  background: linear-gradient(135deg, #fffaf0, #e7d9b7);
  font-size: 0.78rem;
}

.sound-toggle-button[aria-pressed="false"] {
  color: var(--ink-soft);
  background: linear-gradient(135deg, #e8dfd0, #c7b59a);
}

@media (max-width: 720px) {
  .setup-footer {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .team-comment {
    grid-template-columns: 1fr;
    gap: 6px;
  }

  .team-comment-label {
    width: fit-content;
  }

  .setup-sound-actions {
    justify-content: flex-start;
  }
}

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

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 384px;
  gap: 10px;
  height: 100%;
  min-height: 0;
  overflow: hidden;
  margin-top: 10px;
}

.left-column {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 8px;
  min-height: 0;
  overflow: hidden;
}

.battlefield {
  position: relative;
  display: grid;
  grid-template-rows: auto 58px auto;
  align-content: space-between;
  gap: 8px;
  min-height: 0;
  padding: 9px;
  overflow: hidden;
  border: 2px solid rgba(124, 79, 42, 0.34);
  border-radius: 4px;
  background:
    linear-gradient(rgba(255, 248, 230, 0.22), rgba(233, 219, 195, 0.32)),
    var(--battle-bg),
    linear-gradient(180deg, rgba(58, 74, 91, 0.18), rgba(232, 192, 126, 0.18));
  background-position: center;
  background-size: cover, cover, cover;
  box-shadow: inset 0 0 0 2px rgba(255, 250, 240, 0.3), var(--panel-shadow);
}

.team-area {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 7px;
  min-height: 0;
}

.team-heading {
  display: grid;
  align-self: stretch;
  align-items: stretch;
  color: #4f3326;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  font-weight: 800;
}

.team-heading span {
  display: grid;
  width: 100%;
  min-height: 140px;
  place-items: center;
  padding: 10px 0;
  border: 1px solid rgba(124, 79, 42, 0.32);
  border-radius: 4px;
  background: rgba(255, 250, 240, 0.62);
  writing-mode: vertical-rl;
  letter-spacing: 0.12em;
}

.team-heading small {
  color: #8b6844;
  font-weight: 700;
}

.team-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 7px;
  min-height: 0;
  align-items: stretch;
}

.unit {
  position: relative;
  display: grid;
  grid-template-columns: 112px 1fr;
  gap: 8px;
  min-height: 140px;
  padding: 7px;
  overflow: hidden;
  border: 2px solid rgba(66, 44, 31, 0.18);
  border-radius: 7px;
  background: rgba(255, 252, 242, 0.86);
  box-shadow: 0 10px 22px rgba(43, 35, 32, 0.12), inset 0 0 0 1px rgba(255, 255, 255, 0.45);
  transition: transform 160ms ease, border-color 160ms ease, filter 160ms ease;
}

.unit.enemy {
  border-color: rgba(88, 111, 142, 0.26);
  background:
    linear-gradient(90deg, rgba(86, 111, 150, 0.08), transparent 62%),
    rgba(241, 246, 249, 0.95);
}

.unit.player {
  border-color: rgba(152, 88, 48, 0.28);
  background:
    linear-gradient(90deg, rgba(217, 156, 57, 0.16), transparent 62%),
    rgba(255, 249, 232, 0.95);
}

.unit.enemy .portrait-wrap {
  border-color: rgba(78, 103, 137, 0.32);
  background: linear-gradient(145deg, #e1eef5, #bfd2df);
  box-shadow: inset 0 0 0 3px rgba(255, 250, 240, 0.55);
}

.unit.player .portrait-wrap {
  border-color: rgba(155, 91, 43, 0.38);
  background: linear-gradient(145deg, #f7d79e, #d9a965);
  box-shadow: inset 0 0 0 3px rgba(255, 250, 240, 0.58);
}

.unit.active {
  border-color: var(--gold);
  transform: translateY(-4px);
  box-shadow: 0 16px 28px rgba(108, 65, 22, 0.2), inset 0 0 0 1px rgba(255, 255, 255, 0.72);
}

.unit.targeted {
  border-color: var(--red);
}

.unit.down {
  filter: grayscale(0.9);
  opacity: 0.55;
}

.portrait-wrap {
  align-self: center;
  width: 112px;
  aspect-ratio: 1;
  overflow: hidden;
  border: 1px solid rgba(124, 79, 42, 0.25);
  border-radius: 7px;
  background: linear-gradient(145deg, #fff7df, #dfebec);
}

.portrait-wrap img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.unit-info {
  display: grid;
  align-content: center;
  gap: 4px;
  min-width: 0;
}

.name-line {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 8px;
  min-width: 0;
}

.name-line strong {
  color: #261b16;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  font-size: 0.92rem;
  font-weight: 900;
  overflow-wrap: anywhere;
}

.bar {
  width: min(100%, 128px);
  height: 8px;
  overflow: hidden;
  border: 1px solid rgba(43, 35, 32, 0.22);
  border-radius: 999px;
  background: rgba(43, 35, 32, 0.12);
  box-shadow: inset 0 1px 2px rgba(43, 35, 32, 0.18);
}

.bar-fill {
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--red);
  transition: width 260ms ease;
}

.breath .bar-fill {
  background: var(--blue);
}

.stat-row {
  width: min(100%, 128px);
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: #6d5138;
  font-size: 0.68rem;
  font-weight: 800;
}

.status-list {
  display: flex;
  flex-wrap: wrap;
  align-content: flex-start;
  gap: 4px;
  min-height: 22px;
}

.status {
  padding: 2px 6px;
  border-radius: 6px;
  color: #fffaf0;
  background: var(--violet);
  font-size: 0.6rem;
  font-weight: 800;
}

.stage-center {
  position: relative;
  display: grid;
  align-content: center;
  place-items: center;
  gap: 8px;
}

.message-box {
  position: relative;
  width: min(500px, 100%);
  min-height: 48px;
  padding: 6px 14px;
  border: 2px solid rgba(217, 156, 57, 0.36);
  border-radius: 4px;
  background:
    linear-gradient(90deg, rgba(217, 156, 57, 0.08), transparent 28%, rgba(217, 156, 57, 0.08)),
    rgba(43, 35, 32, 0.86);
  color: #fffaf0;
  text-align: center;
  box-shadow: 0 12px 28px rgba(43, 35, 32, 0.22);
  transition: border-color 160ms ease, background 160ms ease;
}

.message-box span {
  display: block;
  margin-bottom: 3px;
  color: #f7c56d;
  font-size: 0.82rem;
  font-weight: 800;
}

.message-box.player {
  border-color: rgba(217, 156, 57, 0.52);
  background:
    linear-gradient(90deg, rgba(217, 156, 57, 0.12), transparent 30%, rgba(217, 156, 57, 0.1)),
    rgba(55, 38, 31, 0.88);
}

.message-box.player span {
  color: #ffd27e;
}

.message-box.enemy {
  border-color: rgba(116, 166, 205, 0.72);
  background:
    linear-gradient(90deg, rgba(102, 153, 198, 0.18), transparent 30%, rgba(102, 153, 198, 0.14)),
    rgba(28, 44, 61, 0.9);
  box-shadow: 0 12px 28px rgba(31, 56, 78, 0.28);
}

.message-box.enemy span {
  color: #a9d7ff;
}

.message-box.neutral {
  display: grid;
  align-items: center;
  padding: 8px 14px;
  border-color: rgba(235, 235, 235, 0.62);
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.13), transparent 30%, rgba(255, 255, 255, 0.1)),
    rgba(42, 42, 44, 0.88);
  color: #f4f1ed;
  box-shadow: 0 12px 28px rgba(35, 35, 38, 0.24);
}

.message-box.neutral span {
  color: #e8e5df;
}

.message-box.neutral p {
  line-height: 1.3;
}

.result-actions {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 16px;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
}

.result-actions.is-visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
  animation: result-actions-in 260ms ease-out;
}

.effect-layer {
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.effect-burst {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 130px;
  height: 130px;
  border: 4px solid currentColor;
  border-radius: 50%;
  color: var(--gold);
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.3);
  animation: burst 560ms ease-out;
}

.unit-burst {
  pointer-events: none;
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 4;
  width: 74px;
  height: 74px;
  border: 4px solid currentColor;
  border-radius: 50%;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.28);
  animation: burst 560ms ease-out;
}

.unit-burst::after {
  content: "";
  position: absolute;
  inset: 16px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.22;
}

.command-board {
  display: grid;
  grid-template-rows: auto auto 312px minmax(0, 1fr);
  gap: 6px;
  min-height: 0;
  padding: 10px;
  overflow: hidden;
  border-radius: 4px;
}

.active-card,
.target-panel,
.skill-panel,
.combo-panel,
.log-panel {
  border: 1px solid rgba(124, 79, 42, 0.3);
  border-radius: 4px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.45), transparent 45%),
    #fff7e5;
}

.battle-info {
  height: 150px;
  padding: 6px;
  overflow: hidden;
  border-radius: 4px;
}

.active-card {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  padding: 6px;
}

.active-card.player {
  border-color: rgba(152, 88, 48, 0.3);
  background:
    linear-gradient(90deg, rgba(217, 156, 57, 0.14), transparent 62%),
    #fff7e5;
}

.active-card.enemy {
  border-color: rgba(86, 111, 150, 0.34);
  background:
    linear-gradient(90deg, rgba(86, 111, 150, 0.12), transparent 62%),
    #edf4f7;
}

.active-card img {
  width: 64px;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid rgba(155, 91, 43, 0.32);
  border-radius: 7px;
  background: linear-gradient(145deg, #f7d79e, #d9a965);
  box-shadow: inset 0 0 0 3px rgba(255, 250, 240, 0.58);
}

.active-card.enemy img {
  border-color: rgba(78, 103, 137, 0.34);
  background: linear-gradient(145deg, #e1eef5, #bfd2df);
}

.active-card strong {
  color: #241a16;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  font-size: 1rem;
  font-weight: 900;
}

.active-card p {
  color: #5f4b3a;
  font-size: 0.7rem;
  line-height: 1.18;
}

.skill-panel {
  padding: 6px;
  min-height: 0;
  overflow: hidden;
}

.combo-panel {
  padding: 6px;
  min-height: 0;
  overflow: visible;
}

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

.board-title h2,
.target-panel h2,
.combo-panel h2,
.log-panel h2 {
  color: #3b2921;
  font-family: "Hiragino Maru Gothic ProN", "Yu Gothic", system-ui, sans-serif;
  font-size: 1rem;
  letter-spacing: 0.04em;
}

.board-title h2::before,
.target-panel h2::before,
.combo-panel h2::before,
.log-panel h2::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 1em;
  margin-right: 6px;
  border-radius: 999px;
  background: var(--red);
  vertical-align: -0.12em;
}

.skill-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  overflow: visible;
  padding-right: 0;
}

.combo-grid {
  display: grid;
  gap: 8px;
  min-height: 0;
  max-height: none;
  overflow: visible;
  padding: 3px 2px 13px 0;
}

.skill-card,
.target-button,
#resetButton {
  cursor: pointer;
  border: 1px solid rgba(43, 35, 32, 0.22);
  border-radius: 4px;
  color: var(--ink);
  background: #fffaf0;
  box-shadow: 0 4px 0 rgba(89, 57, 30, 0.16);
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.skill-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  min-height: 36px;
  padding: 5px 8px;
  text-align: left;
  background:
    linear-gradient(90deg, rgba(217, 156, 57, 0.1), transparent 22%),
    #fffaf0;
}

.skill-card p {
  grid-column: 1 / -1;
}

.skill-card strong {
  color: #3f2b22;
  font-size: 0.86rem;
}

.skill-card small {
  color: #7b593a;
  font-size: 0.72rem;
  font-weight: 800;
}

.skill-card p {
  color: #5f4b3a;
  font-size: 0.62rem;
  line-height: 1.18;
}

.skill-card.ultimate {
  border-color: rgba(190, 126, 32, 0.66);
  background:
    linear-gradient(135deg, rgba(255, 223, 132, 0.5), transparent 46%),
    linear-gradient(90deg, rgba(217, 156, 57, 0.18), transparent 28%),
    #fff4cf;
  box-shadow:
    inset 0 0 0 1px rgba(255, 250, 226, 0.76),
    0 4px 0 rgba(132, 86, 28, 0.18);
}

.skill-card.ultimate strong {
  color: #6c3d11;
}

.skill-card.ultimate small {
  color: #7f5318;
}

.combo-skill-card {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 2px 10px;
  min-height: 50px;
  width: 100%;
  padding: 6px 8px;
  cursor: pointer;
  text-align: left;
  border: 1px solid rgba(166, 66, 53, 0.58);
  border-radius: 4px;
  border-color: rgba(166, 66, 53, 0.58);
  color: #fff8ed;
  background:
    linear-gradient(135deg, rgba(255, 218, 125, 0.32), transparent 42%),
    linear-gradient(135deg, #b94b3b, #71323e);
  box-shadow: 0 5px 0 rgba(89, 32, 30, 0.24), 0 12px 22px rgba(113, 50, 62, 0.22);
  transition: transform 120ms ease, box-shadow 120ms ease;
}

.combo-skill-card strong,
.combo-skill-card small,
.combo-skill-card p {
  color: #fff8ed;
}

.combo-skill-card strong {
  font-size: 0.88rem;
}

.combo-skill-card small {
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255, 250, 240, 0.18);
  font-size: 0.68rem;
  font-weight: 900;
}

.combo-skill-card p {
  grid-column: 1 / -1;
  font-size: 0.61rem;
  line-height: 1.14;
}

.combo-skill-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 7px 0 rgba(89, 32, 30, 0.24), 0 14px 24px rgba(113, 50, 62, 0.26);
}

.combo-skill-card:disabled {
  cursor: not-allowed;
  opacity: 0.52;
  transform: none;
  box-shadow: none;
  filter: grayscale(0.28);
}

.combo-empty {
  min-height: 38px;
  padding: 9px 10px;
  border: 1px dashed rgba(124, 79, 42, 0.34);
  border-radius: 4px;
  color: #846c5b;
  background: rgba(255, 250, 240, 0.52);
  font-size: 0.76rem;
  font-weight: 800;
}

.skill-card:hover,
.target-button:hover,
#resetButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 0 rgba(89, 57, 30, 0.16);
}

.skill-card:disabled,
.target-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  transform: none;
}

.target-panel,
.log-panel {
  padding: 7px;
  min-height: 0;
  overflow: hidden;
}

.battle-info .log-panel {
  height: 100%;
  min-height: 0;
}

.target-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px;
  margin-top: 6px;
  overflow: visible;
}

.target-button {
  display: grid;
  place-items: center;
  width: 100%;
  min-height: 28px;
  padding: 4px 6px;
  font-size: 0.74rem;
  font-weight: 800;
}

.target-button.selected {
  border-color: var(--red);
  background:
    linear-gradient(135deg, rgba(166, 66, 53, 0.18), transparent 58%),
    #ffe6dc;
}

.log-panel {
  position: relative;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  padding: 6px;
  border-color: rgba(62, 51, 63, 0.34);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.16), transparent 42%),
    #ebe5df;
  overflow: hidden;
}

.battle-control-buttons {
  position: absolute;
  bottom: 6px;
  right: 7px;
  display: flex;
  gap: 5px;
}

.battle-toggle-button {
  width: 84px;
  min-height: 26px;
  padding: 3px 7px;
  cursor: pointer;
  border: 1px solid rgba(43, 35, 32, 0.22);
  border-radius: 4px;
  color: var(--ink-soft);
  background: #fffaf0;
  box-shadow: 0 3px 0 rgba(89, 57, 30, 0.14);
  font: inherit;
  font-size: 0.72rem;
  font-weight: 900;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.battle-toggle-button.rematch-button {
  position: relative;
  width: 184px;
  min-height: 40px;
  color: #fffaf0;
  border: 2px solid rgba(255, 250, 240, 0.88);
  background:
    linear-gradient(135deg, rgba(255, 218, 125, 0.22), transparent 46%),
    #a64235;
  box-shadow:
    0 0 0 2px rgba(90, 42, 32, 0.32),
    0 6px 0 rgba(89, 32, 30, 0.28),
    0 12px 24px rgba(43, 35, 32, 0.28);
  font-size: 0.9rem;
}

.battle-toggle-button.back-to-setup-button {
  width: 132px;
  min-height: 38px;
  color: #46352d;
  border: 2px solid rgba(255, 250, 240, 0.74);
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.28), transparent 52%),
    rgba(255, 250, 240, 0.94);
  box-shadow:
    0 0 0 2px rgba(43, 35, 32, 0.18),
    0 5px 0 rgba(89, 57, 30, 0.16),
    0 10px 20px rgba(43, 35, 32, 0.18);
  font-size: 0.82rem;
}

.battle-toggle-button:hover {
  transform: translateY(-1px);
}

.battle-toggle-button[aria-pressed="false"] {
  color: #7b6858;
  background: #eee5d8;
}

.battle-toggle-button.auto-toggle[aria-pressed="true"] {
  color: #fffaf0;
  border-color: rgba(72, 122, 90, 0.62);
  background: linear-gradient(135deg, #5b9468, #3f7352);
}

.log-panel ul {
  display: block;
  min-height: 0;
  height: auto;
  max-height: none;
  margin: 4px 0 0;
  padding-left: 20px;
  padding-right: 8px;
  overflow-y: scroll;
  color: #40313a;
  font-size: 0.74rem;
  line-height: 1.25;
  list-style: none;
  scrollbar-color: #8e6f68 rgba(64, 49, 58, 0.14);
  scrollbar-width: thin;
}

.log-panel li + li {
  margin-top: 4px;
}

.log-panel ul::-webkit-scrollbar {
  width: 9px;
}

.log-panel ul::-webkit-scrollbar-track {
  border-radius: 999px;
  background: rgba(64, 49, 58, 0.12);
}

.log-panel ul::-webkit-scrollbar-thumb {
  border: 2px solid #ebe5df;
  border-radius: 999px;
  background: #8e6f68;
}

.log-panel li::before {
  content: "- ";
}

#resetButton {
  flex: 0 0 auto;
  cursor: pointer;
  border: 1px solid rgba(43, 35, 32, 0.22);
  border-radius: 4px;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(217, 156, 57, 0.18), transparent 56%),
    #fffaf0;
  box-shadow: 0 4px 0 rgba(89, 57, 30, 0.16);
  padding: 8px 14px;
  font-weight: 900;
  transition: transform 120ms ease, box-shadow 120ms ease, opacity 120ms ease;
}

.ultimate-overlay {
  pointer-events: none;
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  z-index: 10;
  background: rgba(13, 12, 16, 0);
  color: #fffaf0;
  opacity: 0;
}

.ultimate-overlay.show {
  animation: darken 980ms ease;
}

.ultimate-overlay.combo {
  color: #fff3cf;
}

.ultimate-overlay.combo.show {
  animation: comboDarken 980ms ease;
}

.ultimate-overlay.special {
  color: #e9fbff;
}

.ultimate-overlay.special.show {
  animation: specialDarken 980ms ease;
}

.ultimate-overlay div {
  max-width: min(88vw, 760px);
  font-size: clamp(2rem, 8vw, 5.2rem);
  font-weight: 900;
  text-align: center;
  text-shadow: 0 0 22px rgba(255, 183, 75, 0.8);
}

.ultimate-overlay.combo div {
  padding: 0 18px;
  color: #fffaf0;
  font-size: clamp(2.45rem, 9vw, 6rem);
  text-shadow:
    0 2px 0 rgba(77, 30, 20, 0.92),
    0 0 18px rgba(255, 243, 179, 0.98),
    0 0 42px rgba(255, 176, 68, 0.88);
}

.ultimate-overlay.special div {
  text-shadow:
    0 0 18px rgba(143, 180, 199, 0.95),
    0 0 42px rgba(66, 105, 140, 0.72);
}

.shake {
  animation: shake 360ms ease;
}

.lunge-player {
  animation: lungePlayer 480ms ease;
}

.lunge-enemy {
  animation: lungeEnemy 480ms ease;
}

.heal-pop {
  animation: healPop 560ms ease;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-8px);
  }
  50% {
    transform: translateX(7px);
  }
  75% {
    transform: translateX(-4px);
  }
}

@keyframes lungePlayer {
  45% {
    transform: translateY(-18px) scale(1.03);
  }
}

@keyframes lungeEnemy {
  45% {
    transform: translateY(18px) scale(1.03);
  }
}

@keyframes healPop {
  50% {
    filter: brightness(1.25);
    transform: translateY(-5px);
  }
}

@keyframes burst {
  10% {
    opacity: 0.95;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(1.4);
  }
}

@keyframes darken {
  0%,
  100% {
    opacity: 0;
    background: rgba(13, 12, 16, 0);
  }
  25%,
  78% {
    opacity: 1;
    background: rgba(13, 12, 16, 0.78);
  }
}

@keyframes comboDarken {
  0%,
  100% {
    opacity: 0;
    background:
      radial-gradient(circle at 50% 46%, rgba(217, 156, 57, 0), transparent 36%),
      rgba(13, 12, 16, 0);
  }
  25%,
  78% {
    opacity: 1;
    background:
      radial-gradient(circle at 50% 46%, rgba(217, 156, 57, 0.32), transparent 42%),
      linear-gradient(135deg, rgba(123, 37, 35, 0.62), rgba(20, 12, 18, 0.86));
  }
}

@keyframes specialDarken {
  0%,
  100% {
    opacity: 0;
    background:
      radial-gradient(circle at 50% 46%, rgba(143, 180, 199, 0), transparent 36%),
      rgba(13, 12, 16, 0);
  }
  25%,
  78% {
    opacity: 1;
    background:
      radial-gradient(circle at 50% 46%, rgba(143, 180, 199, 0.28), transparent 42%),
      linear-gradient(135deg, rgba(26, 55, 78, 0.76), rgba(8, 17, 28, 0.9));
  }
}

@keyframes result-actions-in {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (pointer: coarse) and (max-width: 767px), (pointer: coarse) and (max-height: 500px) {
  body {
    overflow: hidden;
  }

  .game-shell {
    display: none;
  }

  .unsupported-notice {
    display: grid;
  }
}

@media (pointer: coarse) and (min-width: 768px) and (max-width: 1366px) and (min-height: 501px) and (orientation: portrait) {
  body {
    overflow: hidden;
  }

  .game-shell {
    display: none;
  }

  .orientation-notice {
    display: grid;
  }
}

@media (pointer: coarse) and (min-width: 768px) and (max-width: 1366px) and (min-height: 501px) and (orientation: landscape) {
  body {
    min-height: 100vh;
    overflow: hidden;
  }

  .game-shell {
    --game-scale: 0.96;
    margin: 15px 0 0;
    transform: translateX(calc(50vw - 640px)) scale(var(--game-scale));
    transform-origin: top center;
  }
}

@media (pointer: coarse) and (min-width: 768px) and (max-width: 1200px) and (min-height: 501px) and (orientation: landscape) {
  .game-shell {
    --game-scale: 0.9;
  }
}

@media (pointer: coarse) and (min-width: 768px) and (max-width: 1120px) and (min-height: 501px) and (orientation: landscape) {
  .game-shell {
    --game-scale: 0.86;
  }
}

@media (pointer: coarse) and (min-width: 768px) and (max-width: 1080px) and (min-height: 501px) and (orientation: landscape) {
  .game-shell {
    --game-scale: 0.8;
  }
}

@media (pointer: coarse) and (min-width: 768px) and (max-width: 920px) and (min-height: 501px) and (orientation: landscape) {
  .game-shell {
    --game-scale: 0.7;
  }
}

.device-notice {
  position: fixed;
  inset: 0;
  z-index: 20;
  place-items: center;
  padding: 24px;
  color: var(--ink);
  text-align: center;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.7), rgba(255, 246, 224, 0.62)),
    url("../images/bg_main.webp") center / cover no-repeat;
}

.device-notice > div {
  width: min(100%, 520px);
  padding: 28px 24px;
  border: 2px solid rgba(124, 79, 42, 0.28);
  border-radius: 4px;
  background: rgba(255, 250, 240, 0.92);
  box-shadow: var(--shadow);
}

.device-notice strong {
  display: block;
  color: #3b2921;
  font-size: 1.55rem;
  font-weight: 900;
  line-height: 1.25;
}

.device-notice p {
  margin-top: 12px;
  color: var(--ink-soft);
  font-size: 0.98rem;
  font-weight: 800;
  line-height: 1.55;
}
