:root {
  --bg: #0f172a;
  --panel: #172033;
  --panel-2: #1f2a44;
  --line: rgba(148, 163, 184, 0.26);
  --text: #f8fafc;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --accent-2: #facc15;
  --danger: #fb7185;
  --ok: #4ade80;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% -10%, rgba(56, 189, 248, 0.22), transparent 32%),
    linear-gradient(180deg, #111827, var(--bg));
  color: var(--text);
  font-size: 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Hiragino Sans", "Noto Sans JP", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #26344f;
  color: var(--text);
  font-weight: 800;
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
  filter: grayscale(0.45);
  opacity: 0.45;
}

button.danger-soft {
  border-color: rgba(251, 113, 133, 0.44);
  background: rgba(127, 29, 29, 0.46);
  color: #ffe4e6;
}

button.danger-soft:hover {
  border-color: rgba(251, 113, 133, 0.72);
  background: rgba(127, 29, 29, 0.64);
}

button:hover {
  border-color: rgba(56, 189, 248, 0.58);
}

button.primary {
  border-color: rgba(56, 189, 248, 0.72);
  background: linear-gradient(180deg, #0284c7, #075985);
}

button.danger {
  border-color: rgba(251, 113, 133, 0.58);
  color: #ffe4e6;
}

input,
select {
  width: 100%;
  min-height: 28px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.88);
  color: var(--text);
  padding: 4px 7px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 68px;
  padding: 9px 14px;
  border-bottom: 1px solid var(--line);
  background: rgba(15, 23, 42, 0.9);
  backdrop-filter: blur(14px);
}

.topbar p,
.side-label {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 900;
}

h1 {
  margin: 0;
  font-size: 20px;
}

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

.title-row {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.match-timer {
  position: absolute;
  top: 50%;
  left: 50%;
  display: flex;
  align-items: center;
  gap: 5px;
  transform: translate(-50%, -50%);
  padding: 5px 7px;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.68);
}

.match-timer strong {
  min-width: 74px;
  color: #fde68a;
  font-size: 24px;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  text-align: center;
}

.match-timer label {
  display: grid;
  grid-template-columns: 16px 42px;
  gap: 3px;
  align-items: center;
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
}

.match-timer input {
  min-height: 24px;
  padding: 2px 5px;
  text-align: center;
}

.match-timer button {
  min-height: 24px;
  padding: 0 7px;
  font-size: 11px;
}

.match-timer.is-running {
  border-color: rgba(74, 222, 128, 0.38);
  background: rgba(20, 83, 45, 0.28);
}

.match-timer.is-finished {
  border-color: rgba(251, 113, 133, 0.6);
  background: rgba(127, 29, 29, 0.36);
}

.top-actions {
  position: relative;
  display: flex;
  gap: 6px;
  align-items: end;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.top-actions button {
  min-width: max-content;
  padding: 0 10px;
  font-size: 12px;
}

.top-settings-menu {
  position: relative;
  order: -1;
}

.top-settings-menu summary {
  display: inline-grid;
  width: 34px;
  min-height: 28px;
  place-items: center;
  gap: 3px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: #26344f;
  cursor: pointer;
  list-style: none;
}

.top-settings-menu summary::-webkit-details-marker {
  display: none;
}

.top-settings-menu summary span {
  display: block;
  width: 16px;
  height: 2px;
  border-radius: 999px;
  background: #e2e8f0;
}

.top-settings-menu[open] summary {
  border-color: rgba(56, 189, 248, 0.72);
  background: rgba(14, 116, 144, 0.62);
}

.top-settings-panel {
  position: absolute;
  top: calc(100% + 7px);
  right: 0;
  z-index: 20;
  display: grid;
  width: 220px;
  gap: 7px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    rgba(15, 23, 42, 0.98);
  box-shadow: 0 14px 34px rgba(0, 0, 0, 0.36);
}

.top-settings-panel label {
  min-width: 0;
}

.top-settings-panel button,
.top-settings-panel select {
  width: 100%;
}

label,
.player-head span,
.energy-block span {
  display: grid;
  gap: 3px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.control-shell {
  position: relative;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
  width: 100%;
  margin: 0 auto;
  padding: 8px;
}

.field-control {
  position: absolute;
  top: 8px;
  left: 50%;
  z-index: 8;
  display: grid;
  grid-template-columns: minmax(0, 0.62fr) minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  align-self: start;
  width: clamp(320px, 24vw, 440px);
  min-width: 0;
  padding: 5px;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(250, 204, 21, 0.08), transparent),
    rgba(15, 23, 42, 0.68);
  transform: translateX(-50%);
}

.player-control[data-side="left"] {
  grid-column: 1;
}

.player-control[data-side="right"] {
  grid-column: 2;
}

.field-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
}

.field-control-head p {
  margin: 0 0 3px;
  color: var(--accent-2);
  font-size: 10px;
  font-weight: 900;
}

.field-control-head h2 {
  margin: 0;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-card-editor {
  display: grid;
  grid-template-columns: 62px minmax(0, 1fr);
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.field-card-editor label {
  min-width: 0;
}

.field-card-editor select {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.field-card-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 40px;
  overflow: hidden;
  border: 1px solid rgba(250, 204, 21, 0.34);
  border-radius: 6px;
  background: rgba(2, 6, 23, 0.62);
}

.field-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
}

.field-card-thumb span {
  position: absolute;
  color: rgba(248, 250, 252, 0.64);
  font-size: 22px;
  font-weight: 900;
}

.field-card-thumb:not(.is-empty) span {
  display: none;
}

.field-card-thumb.is-dummy span {
  display: none;
}

.auth-panel,
.password-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 420px);
  gap: 16px;
  align-items: end;
  margin: 14px;
  padding: 14px;
  border: 1px solid rgba(250, 204, 21, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(250, 204, 21, 0.08), transparent),
    rgba(23, 32, 51, 0.96);
}

