/* ============================================================================
   Archmage Chess — UI styling
   ============================================================================ */
:root {
  --gold: #e8c66a;
  --rune: #9d7bff;
  --rune-bright: #c4a8ff;
  --frost: #6fd0ff;
  --crimson: #ff3a4a;
  --panel: rgba(14, 10, 28, 0.82);
  --panel-edge: rgba(157, 123, 255, 0.35);
  --text: #e9e3ff;
  --text-dim: #a99fce;
  --display: 'Cinzel', 'Spectral', Georgia, serif;
  --body: 'Spectral', Georgia, 'Times New Roman', serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; background: #08060f; }
body {
  font-family: var(--body);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
}
#scene { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; }

.hidden { display: none !important; }

/* ---------------- overlays ---------------- */
.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle at 50% 30%, rgba(40, 20, 80, 0.55), rgba(6, 4, 14, 0.92));
  backdrop-filter: blur(4px);
  z-index: 20;
}

.menu-card {
  width: min(560px, 92vw);
  max-height: 92vh; overflow-y: auto;
  padding: 34px 38px;
  background: var(--panel);
  border: 1px solid var(--panel-edge);
  border-radius: 18px;
  box-shadow: 0 0 60px rgba(120, 80, 220, 0.35), inset 0 0 40px rgba(120, 80, 220, 0.08);
}
.menu-card.center { text-align: center; }

