:root {
  color-scheme: dark;
  --bg: #101215;
  --bg-2: #181613;
  --panel: rgba(28, 28, 29, 0.9);
  --panel-2: rgba(39, 37, 34, 0.92);
  --paper: #e2d4a3;
  --paper-2: #c5a96b;
  --ink: #f4ecd4;
  --muted: #b9ad93;
  --line: rgba(229, 202, 134, 0.22);
  --teal: #50c7c2;
  --fire: #e35d3f;
  --water: #43a4d7;
  --wind: #7ccf74;
  --earth: #c49a45;
  --light: #eadc82;
  --chocobo: #f4c83d;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 10%, rgba(80, 199, 194, 0.18), transparent 28rem),
    linear-gradient(145deg, var(--bg), #18110f 52%, #0f1414);
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  width: min(1500px, calc(100vw - 28px));
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 0 24px;
}

.topbar,
.phase-panel,
.mode-panel,
.board,
.hand-panel {
  width: 100%;
}

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

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border: 1px solid var(--line);
  background:
    linear-gradient(135deg, rgba(234, 220, 130, 0.9), rgba(80, 199, 194, 0.9)),
    #1d1b18;
  clip-path: polygon(50% 0, 92% 28%, 76% 100%, 24% 100%, 8% 28%);
  box-shadow: 0 10px 24px rgba(80, 199, 194, 0.14);
}

.brand h1 {
  margin: 0;
  font-size: clamp(1.7rem, 4vw, 3.2rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.brand p,
.score-card span,
.panel-head,
.hand-head {
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0;
  font-size: 0.76rem;
  font-weight: 800;
}

.brand p {
  margin: 5px 0 0;
}

.score-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 8px;
  min-width: min(620px, 100%);
}

.player-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-width: 190px;
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 21, 22, 0.74);
}

.player-card span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.player-card strong {
  display: block;
  margin-top: 3px;
  color: var(--paper);
  font-size: 1rem;
}

.score-card {
  min-height: 62px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 21, 22, 0.74);
}

.score-card strong {
  display: block;
  margin-top: 2px;
  color: var(--paper);
  font-size: 1.45rem;
  line-height: 1;
}

.phase-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.45fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.phase-track,
.phase-copy {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 21, 22, 0.74);
}

.phase-track {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 8px;
}

.phase-step {
  min-height: 52px;
  border: 1px solid rgba(244, 236, 212, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  padding: 9px 10px;
}

.phase-step span,
.phase-copy span {
  display: block;
}

.phase-step span:first-child {
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.phase-step span:last-child {
  margin-top: 3px;
  font-size: 0.86rem;
  font-weight: 900;
  color: var(--ink);
}

.phase-step.is-active {
  border-color: rgba(80, 199, 194, 0.65);
  background: linear-gradient(180deg, rgba(80, 199, 194, 0.22), rgba(80, 199, 194, 0.05));
  box-shadow: inset 0 0 0 1px rgba(80, 199, 194, 0.14);
}

.phase-step.is-done {
  border-color: rgba(234, 220, 130, 0.28);
  color: var(--paper-2);
}

.phase-copy {
  min-height: 70px;
  padding: 12px;
}

.phase-copy strong {
  display: block;
  color: var(--paper);
  font-size: 1rem;
}

.phase-copy span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.mode-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.32fr) minmax(0, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
}

.mode-switch,
.duelist-strip {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(21, 21, 22, 0.74);
}

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

.mode-button {
  min-height: 50px;
  border: 1px solid rgba(244, 236, 212, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--muted);
  font-weight: 900;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, color 140ms ease;
}

.mode-button.is-active {
  border-color: rgba(80, 199, 194, 0.68);
  background: linear-gradient(180deg, rgba(80, 199, 194, 0.24), rgba(80, 199, 194, 0.06));
  color: var(--ink);
}

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

.duelist-card {
  min-height: 74px;
  border: 1px solid rgba(244, 236, 212, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.duelist-card.is-active {
  border-color: rgba(234, 220, 130, 0.52);
  background: linear-gradient(180deg, rgba(234, 220, 130, 0.14), rgba(255, 255, 255, 0.035));
}

.duelist-card span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.duelist-card strong {
  display: block;
  margin-top: 2px;
  color: var(--paper);
  font-size: 1rem;
  line-height: 1.15;
}

.duelist-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.duelist-stats b {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border: 1px solid rgba(244, 236, 212, 0.13);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: #d7ccb2;
  padding: 0 8px;
  font-size: 0.69rem;
}

.board {
  display: grid;
  grid-template-columns: minmax(260px, 0.88fr) minmax(460px, 1.5fr) minmax(260px, 0.82fr);
  gap: 14px;
}

.panel,
.hand-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--panel), rgba(17, 18, 19, 0.94));
  box-shadow: var(--shadow);
}

