:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --ink: #14213d;
  --muted: #637084;
  --line: #d8e2ee;
  --soft: #f7fafc;
  --accent: #0d7c86;
  --accent-dark: #07545c;
  --warn: #a95f00;
  --good: #0f766e;
  --shadow: 0 16px 36px rgba(20, 33, 61, 0.09);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: linear-gradient(180deg, #f8fbfd 0, var(--bg) 320px);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

button,
input,
select {
  font: inherit;
}

.app-shell {
  width: min(1440px, calc(100% - 32px));
  margin: 0 auto;
  padding: 24px 0 48px;
}

.topbar,
.battle-layout,
.tools-layout,
.table-panel,
.notice {
  margin-bottom: 16px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 4vw, 44px);
  letter-spacing: 0;
}

h2 {
  font-size: 18px;
}

.top-actions,
.inline-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.inline-control {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 800;
}

.inline-control select {
  min-height: 30px;
  padding: 4px 24px 4px 8px;
}

.button {
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 8px 14px;
  cursor: pointer;
  font-weight: 800;
}

.top-actions .button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-color: #9fcbd2;
  background: linear-gradient(180deg, #ffffff, #edf8fa);
  color: var(--accent-dark);
  box-shadow: 0 3px 10px rgba(13, 124, 134, 0.12);
  text-decoration: none;
}

.top-actions .button:hover {
  border-color: var(--accent);
  background: #e0f3f5;
}

.button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.top-actions .button.primary {
  background: var(--accent);
  color: #fff;
}

.share-button {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.top-actions .share-button {
  border-color: #111827;
  background: #111827;
  color: #fff;
}

.top-actions .share-button:hover {
  background: #000;
  border-color: #000;
}

.button:disabled {
  cursor: progress;
  opacity: 0.65;
}

.file-button {
  display: inline-flex;
  align-items: center;
  position: relative;
  overflow: hidden;
}

.file-button input {
  position: absolute;
  inset: 0;
  opacity: 0;
  pointer-events: none;
}

.notice {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  padding: 12px 14px;
  color: var(--muted);
}

.battle-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 190px minmax(0, 1fr);
  gap: 16px;
  align-items: stretch;
}

.side-panel,
.tool-panel,
.table-panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.side-panel {
  padding: 16px;
}

.pokemon-summary {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr) minmax(108px, auto);
  gap: 14px;
  align-items: center;
  min-height: 120px;
  margin: -4px -4px 14px;
  padding: 12px;
  border: 1px solid #e4edf5;
  border-radius: 8px;
  background: #f8fbfd;
}

.sprite-frame {
  display: grid;
  place-items: center;
  width: 96px;
  height: 96px;
  border-radius: 8px;
  background: radial-gradient(circle at 50% 35%, #ffffff 0 28px, #e7f0f6 29px 100%);
  border: 1px solid #dce7f0;
}

.sprite-frame img {
  width: 88px;
  height: 88px;
  object-fit: contain;
  image-rendering: auto;
}

.summary-main {
  min-width: 0;
}

.summary-main p,
.section-heading p {
  color: var(--muted);
  font-size: 13px;
}

.summary-main strong {
  display: block;
  margin: 2px 0 8px;
  font-size: 24px;
  line-height: 1.15;
  overflow-wrap: anywhere;
}

.speed-stack {
  display: grid;
  justify-items: end;
  gap: 2px;
  text-align: right;
}

.speed-stack span,
.speed-stack small {
  color: var(--muted);
  font-weight: 800;
}

.speed-stack strong {
  font-size: 46px;
  line-height: 1;
  color: var(--accent-dark);
}

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

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

.span-2 {
  grid-column: 1 / -1;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  padding: 9px 10px;
}

input:focus,
select:focus,
button:focus-visible {
  outline: 3px solid rgba(13, 124, 134, 0.22);
  outline-offset: 1px;
}

.toggle-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin: 12px 0;
}

.toggle-row label,
.trick-room {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  color: var(--ink);
  background: #fff;
}

.toggle-row input,
.trick-room input {
  width: 18px;
  min-height: 18px;
}

.stat-lines {
  display: grid;
  gap: 8px;
  margin: 0;
}

.stat-lines div {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 10px;
  border-top: 1px solid var(--line);
  padding-top: 10px;
}

