/* Battleground: "Iron & Ember" — a dark, torchlit fantasy arena. */

/* ---------- Tokens ---------- */
@property --spot-x {
  syntax: '<percentage>';
  inherits: true;
  initial-value: 50%;
}

:root {
  --bg: #120E0A;
  --panel: linear-gradient(180deg, #221A12, #17120D);
  --panel-bevel: inset 0 0 0 4px #17120D, inset 0 0 0 5px #3A2F20;
  --line: #3A2F20;
  --bronze: #8F7246;
  --border: #5A4A32;
  --input-border: #6B5536;

  --gold: #E2B65C;
  --gold-title: #E8BD62;
  --gold-hi: #F0C978;
  --gold-pale: #F6DDA0;
  --gold-muted: #C9A25A;

  --text: #E9DCC0;
  --text-bright: #F4E6C8;
  --text-soft: #CDBE9F;
  --text-dim: #A8987A;

  --ember: #E0714D;
  --steel: #7FB3CC;
  --danger: #E0927A;

  --font-head: 'Cinzel', Georgia, serif;
  --font-deco: 'Cinzel Decorative', 'Cinzel', Georgia, serif;
  --font-body: 'EB Garamond', Georgia, serif;
}

/* ---------- Base ---------- */
* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  overflow-x: clip;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: clip;
  color: var(--text);
  font-family: var(--font-body);
  font-size: 20px;
  line-height: 1.5;
  background-color: var(--bg);
  background-image:
    radial-gradient(ellipse 60% 45% at var(--spot-x) 0, rgba(226, 130, 50, 0.2), transparent 70%),
    radial-gradient(ellipse 35% 50% at 0 45%, rgba(194, 80, 47, 0.1), transparent 70%),
    radial-gradient(ellipse 35% 50% at 100% 45%, rgba(194, 80, 47, 0.1), transparent 70%);
  background-attachment: fixed;
  background-repeat: no-repeat;
  transition: --spot-x 1s ease;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

.icon {
  width: 1.2em;
  height: 1.2em;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

:focus-visible {
  outline: 2px solid #F3D58E;
  outline-offset: 3px;
}

/* ---------- Buttons ---------- */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid var(--bronze);
  border-radius: 4px;
  background: transparent;
  color: var(--text);
  font-family: var(--font-head);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
}

button:hover,
.button:hover {
  background: #221A12;
}

button:disabled {
  cursor: default;
}

button:disabled:hover {
  background: transparent;
}

.primary {
  border-color: var(--gold-pale);
  background: linear-gradient(180deg, #F0C978, #C8933C 55%, #A8762A);
  color: #1A120A;
  font-weight: 900;
  box-shadow: 0 0 0 4px var(--bg), 0 0 0 5px var(--bronze), 0 10px 30px rgba(226, 140, 60, 0.35);
}

.primary:hover {
  background: linear-gradient(180deg, #F6D88F, #D5A04A 55%, #B5832F);
  transform: translateY(-1px);
}

.danger {
  border-color: #7A3A2C;
  color: var(--danger);
}

.danger:hover {
  background: #2A1410;
}

/* ---------- Shared chrome ---------- */
.site-header {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 22px 40px;
  border-bottom: 1px solid var(--line);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  color: var(--gold);
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  text-decoration: none;
}

.nav-btn[aria-current='page'] {
  border-color: var(--gold);
  background: #221A12;
  color: var(--gold-pale);
}

.content {
  max-width: 1160px;
  margin: 0 auto;
  padding: 24px;
}

.content.wide {
  max-width: 1240px;
}

.eyebrow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin: 0;
  color: var(--gold-muted);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}

.eyebrow::before,
.eyebrow::after {
  content: '';
  width: 64px;
  height: 1px;
  background: var(--bronze);
}

.foot {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 24px 0 40px;
}

.foot::before,
.foot::after {
  content: '';
  width: 120px;
  height: 1px;
}

.foot::before {
  background: linear-gradient(90deg, transparent, #6B5536);
}

.foot::after {
  background: linear-gradient(270deg, transparent, #6B5536);
}

/* ---------- Screen 1: input ---------- */
.hero {
  padding: 40px 0 8px;
  text-align: center;
}

.wordmark {
  margin: 18px 0 14px;
  color: var(--gold-title);
  font-family: var(--font-deco);
  font-size: clamp(30px, 9vw, 96px);
  font-weight: 900;
  line-height: 1.05;
  text-shadow: 0 2px 0 #5C3D12, 0 0 36px rgba(232, 150, 60, 0.45);
  animation: flicker 3.2s ease-in-out infinite;
}

.subline {
  max-width: 640px;
  margin: 0 auto;
  color: var(--text-soft);
  font-size: 22px;
  font-style: italic;
}

.duel {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 28px;
  margin-top: 56px;
}

.panel {
  position: relative;
  flex: 1 1 340px;
  padding: 44px 28px 24px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--panel-bevel), 0 18px 40px rgba(0, 0, 0, 0.5);
}

.panel-tag {
  position: absolute;
  top: 0;
  left: 50%;
  padding: 6px 18px;
  border: 1px solid;
  border-radius: 3px;
  color: var(--text-bright);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  white-space: nowrap;
  transform: translate(-50%, -50%);
}

.tag-a {
  border-color: #B5543A;
  background: #7A2A1C;
}

.tag-b {
  border-color: #4F7F96;
  background: #1F3A4A;
}

.fighter-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
  font-family: var(--font-head);
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.panel-a .fighter-label {
  color: var(--ember);
}

.panel-b .fighter-label {
  color: var(--steel);
}

input[type='text'] {
  width: 100%;
  min-height: 60px;
  padding: 0 18px;
  border: 1px solid var(--input-border);
  border-radius: 4px;
  background: #0D0A07;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.7);
  color: var(--text-bright);
  font-family: var(--font-body);
  font-size: 24px;
}

input[type='text']::placeholder {
  color: #8C7D63;
  font-style: italic;
}

input[type='text']:focus {
  border-color: var(--gold);
  outline: none;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.7), 0 0 0 3px rgba(226, 182, 92, 0.22);
}

.panel-meta {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  color: var(--text-dim);
  font-size: 17px;
}

.flavour {
  font-style: italic;
}

.counter {
  flex: none;
  font-family: var(--font-head);
  font-size: 14px;
  letter-spacing: 0.1em;
}

.vs-medallion {
  display: grid;
  place-items: center;
  flex: none;
  width: 96px;
  height: 96px;
  border: 2px solid var(--bronze);
  border-radius: 50%;
  background: radial-gradient(circle, #3A2A18, #140F0A);
  color: var(--gold);
  font-family: var(--font-deco);
  font-size: 30px;
  font-weight: 900;
  animation: vs-pulse 2.8s ease-in-out infinite;
}

#form-hint {
  max-width: 640px;
  margin: 28px auto 0;
  padding: 12px 20px;
  border: 1px dashed var(--bronze);
  background: #2A1D12;
  color: var(--text-bright);
  font-size: 17px;
  font-style: italic;
  text-align: center;
}

.fight-row {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  margin-top: 40px;
}

.btn-fight {
  min-height: 68px;
  padding: 0 56px;
  font-size: 24px;
  letter-spacing: 0.24em;
}

.decree {
  margin: 0;
  color: var(--text-dim);
  font-style: italic;
}

/* ---------- Screen 2: loading ---------- */
#view-loading {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 44px;
  padding: 40px 0 24px;
  text-align: center;
}

#view-loading::before {
  content: '';
  position: absolute;
  inset: 0 -20%;
  z-index: -1;
  background: radial-gradient(ellipse closest-side at 50% 50%, rgba(226, 130, 50, 0.24), transparent);
  pointer-events: none;
}

