/* ===== Arena Fable — WoW-inspired game UI theme ===== */
:root {
  --gold: #d9b24c;
  --gold-bright: #ffd75e;
  --gold-dark: #8a6a23;
  --panel: rgba(14, 12, 9, 0.94);
  --panel-edge: #5d4a1f;
  --hp-green: #3fc24e;
  --hp-red: #d6453a;
  --hp-blue: #3a7bd6;
  --text: #f1e6c8;
  --text-dim: #a89b78;
  --serif: Georgia, 'Palatino Linotype', 'Times New Roman', serif;
  --sans: "Segoe UI", "Trebuchet MS", system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0a0805;
  color: var(--text);
  font-family: var(--sans);
  user-select: none;
}

#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.42) 100%);
}

#overlay-3d { position: fixed; inset: 0; pointer-events: none; overflow: hidden; z-index: 6; }

.hidden { display: none !important; }

/* ===== ornate gold panel chrome (shared) ===== */
.menu-content {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 224, 138, 0.05), rgba(0,0,0,0) 30%),
    var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 8px;
  padding: 34px 46px 30px;
  text-align: center;
  box-shadow:
    0 0 0 1px #000,
    inset 0 0 0 1px rgba(255, 215, 120, 0.18),
    0 24px 80px rgba(0,0,0,0.85),
    inset 0 0 60px rgba(0,0,0,0.55);
}
.menu-content::before, .menu-content::after {
  content: ""; position: absolute; width: 46px; height: 46px;
  border: 3px solid var(--gold);
  pointer-events: none;
}
.menu-content::before { top: -3px; left: -3px; border-right: 0; border-bottom: 0; border-radius: 8px 0 0 0; }
.menu-content::after { bottom: -3px; right: -3px; border-left: 0; border-top: 0; border-radius: 0 0 8px 0; }

/* ===== full-screen menus ===== */
.screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background:
    radial-gradient(ellipse at 50% 20%, rgba(120, 78, 22, 0.25), transparent 55%),
    radial-gradient(ellipse at center, rgba(26, 20, 12, 0.94), rgba(5, 4, 2, 0.99));
  z-index: 20;
}
.screen.overlay { background: rgba(5, 4, 2, 0.66); }

