/* Realm of the Riven Sky — HUD + menus.
   Design goal: readable at a glance, never in the way of the crosshair. */

:root {
  --gold: #d9b45b;
  --gold-dim: #8a6f33;
  --ink: #0b0a10;
  --parch: #efe3c8;
  --hp: #d64550;
  --mana: #4aa3ff;
  --shield: #b7b2a8;
  --ok: #7ee787;
  --panel: rgba(14, 12, 20, 0.86);
  --edge: rgba(217, 180, 91, 0.32);
  --font: 'Iowan Old Style', 'Palatino Linotype', Palatino, 'Book Antiqua', Georgia, serif;
  --ui: ui-sans-serif, system-ui, 'Segoe UI', Roboto, sans-serif;
}

* { box-sizing: border-box; }
html, body {
  margin: 0; padding: 0; height: 100%; overflow: hidden;
  background: #05060a; color: var(--parch);
  font-family: var(--ui);
  -webkit-font-smoothing: antialiased;
}
canvas#view { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }
kbd {
  font-family: var(--ui); font-size: 11px; padding: 1px 5px; border-radius: 4px;
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 1px 0 rgba(0,0,0,0.4); color: #fff;
}
button { font-family: var(--ui); cursor: pointer; }

/* ------------------------------------------------------------------ overlays */
.overlay {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 40%, rgba(30,22,48,0.72), rgba(4,4,8,0.95));
  backdrop-filter: blur(6px);
}
.panel {
  width: min(1080px, 94vw); max-height: 92vh; overflow: auto;
  background: var(--panel);
  border: 1px solid var(--edge);
  border-radius: 14px;
  padding: 26px 30px;
  box-shadow: 0 30px 90px rgba(0,0,0,0.7), inset 0 1px 0 rgba(255,255,255,0.06);
}
.panel.narrow { width: min(520px, 92vw); text-align: center; }
.panel.wide { width: min(940px, 94vw); }