.matchup {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: center;
  gap: 8px 16px;
  margin: 0;
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  overflow-wrap: anywhere;
}

.name-a {
  color: var(--ember);
}

.name-b {
  color: var(--steel);
}

.vs-small {
  color: var(--bronze);
  font-family: var(--font-deco);
  font-size: 18px;
  text-transform: none;
}

.emblem {
  position: relative;
  width: min(300px, 80vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
}

.emblem > * {
  position: absolute;
}

.ring {
  inset: 0;
  width: 100%;
  height: 100%;
}

.ring-outer {
  animation: spin 18s linear infinite;
}

.ring-inner {
  animation: spin 11s linear infinite reverse;
}

.core {
  inset: 18%;
  border-radius: 50%;
  background: radial-gradient(circle, #2A1D10, #0D0A07 75%);
  box-shadow: inset 0 0 30px rgba(0, 0, 0, 0.8);
}

.spark {
  inset: 30%;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 190, 90, 0.5), transparent 70%);
  animation: spark 1.6s ease-in-out infinite;
}

.clash {
  width: 96px;
  height: 96px;
  color: var(--gold);
  stroke-width: 1.5;
  animation: clash 1.6s ease-in-out infinite;
}

.loading-text .eyebrow {
  margin-bottom: 14px;
}

