:root {
  color-scheme: light;
  --bg: #f7f4ee;
  --ink: #231f20;
  --muted: #756f68;
  --line: #d9d1c3;
  --panel: #fffdf8;
  --danger: #a63131;
  --aether: #5577a8;
  --anima: #4d8b57;
  --aqua: #347c9d;
  --ignis: #b44b32;
  --machina: #7b7080;
  --terra: #876b36;
  --focus: #2f6f6c;
  --parchment: #f2d488;
  --stone: #3a3734;
  --dragon: #b32121;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Segoe UI", system-ui, sans-serif;
}

a {
  color: inherit;
  text-decoration: none;
}

button,
select {
  font: inherit;
}

button {
  border: 1px solid #2f2b27;
  background: #2f2b27;
  color: white;
  border-radius: 6px;
  padding: 0.65rem 0.85rem;
  cursor: pointer;
}

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

button.secondary,
.log-section button {
  background: transparent;
  color: var(--ink);
}

.site-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 14px 0 0;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-width: max-content;
  font-size: 1.1rem;
  font-weight: 950;
}
.brand-mark img {
  width: 38px;
  height: 38px;
  object-fit: contain;
}

.nav-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.nav-links a {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 0 12px;
  font-weight: 800;
}

.nav-links a:hover {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(47, 111, 108, 0.16);
}

select {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.55rem;
  background: white;
}

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

.topbar,
.section-title,
.actions,
.setup,
.phase-actions,
.dice-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.topbar {
  justify-content: space-between;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--focus);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2rem, 4vw, 3.8rem);
}

h2 {
  margin-bottom: 0;
  font-size: 1.05rem;
}

.setup {
  flex-wrap: wrap;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.52);
  margin-bottom: 16px;
}

.setup label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.board {
  display: grid;
  gap: 16px;
}

.panel,
.hand-section,
.log-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 16px;
}

.dragon-panel,
.wizard-card-panel {
  position: relative;
  overflow: hidden;
  border: 2px solid #c8bda8;
  background:
    linear-gradient(90deg, rgba(65, 165, 69, 0.18), transparent 17%, transparent 83%, rgba(238, 93, 44, 0.18)),
    linear-gradient(180deg, rgba(24, 99, 226, 0.16), transparent 20%, transparent 78%, rgba(165, 96, 216, 0.18)),
    var(--panel);
}

.dragon-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 0.46fr);
  gap: 16px;
  background:
    linear-gradient(90deg, rgba(179, 33, 33, 0.2), transparent 18%, transparent 82%, rgba(179, 33, 33, 0.2)),
    linear-gradient(180deg, rgba(234, 197, 41, 0.2), transparent 24%, transparent 76%, rgba(234, 197, 41, 0.2)),
    var(--panel);
}

.wizard-card-panel {
  display: grid;
  grid-template-columns: minmax(220px, 0.6fr) minmax(320px, 1fr) minmax(240px, 0.56fr);
  gap: 16px;
  align-items: start;
}

.dragon-main,
.dragon-card-lane,
.wizard-main,
.wizard-dice,
.wizard-equipment {
  min-width: 0;
}

.dragon-card-lane,
.wizard-dice,
.wizard-equipment {
  border: 1px solid rgba(217, 209, 195, 0.82);
  border-radius: 8px;
  background: rgba(255, 253, 248, 0.72);
  padding: 12px;
}

.card-slot-placeholder {
  display: grid;
  place-items: center;
  min-height: 196px;
  border: 1px dashed #bcae94;
  border-radius: 8px;
  background: rgba(246, 240, 229, 0.72);
  color: var(--muted);
  padding: 16px;
  text-align: center;
  font-size: 0.9rem;
}

#dragonCardSlot .card {
  min-height: 0;
}

#dragonCardSlot .card-controls {
  grid-template-columns: 1fr;
}

.wizard-card-panel .section-title span {
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #f6f0e5;
  color: var(--ink);
  padding: 0.24rem 0.58rem;
  font-weight: 700;
}

.section-title {
  justify-content: space-between;
  margin-bottom: 12px;
}

.section-title span {
  color: var(--muted);
  font-size: 0.88rem;
}

.stat-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-grid div {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 10px;
  background: white;
}