.auth-panel[hidden],
.password-panel[hidden] {
  display: none;
}

.auth-panel p,
.password-panel p {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 12px;
  font-weight: 900;
}

.auth-panel h2,
.password-panel h2 {
  margin: 0;
  font-size: 20px;
}

.auth-panel span {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.auth-panel form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 8px;
}

.password-tools {
  grid-column: 1 / -1;
}

.password-tools[hidden] {
  display: none;
}

.password-tools {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.password-panel {
  grid-template-columns: minmax(0, 1fr) minmax(220px, 420px) 96px 86px;
  align-items: center;
  border-color: rgba(74, 222, 128, 0.42);
  background:
    linear-gradient(180deg, rgba(74, 222, 128, 0.08), transparent),
    rgba(23, 32, 51, 0.96);
}

.password-panel code {
  overflow-wrap: anywhere;
  padding: 8px 10px;
  border: 1px solid rgba(74, 222, 128, 0.34);
  border-radius: 6px;
  background: rgba(2, 6, 23, 0.48);
  color: #dcfce7;
  font-size: 14px;
  font-weight: 900;
}

.disclaimer {
  margin: 0;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  line-height: 1.65;
}

.player-control {
  display: grid;
  gap: 6px;
  min-width: 0;
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.38);
}

.player-status-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) minmax(330px, 430px);
  gap: 6px;
  align-items: start;
  min-width: 0;
}

.player-status-row.is-reversed {
  grid-template-columns: minmax(330px, 430px) minmax(240px, 1fr);
}

.player-summary {
  display: grid;
  align-content: start;
  gap: 6px;
  min-width: 0;
}

.player-summary .player-head {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.turn-order-tabs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  width: calc(100% - 220px);
  gap: 6px;
  padding: 5px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    rgba(15, 23, 42, 0.78);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.16);
}

.player-control[data-side="left"] > .turn-order-tabs {
  justify-self: start;
}

.player-control[data-side="right"] > .turn-order-tabs {
  justify-self: end;
}

.turn-order-tabs.has-selection {
  grid-template-columns: 1fr;
}

.turn-order-tab {
  min-height: 38px;
  border-color: rgba(148, 163, 184, 0.2);
  background: rgba(30, 41, 59, 0.74);
  color: #cbd5e1;
  font-size: 15px;
  font-weight: 950;
}

.turn-order-tab.is-active {
  color: #0f172a;
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(0, 0, 0, 0.24);
}

.turn-order-tab.is-first.is-active {
  border-color: rgba(250, 204, 21, 0.75);
  background: linear-gradient(180deg, #fde68a, #facc15);
}

.turn-order-tab.is-second.is-active {
  border-color: rgba(56, 189, 248, 0.76);
  background: linear-gradient(180deg, #7dd3fc, #38bdf8);
}

.turn-order-tab.is-eliminated {
  display: none;
}

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

.score-inputs {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px;
  min-width: 0;
}

.record-inputs input {
  min-width: 0;
  padding-inline: 4px;
  text-align: center;
}

.score-inputs input {
  min-width: 0;
  padding-inline: 5px;
  text-align: center;
}

.player-head,
.deck-code-panel,
.slot-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.04), transparent),
    rgba(23, 32, 51, 0.95);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.18);
}

.deck-code-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 48px 52px;
  gap: 5px;
  align-items: end;
  padding: 6px;
}

.deck-code-panel a,
.deck-code-panel button {
  display: inline-grid;
  min-height: 28px;
  place-items: center;
  padding: 0 8px;
  border: 1px solid rgba(56, 189, 248, 0.46);
  border-radius: 6px;
  background: rgba(14, 116, 144, 0.36);
  color: #e0f2fe;
  font-size: 11px;
  font-weight: 900;
  text-decoration: none;
}

.deck-code-panel button {
  border-color: rgba(74, 222, 128, 0.42);
  background: rgba(22, 101, 52, 0.44);
  color: #dcfce7;
}

.deck-code-panel a.is-disabled {
  opacity: 0.42;
  pointer-events: none;
}

.deck-code-note {
  grid-column: 1 / -1;
  min-height: 34px;
  padding: 6px 7px;
  border: 1px solid rgba(250, 204, 21, 0.22);
  border-radius: 6px;
  background: rgba(250, 204, 21, 0.07);
  color: #fde68a;
  font-size: 11px;
  font-weight: 850;
  line-height: 1.45;
}

.deck-code-note[hidden] {
  display: none;
}

.deck-code-note.is-loading {
  border-color: rgba(56, 189, 248, 0.36);
  background: rgba(56, 189, 248, 0.11);
  color: #bae6fd;
}

.deck-code-note.is-error {
  border-color: rgba(251, 113, 133, 0.42);
  background: rgba(251, 113, 133, 0.12);
  color: #fecdd3;
}

.deck-pickup-panel {
  display: grid;
  gap: 6px;
  min-width: 0;
  height: clamp(132px, 17vh, 176px);
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(74, 222, 128, 0.24);
  border-radius: 8px;
  background: rgba(5, 46, 22, 0.28);
}

.deck-pickup-panel[hidden] {
  display: none;
}

.deck-pickup-panel.is-empty {
  visibility: hidden;
  pointer-events: none;
}

.deck-pickup-panel > div:first-child {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.deck-image-preview {
  display: block;
  overflow: hidden;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 7px;
  background: rgba(2, 6, 23, 0.5);
}

.deck-image-preview img {
  display: block;
  width: 100%;
  height: auto;
}

.deck-pickup-panel strong {
  font-size: 11px;
}

.deck-pickup-panel span {
  color: var(--muted);
  font-size: 10px;
  font-weight: 800;
}

.deck-pickup-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
  gap: 6px;
}

