:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #090915;
  color: #f8fafc;
}

* {
  box-sizing: border-box;
}

html,
body,
#gameRoot {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

body {
  min-width: 320px;
  min-height: 100vh;
  background: #090915;
  touch-action: none;
  user-select: none;
}

#gameRoot {
  position: relative;
  isolation: isolate;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  outline: none;
  background: #090915;
}

#hud {
  position: fixed;
  z-index: 3;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  top: max(12px, env(safe-area-inset-top));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  pointer-events: none;
}

.brand-lockup,
.meter,
.target-card,
.spell-entry {
  border: 1px solid rgba(94, 234, 212, 0.38);
  background: rgba(9, 9, 21, 0.78);
  box-shadow: 0 10px 34px rgba(0, 0, 0, 0.34), inset 0 0 0 1px rgba(255, 209, 102, 0.08);
  backdrop-filter: blur(9px);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: min(640px, 48vw);
  padding: 12px 16px;
  border-radius: 8px;
}

.mark {
  position: relative;
  width: 50px;
  height: 50px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: conic-gradient(from 20deg, #5eead4, #ffd166, #ff5f8a, #9f7aea, #5eead4);
  box-shadow: 0 0 26px rgba(94, 234, 212, 0.4);
}

.mark::before {
  content: "";
  position: absolute;
  inset: 9px;
  border-radius: 50%;
  background: #090915;
  border: 2px solid rgba(255, 255, 255, 0.82);
}

.mark::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 6px;
  width: 6px;
  height: 38px;
  background: #ffd166;
  box-shadow: -12px 15px 0 -1px #5eead4, 13px 15px 0 -1px #ff5f8a;
  transform: rotate(45deg);
}

h1,
h2,
p {
  margin: 0;
}

.brand-lockup h1 {
  font-size: clamp(1.16rem, 2vw, 1.96rem);
  line-height: 1;
  letter-spacing: 0;
}

.brand-lockup p {
  margin-top: 5px;
  color: rgba(248, 250, 252, 0.84);
  font-weight: 760;
  line-height: 1.25;
}

.meter-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(96px, 1fr));
  gap: 10px;
  min-width: min(540px, 52vw);
}

.meter {
  position: relative;
  min-height: 56px;
  padding: 9px 12px 13px;
  border-radius: 8px;
  overflow: hidden;
}

.meter span,
.target-card span,
.spell-entry span {
  display: block;
  color: rgba(248, 250, 252, 0.72);
  font-size: 0.68rem;
  font-weight: 950;
  line-height: 1;
  text-transform: uppercase;
}

.meter b {
  display: block;
  margin-top: 3px;
  color: #f8fafc;
  font-size: 1.3rem;
  line-height: 1.05;
}

.meter i {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  width: var(--fill, 100%);
  background: #5eead4;
}

.meter.score i {
  background: #ffd166;
}

.meter.focus i {
  background: #38bdf8;
}

.meter.ward i {
  background: #9f7aea;
}

.meter.combo i {
  background: #ff5f8a;
}

#spellDock {
  position: fixed;
  z-index: 4;
  left: max(12px, env(safe-area-inset-left));
  right: max(12px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 148px minmax(180px, 320px) 118px minmax(360px, 1fr);
  gap: 10px;
  align-items: stretch;
}

.target-card,
.spell-entry {
  border-radius: 8px;
  padding: 9px 12px;
}

.target-card b {
  display: block;
  margin-top: 6px;
  color: #ffd166;
  font-size: 1.35rem;
  line-height: 1;
  letter-spacing: 0.08em;
}

.spell-entry input {
  width: 100%;
  height: 52px;
  margin-top: 5px;
  border: 0;
  border-bottom: 2px solid rgba(94, 234, 212, 0.75);
  border-radius: 0;
  background: transparent;
  color: #f8fafc;
  font: inherit;
  font-size: 1.12rem;
  font-weight: 950;
  letter-spacing: 0.08em;
  outline: none;
  text-transform: uppercase;
}

.cast-button,
.rune-buttons button,
#modalPrimary {
  border: 0;
  border-radius: 8px;
  min-height: 64px;
  color: #090915;
  font: inherit;
  font-weight: 950;
  letter-spacing: 0;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 10px 0 rgba(0, 0, 0, 0.3), inset 0 -4px 0 rgba(0, 0, 0, 0.22), inset 0 2px 0 rgba(255, 255, 255, 0.36);
}