dt {
  color: var(--muted);
  font-weight: 800;
}

dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.versus {
  display: grid;
  align-content: center;
  gap: 12px;
}

.winner-badge {
  display: grid;
  place-items: center;
  min-height: 128px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  padding: 16px;
  text-align: center;
  font-weight: 900;
  line-height: 1.45;
  white-space: pre-line;
  box-shadow: var(--shadow);
}

.winner-badge.tie {
  background: var(--warn);
}

.winner-badge.win {
  background: var(--good);
}

.tools-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.damage-hero {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.damage-result,
.damage-breakdown {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 16px;
}

.damage-result p {
  color: var(--muted);
  font-weight: 800;
}

.selected-move {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font-weight: 900;
}

.selected-move span {
  color: var(--muted);
  font-size: 13px;
}

.damage-result strong {
  display: block;
  margin: 6px 0;
  color: var(--accent-dark);
  font-size: 42px;
  line-height: 1;
}

.damage-result span {
  color: var(--ink);
  font-weight: 900;
}

.damage-breakdown {
  display: grid;
  align-content: center;
  gap: 10px;
}

.damage-layout {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 16px;
}

.damage-move-grid {
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.damage-toggles {
  grid-template-columns: repeat(6, minmax(0, 1fr));
}

.type-tool-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(280px, 0.9fr);
  gap: 16px;
  margin-bottom: 16px;
}

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

.type-result-box {
  display: grid;
  grid-template-columns: minmax(180px, 260px) minmax(0, 1fr);
  gap: 12px;
  margin-top: 14px;
}

.type-result-main {
  display: grid;
  place-items: center;
  min-height: 138px;
  border-radius: 8px;
  color: #fff;
  text-align: center;
  padding: 16px;
}

.type-result-main span {
  font-weight: 900;
}

.type-result-main strong {
  display: block;
  font-size: 54px;
  line-height: 1;
}

.type-result-ultra { background: #8f2d56; }
.type-result-super { background: #b43b32; }
.type-result-normal { background: #315f76; }
.type-result-resist { background: #6a7580; }
.type-result-immune { background: #313846; }

.type-result-detail {
  display: grid;
  gap: 8px;
  align-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 12px;
}

.type-result-detail div {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.type-result-detail b {
  color: var(--muted);
  min-width: 48px;
}

.type-legend,
.type-table-help {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.type-legend {
  margin-bottom: 12px;
}

.type-table-help {
  margin-bottom: 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}

.match-symbol {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  border-radius: 8px;
  padding: 4px 10px;
  color: #fff;
  font-weight: 900;
}

.guide-text,
.type-explanation p {
  color: var(--muted);
  line-height: 1.8;
}

.type-explanation {
  display: grid;
  gap: 10px;
}

.type-explanation h2:not(:first-child) {
  margin-top: 12px;
}

.type-chart-wrap {
  max-height: 720px;
}

.type-chart-table {
  min-width: 1320px;
}

.type-chart-table th,
.type-chart-table td {
  text-align: center;
  padding: 8px;
}

.type-chart-table th:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #eef4f8;
}

.type-chart-table thead th:first-child {
  z-index: 3;
}

.type-chart-table td {
  min-width: 64px;
}

.type-chart-table td b {
  display: block;
  font-size: 17px;
  line-height: 1;
}

.type-chart-table td small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.type-chart-table tr.is-related th:first-child {
  background: #d9f0f2;
}

.type-chart-table td.is-selected {
  outline: 3px solid var(--accent);
  outline-offset: -3px;
}

.effect-layout {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.effect-panel {
  display: grid;
  gap: 12px;
}

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

.effect-row {
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr);
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  padding: 10px;
}

.effect-row b {
  color: var(--accent-dark);
}

.effect-row span {
  color: var(--muted);
  line-height: 1.7;
}

.match-super { background: #fce9e7; color: #9f2e27; }
.match-normal { background: #edf5f8; color: #315f76; }
.match-resist { background: #f0f2f4; color: #59636d; }
.match-immune { background: #e6e9ee; color: #242b36; }

.match-symbol.match-super,
.match-symbol.match-normal,
.match-symbol.match-resist,
.match-symbol.match-immune {
  color: #fff;
}

.match-symbol.match-super { background: #b43b32; }
.match-symbol.match-normal { background: #315f76; }
.match-symbol.match-resist { background: #6a7580; }
.match-symbol.match-immune { background: #313846; }

.small-table {
  max-height: 360px;
}

.team-layout {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  margin-bottom: 16px;
}

.team-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 14px;
}

.team-card-head {
  display: grid;
  grid-template-columns: 64px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid #e4edf5;
  border-radius: 8px;
  background: #f8fbfd;
}

.team-card-head p {
  color: var(--muted);
  font-size: 12px;
}

.team-card-head strong {
  display: block;
  margin-bottom: 5px;
  font-size: 18px;
}

.team-sprite {
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  border-radius: 8px;
  background: #eef5f9;
}

.team-sprite::before {
  content: "";
  width: 30px;
  height: 30px;
  border: 2px solid #b6c7d4;
  border-radius: 50%;
  background: linear-gradient(#f8fbfd 0 45%, #b6c7d4 45% 55%, #f8fbfd 55% 100%);
  box-shadow: inset 0 0 0 8px #eef5f9;
}

.team-sprite.has-sprite::before {
  display: none;
}

.team-sprite img,
.selected-pill img {
  width: 56px;
  height: 56px;
  object-fit: contain;
}

.select-check {
  display: flex;
  align-items: center;
  gap: 6px;
}

.move-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.effort-box {
  margin-top: 10px;
  border: 1px solid #d9e6ea;
  border-radius: 8px;
  background: #f8fbfc;
}

.effort-box summary {
  cursor: pointer;
  padding: 9px 10px;
  color: var(--ink);
  font-weight: 700;
}

.effort-grid,
.nature-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  padding: 0 10px 10px;
}

.nature-grid {
  grid-template-columns: repeat(5, minmax(0, 1fr));
  padding-top: 2px;
}

.slot-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 10px;
}

.mini-button {
  min-height: 36px;
  padding: 7px 10px;
  font-size: 13px;
  white-space: normal;
}

.slot-summary {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.selected-preview {
  display: grid;
  gap: 8px;
}

.selected-pill {
  display: grid;
  grid-template-columns: 56px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: #fff;
}

.team-matchup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.team-matchup-grid h3 {
  margin: 0 0 10px;
}

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

.matchup-row,
.opponent-row {
  display: grid;
  grid-template-columns: 104px 88px 1fr 70px;
  gap: 8px;
  align-items: center;
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.matchup-row-detail {
  grid-template-columns: 92px minmax(0, 1fr);
  align-items: start;
}

.matchup-detail {
  display: grid;
  gap: 6px;
}

.matchup-group {
  display: grid;
  grid-template-columns: 70px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
  min-width: 0;
}

.matchup-group-offense {
  grid-template-columns: 1fr;
  gap: 4px;
}

.matchup-group b {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.7;
  white-space: nowrap;
}

.matchup-group-offense b {
  line-height: 1.45;
  white-space: normal;
}

.matchup-group.bad b {
  color: #b04f44;
}

.matchup-group.good b {
  color: var(--good);
}

.matchup-group.neutral b {
  color: var(--muted);
}

.matchup-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-width: 0;
}

.matchup-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--soft);
  padding: 3px 8px;
  font-size: 12px;
  line-height: 1.4;
  white-space: nowrap;
}

.matchup-chip-offense {
  display: inline-grid;
  grid-template-columns: minmax(64px, auto) minmax(64px, 1fr) auto;
  max-width: 100%;
}

.matchup-chip strong,
.matchup-chip span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.matchup-chip-offense span {
  padding-left: 5px;
  border-left: 1px solid var(--line);
}

.matchup-chip em {
  color: var(--accent-dark);
  font-style: normal;
  font-weight: 900;
}

.matchup-empty {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.7;
}

.opponent-row {
  grid-template-columns: 120px 1fr 1fr;
  margin-top: 8px;
}

.tool-panel,
.table-panel {
  padding: 16px;
}

.result-box {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  margin-top: 12px;
  padding: 12px;
}

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

.wide-input {
  margin-bottom: 12px;
}

.table-wrap {
  max-height: 560px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
}

table {
  width: 100%;
  min-width: 860px;
  border-collapse: collapse;
  background: #fff;
}

th,
td {
  border-bottom: 1px solid var(--line);
  padding: 10px;
  text-align: left;
  vertical-align: middle;
  font-size: 14px;
}

th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: #eef4f8;
}

.table-mon {
  display: flex;
  align-items: center;
  gap: 10px;
}

.table-mon img {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: 8px;
  background: #f1f6fa;
}

.table-mon strong {
  display: block;
}

.table-mon small {
  color: var(--muted);
}

.type-row {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.type-badge {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  border-radius: 999px;
  color: #fff;
  padding: 2px 8px;
  font-size: 12px;
  font-weight: 900;
}

.type-normal { background: #8a8f98; }
.type-fire { background: #e05d35; }
.type-water { background: #3478c8; }
.type-electric { background: #c89413; }
.type-grass { background: #39935a; }
.type-ice { background: #37a9c4; }
.type-fighting { background: #b04f44; }
.type-poison { background: #8a54b8; }
.type-ground { background: #a96f36; }
.type-flying { background: #607fbd; }
.type-psychic { background: #c6537b; }
.type-bug { background: #789331; }
.type-rock { background: #8b7751; }
.type-ghost { background: #5d5a9a; }
.type-dragon { background: #5360c7; }
.type-dark { background: #4a4d58; }
.type-steel { background: #607884; }
.type-fairy { background: #bf6da5; }

@media (max-width: 1120px) {
  .battle-layout {
    grid-template-columns: 1fr;
  }

  .damage-layout,
  .damage-hero,
  .team-layout,
  .team-matchup-grid,
  .type-tool-layout,
  .effect-layout {
    grid-template-columns: 1fr;
  }

  .versus {
    order: -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .tools-layout {
    display: grid;
    grid-template-columns: 1fr;
  }

  .top-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .top-actions .primary {
    grid-column: 1 / -1;
  }

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

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

  .type-checker-grid,
  .type-result-box {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 20px, 1440px);
    padding-top: 12px;
  }

  h1 {
    font-size: 27px;
  }

  .versus {
    position: sticky;
    top: 8px;
    z-index: 5;
  }

  .winner-badge {
    min-height: 88px;
    padding: 12px;
  }

  .pokemon-summary {
    grid-template-columns: 76px minmax(0, 1fr);
  }

  .sprite-frame {
    width: 76px;
    height: 76px;
  }

  .sprite-frame img {
    width: 70px;
    height: 70px;
  }

  .speed-stack {
    grid-column: 1 / -1;
    grid-template-columns: 1fr auto auto;
    align-items: baseline;
    justify-items: start;
    text-align: left;
  }

  .speed-stack strong {
    font-size: 34px;
  }

  .form-grid,
  .manual-grid,
  .toggle-row,
  .damage-move-grid,
  .damage-toggles,
  .type-checker-grid {
    grid-template-columns: 1fr;
  }

  .damage-result strong {
    font-size: 34px;
  }

  .team-card-head,
  .selected-pill,
  .matchup-row,
  .opponent-row {
    grid-template-columns: 1fr;
  }

  .matchup-row-detail {
    grid-template-columns: 1fr;
  }

  .matchup-group {
    grid-template-columns: 64px minmax(0, 1fr);
  }

  .move-grid {
    grid-template-columns: 1fr;
  }

  .effort-grid,
  .nature-grid,
  .slot-actions {
    grid-template-columns: 1fr 1fr;
  }

  .section-heading {
    display: grid;
  }

  .stat-lines div {
    grid-template-columns: 1fr;
  }

  .type-result-main {
    min-height: 112px;
  }

  .type-result-main strong {
    font-size: 42px;
  }

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

.embed-mode body {
  background: transparent;
}

.embed-mode .app-shell {
  max-width: none;
  padding: 10px;
}

.embed-mode .topbar {
  margin-bottom: 10px;
}

.embed-mode .topbar h1 {
  font-size: 30px;
}

.embed-mode .notice,
.embed-mode .side-panel,
.embed-mode .table-panel,
.embed-mode .tool-panel,
.embed-mode .damage-result,
.embed-mode .damage-breakdown,
.embed-mode .team-card {
  box-shadow: none;
}

.embed-mode .table-panel:last-child {
  margin-bottom: 0;
}