.deck-pickup-card {
  min-width: 0;
  padding: 2px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 7px;
  background: rgba(15, 23, 42, 0.62);
}

.deck-pickup-card.is-pokemon {
  border-color: rgba(74, 222, 128, 0.34);
}

.deck-pickup-main {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.deck-pickup-main:disabled {
  opacity: 0.58;
}

.deck-pickup-thumb {
  display: grid;
  place-items: center;
  width: 100%;
  aspect-ratio: 5 / 7;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.26);
  border-radius: 5px;
  background: rgba(2, 6, 23, 0.54);
}

.deck-pickup-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
}

.player-head {
  display: grid;
  grid-template-columns: minmax(150px, 1.2fr) minmax(120px, 1fr) 68px 68px 52px 54px;
  gap: 5px;
  padding: 6px;
}

.turn-actions-panel {
  padding: 6px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
}

.turn-actions-controls {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.turn-actions-controls button {
  min-height: 30px;
  padding: 0 8px;
  font-size: 10px;
}

.turn-actions-controls button.turn-action-primary {
  border-color: rgba(251, 113, 133, 0.64);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.2), transparent 45%),
    linear-gradient(180deg, #ef4444, #991b1b);
  color: #ffffff;
  font-weight: 950;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.58);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 0 1px rgba(127, 29, 29, 0.58),
    0 4px 10px rgba(127, 29, 29, 0.24);
}

.turn-actions-controls button.turn-action-primary:hover:not(:disabled) {
  border-color: rgba(254, 202, 202, 0.9);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), transparent 45%),
    linear-gradient(180deg, #fb7185, #b91c1c);
}

.turn-actions-controls button.turn-action-primary.is-off-turn:not(:disabled) {
  border-color: rgba(100, 116, 139, 0.48);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.09), transparent 45%),
    linear-gradient(180deg, rgba(51, 65, 85, 0.92), rgba(15, 23, 42, 0.96));
  color: rgba(226, 232, 240, 0.78);
  text-shadow: none;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.06),
    0 0 0 1px rgba(15, 23, 42, 0.52);
}

.turn-actions-controls button.turn-action-primary:disabled {
  border-color: rgba(148, 163, 184, 0.18);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), transparent),
    rgba(30, 41, 59, 0.64);
  color: rgba(203, 213, 225, 0.46);
  box-shadow: none;
}

.turn-actions-controls button.is-next-turn {
  border-color: rgba(255, 236, 128, 0.88);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.26), transparent 48%),
    linear-gradient(180deg, #ffe45c, #e7a90c);
  color: #111827;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.32);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.24),
    0 0 0 1px rgba(120, 80, 0, 0.5),
    0 0 14px rgba(250, 204, 21, 0.28);
}

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

.slot-card-active {
  grid-column: auto;
  align-self: start;
  width: 100%;
  max-width: 430px;
  min-width: 0;
}

.slot-card-bench {
  grid-column: span 2;
}

.slot-card {
  display: grid;
  box-sizing: border-box;
  gap: 5px;
  padding: 6px;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
}

.slot-card.is-dragging {
  opacity: 0.58;
}

.slot-card.is-drop-target {
  border-color: rgba(56, 189, 248, 0.78);
  box-shadow:
    0 0 0 2px rgba(56, 189, 248, 0.24),
    0 8px 18px rgba(0, 0, 0, 0.18);
}

.slot-title,
.slot-actions,
.hp-controls,
.energy-block,
.energy-list,
.energy-buttons {
  display: flex;
  align-items: center;
  gap: 4px;
}

.slot-title {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 5px;
  min-width: 0;
}

.slot-title strong {
  min-width: 0;
  font-size: 13px;
}

.slot-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  min-width: 0;
  justify-content: flex-end;
  overflow: visible;
}

.slot-card-active .slot-title {
  grid-template-columns: minmax(0, 1fr);
  gap: 4px;
}

.slot-card-active .slot-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  width: 100%;
  max-width: 100%;
  justify-content: stretch;
}

.slot-card-active .slot-actions button {
  min-width: 0;
  width: 100%;
  padding-inline: 4px;
  font-size: 9px;
}

.slot-actions button {
  min-height: 24px;
  padding: 0 7px;
  font-size: 10px;
}

.card-picker {
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  gap: 6px;
  align-items: start;
}

.slot-card-active .card-picker {
  grid-template-columns: 128px minmax(0, 1fr);
}

.card-visual {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.card-fields {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.card-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 36px;
  gap: 5px;
  align-items: center;
  min-width: 0;
}

.card-select-row.has-image-menu {
  grid-template-columns: minmax(0, 1fr);
}

.card-select-row.has-image-menu > select {
  display: none;
}

.card-image-select {
  position: relative;
  min-width: 0;
}

.card-image-select-summary {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 7px;
  min-height: 34px;
  padding: 3px 28px 3px 5px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.035), transparent),
    rgba(2, 6, 23, 0.58);
  color: var(--text);
  cursor: pointer;
  list-style: none;
}

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

.card-image-select-summary::after {
  position: absolute;
  right: 10px;
  color: #cbd5e1;
  font-size: 12px;
  content: "⌄";
}

.card-image-select[open] .card-image-select-summary {
  border-color: rgba(56, 189, 248, 0.54);
  box-shadow: 0 0 0 1px rgba(56, 189, 248, 0.16);
}

.card-image-select.is-disabled {
  opacity: 0.58;
}

.card-image-select.is-disabled .card-image-select-summary {
  cursor: not-allowed;
}

.card-image-select-menu {
  position: absolute;
  z-index: 80;
  top: calc(100% + 5px);
  left: 0;
  display: grid;
  gap: 3px;
  width: min(260px, 78vw);
  max-height: 260px;
  overflow: auto;
  padding: 6px;
  border: 1px solid rgba(56, 189, 248, 0.36);
  border-radius: 9px;
  background:
    linear-gradient(180deg, rgba(20, 184, 166, 0.08), transparent),
    rgba(15, 23, 42, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.42);
}