.title {
  font-family: var(--display);
  font-size: 46px; letter-spacing: 8px; font-weight: 900;
  text-align: center; line-height: 1.05;
  background: linear-gradient(180deg, #fff, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 30px rgba(232, 198, 106, 0.3);
}
.title span { display: block; font-size: 30px; letter-spacing: 14px; color: var(--rune-bright);
  background: linear-gradient(180deg, var(--rune-bright), var(--rune));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }
.title.small { font-size: 34px; letter-spacing: 5px; }
.subtitle { text-align: center; color: var(--text-dim); margin: 8px 0 22px; font-size: 14px; letter-spacing: 1px; }

.menu-section { margin-bottom: 18px; }
.menu-section h3 {
  font-family: var(--display); font-weight: 700;
  font-size: 13px; text-transform: uppercase; letter-spacing: 3px;
  color: var(--gold); margin-bottom: 8px; text-shadow: 0 0 10px rgba(232, 198, 106, 0.35);
}
.choice-row { display: flex; gap: 10px; flex-wrap: wrap; }
.choice {
  flex: 1 1 0; min-width: 120px;
  display: flex; flex-direction: column; gap: 3px;
  padding: 12px 14px; cursor: pointer;
  background: rgba(40, 28, 70, 0.5);
  border: 1px solid rgba(157, 123, 255, 0.25);
  border-radius: 10px; color: var(--text);
  font-size: 14px; text-align: left;
  transition: all 0.18s ease;
}
.choice.small { flex-direction: row; justify-content: center; text-align: center; font-size: 13px; padding: 9px 10px; }
.choice:hover { border-color: var(--rune); background: rgba(60, 40, 100, 0.6); transform: translateY(-1px); }
.choice.selected {
  border-color: var(--gold);
  background: linear-gradient(180deg, rgba(90, 60, 150, 0.7), rgba(60, 40, 100, 0.55));
  box-shadow: 0 0 18px rgba(232, 198, 106, 0.25);
}
.choice-name { font-weight: 700; letter-spacing: 0.5px; }
.choice-sub { font-size: 11px; color: var(--text-dim); }

.start-btn {
  display: block; width: 100%; margin-top: 14px;
  padding: 14px; cursor: pointer;
  font-family: var(--display);
  font-size: 16px; font-weight: 700; letter-spacing: 3px;
  color: #1a1030;
  background: linear-gradient(180deg, var(--gold), #c79a3e);
  border: none; border-radius: 12px;
  box-shadow: 0 0 26px rgba(232, 198, 106, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
}
.start-btn:hover { transform: translateY(-2px); box-shadow: 0 0 38px rgba(232, 198, 106, 0.6); }
.start-btn.ghost {
  background: transparent; color: var(--text-dim);
  border: 1px solid var(--panel-edge); box-shadow: none; margin-top: 10px; letter-spacing: 2px;
}
.start-btn.ghost:hover { color: var(--text); border-color: var(--rune); }
.hint { text-align: center; color: var(--text-dim); font-size: 12px; margin-top: 14px; }

/* ---------------- HUD ---------------- */
#hud { position: fixed; inset: 0; pointer-events: none; z-index: 10; font-family: var(--body); }
#hud button, #hud .spell-card, #hud canvas { pointer-events: auto; }

.icon-btn {
  width: 40px; height: 40px; border-radius: 9px; cursor: pointer;
  background: var(--panel); color: var(--text);
  border: 1px solid var(--panel-edge); font-size: 17px; transition: all 0.15s;
}
.icon-btn:hover { border-color: var(--rune); color: var(--gold); }
.icon-btn.muted { opacity: 0.5; text-decoration: line-through; }
#corner-btns { position: absolute; top: 14px; left: 50%; transform: translateX(-50%); display: flex; gap: 8px; }

/* top-left: Aether + spell cards */
#left-panel { position: absolute; top: 16px; left: 18px; width: 270px; display: flex; flex-direction: column; gap: 12px; }
#aether-box {
  padding: 10px 14px; border-radius: 10px;
  background: linear-gradient(180deg, rgba(10,18,34,0.85), rgba(6,10,22,0.8));
  border: 1px solid rgba(111,208,255,0.35); box-shadow: 0 0 22px rgba(58,176,255,0.18);
}
#aether-label { font-size: 17px; font-weight: 700; letter-spacing: 1px; color: #d6f2ff; text-shadow: 0 0 10px rgba(58,176,255,0.6); }
#aether-label .dim { color: #6f93b8; font-weight: 400; }
#mana-bar {
  margin-top: 7px; height: 14px; border-radius: 7px; overflow: hidden;
  background: rgba(10,20,40,0.9); border: 1px solid rgba(111,208,255,0.45);
  background-image: repeating-linear-gradient(90deg, transparent 0 18px, rgba(0,0,0,0.4) 18px 20px);
}
#mana-fill { height: 100%; width: 35%; border-radius: 6px;
  background: linear-gradient(90deg, #1f6fd0, #5fd6ff, #aef0ff); box-shadow: 0 0 14px var(--frost); transition: width 0.4s ease; }

#spell-cards { display: flex; flex-direction: column; gap: 10px; }
.spell-card {
  position: relative; display: flex; align-items: center; gap: 12px;
  padding: 10px 12px; cursor: pointer; border-radius: 10px;
  background: linear-gradient(180deg, rgba(26,20,44,0.82), rgba(14,10,26,0.8));
  border: 1px solid rgba(157,123,255,0.3); transition: all 0.15s;
}
.spell-card .ico {
  width: 46px; height: 46px; flex: none; border-radius: 8px; font-size: 24px;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(90,60,150,0.7), rgba(30,20,50,0.7));
  border: 1px solid rgba(157,123,255,0.5); box-shadow: inset 0 0 12px rgba(157,123,255,0.3);
}
.spell-card .meta { display: flex; flex-direction: column; gap: 2px; }
.spell-card .nm { font-size: 15px; font-weight: 700; letter-spacing: 0.3px; color: #ede7ff; }
.spell-card .st { font-size: 12px; color: #9b8fc4; }
.spell-card .st.ready { color: #7dffb0; }
.spell-card:hover:not(.disabled) { border-color: var(--gold); transform: translateX(3px); box-shadow: 0 0 18px rgba(157,123,255,0.35); }
.spell-card.armed { border-color: var(--gold); box-shadow: 0 0 24px var(--gold); background: linear-gradient(180deg, rgba(70,46,120,0.85), rgba(40,26,70,0.8)); }
.spell-card.disabled { opacity: 0.45; cursor: not-allowed; }
.spell-card .cd-badge {
  position: absolute; bottom: 6px; left: 40px;
  font-size: 11px; font-weight: 800; color: var(--frost);
}

/* top-right: minimap + turn */
#right-panel { position: absolute; top: 16px; right: 18px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
#minimap {
  width: 168px; height: 168px; border-radius: 8px;
  background: rgba(8,8,16,0.7); border: 1px solid var(--panel-edge);
  box-shadow: 0 0 22px rgba(0,0,0,0.5);
}
#turn-num { font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: 1px; color: #d8d2f0; }
#turn-state {
  font-family: var(--display); font-size: 15px; font-weight: 700; letter-spacing: 3px; color: #7dffb0;
  text-shadow: 0 0 12px currentColor; padding: 4px 14px; margin-top: 2px;
  background: rgba(10, 8, 20, 0.7); border: 1px solid currentColor; border-radius: 13px;
  box-shadow: 0 0 14px rgba(125, 255, 176, 0.25);
}
#turn-state.enemy { color: var(--crimson); box-shadow: 0 0 14px rgba(255, 58, 74, 0.3); }

/* captured trays — vertical, mid-screen edges */
.captured-tray {
  position: absolute; top: 50%; transform: translateY(-50%); width: 42px;
  display: flex; flex-direction: column; gap: 4px; padding: 6px;
}
.captured-tray.left { left: 8px; }
.captured-tray.right { right: 8px; }
.cap-slot {
  width: 30px; height: 30px; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(180deg, rgba(30, 22, 46, 0.82), rgba(16, 12, 26, 0.8));
  border: 1px solid rgba(157, 123, 255, 0.32); border-radius: 7px;
  box-shadow: 0 0 8px rgba(157, 123, 255, 0.14), inset 0 0 6px rgba(0, 0, 0, 0.4);
}
.cap-slot span { font-size: 20px; line-height: 1; color: var(--text); filter: drop-shadow(0 0 5px rgba(157, 123, 255, 0.4)); }

/* bottom-left: selected unit */
#unit-panel {
  position: absolute; bottom: 22px; left: 20px; width: 340px;
  display: flex; align-items: flex-start; gap: 12px; padding: 12px;
  border-radius: 12px; background: linear-gradient(180deg, rgba(18,14,30,0.92), rgba(10,8,18,0.9));
  border: 1px solid var(--panel-edge); box-shadow: 0 0 26px rgba(0,0,0,0.6);
}
#unit-desc {
  margin-top: 7px; font-size: 11.5px; line-height: 1.45; color: #b3a9d4;
  font-style: italic; max-width: 250px;
}
#unit-portrait {
  position: relative; width: 58px; height: 58px; flex: none; border-radius: 9px;
  display: flex; align-items: center; justify-content: center; font-size: 36px;
  background: radial-gradient(circle, rgba(60,40,100,0.8), rgba(20,14,36,0.9));
  border: 1px solid var(--gold);
}
#unit-level {
  position: absolute; bottom: -6px; right: -6px; min-width: 22px; height: 22px;
  border-radius: 11px; background: var(--gold); color: #1a1030;
  font-size: 12px; font-weight: 800; display: flex; align-items: center; justify-content: center; padding: 0 5px;
}
#unit-info { flex: 1; display: flex; flex-direction: column; gap: 3px; }
#unit-name { font-family: var(--display); font-size: 17px; font-weight: 700; letter-spacing: 0.5px; color: #f0ebff; }
#unit-sub { font-size: 12px; color: #a99fce; letter-spacing: 0.5px; }
#unit-bar { height: 9px; border-radius: 5px; background: rgba(40,10,12,0.9); border: 1px solid rgba(255,90,80,0.4); overflow: hidden; margin-top: 2px; }
#unit-bar-fill { height: 100%; width: 100%; background: linear-gradient(90deg, #8a1620, #ff5a4a, #ff8a6a); box-shadow: 0 0 10px rgba(255,90,74,0.6); transition: width 0.3s; }