.panel {
  min-height: 560px;
  padding: 14px;
}

.panel-head,
.hand-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 34px;
  margin-bottom: 12px;
}

.field-actions,
.action-stack {
  display: flex;
  gap: 8px;
}

.icon-button,
.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 36px;
  border: 1px solid var(--line);
  border-radius: 7px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.icon-button {
  width: 38px;
  padding: 0;
}

.primary-button,
.secondary-button {
  padding: 0 12px;
  font-size: 0.84rem;
  font-weight: 800;
}

.primary-button {
  background: linear-gradient(180deg, rgba(80, 199, 194, 0.18), rgba(80, 199, 194, 0.05));
  border-color: rgba(80, 199, 194, 0.46);
}

.primary-button.quiet {
  background: linear-gradient(180deg, rgba(244, 236, 212, 0.12), rgba(244, 236, 212, 0.04));
  border-color: rgba(244, 236, 212, 0.25);
}

.primary-button.danger {
  background: linear-gradient(180deg, rgba(227, 93, 63, 0.22), rgba(227, 93, 63, 0.06));
  border-color: rgba(227, 93, 63, 0.44);
}

.secondary-button {
  width: 100%;
}

.icon-button svg,
.primary-button svg,
.secondary-button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  border-color: rgba(244, 236, 212, 0.45);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.encounter-card,
.card,
.opponent-card {
  overflow: hidden;
  border: 1px solid rgba(244, 236, 212, 0.18);
  border-radius: var(--radius);
  background: #171717;
}

.encounter-card {
  min-height: 286px;
  margin-bottom: 12px;
}

.opponent-card {
  min-height: 124px;
  margin-bottom: 12px;
  background:
    linear-gradient(135deg, rgba(227, 93, 63, 0.16), rgba(80, 199, 194, 0.06)),
    rgba(255, 255, 255, 0.035);
}

.opponent-body {
  padding: 12px;
}

.opponent-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.opponent-body h3 {
  margin: 0;
  font-size: 1rem;
  line-height: 1.12;
}

.opponent-body p {
  margin: 8px 0 0;
  color: #d7ccb2;
  font-size: 0.78rem;
  line-height: 1.38;
}

.encounter-art,
.card-art,
.selected-art {
  width: 100%;
  object-fit: cover;
  display: block;
  background: #0b0c0d;
}

.encounter-art {
  height: 148px;
}

.encounter-body,
.card-body {
  padding: 11px;
}

.encounter-body h2,
.card-title,
.selected-title {
  margin: 0;
  font-size: 1.08rem;
  line-height: 1.08;
  letter-spacing: 0;
}

.encounter-meta,
.card-meta,
.selected-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  padding: 0 8px;
  border: 1px solid rgba(244, 236, 212, 0.16);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 800;
  text-transform: uppercase;
}

.encounter-stats,
.card-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
  margin-top: 12px;
}

.stat-box {
  min-height: 48px;
  border: 1px solid rgba(244, 236, 212, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  padding: 8px;
}

.stat-box span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.stat-box strong {
  display: block;
  margin-top: 1px;
  color: var(--paper);
  font-size: 1.05rem;
}

.map-frame {
  height: 230px;
  border: 1px solid rgba(244, 236, 212, 0.14);
  border-radius: var(--radius);
  background: #0a0b0b;
  overflow: hidden;
}

.map-frame img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.88;
}