.brand h1 {
  font-family: var(--font); font-weight: 500; font-size: 40px; margin: 0 0 4px;
  letter-spacing: 0.5px;
}
.brand h1 em { color: var(--gold); font-style: italic; }
.tag { margin: 0 0 18px; color: #a9a2b8; font-size: 14px; }

.menu-grid { display: grid; grid-template-columns: 1fr 1.15fr; gap: 26px; }
@media (max-width: 860px) { .menu-grid { grid-template-columns: 1fr; } }

h4 {
  margin: 16px 0 8px; font-size: 12px; letter-spacing: 1.6px; text-transform: uppercase;
  color: var(--gold-dim); font-weight: 700;
}
h4 small { text-transform: none; letter-spacing: 0; color: #7d7690; font-weight: 400; }

input[type=text], input:not([type]) {
  width: 100%; padding: 10px 12px; border-radius: 8px; font-size: 15px;
  background: rgba(255,255,255,0.06); color: var(--parch);
  border: 1px solid rgba(255,255,255,0.14); outline: none;
}
input:focus { border-color: var(--gold); }

.choices { display: grid; gap: 8px; }
.choices.compact { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
.choice {
  text-align: left; padding: 10px 12px; border-radius: 9px;
  background: rgba(255,255,255,0.045); color: var(--parch);
  border: 1px solid rgba(255,255,255,0.1); transition: 0.15s;
}
.choice strong { display: block; font-size: 14px; }
.choice span { display: block; font-size: 11.5px; color: #a29ab5; margin-top: 2px; line-height: 1.35; }
.choice:hover { background: rgba(255,255,255,0.09); }
.choice.selected { border-color: var(--gold); background: rgba(217,180,91,0.14); }
.choice.locked { opacity: 0.42; cursor: not-allowed; }
.choice.locked:hover { background: rgba(255,255,255,0.045); }

#charGrid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.char-card {
  border-radius: 10px; padding: 8px; text-align: center;
  background: rgba(255,255,255,0.045); border: 1px solid rgba(255,255,255,0.1);
  transition: 0.15s; color: var(--parch);
}
.char-card:hover { background: rgba(255,255,255,0.09); transform: translateY(-2px); }
.char-card.selected { border-color: var(--gold); background: rgba(217,180,91,0.16); }
.char-card canvas { width: 100%; height: 128px; display: block; border-radius: 7px; }
.char-card b { display: block; font-size: 12.5px; margin-top: 6px; }
.char-card i { display: block; font-size: 11px; color: var(--gold-dim); font-style: normal; }
#charBlurb {
  margin-top: 10px; min-height: 34px; font-size: 13px; color: #b8b0c8;
  font-family: var(--font); font-style: italic;
}

.menu-foot { margin-top: 20px; border-top: 1px solid rgba(255,255,255,0.1); padding-top: 16px; text-align: center; }
.controls-hint { display: flex; flex-wrap: wrap; gap: 10px 16px; justify-content: center; font-size: 11.5px; color: #8f88a3; margin-bottom: 16px; }
#playBtn {
  padding: 13px 42px; font-size: 16px; letter-spacing: 0.6px; border-radius: 10px;
  border: 1px solid var(--gold); color: #191308; font-weight: 700;
  background: linear-gradient(180deg, #f0d183, #c39c40);
  box-shadow: 0 6px 24px rgba(217,180,91,0.28);
}
#playBtn:hover { filter: brightness(1.08); }
#playBtn:disabled { filter: grayscale(0.7); cursor: wait; }
#menuStatus { font-size: 12.5px; color: #d18a8a; min-height: 18px; margin: 10px 0 0; }
.muted { color: #8f88a3; font-size: 12.5px; }
.ghost {
  background: transparent; color: var(--gold); border: 1px solid var(--edge);
  padding: 7px 14px; border-radius: 8px; font-size: 12.5px; margin-top: 10px;
}

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

#crosshair {
  position: absolute; left: 50%; top: 50%; width: 26px; height: 26px;
  transform: translate(-50%, -50%);
}
#crosshair span {
  position: absolute; background: rgba(255,255,255,0.82); border-radius: 1px;
  box-shadow: 0 0 3px rgba(0,0,0,0.9);
}
#crosshair span:nth-child(1) { left: 50%; top: 0; width: 1.5px; height: 7px; margin-left: -0.75px; }
#crosshair span:nth-child(2) { left: 50%; bottom: 0; width: 1.5px; height: 7px; margin-left: -0.75px; }
#crosshair span:nth-child(3) { top: 50%; left: 0; height: 1.5px; width: 7px; margin-top: -0.75px; }
#crosshair span:nth-child(4) { top: 50%; right: 0; height: 1.5px; width: 7px; margin-top: -0.75px; }
#crosshair i {
  position: absolute; left: 50%; top: 50%; width: 2px; height: 2px; margin: -1px 0 0 -1px;
  background: rgba(255,255,255,0.9); border-radius: 50%;
}
#crosshair.hit i { background: #ff5a5a; box-shadow: 0 0 8px #ff2d2d; transform: scale(2.6); }
#crosshair.hit span { background: #ff6b6b; }

#dmgFlash {
  position: absolute; inset: 0; opacity: 0; transition: opacity 0.35s;
  background: radial-gradient(ellipse at center, transparent 42%, rgba(150,10,20,0.55) 100%);
}
#dmgFlash.on { opacity: 1; transition: opacity 0.06s; }

#hitDir { position: absolute; inset: 0; }
.hit-arrow {
  position: absolute; left: 50%; top: 50%; width: 190px; height: 190px;
  margin: -95px 0 0 -95px; opacity: 0.9;
  transition: opacity 0.9s ease-out;
}
.hit-arrow::before {
  content: ''; position: absolute; left: 50%; top: -6px; margin-left: -13px;
  border-left: 13px solid transparent; border-right: 13px solid transparent;
  border-bottom: 17px solid rgba(255,70,70,0.92);
  filter: drop-shadow(0 0 5px rgba(0,0,0,0.8));
}

#topbar {
  position: absolute; top: 14px; left: 50%; transform: translateX(-50%);
  display: flex; align-items: center; gap: 14px;
}
.timer {
  font-family: var(--font); font-size: 24px; letter-spacing: 1px; color: var(--parch);
  background: rgba(10,8,16,0.6); border: 1px solid var(--edge); border-radius: 8px;
  padding: 3px 16px; text-shadow: 0 2px 6px #000; min-width: 96px; text-align: center;
}
.score-chip {
  min-width: 74px; text-align: center; font-size: 13px; padding: 5px 10px;
  border-radius: 8px; background: rgba(10,8,16,0.6); border: 1px solid rgba(255,255,255,0.12);
  text-shadow: 0 1px 3px #000; white-space: nowrap;
}
.score-chip b { font-size: 17px; display: block; line-height: 1.1; }
.score-chip.you { border-color: var(--gold); color: var(--gold); }