.card-image-select-option {
  display: grid;
  grid-template-columns: 34px minmax(0, 1fr);
  align-items: center;
  gap: 8px;
  min-height: 38px;
  padding: 4px 7px;
  border: 1px solid transparent;
  border-radius: 7px;
  background: transparent;
  color: #e5edf8;
  font-size: 11px;
  font-weight: 900;
  text-align: left;
}

.card-image-select-option:hover,
.card-image-select-option[aria-selected="true"] {
  border-color: rgba(251, 146, 60, 0.42);
  background: rgba(194, 65, 12, 0.76);
  color: #ffffff;
}

.card-image-select-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 32px;
  height: 28px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 5px;
  background: rgba(2, 6, 23, 0.58);
}

.card-image-select-thumb img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
}

.card-image-select-thumb:not(.is-empty) .card-image-select-initial {
  display: none;
}

.card-image-select-initial {
  position: absolute;
  color: rgba(226, 232, 240, 0.72);
  font-size: 13px;
  font-weight: 950;
}

.card-image-select-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-select-preview {
  position: relative;
  display: grid;
  place-items: center;
  width: 36px;
  height: 28px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 5px;
  background: rgba(2, 6, 23, 0.52);
  color: rgba(226, 232, 240, 0.72);
  font-size: 13px;
  font-weight: 950;
}

.card-select-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
}

.card-select-preview span {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
}

.card-select-preview.is-empty span {
  display: grid;
}

.card-select-preview.is-empty img {
  display: none;
}

.slot-card-bench .card-picker {
  grid-template-columns: 112px minmax(0, 1fr);
  align-items: start;
}

.slot-card-bench [data-card-select="replace"] {
  min-height: 32px;
  font-size: 12px;
  font-weight: 950;
}

.card-thumb {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 66px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 6px;
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.08), transparent),
    rgba(2, 6, 23, 0.5);
}

.card-thumb[draggable="true"] {
  cursor: grab;
}

.card-thumb[draggable="true"]:active {
  cursor: grabbing;
}

.slot-card.is-drop-target .card-thumb {
  border-color: rgba(56, 189, 248, 0.72);
}

.slot-card-bench .card-thumb {
  height: 72px;
}

.bench-energy-overlay {
  position: absolute;
  right: 4px;
  bottom: 4px;
  z-index: 2;
  display: flex;
  flex-direction: row-reverse;
  flex-wrap: wrap-reverse;
  gap: 2px;
  width: 66px;
  min-height: 26px;
  justify-content: flex-start;
  padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.72);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.42);
  pointer-events: auto;
}

.bench-energy-overlay[hidden] {
  display: none;
}

.bench-energy-overlay .energy-chip {
  flex: 0 0 24px;
  width: 24px;
  min-width: 24px;
  max-width: 24px;
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  border-width: 1px;
  box-shadow:
    0 0 0 1px rgba(2, 6, 23, 0.72),
    0 1px 4px rgba(0, 0, 0, 0.42);
}

.bench-energy-overlay .energy-chip::after {
  inset: -2px;
}

.pokemon-tool-badge {
  position: absolute;
  left: 3px;
  bottom: 3px;
  z-index: 3;
  max-width: calc(100% - 6px);
  overflow: hidden;
  padding: 3px 5px;
  border: 1px solid rgba(250, 204, 21, 0.66);
  border-radius: 999px;
  background: rgba(113, 63, 18, 0.88);
  color: #fef3c7;
  font-size: 9px;
  font-weight: 950;
  line-height: 1;
  text-overflow: ellipsis;
  white-space: nowrap;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.35);
  pointer-events: none;
}

.pokemon-tool-badge.has-image {
  display: grid;
  width: 42px;
  height: 30px;
  place-items: center;
  padding: 2px;
  border-radius: 5px;
  background: rgba(15, 23, 42, 0.82);
}

.pokemon-tool-badge.has-image img {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 3px;
  object-fit: cover;
  object-position: 50% 18%;
}

.card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
}

.card-thumb span {
  position: absolute;
  color: rgba(248, 250, 252, 0.62);
  font-size: 22px;
  font-weight: 900;
}

.card-thumb:not(.is-empty) span {
  display: none;
}

.card-thumb.is-placeholder {
  background: rgba(2, 6, 23, 0.62);
}

.card-thumb.is-placeholder img {
  object-fit: cover;
  object-position: 50% 50%;
}

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

.slot-card-bench .hp-controls {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hp-controls input {
  min-height: 30px;
  padding: 4px 6px;
  font-size: 12px;
  font-weight: 900;
}

.hp-controls label {
  min-width: 0;
  font-size: 10px;
}

.battle-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 5px;
  align-items: start;
}

.combat-controls {
  display: grid;
  gap: 5px;
  min-width: 0;
  align-self: start;
  overflow: visible;
}

.damage-controls {
  display: grid;
  grid-template-columns: repeat(3, 34px) minmax(50px, 68px) 42px;
  gap: 3px;
  align-items: center;
  width: min(100%, 232px);
  max-width: 100%;
}

.damage-controls button,
.condition-toggle {
  min-height: 24px;
  padding: 0 6px;
  font-size: 10px;
}

.damage-controls button {
  min-width: 0;
  padding-inline: 0;
}

.damage-controls [data-damage-select="10"] {
  border-color: rgba(250, 204, 21, 0.34);
  background:
    linear-gradient(180deg, rgba(250, 204, 21, 0.22), rgba(113, 63, 18, 0.2)),
    rgba(15, 23, 42, 0.7);
  color: #fef3c7;
}

.damage-controls [data-damage-select="50"] {
  border-color: rgba(251, 146, 60, 0.36);
  background:
    linear-gradient(180deg, rgba(251, 146, 60, 0.22), rgba(124, 45, 18, 0.22)),
    rgba(15, 23, 42, 0.7);
  color: #ffedd5;
}