.party-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(112px, 1fr));
  gap: 10px;
  min-height: 286px;
}

.party-slot {
  min-height: 276px;
  border: 1px dashed rgba(244, 236, 212, 0.2);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.025);
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.party-slot .card {
  height: 100%;
}

.party-slot.is-drop-ready,
.drop-zone.is-drop-ready {
  border-color: rgba(80, 199, 194, 0.74);
  background: rgba(80, 199, 194, 0.085);
  box-shadow: inset 0 0 0 1px rgba(80, 199, 194, 0.2);
}

.card {
  position: relative;
  min-height: 276px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, box-shadow 150ms ease;
}

.hand-grid .card {
  width: 172px;
  min-height: 292px;
  flex: 0 0 auto;
}

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

.card.is-dragging {
  opacity: 0.48;
  transform: scale(0.98);
}

.card:hover,
.card.is-selected {
  transform: translateY(-3px);
  border-color: rgba(80, 199, 194, 0.64);
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.36);
}

.card-art {
  height: 104px;
}

.party-slot .card-art {
  height: 118px;
}

.card-kicker {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.cost-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  min-height: 20px;
}

.gem {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 21px;
  height: 21px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 50%;
  color: #101215;
  font-size: 0.67rem;
  font-weight: 900;
}

.gem.fire { background: var(--fire); }
.gem.water { background: var(--water); }
.gem.wind { background: var(--wind); }
.gem.earth { background: var(--earth); }
.gem.light { background: var(--light); }
.gem.chocobo { background: var(--chocobo); }

.card-text,
.selected-text,
.logbook p {
  color: #d7ccb2;
  font-size: 0.78rem;
  line-height: 1.38;
}

.card-text {
  min-height: 52px;
  margin: 9px 0 0;
}

.card-stats {
  grid-template-columns: repeat(3, 1fr);
  gap: 5px;
}

.card-stats .stat-box {
  min-height: 38px;
  padding: 6px;
}

.card-stats .stat-box strong {
  font-size: 0.93rem;
}

.drop-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.drop-zone {
  min-height: 78px;
  border: 1px dashed rgba(244, 236, 212, 0.25);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.032);
  padding: 12px;
  transition: border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
}

.drop-zone strong,
.drop-zone span {
  display: block;
}

.drop-zone strong {
  color: var(--paper);
  font-size: 0.85rem;
  text-transform: uppercase;
}

.drop-zone span {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.76rem;
  line-height: 1.32;
}