#loading-message {
  min-height: 1.4em;
  margin: 0;
  color: var(--text-bright);
  font-size: 30px;
  font-style: italic;
}

#loading-message.msg-in {
  animation: fade-up 0.5s ease-out both;
}

.dots {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-top: 18px;
}

.dots i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--gold);
  animation: blink 1.2s ease-in-out infinite;
}

.dots i:nth-child(2) {
  animation-delay: 0.2s;
}

.dots i:nth-child(3) {
  animation-delay: 0.4s;
}

/* ---------- Screen 3: result ---------- */
#view-result {
  text-align: center;
}

#result-winner {
  margin: 14px 0 0;
  color: var(--gold);
  font-family: var(--font-deco);
  font-size: clamp(36px, 5vw, 60px);
  font-weight: 900;
  line-height: 1.15;
  overflow-wrap: anywhere;
  animation: title-glow 2.6s ease-in-out infinite;
}

.fighters {
  position: relative;
  isolation: isolate;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 56px 40px;
  padding-top: 64px;
}

.fighter {
  position: relative;
  flex: 1 1 340px;
  max-width: 440px;
  margin: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* A square the width of the figure; frame, crown and rays all key off it. */
.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
}

.frame {
  position: absolute;
  inset: 0;
  border: 2px solid var(--input-border);
  border-radius: 6px;
  background: #0D0A07;
  box-shadow: 0 0 0 3px var(--bg), 0 0 0 4px #4A3D2A, 0 20px 40px rgba(0, 0, 0, 0.6);
}

.frame img {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 4px;
}

.frame-ph {
  position: absolute;
  inset: 0;
  width: 30%;
  height: 30%;
  margin: auto;
  color: #3A2F20;
  stroke-width: 1;
}