.damage-controls [data-damage-select="100"] {
  border-color: rgba(248, 113, 113, 0.38);
  background:
    linear-gradient(180deg, rgba(248, 113, 113, 0.23), rgba(127, 29, 29, 0.24)),
    rgba(15, 23, 42, 0.7);
  color: #fee2e2;
}

.damage-controls [data-damage-select].is-selected {
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.1),
    0 0 10px rgba(15, 23, 42, 0.28);
}

.damage-controls [data-damage-select="10"].is-selected {
  border-color: rgba(250, 204, 21, 0.56);
  background:
    linear-gradient(180deg, rgba(250, 204, 21, 0.34), rgba(113, 63, 18, 0.28)),
    rgba(15, 23, 42, 0.72);
}

.damage-controls [data-damage-select="50"].is-selected {
  border-color: rgba(251, 146, 60, 0.6);
  background:
    linear-gradient(180deg, rgba(251, 146, 60, 0.35), rgba(124, 45, 18, 0.32)),
    rgba(15, 23, 42, 0.72);
}

.damage-controls [data-damage-select="100"].is-selected {
  border-color: rgba(248, 113, 113, 0.62);
  background:
    linear-gradient(180deg, rgba(248, 113, 113, 0.36), rgba(127, 29, 29, 0.36)),
    rgba(15, 23, 42, 0.72);
}

.damage-input {
  width: 100%;
  min-width: 0;
  min-height: 24px;
  padding: 0 5px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: rgba(2, 6, 23, 0.58);
  color: var(--text);
  font-size: 11px;
  font-weight: 850;
  line-height: 1;
}

.damage-input:focus {
  border-color: rgba(56, 189, 248, 0.82);
  outline: 2px solid rgba(56, 189, 248, 0.18);
}

.damage-apply {
  border-color: rgba(74, 222, 128, 0.44);
  background: rgba(22, 101, 52, 0.58);
  color: #dcfce7;
}

.damage-controls .knockout-pending,
.slot-actions .knockout-pending {
  border-color: rgba(251, 113, 133, 0.58);
  background: rgba(127, 29, 29, 0.72);
  color: #ffe4e6;
}

.condition-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.pokemon-check-note {
  padding: 4px 6px;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 6px;
  background: rgba(250, 204, 21, 0.08);
  color: #fde68a;
  font-size: 10px;
  font-weight: 900;
  line-height: 1.35;
}

.condition-toggle {
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(15, 23, 42, 0.72);
  color: #dbeafe;
}

.condition-toggle.is-on {
  color: #fff;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.18), 0 0 16px rgba(56, 189, 248, 0.2);
}

.condition-poison.is-on {
  border-color: rgba(168, 85, 247, 0.7);
  background: #6d28d9;
}

.condition-burn.is-on {
  border-color: rgba(248, 113, 113, 0.75);
  background: #b91c1c;
}

.condition-confusion.is-on {
  border-color: rgba(244, 114, 182, 0.75);
  background: #be185d;
}

.condition-paralysis.is-on {
  border-color: rgba(250, 204, 21, 0.82);
  background: #a16207;
}

.energy-block {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 7px;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
  padding: 5px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.52);
}

.slot-card-bench .energy-block {
  grid-template-columns: 1fr;
}

.slot-card-bench .energy-buttons {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 1px;
}

.slot-card-bench .energy-stepper {
  grid-template-rows: 12px 18px 12px;
  max-width: 24px;
  min-width: 18px;
  padding: 1px;
}

.slot-card-bench .energy-stepper .energy-add {
  flex-basis: 18px;
  width: 18px;
  min-width: 18px;
  max-width: 18px;
  height: 18px;
  min-height: 18px;
  max-height: 18px;
  border-width: 1px;
}

.slot-card-bench .energy-step {
  width: 12px;
  min-width: 12px;
  height: 12px;
  min-height: 12px;
  font-size: 9px;
}

.slot-card-bench .energy-count-badge {
  top: 13px;
  right: -2px;
  min-width: 13px;
  height: 13px;
  padding: 0 3px;
  font-size: 8px;
}

.energy-current {
  display: grid;
  grid-template-columns: 66px minmax(0, 1fr);
  gap: 6px;
  align-items: stretch;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  overflow: visible;
}

.energy-current > span {
  display: grid;
  min-height: 38px;
  align-items: center;
  align-self: stretch;
}

.attached-energy-display {
  display: grid;
  grid-template-columns: 1fr;
  gap: 3px;
  align-items: stretch;
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-width: 0;
  min-height: 42px;
  padding: 4px;
  border: 1px solid rgba(96, 165, 250, 0.42);
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(96, 165, 250, 0.12), rgba(15, 23, 42, 0.2)),
    rgba(2, 6, 23, 0.34);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.035),
    0 0 0 1px rgba(15, 23, 42, 0.22);
}

.attached-energy-display .energy-list {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  min-height: 32px;
  max-height: 32px;
  flex-wrap: nowrap;
  overflow: hidden;
  padding: 2px;
  border: 1px dashed rgba(148, 163, 184, 0.32);
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.36);
}

.slot-card-bench .damage-controls {
  grid-template-columns: repeat(3, 27px) minmax(34px, 40px) 34px;
  gap: 2px;
  width: 100%;
}

.slot-card-bench .damage-controls button {
  min-height: 22px;
  font-size: 9px;
}

.slot-card-bench .damage-input {
  min-height: 22px;
  padding-inline: 4px;
  font-size: 10px;
}

.retreat-block {
  grid-template-columns: 1fr;
  background: rgba(250, 204, 21, 0.06);
}

.retreat-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  white-space: nowrap;
}