/* bottom-right: logo */
#game-logo { position: absolute; bottom: 20px; right: 22px; text-align: right; pointer-events: none; }
.logo-main { font-family: var(--display); font-size: 30px; font-weight: 900; letter-spacing: 4px; line-height: 1;
  background: linear-gradient(180deg, #fff, var(--gold)); -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 24px rgba(232,198,106,0.3); }
.logo-arena { font-family: var(--display); font-size: 22px; font-weight: 700; letter-spacing: 6px; color: var(--rune-bright); text-shadow: 0 0 16px rgba(157,123,255,0.5); margin-top: 2px; }
.logo-mode { font-size: 11px; letter-spacing: 3px; color: #b9aee0; margin-top: 3px; }

/* cinematic vignette */
#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 9;
  box-shadow: inset 0 0 240px 60px rgba(0,0,0,0.7);
  background: radial-gradient(ellipse at center, transparent 55%, rgba(0,0,0,0.35) 100%);
}

/* ---------------- toasts / banners ---------------- */
#toast {
  position: absolute; top: 76px; left: 50%; transform: translateX(-50%);
  padding: 10px 22px; border-radius: 22px;
  background: var(--panel); border: 1px solid var(--panel-edge);
  font-size: 14px; letter-spacing: 1px; opacity: 0; transition: opacity 0.3s;
  white-space: nowrap;
}
#toast.show { opacity: 1; }

#check-banner {
  position: absolute; top: 40%; left: 50%; transform: translate(-50%, -50%);
  font-family: var(--display);
  font-size: 80px; font-weight: 900; letter-spacing: 14px; color: var(--crimson);
  text-shadow: 0 0 40px var(--crimson); animation: checkpulse 0.7s ease;
  pointer-events: none;
}
@keyframes checkpulse {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(1.6); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1); }
}