.vs-disc {
  display: grid;
  place-items: center;
  flex: none;
  width: 72px;
  height: 72px;
  border: 2px solid var(--bronze);
  border-radius: 50%;
  background: radial-gradient(circle, #2A1D10, #0D0A07);
  color: var(--gold);
  font-family: var(--font-deco);
  font-size: 22px;
  font-weight: 900;
}

.ribbon {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 8px;
  position: relative;
  z-index: 2;
  margin-top: -34px;
  padding: 8px 30px;
  font-family: var(--font-head);
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 0.4em;
  text-transform: uppercase;
}

.is-winner .ribbon-victor {
  display: inline-flex;
  border: 1px solid var(--gold-pale);
  background: linear-gradient(180deg, #F0C978, #C8933C);
  color: #1A120A;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.is-loser .ribbon-fallen {
  display: inline-flex;
  border: 1px solid #7A3A2C;
  background: #2A1410;
  color: #E0927A;
  font-size: 15px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5);
}

.plate {
  margin-top: 14px;
  padding: 10px 24px;
  border: 1px solid var(--border);
  background: linear-gradient(180deg, #2A2016, #18120C);
  color: var(--text-bright);
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  overflow-wrap: anywhere;
}

.is-winner .plate {
  border-color: var(--gold);
  background: linear-gradient(180deg, #3A2A16, #22180E);
  color: var(--gold-pale);
}

.save-btn {
  margin-top: 14px;
}

.save-btn:disabled {
  border-color: var(--line);
  color: var(--text-dim);
}

#save-status {
  margin: 24px 0 0;
  color: var(--text-soft);
  font-style: italic;
}

/* Winner treatment */
.is-winner {
  animation: rise 1s cubic-bezier(0.2, 0.9, 0.25, 1.25) both;
}

.is-winner .frame {
  border-color: var(--gold-hi);
  transform: scale(1.04);
  box-shadow:
    0 0 0 3px var(--bg),
    0 0 0 5px #C8933C,
    0 0 40px 6px rgba(255, 190, 90, 0.45),
    0 0 110px 24px rgba(232, 140, 50, 0.22);
  animation: frame-glow 2.6s ease-in-out 1s infinite;
}

.is-winner .frame::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(circle, rgba(255, 252, 230, 0.95), rgba(255, 210, 120, 0.5) 50%, transparent 78%);
  opacity: 0;
  pointer-events: none;
  animation: flash 1.1s ease-out 0.35s both;
}

.rays,
.crown,
.embers {
  display: none;
}

.is-winner .rays {
  display: block;
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: -1;
  width: 900px;
  height: 900px;
  margin: -450px 0 0 -450px;
  border-radius: 50%;
  background: repeating-conic-gradient(rgba(255, 205, 120, 0.16) 0 5deg, transparent 5deg 15deg);
  -webkit-mask-image: radial-gradient(circle, #000 0, transparent 68%);
  mask-image: radial-gradient(circle, #000 0, transparent 68%);
  pointer-events: none;
  animation: fade-in 1.4s ease-out both, spin 50s linear infinite;
}

.is-winner .crown {
  position: absolute;
  top: -70px;
  left: 50%;
  z-index: 3;
  display: grid;
  place-items: center;
  width: 80px;
  height: 80px;
  margin-left: -40px;
  border: 2px solid var(--gold-pale);
  border-radius: 50%;
  background: radial-gradient(circle, #F0C978, #B8802C);
  color: #2A1C0E;
  box-shadow: 0 0 30px rgba(255, 190, 90, 0.6);
  animation: bob 3s ease-in-out infinite;
}

.crown .icon {
  width: 42px;
  height: 42px;
}

.is-winner .embers {
  display: block;
  position: absolute;
  inset: auto 0 0 0;
  height: 0;
  z-index: 2;
  pointer-events: none;
}

.embers i {
  position: absolute;
  bottom: 0;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #FFD27A;
  box-shadow: 0 0 8px 2px rgba(255, 190, 90, 0.8);
  opacity: 0;
  animation: ember 3.6s ease-out infinite;
}

.embers i:nth-child(1) { left: 10%; animation-delay: 0s; }
.embers i:nth-child(2) { left: 24%; animation-delay: 0.7s; }
.embers i:nth-child(3) { left: 38%; animation-delay: 1.5s; }
.embers i:nth-child(4) { left: 52%; animation-delay: 0.3s; }
.embers i:nth-child(5) { left: 66%; animation-delay: 2.1s; }
.embers i:nth-child(6) { left: 80%; animation-delay: 1.1s; }
.embers i:nth-child(7) { left: 92%; animation-delay: 2.7s; }

/* Loser treatment */
.is-loser {
  animation: fade-slide 0.8s ease-out both;
}

.is-loser .frame {
  border-color: #4A3D2A;
}

.is-loser .frame img {
  filter: grayscale(1) brightness(0.5) contrast(0.9);
}

/* Verdict parchment */
.parchment {
  position: relative;
  max-width: 760px;
  margin: 56px auto 0;
  padding: 40px 48px 48px;
  background: linear-gradient(180deg, #EFE2C2, #E2CFA4);
  box-shadow: 0 0 0 1px var(--bronze), 0 0 0 6px #1A140E, 0 0 0 7px var(--border);
  color: #2A1C0E;
}

.parchment h3 {
  margin: 0 0 16px;
  color: #6B3A16;
  font-family: var(--font-head);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.34em;
  text-transform: uppercase;
}

#result-reasoning {
  margin: 0;
  font-size: 22px;
  font-style: italic;
  line-height: 1.55;
}

.seal {
  position: absolute;
  bottom: -22px;
  left: 50%;
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  margin-left: -22px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #C0503A, #7A2214);
  color: #F4D9B8;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.5);
}

.seal .icon {
  width: 22px;
  height: 22px;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 20px;
  margin-top: 64px;
}

/* ---------- Error view ---------- */
#view-error {
  display: flex;
  justify-content: center;
  padding: 48px 0;
}

.error-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  max-width: 600px;
  padding: 40px 36px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--panel-bevel), 0 18px 40px rgba(0, 0, 0, 0.5);
  text-align: center;
}

.error-icon {
  width: 64px;
  height: 64px;
  color: var(--ember);
  stroke-width: 1.5;
}

#error-message {
  margin: 0;
  color: var(--text);
  font-size: 20px;
  font-style: italic;
}