.retreat-open {
  min-height: 24px;
  min-width: 0;
  width: auto;
  padding: 0 7px;
  border-color: rgba(250, 204, 21, 0.5);
  background: rgba(113, 63, 18, 0.58);
  color: #fef3c7;
  font-size: 10px;
}

.retreat-cost-editor {
  display: flex;
  align-items: center;
  gap: 4px;
  min-width: 0;
  overflow-x: auto;
  scrollbar-width: thin;
}

.retreat-cost-editor select {
  flex: 0 0 auto;
  min-height: 24px;
  padding: 0 18px 0 6px;
  font-size: 10px;
  font-weight: 900;
}

.retreat-cost-count {
  width: 58px;
}

.retreat-open:disabled {
  border-color: rgba(148, 163, 184, 0.22);
  background: rgba(15, 23, 42, 0.48);
  color: #94a3b8;
  opacity: 0.62;
}

.retreat-warning {
  padding: 5px 7px;
  border: 1px solid rgba(251, 191, 36, 0.42);
  border-radius: 6px;
  background: rgba(113, 63, 18, 0.34);
  color: #fde68a;
  font-size: 11px;
  font-weight: 900;
  line-height: 1.35;
}

.retreat-warning[hidden] {
  display: none;
}

.energy-list {
  min-height: 28px;
  flex-wrap: wrap;
}

.energy-buttons {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 2px;
  align-items: center;
  justify-items: center;
  width: 100%;
  max-width: none;
  min-width: 0;
  overflow: visible;
}

.slot-card-active .energy-buttons {
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 1px;
}

.slot-card-active .energy-stepper {
  grid-template-rows: 12px 20px 12px;
  max-width: 24px;
  min-width: 18px;
  padding: 1px;
}

.slot-card-active .energy-stepper .energy-add {
  flex-basis: 20px;
  width: 20px;
  min-width: 20px;
  max-width: 20px;
  height: 20px;
  min-height: 20px;
  max-height: 20px;
  border-width: 1px;
}

.slot-card-active .energy-step {
  width: 12px;
  min-width: 12px;
  height: 12px;
  min-height: 12px;
  font-size: 9px;
}

.slot-card-active .energy-count-badge {
  top: 14px;
  right: -2px;
  min-width: 13px;
  height: 13px;
  padding: 0 3px;
  font-size: 8px;
}

.energy-chip,
.energy-add {
  display: inline-flex;
  flex: 0 0 28px;
  width: 28px;
  min-width: 28px;
  max-width: 28px;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  aspect-ratio: 1 / 1;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 2px solid rgba(255, 255, 255, 0.58);
  border-radius: 999px;
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  color: transparent;
  font-size: 0;
  font-weight: 850;
  line-height: 1;
  letter-spacing: 0;
  overflow: hidden;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.28), 0 1px 4px rgba(0, 0, 0, 0.22);
}

.energy-chip {
  cursor: pointer;
  position: relative;
  overflow: visible;
}

.energy-stack-count {
  position: absolute;
  inset: auto -4px -4px auto;
  z-index: 3;
  display: inline-grid;
  min-width: 17px;
  height: 17px;
  place-items: center;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.78);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(15, 23, 42, 0.45);
  pointer-events: none;
}

.bench-energy-overlay .energy-stack-count {
  min-width: 16px;
  height: 16px;
  padding: 0 3px;
  font-size: 10px;
}

.energy-chip::after {
  position: absolute;
  inset: -4px;
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 999px;
  content: "";
}

.energy-chip.is-energy-attach-animation {
  animation: energyAttachPop 0.82s cubic-bezier(0.2, 1.35, 0.32, 1) both;
}

.energy-chip.is-energy-attach-animation::after {
  animation: energyAttachRing 0.82s ease-out both;
}

@keyframes energyAttachPop {
  0% {
    filter: brightness(1.25) saturate(1.25);
    transform: scale(0.45) rotate(-10deg);
  }

  45% {
    filter: brightness(1.65) saturate(1.45);
    transform: scale(1.34) rotate(8deg);
  }

  100% {
    filter: brightness(1) saturate(1);
    transform: scale(1) rotate(0);
  }
}

@keyframes energyAttachRing {
  0% {
    border-color: rgba(250, 204, 21, 0.95);
    box-shadow: 0 0 0 0 rgba(250, 204, 21, 0.68);
    opacity: 1;
    transform: scale(0.7);
  }

  100% {
    border-color: rgba(255, 255, 255, 0);
    box-shadow: 0 0 0 13px rgba(250, 204, 21, 0);
    opacity: 0;
    transform: scale(1.45);
  }
}

.energy-add {
  border-color: rgba(255, 255, 255, 0.24);
  color: #fff;
}

.energy-add:hover,
.energy-chip:hover {
  transform: translateY(-1px);
  border-color: rgba(255, 255, 255, 0.86);
}

.energy-add:disabled {
  opacity: 0.26;
  transform: none;
}

.energy-stepper {
  position: relative;
  display: grid;
  grid-template-rows: 14px 22px 14px;
  gap: 2px;
  align-items: center;
  justify-items: center;
  justify-content: center;
  min-width: 0;
  width: 100%;
  max-width: 28px;
  padding: 1px;
  border: 1px solid rgba(148, 163, 184, 0.16);
  border-radius: 999px;
  background: rgba(2, 6, 23, 0.28);
}

.energy-count-badge {
  position: absolute;
  right: -3px;
  top: 18px;
  z-index: 2;
  display: inline-grid;
  min-width: 16px;
  height: 16px;
  place-items: center;
  padding: 0 4px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.94);
  color: #ffffff;
  font-size: 10px;
  font-weight: 950;
  line-height: 1;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.38),
    0 0 0 1px rgba(15, 23, 42, 0.52);
  pointer-events: none;
}