.selected-card {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr);
  gap: 14px;
  min-height: 156px;
  margin-top: 14px;
  border: 1px solid rgba(244, 236, 212, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.field-spell-zone {
  display: grid;
  grid-template-columns: minmax(120px, 0.36fr) minmax(0, 1fr);
  gap: 10px;
  align-items: center;
  min-height: 74px;
  margin-top: 10px;
  border: 1px solid rgba(80, 199, 194, 0.22);
  border-radius: var(--radius);
  background: linear-gradient(135deg, rgba(80, 199, 194, 0.08), rgba(244, 236, 212, 0.035));
  padding: 10px;
}

.field-spell-zone span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.field-spell-zone strong {
  color: var(--paper);
}

.field-spell-zone p {
  margin: 5px 0 0;
  color: #d7ccb2;
  font-size: 0.76rem;
  line-height: 1.32;
}

.field-spell-art {
  width: 100%;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  background: #0b0c0d;
}

.selected-art {
  height: 136px;
  border-radius: 6px;
}

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

.hand-toolbar .primary-button {
  min-height: 42px;
}

.empty-state {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 136px;
  color: var(--muted);
  grid-column: 1 / -1;
}

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

.resource {
  min-height: 62px;
  border: 1px solid rgba(244, 236, 212, 0.13);
  border-radius: var(--radius);
  padding: 10px;
  background: rgba(255, 255, 255, 0.035);
}

.resource span {
  display: block;
  color: var(--muted);
  font-size: 0.69rem;
  font-weight: 900;
  text-transform: uppercase;
}

.resource strong {
  display: block;
  margin-top: 3px;
  font-size: 1.4rem;
  line-height: 1;
}

.resource.fire strong { color: var(--fire); }
.resource.water strong { color: var(--water); }
.resource.wind strong { color: var(--wind); }
.resource.earth strong { color: var(--earth); }
.resource.light strong { color: var(--light); }
.resource.chocobo strong { color: var(--chocobo); }

.action-stack {
  flex-direction: column;
  margin-bottom: 12px;
}

.logbook {
  height: 176px;
  overflow: auto;
  border: 1px solid rgba(244, 236, 212, 0.13);
  border-radius: var(--radius);
  background: rgba(0, 0, 0, 0.2);
  padding: 10px;
}

.logbook p {
  margin: 0 0 8px;
}

.hand-panel {
  margin-top: 14px;
  padding: 12px 14px 14px;
}

.hand-grid {
  display: flex;
  gap: 10px;
  min-height: 306px;
  overflow-x: auto;
  padding: 4px 2px 10px;
  scrollbar-color: rgba(234, 220, 130, 0.44) rgba(255, 255, 255, 0.05);
}

.is-unplayable {
  filter: saturate(0.62) brightness(0.72);
}

.modal-layer {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(3, 4, 5, 0.72);
}

.modal-layer.is-open {
  display: flex;
}

.modal-card {
  width: min(1120px, 100%);
  max-height: min(86vh, 860px);
  overflow: hidden;
  border: 1px solid rgba(234, 220, 130, 0.32);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(28, 28, 29, 0.98), rgba(14, 15, 16, 0.98));
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.7);
}

.modal-card.compact {
  width: min(520px, 100%);
}

.modal-card.deckbuilder-card {
  width: min(1280px, 100%);
  display: flex;
  flex-direction: column;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 64px;
  padding: 14px;
  border-bottom: 1px solid rgba(244, 236, 212, 0.12);
}

.modal-head span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.modal-head strong {
  display: block;
  margin-top: 4px;
  color: var(--paper);
  font-size: 1.15rem;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(172px, 1fr));
  gap: 10px;
  max-height: calc(86vh - 90px);
  overflow: auto;
  padding: 14px;
}

.modal-grid .card {
  min-height: 292px;
}

.ranking-list {
  display: grid;
  gap: 8px;
  max-height: calc(86vh - 90px);
  overflow: auto;
  padding: 14px;
}

.ranking-row {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  min-height: 48px;
  border: 1px solid rgba(244, 236, 212, 0.12);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.035);
  padding: 9px 10px;
}

.ranking-row strong {
  color: var(--paper);
}

.ranking-section-title {
  margin-top: 4px;
  color: var(--paper);
  font-size: 0.72rem;
  font-weight: 900;
  text-transform: uppercase;
}

.ranking-row span {
  color: var(--muted);
  font-size: 0.78rem;
}

.ranking-empty {
  min-height: 84px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  border: 1px dashed rgba(244, 236, 212, 0.18);
  border-radius: var(--radius);
}

.profile-form,
.builder-sidebar {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.profile-form label,
.builder-sidebar label {
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.profile-form input,
.builder-sidebar input,
.builder-sidebar select {
  width: 100%;
  min-height: 40px;
  border: 1px solid rgba(244, 236, 212, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.045);
  color: var(--ink);
  padding: 0 10px;
  font: inherit;
}

.profile-form p,
.builder-sidebar p {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
}

.builder-shell {
  display: grid;
  grid-template-columns: minmax(240px, 300px) minmax(0, 1fr);
  flex: 1;
  min-height: 0;
  height: calc(min(86vh, 860px) - 90px);
}

.builder-sidebar {
  align-content: start;
  border-right: 1px solid rgba(244, 236, 212, 0.12);
  overflow: auto;
}

.builder-stat {
  min-height: 62px;
  border: 1px solid rgba(244, 236, 212, 0.13);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  padding: 10px;
}

.builder-stat span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 900;
  text-transform: uppercase;
}

.builder-stat strong {
  display: block;
  margin-top: 2px;
  color: var(--paper);
  font-size: 1.35rem;
}

.builder-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(238px, 1fr));
  align-content: start;
  gap: 10px;
  overflow: auto;
  padding: 14px;
  min-height: 0;
  scrollbar-color: rgba(234, 220, 130, 0.44) rgba(255, 255, 255, 0.05);
}