/* ---------- Screen 4: BattleDex ---------- */
.dex-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 24px;
  padding: 32px 0 28px;
  border-bottom: 1px solid var(--line);
}

.dex-title .eyebrow {
  justify-content: flex-start;
}

.dex-title .eyebrow::before {
  display: none;
}

.page-title {
  margin: 12px 0 6px;
  color: var(--gold);
  font-family: var(--font-deco);
  font-size: clamp(40px, 5vw, 60px);
  font-weight: 900;
  line-height: 1.1;
  text-shadow: 0 2px 0 #5C3D12, 0 0 36px rgba(232, 150, 60, 0.4);
}

.dex-count {
  margin: 0;
  color: var(--text-soft);
  font-style: italic;
}

.dex-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  margin-left: auto;
}

.dex-actions .button {
  padding: 0 16px;
  letter-spacing: 0.12em;
}

#dex-empty {
  max-width: 560px;
  margin: 56px auto;
  padding: 32px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--panel-bevel);
  color: var(--text-soft);
  font-style: italic;
  text-align: center;
}

.dex-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  align-items: start;
  gap: 32px;
  margin-top: 40px;
}

.card {
  display: flex;
  flex-direction: column;
  padding: 12px;
  border-radius: 6px;
  background: linear-gradient(180deg, #2A2016, #18120C);
  box-shadow: 0 0 0 1px var(--bronze), 0 0 0 5px #17120D, 0 0 0 6px #4A3D2A, 0 14px 30px rgba(0, 0, 0, 0.5);
  transition: transform 0.25s, box-shadow 0.25s;
}

.card:hover {
  transform: translateY(-6px) rotate(-0.4deg);
  box-shadow: 0 0 0 1px var(--gold), 0 0 0 5px #17120D, 0 0 0 6px var(--gold-muted), 0 18px 40px rgba(232, 140, 50, 0.3);
}

.card-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.card-no {
  color: var(--gold-muted);
  font-family: var(--font-head);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
}

.card-delete {
  width: 44px;
  min-height: 44px;
  padding: 0;
  border-color: transparent;
  color: var(--danger);
}

.card-delete:hover {
  background: #2A1410;
}

.card img {
  display: block;
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border: 1px solid var(--input-border);
  background: #0D0A07;
}

.card-name {
  margin: 12px 0 0;
  padding: 10px 4px;
  border-top: 1px solid var(--bronze);
  border-bottom: 1px solid var(--bronze);
  color: var(--text-bright);
  font-family: var(--font-head);
  font-size: 17px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: center;
  overflow-wrap: anywhere;
}

#dex-clear {
  display: flex;
  margin: 48px auto 0;
}

/* ---------- Confirm dialog ---------- */
.confirm {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(8, 5, 3, 0.8);
  backdrop-filter: blur(3px);
}

.confirm-box {
  position: relative;
  width: 100%;
  max-width: 440px;
  padding: 36px 28px 26px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--panel);
  box-shadow: var(--panel-bevel), 0 24px 60px rgba(0, 0, 0, 0.7), 0 0 40px rgba(224, 113, 77, 0.15);
  text-align: center;
}

.confirm-icon {
  width: 40px;
  height: 40px;
  margin-bottom: 8px;
  color: var(--danger);
}