.stat-grid span {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.stat-grid strong {
  display: block;
  margin-top: 4px;
  font-size: 1.35rem;
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.stat-chip {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f0e5;
  padding: 8px;
}

.stat-chip span,
.stat-chip strong {
  display: block;
}

.stat-chip span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.stat-chip strong {
  margin-top: 2px;
  font-size: 1.05rem;
}

.rules-text {
  color: var(--muted);
  line-height: 1.45;
  margin-bottom: 0;
}

.markup-color {
  font-weight: 800;
}

.wizard-main > .rules-text,
.dragon-main > .rules-text {
  border: 1px solid #c09b56;
  border-radius: 6px;
  background: linear-gradient(180deg, #f5dda0, var(--parchment));
  color: var(--ink);
  padding: 10px;
  font-family: Georgia, "Times New Roman", serif;
}

.attached {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.ability-actions {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.ability-actions button {
  width: 100%;
}

.attached-item {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #f6f0e5;
  padding: 9px;
  color: var(--muted);
  font-size: 0.86rem;
  line-height: 1.35;
}

.attached-item strong {
  display: block;
  color: var(--ink);
  margin-bottom: 4px;
}

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

.slot-item {
  min-height: 58px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  background: white;
  padding: 8px;
}

.slot-item span,
.slot-item strong {
  display: block;
}

.slot-item span {
  color: var(--muted);
  font-size: 0.72rem;
  text-transform: uppercase;
}

.slot-item strong {
  margin-top: 3px;
  font-size: 0.88rem;
}

.phase-actions {
  align-items: stretch;
  flex-direction: column;
}

.mana-choice-controls,
.turn-buttons {
  display: grid;
  gap: 8px;
}

.mana-roll-grid {
  display: grid;
  gap: 8px;
}

.mana-roll-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 8px;
}

.mana-roll-choice span,
.mana-roll-choice small {
  display: block;
}

.mana-roll-choice span {
  color: var(--ink);
  font-weight: 800;
}

.mana-roll-choice small {
  color: var(--muted);
  font-size: 0.78rem;
}

.mana-roll-buttons {
  display: grid;
  grid-template-columns: repeat(2, minmax(56px, 1fr));
  gap: 6px;
}

.mana-roll-buttons button {
  padding: 0.45rem 0.55rem;
  min-width: 0;
}

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

.hand-section,
.log-section {
  margin-top: 16px;
}

.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 12px;
}

.cards.compact {
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
  min-height: 210px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  border: 0;
  border-left: 0;
  border-radius: 8px;
  background: transparent;
  padding: 0;
}

.visual-card .card-border {
  position: relative;
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 10px;
  overflow: hidden;
  border: 2px solid #2e2b28;
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.34), transparent 18%, transparent 82%, rgba(0, 0, 0, 0.16)),
    var(--stone);
  padding: 12px;
  box-shadow: inset 0 0 0 5px rgba(255, 255, 255, 0.24);
}

.visual-card.landscape .card-border {
  aspect-ratio: 1.55;
}

.visual-card.portrait .card-border {
  aspect-ratio: 0.68;
}

.visual-card .card-title {
  min-height: 38px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  border: 1px solid #b18a44;
  background: linear-gradient(180deg, #f5dda0, var(--parchment));
  padding: 6px 8px;
}

.visual-card h3 {
  margin: 0;
  overflow-wrap: anywhere;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.02rem;
  font-weight: 600;
  line-height: 1.1;
  text-align: center;
}

.visual-card .card-body {
  min-height: 0;
  display: grid;
  grid-template-columns: 0.62fr 1fr;
  gap: 10px;
}

.visual-card.portrait .card-body {
  grid-template-columns: 1fr;
  grid-template-rows: 1fr auto;
}

.card-art {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  min-height: 68px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background:
    radial-gradient(circle at 50% 42%, rgba(255, 255, 255, 0.48), transparent 33%),
    linear-gradient(135deg, rgba(255, 255, 255, 0.2), rgba(0, 0, 0, 0.16));
  padding: 8px;
}

.card-art span {
  align-self: center;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  background: rgba(20, 18, 16, 0.52);
  color: white;
  padding: 0.38rem 0.5rem;
  font-size: 0.76rem;
  font-weight: 800;
}

.card-copy {
  display: grid;
  align-content: center;
  gap: 6px;
  border: 1px solid #b18a44;
  background: linear-gradient(180deg, #f8e4ad, var(--parchment));
  padding: 10px;
}

.card-copy p {
  margin: 0;
  color: var(--ink);
  font-family: Georgia, "Times New Roman", serif;
  line-height: 1.18;
  font-size: var(--effect-font-size, 0.95rem);
  text-align: center;
}

.card-copy small {
  color: #5d4b31;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 0.74rem;
  line-height: 1.15;
  text-align: center;
}

.visual-card .card-icons {
  display: flex;
  flex-wrap: nowrap;
  gap: 4px;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  overflow: hidden;
}

.card-icon,
.pill {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  min-width: 24px;
  min-height: 24px;
  border-radius: 999px;
  border: 2px solid #211f1d;
  background: #eee8dc;
  color: var(--ink);
  padding: 0.1rem 0.22rem;
  font-size: 0.52rem;
  font-weight: 800;
}

.card-icon.cost {
  background: #d9bd3a;
}

.card-icon.school {
  background: #f1e3c7;
}

.card-icon.element {
  color: white;
  background: var(--focus);
}

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

.card button {
  margin-top: 0;
  width: 100%;
}

.card-spell .card-border {
  background:
    linear-gradient(90deg, rgba(70, 70, 70, 0.38), transparent 20%, transparent 80%, rgba(70, 70, 70, 0.38)),
    var(--stone);
}

.card-equipment .card-border,
.card-loot .card-border {
  background:
    linear-gradient(90deg, rgba(210, 210, 210, 0.72), transparent 18%, transparent 82%, rgba(210, 210, 210, 0.72)),
    var(--stone);
}

.card-dragon-action .card-border {
  background:
    linear-gradient(90deg, rgba(179, 33, 33, 0.72), transparent 18%, transparent 82%, rgba(179, 33, 33, 0.72)),
    linear-gradient(180deg, rgba(236, 180, 35, 0.76), rgba(117, 54, 23, 0.88));
}

.card-thrash .card-border {
  background:
    linear-gradient(90deg, rgba(8, 48, 57, 0.84), transparent 22%, transparent 78%, rgba(8, 48, 57, 0.84)),
    #244d52;
}

.card-dragon-action .card-copy,
.card-thrash .card-copy {
  background: rgba(33, 22, 12, 0.72);
  color: white;
}

.card-dragon-action .card-copy p,
.card-dragon-action .card-copy small,
.card-thrash .card-copy p,
.card-thrash .card-copy small {
  color: white;
}

.aether .card-icon.element,
.aether .card-art { background-color: var(--aether); }
.anima .card-icon.element,
.anima .card-art { background-color: var(--anima); }
.aqua .card-icon.element,
.aqua .card-art { background-color: var(--aqua); }
.ignis .card-icon.element,
.ignis .card-art { background-color: var(--ignis); }
.machina .card-icon.element,
.machina .card-art { background-color: var(--machina); }
.terra .card-icon.element,
.terra .card-art { background-color: var(--terra); }

.dice {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: white;
  padding: 8px 10px;
  min-width: 124px;
  text-align: center;
}

.dice strong,
.dice span {
  display: block;
}

.dice span {
  color: var(--muted);
  font-size: 0.74rem;
}

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

.dice-actions button {
  padding: 0.42rem 0.35rem;
  font-size: 0.78rem;
}

#gameLog {
  max-height: 300px;
  overflow: auto;
  margin: 0;
  padding-left: 22px;
}

#gameLog li {
  padding: 6px 0;
  color: var(--muted);
}

.card-zoom-dialog {
  width: min(820px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 14px;
}

.card-zoom-dialog::backdrop {
  background: rgba(20, 18, 16, 0.58);
}

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

#cardZoomContent {
  display: grid;
  place-items: center;
}

.zoom-card {
  width: min(620px, 100%);
  min-height: 0;
}

.zoom-card.landscape .card-border {
  aspect-ratio: 1.55;
}

.zoom-card.portrait {
  width: min(360px, 100%);
}

.zoom-card .card-border {
  gap: 10px;
  padding: 14px;
}

.zoom-card .card-copy {
  align-content: center;
  gap: 18px;
  padding: 14px;
}

.zoom-card h3 {
  font-size: 2.1rem;
  line-height: 1;
}

.zoom-card .card-copy p {
  line-height: 1.05;
}

.zoom-card .card-copy small {
  display: block;
  border-top: 1px solid rgba(93, 75, 49, 0.35);
  padding-top: 14px;
  font-size: 1.45rem;
  line-height: 1.05;
}

.zoom-card .card-icon,
.zoom-card .pill {
  min-width: 48px;
  min-height: 48px;
  padding: 0.2rem 0.4rem;
  font-size: 1rem;
}

.zoom-card .card-art span {
  padding: 0.58rem 0.78rem;
  font-size: 1.35rem;
}

.zoom-card .card-icons {
  gap: 8px;
}

@media (max-width: 860px) {
  .site-nav {
    align-items: flex-start;
    flex-direction: column;
    width: min(100% - 18px, 640px);
    padding-top: 9px;
  }

  .nav-links {
    justify-content: flex-start;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .dragon-panel,
  .wizard-card-panel {
    grid-template-columns: 1fr;
  }
}