.cast-button {
  background: linear-gradient(180deg, #ffd166, #f97316);
}

.rune-buttons {
  display: grid;
  grid-template-columns: repeat(5, minmax(64px, 1fr));
  gap: 8px;
}

.rune-buttons button {
  min-width: 0;
  padding: 0 8px;
  background: linear-gradient(180deg, #5eead4, #38bdf8);
  font-size: 0.88rem;
}

.rune-buttons button:nth-child(2) {
  background: linear-gradient(180deg, #c4b5fd, #9f7aea);
}

.rune-buttons button:nth-child(3) {
  background: linear-gradient(180deg, #fde68a, #ffd166);
}

.rune-buttons button:nth-child(4) {
  background: linear-gradient(180deg, #bae6fd, #60a5fa);
}

.rune-buttons button:nth-child(5) {
  background: linear-gradient(180deg, #f9a8d4, #ff5f8a);
}

.cast-button:active,
.rune-buttons button:active,
#modalPrimary:active {
  transform: translateY(5px);
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.32), inset 0 -2px 0 rgba(0, 0, 0, 0.2);
}

#modal {
  position: fixed;
  z-index: 8;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: radial-gradient(circle at center, rgba(159, 122, 234, 0.26), rgba(9, 9, 21, 0.74) 48%, rgba(9, 9, 21, 0.96));
}

#modal.hidden {
  display: none;
}

.modal-frame {
  width: min(640px, calc(100vw - 36px));
  border: 2px solid rgba(255, 209, 102, 0.72);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(24, 18, 42, 0.98), rgba(9, 9, 21, 0.98));
  padding: 22px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.52), 0 0 40px rgba(94, 234, 212, 0.2);
}

.titleplate {
  display: grid;
  grid-template-columns: 62px 1fr;
  grid-template-areas: "icon eyebrow" "icon title";
  gap: 2px 14px;
  align-items: center;
}

.duel-emblem {
  grid-area: icon;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: conic-gradient(from 30deg, #5eead4, #ffd166, #ff5f8a, #9f7aea, #5eead4);
  border: 2px solid #f8fafc;
  box-shadow: inset 0 0 0 9px #090915, 0 0 24px rgba(94, 234, 212, 0.36);
}

.titleplate p {
  color: #5eead4;
  font-weight: 950;
  text-transform: uppercase;
}

.titleplate h2 {
  color: #f8fafc;
  font-size: clamp(2rem, 5vw, 3.85rem);
  line-height: 0.95;
  letter-spacing: 0;
}

.brief {
  margin-top: 18px;
  color: rgba(248, 250, 252, 0.86);
  font-size: 1.04rem;
  font-weight: 750;
  line-height: 1.45;
}

.brief-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin: 18px 0 22px;
}

.brief-grid span {
  border: 1px solid rgba(94, 234, 212, 0.34);
  border-radius: 8px;
  padding: 10px 8px;
  color: #ffd166;
  background: rgba(9, 9, 21, 0.72);
  font-size: 0.88rem;
  font-weight: 900;
  text-align: center;
}

#modalPrimary {
  width: 100%;
  background: linear-gradient(180deg, #ffd166, #f97316);
  font-size: 1.04rem;
}

@media (max-width: 980px) {
  #hud {
    gap: 8px;
    align-items: stretch;
  }

  .brand-lockup {
    max-width: 50vw;
    padding: 9px;
  }

  .mark {
    width: 34px;
    height: 34px;
  }

  .brand-lockup h1 {
    font-size: 1rem;
  }

  .brand-lockup p {
    display: none;
  }

  .meter-row {
    grid-template-columns: repeat(2, minmax(74px, 1fr));
    min-width: 45vw;
    gap: 7px;
  }

  .meter {
    min-height: 48px;
    padding: 8px 9px 12px;
  }

  .meter b {
    font-size: 1.04rem;
  }

  #spellDock {
    grid-template-columns: 1fr 1fr 92px;
    gap: 7px;
  }

  .rune-buttons {
    grid-column: 1 / -1;
    grid-template-columns: repeat(5, minmax(52px, 1fr));
    gap: 6px;
  }

  .cast-button,
  .rune-buttons button {
    min-height: 56px;
    font-size: 0.76rem;
    padding: 0 4px;
  }

  .target-card,
  .spell-entry {
    min-height: 66px;
    padding: 8px;
  }

  .target-card b,
  .spell-entry input {
    font-size: 1rem;
  }
}