.confirm-title {
  margin: 0 0 10px;
  color: var(--gold-title);
  font-family: var(--font-head);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.confirm-text {
  margin: 0 0 24px;
  color: var(--text-soft);
  font-size: 18px;
  font-style: italic;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

/* ---------- Animations ---------- */
@keyframes flicker {
  0%, 100% { opacity: 1; }
  45% { opacity: 0.88; }
  50% { opacity: 1; }
  58% { opacity: 0.93; }
}

@keyframes vs-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(226, 130, 50, 0.25); }
  50% { box-shadow: 0 0 34px 6px rgba(226, 150, 60, 0.5); }
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes spark {
  0%, 100% { opacity: 0.5; transform: scale(0.9); }
  50% { opacity: 1; transform: scale(1.15); }
}

@keyframes clash {
  0%, 100% { transform: scale(1); filter: drop-shadow(0 0 6px rgba(226, 182, 92, 0.4)); }
  50% { transform: scale(1.12); filter: drop-shadow(0 0 20px rgba(255, 190, 90, 0.9)); }
}

@keyframes fade-up {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: none; }
}

@keyframes blink {
  0%, 100% { opacity: 0.2; }
  50% { opacity: 1; }
}

@keyframes title-glow {
  0%, 100% { text-shadow: 0 2px 0 #5C3D12, 0 0 24px rgba(232, 150, 60, 0.35); }
  50% { text-shadow: 0 2px 0 #5C3D12, 0 0 48px rgba(255, 180, 80, 0.75); }
}

@keyframes rise {
  0% { opacity: 0; transform: translateY(30px) scale(0.9); }
  60% { opacity: 1; transform: translateY(-6px) scale(1.03); }
  100% { opacity: 1; transform: none; }
}

@keyframes fade-slide {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: none; }
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes flash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes frame-glow {
  0%, 100% {
    box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px #C8933C, 0 0 40px 6px rgba(255, 190, 90, 0.45), 0 0 110px 24px rgba(232, 140, 50, 0.22);
  }
  50% {
    box-shadow: 0 0 0 3px var(--bg), 0 0 0 5px var(--gold-pale), 0 0 64px 10px rgba(255, 200, 100, 0.65), 0 0 160px 36px rgba(232, 140, 50, 0.32);
  }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes ember {
  0% { opacity: 0; transform: translate(0, 0) scale(1); }
  15% { opacity: 1; }
  100% { opacity: 0; transform: translate(14px, -420px) scale(0.4); }
}

/* ---------- Responsive ---------- */
@media (max-width: 640px) {
  body {
    font-size: 18px;
  }

  .site-header {
    padding: 16px 20px;
  }

  .content {
    padding: 16px;
  }

  .eyebrow {
    gap: 10px;
    letter-spacing: 0.28em;
  }

  .eyebrow::before,
  .eyebrow::after {
    width: 28px;
  }

  .subline {
    font-size: 19px;
  }

  .panel {
    padding: 40px 18px 20px;
  }

  input[type='text'] {
    font-size: 20px;
  }

  .btn-fight {
    padding: 0 36px;
    font-size: 20px;
  }

  .parchment {
    padding: 32px 24px 40px;
  }

  #result-reasoning {
    font-size: 19px;
  }

  #loading-message {
    font-size: 24px;
  }

  .dex-grid {
    gap: 24px;
  }

  .vs-medallion {
    width: 64px;
    height: 64px;
    font-size: 22px;
  }
}

/* VS sits between the two stacked fighter panels (up to 893px wide) */
@media (max-width: 893px) {
  .duel {
    flex-direction: column;
    flex-wrap: nowrap;
    align-items: stretch;
    gap: 26px;
  }

  .panel {
    flex: none;
  }

  .vs-medallion {
    margin: 0 auto;
  }
}

/* ---------- Reduced motion ---------- */
/* Animations and transitions off. The winner keeps its static gold border,
   scale and glow (set on .is-winner .frame), so the result stays obvious. */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }

  .embers {
    display: none !important;
  }
}

@media (max-width: 640px) {
  .dex-actions {
    justify-content: flex-start;
    margin-left: 0;
  }
}