.builder-card {
  display: grid;
  grid-template-columns: 82px minmax(0, 1fr);
  gap: 10px;
  min-height: 126px;
  border: 1px solid rgba(244, 236, 212, 0.14);
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.035);
  overflow: hidden;
}

.builder-card img {
  width: 82px;
  height: 126px;
  object-fit: cover;
}

.builder-card-body {
  display: grid;
  align-content: space-between;
  gap: 8px;
  padding: 10px 10px 10px 0;
}

.builder-card-body h3 {
  margin: 0;
  font-size: 0.96rem;
  line-height: 1.1;
}

.builder-card-body p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.28;
}

.count-control {
  display: flex;
  align-items: center;
  gap: 8px;
}

.count-control button {
  width: 32px;
  min-height: 32px;
  border: 1px solid rgba(244, 236, 212, 0.18);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.055);
  color: var(--ink);
  cursor: pointer;
}

.count-control strong {
  min-width: 28px;
  text-align: center;
  color: var(--paper);
}

.card-preview {
  position: fixed;
  z-index: 90;
  width: min(360px, calc(100vw - 28px));
  pointer-events: none;
  opacity: 0;
  transform: translate3d(0, 8px, 0) scale(0.98);
  transition: opacity 110ms ease, transform 110ms ease;
}

.card-preview.is-visible {
  opacity: 1;
  transform: translate3d(0, 0, 0) scale(1);
}

.preview-card {
  overflow: hidden;
  border: 1px solid rgba(234, 220, 130, 0.48);
  border-radius: var(--radius);
  background: #171717;
  box-shadow: 0 28px 70px rgba(0, 0, 0, 0.62);
}

.preview-card .card-art {
  height: 190px;
}

.preview-card .card-body {
  padding: 15px;
}

.preview-card .card-title {
  font-size: 1.38rem;
}

.preview-card .card-text {
  min-height: auto;
  font-size: 0.92rem;
}

.flash {
  animation: flash 360ms ease;
}

@keyframes flash {
  0% { box-shadow: 0 0 0 0 rgba(80, 199, 194, 0.0); }
  45% { box-shadow: 0 0 0 4px rgba(80, 199, 194, 0.45); }
  100% { box-shadow: 0 0 0 0 rgba(80, 199, 194, 0.0); }
}

@media (max-width: 1100px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
  }

  .player-card {
    min-width: 0;
  }

  .score-strip {
    min-width: 0;
  }

  .phase-panel {
    grid-template-columns: 1fr;
  }

  .mode-panel {
    grid-template-columns: 1fr;
  }

  .builder-shell {
    grid-template-columns: 1fr;
  }

  .builder-sidebar {
    border-right: 0;
    border-bottom: 1px solid rgba(244, 236, 212, 0.12);
  }

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

  .panel {
    min-height: auto;
  }

  .party-grid {
    grid-template-columns: repeat(2, minmax(140px, 1fr));
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100% - 18px, 1500px);
    padding-top: 10px;
  }

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

  .phase-track {
    grid-template-columns: 1fr;
  }

  .duelist-strip {
    grid-template-columns: 1fr;
  }

  .field-actions {
    width: 100%;
    flex-wrap: wrap;
  }

  .hand-toolbar {
    grid-template-columns: 1fr;
  }

  .field-actions .primary-button {
    flex: 1;
  }

  .panel-head {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

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

  .drop-strip {
    grid-template-columns: 1fr;
  }

  .selected-card {
    grid-template-columns: 1fr;
  }

  .field-spell-zone {
    grid-template-columns: 1fr;
  }

  .selected-art {
    height: 150px;
  }

  .hand-grid .card {
    width: min(78vw, 220px);
  }
}