#killfeed {
  position: absolute; top: 62px; right: 18px; width: 330px;
  display: flex; flex-direction: column; align-items: flex-end; gap: 4px;
}
.kf {
  font-size: 12.5px; padding: 4px 9px; border-radius: 6px;
  background: rgba(10,8,16,0.62); border: 1px solid rgba(255,255,255,0.09);
  text-shadow: 0 1px 3px #000; animation: kfIn 0.2s ease-out;
  max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.kf .a { color: #ffd88a; } .kf .b { color: #ff9d9d; } .kf .g { opacity: 0.65; }
.kf.you { border-color: var(--gold); }
@keyframes kfIn { from { opacity: 0; transform: translateX(16px); } to { opacity: 1; transform: none; } }

#objective {
  position: absolute; top: 62px; left: 18px; font-size: 12px;
  background: rgba(10,8,16,0.58); border: 1px solid rgba(255,255,255,0.1);
  border-left: 2px solid var(--gold); border-radius: 0 8px 8px 0; padding: 7px 12px;
}
.obj-title { color: var(--gold-dim); text-transform: uppercase; letter-spacing: 1.2px; font-size: 9.5px; }
.obj-name { font-family: var(--font); font-size: 15px; }
.obj-dist { color: #9a93ad; font-size: 11px; }

#minimap {
  position: absolute; top: 16px; left: 50%; margin-left: -450px;
  width: 178px; height: 178px; border-radius: 50%;
  border: 2px solid rgba(217,180,91,0.4);
  background: rgba(8,10,14,0.55);
  box-shadow: 0 6px 26px rgba(0,0,0,0.6), inset 0 0 30px rgba(0,0,0,0.6);
}
@media (max-width: 1180px) { #minimap { left: 16px; margin-left: 0; top: 120px; } }

#perf {
  position: absolute; top: 14px; right: 18px; font-size: 11.5px; font-weight: 700;
  color: #9fe6a0; background: rgba(10,8,16,0.55); border: 1px solid rgba(255,255,255,0.1);
  border-radius: 6px; padding: 3px 8px; letter-spacing: 0.4px; text-shadow: 0 1px 3px #000;
}
#perf.warn { color: #ffd166; }
#perf.bad { color: #ff8a8a; }

#centerToast {
  position: absolute; left: 50%; top: 27%; transform: translateX(-50%);
  text-align: center; font-family: var(--font); pointer-events: none;
}
.toast {
  font-size: 26px; color: var(--gold); text-shadow: 0 3px 16px rgba(0,0,0,0.9);
  animation: toastIn 0.4s ease-out; margin-bottom: 4px;
}
.toast small { display: block; font-size: 14px; color: var(--parch); opacity: 0.85; font-family: var(--ui); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-14px) scale(0.96); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------------ bottom */
#bottom {
  position: absolute; left: 0; right: 0; bottom: 16px;
  display: flex; align-items: flex-end; justify-content: center; gap: 18px;
}
#vitals { width: 232px; display: flex; flex-direction: column; gap: 6px; padding-bottom: 3px; }
.bar {
  position: relative; height: 17px; border-radius: 4px; overflow: hidden;
  background: rgba(6,5,10,0.72); border: 1px solid rgba(255,255,255,0.14);
  box-shadow: inset 0 1px 4px rgba(0,0,0,0.6);
}
.bar .fill { position: absolute; inset: 0; width: 100%; transform-origin: left; transition: transform 0.14s ease-out; }
.bar span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; text-shadow: 0 1px 3px #000; letter-spacing: 0.4px;
}
.bar.hp .fill { background: linear-gradient(180deg, #e8626d, #a3222d); }
.bar.mana .fill { background: linear-gradient(180deg, #63b5ff, #2467c7); }
.bar.shield { height: 11px; }
.bar.shield .fill { background: linear-gradient(180deg, #e6e1d6, #8e8a80); }
.bar.low .fill { animation: pulseLow 0.85s infinite; }
@keyframes pulseLow { 50% { filter: brightness(1.6); } }

#hotbar { display: flex; gap: 7px; pointer-events: auto; }
.slot {
  position: relative; width: 58px; height: 58px; border-radius: 9px;
  background: rgba(10,9,16,0.72); border: 1.5px solid rgba(255,255,255,0.14);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.1s, border-color 0.1s;
  cursor: pointer;
}
.slot .ico { font-size: 25px; filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8)); line-height: 1; }
.slot .key {
  position: absolute; top: 2px; left: 5px; font-size: 10px; color: #9e97b0; font-weight: 700;
}
.slot .cost {
  position: absolute; bottom: 2px; right: 5px; font-size: 10px; color: var(--mana); font-weight: 700;
}
.slot .cd {
  position: absolute; inset: 0; background: rgba(4,4,8,0.72); border-radius: 7px;
  transform-origin: bottom; pointer-events: none;
}
.slot .cdtext {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 15px; font-weight: 700; text-shadow: 0 2px 4px #000; pointer-events: none;
}
.slot.active { border-color: var(--gold); transform: translateY(-6px); box-shadow: 0 0 20px rgba(217,180,91,0.35); }
.slot.active::after {
  content: ''; position: absolute; left: 50%; bottom: -9px; width: 5px; height: 5px;
  margin-left: -2.5px; border-radius: 50%; background: var(--gold);
}
.slot.nomana .ico { filter: grayscale(1) brightness(0.6); }
.slot.empty .ico { opacity: 0.18; }
.slot.dragover { border-color: var(--ok); background: rgba(126,231,135,0.14); }
.slot.flash { animation: slotFlash 0.28s; }
@keyframes slotFlash { 0% { box-shadow: 0 0 0 0 rgba(255,255,255,0.7); } 100% { box-shadow: 0 0 0 16px rgba(255,255,255,0); } }

#supers { width: 232px; display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.supers-label { font-size: 10px; letter-spacing: 1.4px; text-transform: uppercase; color: var(--gold-dim); }
#superSlots { display: flex; gap: 6px; }
.super {
  width: 46px; height: 46px; border-radius: 50%;
  border: 1.5px solid #b98cff; background: radial-gradient(circle at 40% 35%, rgba(190,140,255,0.4), rgba(20,10,35,0.85));
  display: flex; align-items: center; justify-content: center; font-size: 21px;
  box-shadow: 0 0 18px rgba(150,90,255,0.4); animation: superPulse 2.2s infinite;
}
.super.empty { border-color: rgba(255,255,255,0.1); background: rgba(10,9,16,0.5); box-shadow: none; animation: none; opacity: 0.4; font-size: 15px; }
@keyframes superPulse { 50% { box-shadow: 0 0 30px rgba(170,110,255,0.75); } }

#castbar {
  position: absolute; left: 50%; bottom: 128px; transform: translateX(-50%);
  width: 210px; height: 7px; border-radius: 4px; overflow: hidden;
  background: rgba(6,5,10,0.8); border: 1px solid rgba(255,255,255,0.18);
}
#castbar .cast-fill { height: 100%; width: 0; background: linear-gradient(90deg, #d9b45b, #fff1c2); }
#castbar span {
  position: absolute; left: 0; right: 0; top: -19px; text-align: center; font-size: 11.5px;
  color: var(--parch); text-shadow: 0 1px 3px #000;
}

#deadOverlay {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; background: rgba(20,2,6,0.42);
  text-shadow: 0 3px 14px #000;
}
#deadOverlay h2 { font-family: var(--font); font-size: 46px; margin: 0; color: #e88; letter-spacing: 1px; }
#deadOverlay p { font-size: 16px; color: #ccc; }

/* -------------------------------------------------------------- scoreboard */
#scoreboard {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%,-50%);
  background: var(--panel); border: 1px solid var(--edge); border-radius: 12px;
  padding: 18px 24px; min-width: 420px;
}
#scoreboard h3 { margin: 0 0 10px; font-family: var(--font); font-weight: 500; color: var(--gold); }
#scoreboard table, .endboard { width: 100%; border-collapse: collapse; font-size: 13.5px; }
#scoreboard th { text-align: left; color: var(--gold-dim); font-size: 10.5px; text-transform: uppercase; letter-spacing: 1.2px; padding-bottom: 6px; }
#scoreboard td, .endboard td { padding: 4px 6px; border-top: 1px solid rgba(255,255,255,0.07); }
#scoreboard td:nth-child(n+2), .endboard td:nth-child(n+2) { text-align: right; width: 62px; }
tr.me { color: var(--gold); font-weight: 700; }
tr.bot td:first-child::after { content: ' ⌁'; opacity: 0.5; font-size: 11px; }
.sb-hint { text-align: right; margin: 8px 0 0; font-size: 11px; color: #7d7690; }

/* -------------------------------------------------------------------- chat */
#chatLog {
  position: absolute; left: 18px; bottom: 108px; width: 380px;
  display: flex; flex-direction: column; gap: 3px;
}
.chat-line {
  font-size: 12.5px; text-shadow: 0 1px 3px #000; opacity: 1;
  transition: opacity 0.8s; padding: 2px 0;
}
.chat-line b { color: var(--gold); }
.chat-line.sys { color: #9fd6ff; font-style: italic; }
#chatInput {
  position: absolute; left: 18px; bottom: 80px; width: 380px; pointer-events: auto;
  background: rgba(6,5,10,0.9); border: 1px solid var(--gold); font-size: 13px;
}