/* floating embers */
.embers { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.ember {
  position: absolute; bottom: -10px;
  width: 4px; height: 4px; border-radius: 50%;
  background: radial-gradient(circle, #ffd27a, #ff7a2e 60%, transparent);
  filter: blur(0.5px);
  animation: ember-rise linear infinite;
}
@keyframes ember-rise {
  0% { transform: translate(0, 0) scale(1); opacity: 0; }
  8% { opacity: 0.9; }
  100% { transform: translate(var(--dx), -110vh) scale(0.4); opacity: 0; }
}

/* metallic game logo */
.game-logo {
  font-family: var(--serif);
  font-weight: 700;
  letter-spacing: 8px;
  line-height: 0.95;
  margin-bottom: 6px;
}
.game-logo span, .game-logo b {
  display: inline-block;
  font-size: 58px;
  background: linear-gradient(180deg, #fff3c9 0%, #ffd75e 35%, #9a7224 70%, #e8c25c 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 2px 1px #000) drop-shadow(0 0 22px rgba(255, 196, 84, 0.35));
}
.game-logo b { margin-left: 14px; }
.menu-tag {
  color: var(--text-dim); font-family: var(--serif); font-style: italic;
  letter-spacing: 3px; font-size: 14px; margin: 4px 0 24px;
}

/* ----- class cards ----- */
.class-cards { display: flex; gap: 16px; justify-content: center; margin-bottom: 22px; }

.class-card {
  width: 196px; padding: 16px 12px 12px;
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 224, 138, 0.06), transparent 40%),
    linear-gradient(180deg, #1c160e, #0e0b07);
  border: 2px solid #3a3022;
  border-radius: 6px;
  box-shadow: 0 0 0 1px #000, inset 0 0 26px rgba(0,0,0,0.6);
  cursor: pointer;
  transition: transform .12s, border-color .12s, box-shadow .12s;
}
.class-card:hover { transform: translateY(-3px); border-color: var(--gold-dark); }
.class-card.selected {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px #000, 0 0 24px rgba(255, 200, 90, 0.35), inset 0 0 26px rgba(120, 90, 30, 0.25);
}
.class-card .cc-crest {
  width: 74px; height: 74px; border-radius: 6px;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 0 1px #000, 0 3px 10px rgba(0,0,0,0.7);
  margin-bottom: 8px;
}
.class-card.selected .cc-crest { border-color: var(--gold-bright); }
.class-card h3 {
  font-family: var(--serif); font-size: 21px; letter-spacing: 2px;
  color: var(--gold-bright); text-shadow: 0 2px 2px #000; margin-bottom: 5px;
}
.class-card .cc-tag { font-size: 11.5px; color: var(--text-dim); min-height: 46px; line-height: 1.4; }
.class-card .cc-abilities { display: flex; gap: 5px; justify-content: center; margin-top: 9px; }
.class-card .cc-abilities .cc-ab { position: relative; }
.class-card .cc-abilities img {
  width: 32px; height: 32px; display: block; border-radius: 3px;
  border: 1px solid #4a3c22; box-shadow: 0 0 0 1px #000;
}
.class-card .cc-abilities .cc-ab::after {
  content: attr(data-key);
  position: absolute; bottom: -4px; right: -3px;
  font-size: 9px; font-weight: 800; color: var(--gold-bright);
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
}

/* ----- mode select ----- */
.mode-row { display: flex; gap: 10px; justify-content: center; margin-bottom: 22px; }
.mode-btn {
  padding: 7px 22px; border-radius: 4px;
  font-family: var(--serif); font-size: 14px; letter-spacing: 2px;
  background: linear-gradient(180deg, #241d12, #14100a);
  border: 1px solid #4a3c22; color: var(--text-dim);
  box-shadow: 0 0 0 1px #000;
  cursor: pointer;
}
.mode-btn.selected { border-color: var(--gold); color: var(--gold-bright); box-shadow: 0 0 0 1px #000, 0 0 12px rgba(255,200,90,0.25); }
.mode-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* ----- WoW-style buttons ----- */
.btn-wow {
  position: relative;
  font-family: var(--serif); font-size: 15px; font-weight: 700; letter-spacing: 1.5px;
  color: #f8e7b8; text-shadow: 0 -1px 1px rgba(0,0,0,0.8), 0 1px 1px rgba(0,0,0,0.6);
  padding: 11px 30px;
  background: linear-gradient(180deg, #6a5232 0%, #46341c 48%, #32230f 52%, #4a3318 100%);
  border: 1px solid #181208;
  border-radius: 6px;
  box-shadow:
    inset 0 1px 0 rgba(255, 226, 150, 0.45),
    inset 0 -2px 6px rgba(0,0,0,0.6),
    0 0 0 2px #0a0805, 0 0 0 3px var(--gold-dark),
    0 4px 10px rgba(0,0,0,0.7);
  cursor: pointer;
  transition: filter .1s;
}
.btn-wow:hover { filter: brightness(1.22); }
.btn-wow:active { filter: brightness(0.9); transform: translateY(1px); }
.btn-wow.primary {
  background: linear-gradient(180deg, #c8442c 0%, #92201c 48%, #6e1410 52%, #8a261c 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 200, 160, 0.5),
    inset 0 -2px 6px rgba(0,0,0,0.6),
    0 0 0 2px #0a0805, 0 0 0 3px var(--gold),
    0 4px 14px rgba(170, 60, 30, 0.5);
  font-size: 17px;
  padding: 12px 38px;
}
.play-row { display: flex; gap: 16px; justify-content: center; align-items: center; }
.menu-status { margin-top: 14px; min-height: 18px; color: #ff7a66; font-size: 13px; }

/* ----- queue screen ----- */
.queue-panel { min-width: 420px; }
.q-title { font-family: var(--serif); font-weight: 400; letter-spacing: 1.5px; color: var(--text); }
.queue-info { color: var(--text-dim); margin-top: 8px; font-size: 14px; letter-spacing: 1px; }
.queue-time {
  font-family: var(--serif); font-size: 38px; color: var(--gold-bright);
  margin: 12px 0 22px; font-variant-numeric: tabular-nums;
  text-shadow: 0 0 18px rgba(255, 200, 90, 0.35), 0 2px 2px #000;
}
.rune-spinner {
  position: relative; width: 96px; height: 96px; margin: 0 auto 22px;
}
.rune-spinner::before {
  content: ""; position: absolute; inset: -8px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 18%, var(--gold) 24%, transparent 30%, transparent 50%, rgba(255,215,120,0.5) 58%, transparent 66%);
  -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%, #000 72%, transparent 74%);
  mask: radial-gradient(circle, transparent 58%, #000 60%, #000 72%, transparent 74%);
  animation: spin 1.6s linear infinite;
}
.rune-spinner img {
  position: absolute; inset: 8px; width: 80px; height: 80px;
  border-radius: 50%;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 24px rgba(255, 190, 80, 0.3), 0 0 0 1px #000;
  animation: crest-pulse 2.2s ease-in-out infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes crest-pulse { 0%,100% { filter: brightness(1); } 50% { filter: brightness(1.25); } }

/* ===== HUD ===== */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; }

#match-timer {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  font-family: var(--serif); font-size: 22px; font-weight: 700;
  color: var(--gold-bright); text-shadow: 0 2px 2px #000;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  box-shadow: 0 0 0 1px #000, inset 0 0 14px rgba(0,0,0,0.6);
  padding: 4px 26px; border-radius: 0 0 10px 10px;
  font-variant-numeric: tabular-nums;
}

#countdown {
  position: absolute; top: 30%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--serif); font-size: 120px; font-weight: 900;
  background: linear-gradient(180deg, #fff3c9, #ffd75e 40%, #9a7224 75%, #e8c25c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 2px #000) drop-shadow(0 0 36px rgba(255, 200, 90, 0.5));
  animation: cd-pop 0.9s ease-out;
}
@keyframes cd-pop { 0% { transform: translate(-50%,-50%) scale(1.7); opacity: 0; } 25% { opacity: 1; } 100% { transform: translate(-50%,-50%) scale(1); } }

/* ----- unit frames (WoW-style, arena layout) ----- */
.unit-frame {
  position: absolute;
  display: flex; align-items: center; gap: 10px;
  width: 300px;
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 7px;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(255,215,120,0.12), 0 8px 24px rgba(0,0,0,0.6);
  padding: 8px 10px;
}
/* player bottom-left: 30% up from bottom, 30% in from the left */
#player-frame { left: 30%; bottom: 30%; transform: translateX(-50%); }
/* enemy/target frame mirrored on the right */
#target-frame { right: 30%; bottom: 30%; transform: translateX(50%); }

.unit-frame .uf-portrait {
  width: 52px; height: 52px; border-radius: 50%;
  border: 2px solid var(--gold-dark);
  box-shadow: 0 0 0 1px #000, 0 2px 8px rgba(0,0,0,0.8);
  background: #000;
}
.unit-frame.enemy .uf-portrait { border-color: #7e2a20; }
.unit-frame .uf-body { flex: 1; min-width: 0; }
.unit-frame .uf-name {
  font-family: var(--serif); font-size: 13px; letter-spacing: 1px;
  color: var(--gold-bright); text-shadow: 0 1px 2px #000;
  margin-bottom: 4px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.unit-frame .uf-bar {
  position: relative; height: 20px; border-radius: 3px; overflow: hidden;
  background: linear-gradient(180deg, #2a0f0c, #1a0907);
  border: 1px solid #000;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.8);
}
.unit-frame .uf-fill {
  position: absolute; inset: 0; width: 100%;
  background: linear-gradient(180deg, #6ce17a 0%, #2f9e3c 45%, #1d7028 55%, #36aa44 100%);
  transition: width 0.15s linear;
}
.unit-frame.enemy .uf-fill { background: linear-gradient(180deg, #f0685c 0%, #b02e22 45%, #7e1d14 55%, #c4382a 100%); }
.unit-frame.ally .uf-fill { background: linear-gradient(180deg, #6aa3f0 0%, #2f63b0 45%, #1d437e 55%, #3a72c4 100%); }
.unit-frame .uf-text {
  position: absolute; inset: 0; text-align: center;
  font-size: 12px; font-weight: 700; line-height: 20px;
  color: #fff; text-shadow: 0 1px 2px #000, 0 0 3px #000;
  font-variant-numeric: tabular-nums;
}
.unit-frame .uf-buffs { display: flex; gap: 4px; margin-top: 4px; min-height: 22px; }
.unit-frame .uf-buffs img {
  width: 22px; height: 22px; border-radius: 3px;
  border: 1px solid #000; box-shadow: 0 0 0 1px #3a3022;
}

/* ----- action bar (WoW-style slots) ----- */
#action-bar-wrap {
  position: absolute; bottom: 34px; left: 50%; transform: translateX(-50%);
  pointer-events: none;
  background: var(--panel);
  border: 2px solid var(--panel-edge);
  border-radius: 9px;
  box-shadow: 0 0 0 1px #000, inset 0 0 0 1px rgba(255,215,120,0.12), 0 10px 30px rgba(0,0,0,0.7);
  padding: 8px 10px;
}
#ability-bar { display: flex; gap: 8px; }
.ability {
  position: relative; width: 58px; height: 58px;
  border-radius: 5px;
  border: 1px solid #000;
  box-shadow: 0 0 0 2px #3a3022, inset 0 0 0 1px rgba(255,215,120,0.18);
  overflow: hidden;
}
.ability img { width: 100%; height: 100%; display: block; }
.ability .ab-key {
  position: absolute; top: 1px; left: 4px; z-index: 3;
  font-size: 12px; font-weight: 800; color: #fff;
  text-shadow: 0 1px 2px #000, 0 0 4px #000;
}
.ability .ab-cd {
  position: absolute; inset: 0; z-index: 2;
  /* radial sweep — --p is the fraction of cooldown remaining */
  background: conic-gradient(rgba(0, 0, 0, 0.82) calc(var(--p, 0) * 1turn), transparent 0);
  display: flex; align-items: center; justify-content: center;
}
.ability .ab-cd span {
  font-size: 19px; font-weight: 800; color: #ffd75e;
  text-shadow: 0 1px 2px #000, 0 0 6px #000;
}
.ability.ready { box-shadow: 0 0 0 2px #5d4a1f, inset 0 0 0 1px rgba(255,215,120,0.3); }
.ability.flash::after {
  content: ""; position: absolute; inset: -2px; z-index: 4; border-radius: 5px;
  border: 2px solid var(--gold-bright);
  box-shadow: 0 0 16px rgba(255, 215, 94, 0.9), inset 0 0 14px rgba(255, 215, 94, 0.5);
  animation: ab-flash 0.45s forwards;
}
@keyframes ab-flash { 0% { opacity: 1; } 100% { opacity: 0; } }

/* ----- cast bar ----- */
#cast-bar {
  position: absolute; bottom: 116px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 6px;
  width: 320px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 5px;
  box-shadow: 0 0 0 1px #000;
  padding: 4px;
}
#cast-icon { width: 26px; height: 26px; border-radius: 3px; border: 1px solid #000; }
.cb-track {
  position: relative; flex: 1; height: 18px; border-radius: 3px; overflow: hidden;
  background: #15100a; border: 1px solid #000;
}
#cast-fill {
  position: absolute; inset: 0; width: 0%;
  background: linear-gradient(180deg, #ffd75e, #b07c20);
  box-shadow: inset 0 -3px 6px rgba(0,0,0,0.4);
}
#cast-label {
  position: absolute; inset: 0; text-align: center;
  font-size: 11px; font-weight: 700; line-height: 18px; letter-spacing: 1px;
  color: #fff; text-shadow: 0 1px 2px #000;
  text-transform: capitalize;
}

#error-text {
  position: absolute; bottom: 150px; left: 50%; transform: translateX(-50%);
  font-family: var(--serif); font-size: 17px; font-weight: 700; letter-spacing: 1px;
  color: #ff5546; text-shadow: 0 1px 3px #000;
  animation: err-fade 1.2s forwards;
}
@keyframes err-fade { 0% { opacity: 1; } 70% { opacity: 1; } 100% { opacity: 0; } }

#hud-hint {
  position: absolute; bottom: 8px; left: 50%; transform: translateX(-50%);
  font-size: 11px; color: rgba(241, 230, 200, 0.38); letter-spacing: 0.4px;
  white-space: nowrap;
}

/* ===== world-anchored health bars (nameplates) ===== */
.world-bar { position: absolute; width: 110px; margin-left: -55px; text-align: center; }
.world-bar .wb-name {
  font-size: 11px; font-weight: 700; letter-spacing: 0.5px;
  color: #fff; text-shadow: 0 1px 3px #000, 0 0 4px #000;
  margin-bottom: 2px;
}
.world-bar .wb-bar {
  height: 8px; border-radius: 2px; overflow: hidden;
  background: rgba(20, 8, 6, 0.9); border: 1px solid #000;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.6);
}
.world-bar .wb-fill { height: 100%; width: 100%; background: linear-gradient(180deg, #6ce17a, #2f9e3c); }
.world-bar.enemy .wb-fill { background: linear-gradient(180deg, #f0685c, #b02e22); }
.world-bar.ally .wb-fill { background: linear-gradient(180deg, #6aa3f0, #2f63b0); }
.world-bar .wb-cast {
  height: 4px; margin-top: 1px; border-radius: 2px; overflow: hidden;
  background: rgba(10,10,14,0.85); border: 1px solid #000;
}
.world-bar .wb-cast div { height: 100%; width: 0%; background: #ffd75e; }
.world-bar .wb-fx { margin-top: 2px; min-height: 16px; display: flex; gap: 2px; justify-content: center; }
.world-bar .wb-fx img { width: 15px; height: 15px; border-radius: 2px; border: 1px solid #000; }

/* ===== floating combat text ===== */
.fct {
  position: absolute; transform: translateX(-50%);
  font-weight: 900; font-size: 19px;
  font-family: var(--sans);
  text-shadow: 0 1px 3px #000, 0 0 8px rgba(0,0,0,0.6);
  animation: fct-rise 1.1s ease-out forwards;
  white-space: nowrap;
}
.fct.dmg { color: #ffdf6b; }
.fct.dmg-in { color: #ff5546; }
.fct.crit { font-size: 30px; color: #ff3322; font-family: var(--serif); }
.fct.heal { color: #5fe871; }
.fct.info { color: #cfd5ff; font-size: 14px; letter-spacing: 1px; }
@keyframes fct-rise {
  0% { opacity: 0; margin-top: 0; }
  10% { opacity: 1; }
  75% { opacity: 1; }
  100% { opacity: 0; margin-top: -58px; }
}

/* ===== end screen ===== */
.end-panel { min-width: 460px; }
.end-panel h1 {
  font-family: var(--serif); font-size: 72px; letter-spacing: 14px; font-weight: 900;
  filter: drop-shadow(0 3px 2px #000);
}
#end-title.victory {
  background: linear-gradient(180deg, #fff3c9, #ffd75e 40%, #9a7224 75%, #e8c25c);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 2px #000) drop-shadow(0 0 40px rgba(255, 200, 90, 0.45));
}
#end-title.defeat {
  background: linear-gradient(180deg, #f0857a, #c0392b 45%, #5e120c 80%, #a03224);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 3px 2px #000) drop-shadow(0 0 34px rgba(190, 60, 40, 0.45));
}
#end-title.draw { color: var(--text-dim); }
#end-sub { color: var(--text-dim); margin: 10px 0 26px; font-size: 14px; letter-spacing: 1px; }
.end-buttons { display: flex; gap: 14px; justify-content: center; }

#disconnect-banner {
  position: fixed; top: 0; left: 0; right: 0; z-index: 50;
  background: linear-gradient(180deg, #7e221a, #58150f);
  border-bottom: 1px solid var(--gold-dark);
  color: #ffe9d6; text-align: center;
  padding: 8px; font-size: 14px;
}

body.attack-cursor #game-canvas { cursor: crosshair; }