.energy-stepper .energy-add {
  flex-basis: 24px;
  width: 24px;
  min-width: 24px;
  max-width: 24px;
  height: 24px;
  min-height: 24px;
  max-height: 24px;
  pointer-events: none;
}

.energy-step-controls {
  display: contents;
}

.energy-step {
  display: inline-grid;
  width: 14px;
  min-width: 14px;
  height: 14px;
  min-height: 14px;
  place-items: center;
  padding: 0;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 950;
  line-height: 1;
}

.energy-step-minus {
  border-color: rgba(251, 113, 133, 0.38);
  background: rgba(127, 29, 29, 0.38);
  color: #fecdd3;
}

.energy-step-plus {
  border-color: rgba(74, 222, 128, 0.38);
  background: rgba(22, 101, 52, 0.42);
  color: #bbf7d0;
}

.energy-step-plus:disabled {
  border-color: rgba(148, 163, 184, 0.18);
  background: rgba(15, 23, 42, 0.36);
  color: #64748b;
  opacity: 0.56;
}

.energy-empty {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  white-space: nowrap;
}

.energy-grass {
  background-image: url("../assets/icons/energy-grass.png?v=20260521-1");
  color: #ffffff;
}

.energy-fire {
  background-image: url("../assets/icons/energy-fire.png?v=20260521-1");
  color: #fff8ed;
}

.energy-water {
  background-image: url("../assets/icons/energy-water.png?v=20260521-1");
  color: #ffffff;
}

.energy-lightning {
  background-image: url("../assets/icons/energy-lightning.png?v=20260521-1");
  color: #352708;
}

.energy-psychic {
  background-image: url("../assets/icons/energy-psychic.png?v=20260521-1");
  color: #ffffff;
}

.energy-fighting {
  background-image: url("../assets/icons/energy-fighting.png?v=20260521-1");
  color: #ffffff;
}

.energy-darkness {
  background-image: url("../assets/icons/energy-darkness.png?v=20260521-1");
  color: #ffffff;
}

.energy-metal {
  background-image: url("../assets/icons/energy-metal.png?v=20260521-1");
  color: #172033;
}

.energy-colorless {
  background-image: url("../assets/icons/energy-colorless.png?v=20260521-1");
  color: #172033;
}

.toast {
  position: fixed;
  right: 16px;
  bottom: 16px;
  max-width: min(420px, calc(100vw - 32px));
  padding: 10px 12px;
  border: 1px solid rgba(74, 222, 128, 0.46);
  border-radius: 8px;
  background: rgba(22, 101, 52, 0.96);
  color: #ecfdf5;
  font-weight: 800;
  opacity: 0;
  transform: translateY(8px);
  transition: 0.18s ease;
  pointer-events: none;
}

.toast.is-visible {
  opacity: 1;
  transform: translateY(0);
}

.retreat-modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 20px;
}

.retreat-modal[hidden] {
  display: none;
}

.retreat-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.retreat-modal-panel {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: min(720px, calc(100vh - 40px));
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(250, 204, 21, 0.42);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(250, 204, 21, 0.08), transparent),
    rgba(15, 23, 42, 0.98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.retreat-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.retreat-modal-head p {
  margin: 0 0 4px;
  color: var(--accent-2);
  font-size: 11px;
  font-weight: 900;
}

.retreat-modal-head h2 {
  margin: 0;
  font-size: 18px;
}

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

.retreat-option {
  display: grid;
  grid-template-columns: 92px minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 86px;
  padding: 8px;
  border-color: rgba(148, 163, 184, 0.28);
  background: rgba(23, 32, 51, 0.96);
  text-align: left;
  white-space: normal;
}

.retreat-option:hover {
  border-color: rgba(250, 204, 21, 0.72);
  background: rgba(30, 41, 59, 0.98);
}

.retreat-option:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.retreat-discard {
  display: grid;
  gap: 6px;
  margin-bottom: 12px;
  padding: 10px;
  border: 1px solid rgba(250, 204, 21, 0.28);
  border-radius: 8px;
  background: rgba(113, 63, 18, 0.18);
}

.retreat-discard strong {
  font-size: 13px;
}

.retreat-discard span,
.retreat-discard em {
  color: var(--muted);
  font-size: 12px;
  font-style: normal;
  font-weight: 800;
}

.retreat-discard em {
  color: #fecaca;
}

.retreat-discard-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 30px;
}

.retreat-discard-chip.is-selected {
  outline: 3px solid rgba(250, 204, 21, 0.82);
  outline-offset: 2px;
  transform: translateY(-1px);
}

.retreat-option-thumb {
  display: grid;
  place-items: center;
  width: 92px;
  height: 66px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.34);
  border-radius: 7px;
  background: rgba(2, 6, 23, 0.55);
}

.retreat-option-thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: 50% 50%;
}