#spell-prompt {
  position: absolute; bottom: 130px; left: 50%; transform: translateX(-50%);
  padding: 10px 22px; border-radius: 12px;
  background: rgba(60, 40, 110, 0.85); border: 1px solid var(--gold);
  font-size: 14px; letter-spacing: 1px;
}

/* ---------------- promotion ---------------- */
.promo-card { padding: 24px 30px; background: var(--panel); border: 1px solid var(--gold); border-radius: 16px; text-align: center; }
.promo-card h3 { margin-bottom: 14px; letter-spacing: 2px; }
#promo-row { display: flex; gap: 12px; }
.promo-opt {
  width: 70px; height: 70px; font-size: 38px; cursor: pointer;
  background: rgba(40,28,70,0.6); border: 1px solid var(--panel-edge); border-radius: 12px; color: var(--text);
  transition: all 0.15s;
}
.promo-opt:hover { border-color: var(--gold); transform: translateY(-2px); box-shadow: 0 0 18px var(--gold); }

/* ---------------- first-load screen ---------------- */
#loading-screen {
  position: fixed; inset: 0; z-index: 100;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px;
  background: radial-gradient(circle at 50% 38%, #1a1033, #08060f 72%);
  transition: opacity 0.7s ease;
}
#loading-screen.done { opacity: 0; pointer-events: none; }
.ls-title {
  font-family: var(--display); font-size: 40px; letter-spacing: 9px; font-weight: 900; line-height: 1;
  text-align: center;
  background: linear-gradient(180deg, #fff, var(--gold));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  text-shadow: 0 0 32px rgba(232, 198, 106, 0.3);
}
.ls-title span {
  display: block; font-size: 24px; letter-spacing: 14px; margin-top: 4px;
  background: linear-gradient(180deg, var(--rune-bright), var(--rune));
  -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
}
.ls-ring {
  width: 60px; height: 60px; border-radius: 50%;
  border: 3px solid rgba(157, 123, 255, 0.15);
  border-top-color: var(--gold); border-right-color: var(--rune-bright);
  box-shadow: 0 0 26px rgba(157, 123, 255, 0.4);
  animation: ls-spin 1s linear infinite;
}
@keyframes ls-spin { to { transform: rotate(360deg); } }
.ls-text { font-family: var(--body); color: var(--text-dim); letter-spacing: 4px; font-size: 12px; text-transform: uppercase; animation: pulse 1.6s infinite; }

/* ---------------- loading ---------------- */
.loader { color: var(--gold); font-size: 18px; letter-spacing: 3px; animation: pulse 1.4s infinite; }
@keyframes pulse { 0%,100% { opacity: 0.4; } 50% { opacity: 1; } }

@media (max-width: 760px) {
  .title { font-size: 34px; letter-spacing: 4px; }
  #left-panel { width: 210px; }
  #minimap { width: 120px; height: 120px; }
  #unit-panel { width: 220px; }
  .logo-main { font-size: 22px; } .logo-arena { font-size: 16px; letter-spacing: 4px; }
  #check-banner { font-size: 52px; letter-spacing: 8px; }
}