/* --------------------------------------------------------------- spellbook */
.book-body { display: grid; grid-template-columns: 1.4fr 1fr; gap: 22px; margin-top: 14px; }
@media (max-width: 780px) { .book-body { grid-template-columns: 1fr; } }
#spellList { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; max-height: 52vh; overflow: auto; padding-right: 4px; }
.spell-card {
  display: flex; gap: 10px; align-items: flex-start; padding: 9px 10px; border-radius: 9px;
  background: rgba(255,255,255,0.04); border: 1px solid rgba(255,255,255,0.1);
  cursor: grab; transition: 0.12s;
}
.spell-card:hover { background: rgba(255,255,255,0.09); }
.spell-card.picked { border-color: var(--gold); background: rgba(217,180,91,0.15); }
.spell-card .ico { font-size: 24px; line-height: 1; }
.spell-card b { font-size: 13px; display: block; }
.spell-card em { font-size: 10.5px; color: var(--gold-dim); font-style: normal; letter-spacing: 0.6px; text-transform: uppercase; }
.spell-card p { margin: 3px 0 0; font-size: 11.5px; color: #a49cb8; line-height: 1.35; }
.spell-card .stats { margin-top: 4px; font-size: 10.5px; color: #7f7893; display: flex; gap: 9px; }
.slots-area h4 { margin-top: 0; }
#bookSlots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
#bookSlots .slot { width: 100%; height: 62px; pointer-events: auto; }
header p { font-size: 12.5px; color: #a29ab5; margin: 4px 0 0; }
header h2 { font-family: var(--font); font-weight: 500; margin: 0; color: var(--gold); font-size: 26px; }

/* ------------------------------------------------------------- match end */
#meTitle { font-family: var(--font); font-size: 36px; margin: 0 0 6px; color: var(--gold); }
#meSub { color: #b8b0c8; margin: 0 0 14px; }
.unlock {
  margin: 14px 0; padding: 12px; border-radius: 10px; text-align: left;
  background: linear-gradient(135deg, rgba(217,180,91,0.18), rgba(155,93,229,0.16));
  border: 1px solid var(--gold);
}
.unlock b { color: var(--gold); }
.unlock p { margin: 4px 0 0; font-size: 12.5px; color: #c9c1d8; }
.me-actions { display: flex; gap: 10px; justify-content: center; margin-top: 16px; }
#meClose { padding: 10px 26px; border-radius: 8px; border: 1px solid var(--edge); background: rgba(255,255,255,0.07); color: var(--parch); }
#meMenu { margin-top: 0; }

/* ----------------------------------------------------------------- loading */
.loader { text-align: center; }
.loader .rune {
  width: 56px; height: 56px; margin: 0 auto 16px; border-radius: 50%;
  border: 3px solid rgba(217,180,91,0.25); border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#loadingText { font-family: var(--font); font-size: 17px; color: var(--parch); }