.retreat-option-body {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.retreat-option-body strong {
  color: var(--accent-2);
  font-size: 12px;
}

.retreat-option-body span {
  overflow: hidden;
  color: var(--text);
  font-size: 14px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.retreat-option-body small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.new-game-modal {
  position: fixed;
  inset: 0;
  z-index: 22;
  display: grid;
  place-items: center;
  padding: 20px;
}

.new-game-modal[hidden] {
  display: none;
}

.new-game-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.new-game-modal-panel {
  position: relative;
  z-index: 1;
  width: min(680px, 100%);
  max-height: min(680px, calc(100vh - 40px));
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(74, 222, 128, 0.42);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(74, 222, 128, 0.08), transparent),
    rgba(15, 23, 42, 0.98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.new-game-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.new-game-modal-head p {
  margin: 0 0 4px;
  color: var(--ok);
  font-size: 11px;
  font-weight: 900;
}

.new-game-modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.new-game-turn {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.new-game-turn label {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(23, 32, 51, 0.86);
  font-weight: 900;
}

.new-game-turn input {
  width: 16px;
  min-height: 16px;
  margin: 0;
}

.new-game-setup {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}

.new-game-player-setup {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid rgba(148, 163, 184, 0.24);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.24);
}

.new-game-player-setup > strong {
  color: #e2e8f0;
  font-size: 12px;
  font-weight: 950;
}

.new-game-deck-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 58px;
  gap: 6px;
  min-width: 0;
}

.new-game-deck-row button {
  padding: 0 8px;
}

.new-game-player-setup label {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 900;
}

.new-game-player-setup input,
.new-game-player-setup select {
  min-width: 0;
}

.new-game-checks {
  display: grid;
  gap: 7px;
  margin-bottom: 14px;
}

.new-game-checks div {
  padding: 8px 10px;
  border: 1px solid rgba(148, 163, 184, 0.22);
  border-radius: 7px;
  background: rgba(2, 6, 23, 0.34);
  color: var(--muted);
  font-weight: 850;
}

.new-game-checks .is-ok {
  border-color: rgba(74, 222, 128, 0.34);
  color: #bbf7d0;
}

.new-game-checks .is-error {
  border-color: rgba(251, 113, 133, 0.42);
  background: rgba(127, 29, 29, 0.24);
  color: #fecdd3;
}

.new-game-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
  padding-top: 12px;
}

.new-game-actions button {
  min-height: 34px;
  padding: 0 14px;
}

.deck-card-modal {
  position: fixed;
  inset: 0;
  z-index: 21;
  display: grid;
  place-items: center;
  padding: 20px;
}

.deck-card-modal[hidden] {
  display: none;
}

.deck-card-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(8px);
}

.deck-card-modal-panel {
  position: relative;
  z-index: 1;
  width: min(760px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  padding: 14px;
  border: 1px solid rgba(56, 189, 248, 0.42);
  border-radius: 10px;
  background:
    linear-gradient(180deg, rgba(56, 189, 248, 0.09), transparent),
    rgba(15, 23, 42, 0.98);
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
}

.deck-card-modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.deck-card-modal-head p {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 900;
}

.deck-card-modal-head h2 {
  margin: 0;
  font-size: 18px;
}

.deck-card-modal-body {
  display: grid;
  grid-template-columns: minmax(180px, 240px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.deck-card-modal-image {
  display: grid;
  place-items: center;
  min-height: 260px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.55);
  color: var(--muted);
  font-size: 42px;
  font-weight: 950;
}

.deck-card-modal-image img {
  display: block;
  width: 100%;
  max-height: 420px;
  object-fit: contain;
  object-position: 50% 50%;
}

.deck-card-modal-info {
  display: grid;
  gap: 10px;
  min-width: 0;
}

.deck-card-detail-list {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 6px 10px;
  margin: 0;
}

.deck-card-detail-list dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 900;
}

.deck-card-detail-list dd {
  min-width: 0;
  margin: 0;
  color: var(--text);
  font-size: 13px;
  font-weight: 850;
  overflow-wrap: anywhere;
}

.deck-card-energy-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
}

.deck-card-move-list {
  display: grid;
  gap: 8px;
}

.deck-card-move-list > div {
  display: grid;
  gap: 6px;
  padding: 8px;
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 8px;
  background: rgba(2, 6, 23, 0.3);
}

.deck-card-move-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
}

.deck-card-move-head strong {
  color: var(--text);
  font-size: 13px;
}

.deck-card-move-head span {
  color: #fef3c7;
  font-size: 13px;
  font-weight: 950;
}

.deck-card-detail-link {
  color: #bae6fd;
  font-size: 12px;
  font-weight: 900;
}

.deck-card-modal-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(148, 163, 184, 0.18);
}

.deck-card-modal-actions button {
  min-height: 32px;
  border-color: rgba(74, 222, 128, 0.36);
  background: rgba(22, 101, 52, 0.44);
  color: #dcfce7;
}

@media (max-width: 1180px) {
  .control-shell,
  .player-head,
  .deck-code-panel,
  .field-control {
    grid-template-columns: 1fr;
  }

  .field-control {
    position: static;
    width: auto;
    transform: none;
  }

  .field-control,
  .player-control[data-side="left"],
  .player-control[data-side="right"] {
    grid-column: 1;
    grid-row: auto;
  }

  .turn-order-tabs {
    width: 100%;
  }

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

  .slot-card-active,
  .slot-card-bench {
    grid-column: span 1;
  }

  .slot-card-active {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .topbar,
  .top-actions,
  .player-status-row,
  .player-head,
  .deck-code-panel,
  .card-picker,
  .slot-card-bench .card-picker,
  .hp-controls,
  .slot-card-bench .hp-controls,
  .battle-actions {
    grid-template-columns: 1fr;
  }

  .combat-controls {
    grid-column: 1;
  }

  .topbar {
    display: grid;
  }

  .title-row,
  .match-timer {
    align-items: start;
  }

  .match-timer {
    position: static;
    transform: none;
    flex-wrap: wrap;
  }

  .top-actions {
    display: grid;
  }

  .top-actions label {
    flex: initial;
  }

  .energy-block {
    display: grid;
  }

  .energy-buttons {
    grid-template-columns: repeat(9, minmax(26px, 1fr));
  }

  .slot-card-bench .energy-buttons {
    grid-template-columns: repeat(9, minmax(18px, 1fr));
  }

  .energy-current,
  .attached-energy-display {
    grid-template-columns: 1fr;
  }

  .attached-energy-display {
    min-height: 44px;
  }

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

  .slot-card-active,
  .slot-card-bench {
    grid-column: 1 / -1;
  }

  .retreat-options {
    grid-template-columns: 1fr;
  }

  .new-game-turn {
    grid-template-columns: 1fr;
  }

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

  .deck-card-modal-body {
    grid-template-columns: 1fr;
  }

  .deck-card-modal-image {
    min-height: 220px;
  }

  .deck-pickup-list {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  }
}
