/* Wand — the canvas fills the screen; everything else floats over it. */

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: #070510;
}

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font);
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
}

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

/* ---------- heads-up chrome ---------- */

.hud-top {
  position: fixed;
  top: calc(var(--safe-top) + 10px);
  left: calc(var(--safe-left) + 10px);
  right: calc(var(--safe-right) + 10px);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 3;
}

.hud-top .spacer {
  flex: 1;
}

.hud-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid rgba(232, 176, 74, 0.28);
  border-radius: 999px;
  background: rgba(18, 12, 34, 0.68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #f4e8cc;
  font: inherit;
  font-size: 0.86rem;
  cursor: pointer;
}

.hud-btn:active {
  background: rgba(232, 176, 74, 0.2);
}

.hud-btn svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.hud-btn b {
  font-variant-numeric: tabular-nums;
}

/* ---------- what the last spell did ---------- */

.readout {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  top: calc(var(--safe-top) + 66px);
  width: min(560px, calc(100vw - 32px));
  text-align: center;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s;
}

.readout.show {
  opacity: 1;
}

.readout b {
  display: block;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.5rem;
  letter-spacing: 0.06em;
  color: #ffd98a;
  text-shadow: 0 0 22px rgba(255, 190, 90, 0.55);
}

.readout span {
  display: block;
  margin-top: 2px;
  font-size: 0.95rem;
  color: #e8ddc4;
  text-shadow: 0 2px 10px #000;
}

.readout.fizzle b {
  color: #b9aee0;
  text-shadow: none;
}

.hint {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 18px);
  margin: 0;
  width: min(520px, calc(100vw - 32px));
  text-align: center;
  font-size: 0.82rem;
  color: rgba(244, 232, 204, 0.62);
  text-shadow: 0 2px 8px #000;
  z-index: 2;
  pointer-events: none;
  transition: opacity 0.4s;
}

.hint.gone {
  opacity: 0;
}

/* ---------- trials drawer ---------- */

.drawer {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 12px);
  width: min(460px, calc(100vw - 24px));
  max-height: 62vh;
  overflow: auto;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: 18px;
  background: rgba(26, 18, 48, 0.94);
  -webkit-backdrop-filter: blur(12px);
  backdrop-filter: blur(12px);
  box-shadow: var(--shadow-lg);
  z-index: 4;
}

.drawer h2 {
  margin: 0 0 10px;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.15rem;
  color: #ffd98a;
}

.drawer ul {
  list-style: none;
  margin: 0 0 12px;
  padding: 0;
  display: grid;
  gap: 6px;
}

.drawer li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  align-items: start;
  padding: 7px 8px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  font-size: 0.9rem;
  line-height: 1.35;
}

.drawer li.done {
  color: #9de8b5;
  background: rgba(157, 232, 181, 0.1);
}

.drawer li i {
  font-style: normal;
  text-align: center;
  opacity: 0.8;
}

.drawer li small {
  display: block;
  color: var(--text-muted);
  font-size: 0.78rem;
}

.drawer li.done small {
  display: none;
}

.small {
  font-size: 0.78rem;
}

/* ---------- spellbook ---------- */

.book {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.spell {
  display: grid;
  grid-template-rows: auto auto auto;
  gap: 2px;
  padding: 10px 8px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font: inherit;
  text-align: center;
  cursor: pointer;
}

.spell:active,
.spell.picked {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.spell canvas {
  width: 74px;
  height: 74px;
  margin: 0 auto;
}

.spell strong {
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.02rem;
  letter-spacing: 0.04em;
}

.spell em {
  font-style: normal;
  font-size: 0.74rem;
  color: var(--text-muted);
  line-height: 1.3;
}

@media (prefers-reduced-motion: reduce) {
  .readout,
  .hint {
    transition: none;
  }
}

/* The spellbook needs more room than a standard dialog. */
.dialog.wide .dialog-panel {
  max-width: min(760px, calc(100vw - 24px));
  width: 100%;
}

/* The shared trophy button drops into the top bar; make it match our pills. */
.hud-top .ach-btn {
  margin: 0;
  min-height: 42px;
  padding: 0 10px;
  border: 1px solid rgba(232, 176, 74, 0.28);
  border-radius: 999px;
  background: rgba(18, 12, 34, 0.68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #f4e8cc;
  opacity: 1;
}

.hud-top .hub-link {
  background: rgba(18, 12, 34, 0.68);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: #f4e8cc;
}

/* ---------- which place you are in ---------- */

.place-name {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  bottom: calc(var(--safe-bottom) + 72px);
  margin: 0;
  z-index: 2;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.6s;
  font-family: var(--font-display, Georgia, serif);
  font-size: 0.82rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(244, 232, 204, 0.6);
  text-shadow: 0 2px 10px #000;
}

.place-name.show {
  opacity: 1;
}

/* On a narrow phone the top bar keeps the icons and drops the words. */
@media (max-width: 540px) {
  #places-btn span,
  #book-btn span {
    display: none;
  }
  .hud-top .hud-btn {
    padding: 0 10px;
  }
}

/* ---------- steps drawer ---------- */

.drawer li.now {
  background: rgba(232, 176, 74, 0.12);
  box-shadow: inset 0 0 0 1px rgba(232, 176, 74, 0.25);
}

.drawer li.later {
  opacity: 0.45;
  font-style: italic;
}

/* ---------- full-screen panels: places, and finishing one ---------- */

.panel[hidden] {
  display: none;
}

.panel {
  position: fixed;
  inset: 0;
  z-index: 6;
  display: grid;
  place-items: center;
  padding: calc(var(--safe-top) + 12px) 12px calc(var(--safe-bottom) + 12px);
  background: rgba(8, 5, 16, 0.82);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  overflow: auto;
}

.panel-inner {
  width: min(760px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 18px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: linear-gradient(rgba(36, 26, 66, 0.96), rgba(22, 15, 44, 0.96));
  box-shadow: var(--shadow-lg);
}

.panel-inner > header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.panel h2 {
  margin: 0;
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.5rem;
  color: #ffd98a;
}

.place-list {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

@media (min-width: 620px) {
  .place-list {
    grid-template-columns: 1fr 1fr;
  }
}

.place {
  display: grid;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.04);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.place:not(.locked):hover,
.place:not(.locked):active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.place.locked {
  cursor: default;
  opacity: 0.7;
}

.place-art {
  width: 100%;
  height: auto;
  aspect-ratio: 220 / 132;
  border-radius: 10px;
  background: #07050f;
}

.place-text {
  display: grid;
  gap: 3px;
}

.place-text strong {
  font-family: var(--font-display, Georgia, serif);
  font-size: 1.1rem;
  letter-spacing: 0.02em;
}

.place.beaten .place-text strong::after {
  content: ' ✓';
  color: #9de8b5;
}

.place-text em {
  font-style: normal;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.35;
}

.place-text small {
  font-size: 0.72rem;
  color: rgba(232, 176, 74, 0.7);
  letter-spacing: 0.04em;
  text-transform: lowercase;
}

/* ---------- the flourish when a place is finished ---------- */

.victory .panel-inner {
  width: min(460px, 100%);
  text-align: center;
}

.victory .eyebrow {
  margin: 0;
  font-size: 0.74rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: rgba(232, 176, 74, 0.75);
}

.victory h2 {
  margin: 4px 0 10px;
  font-size: 1.7rem;
}

.victory p {
  margin: 0 0 8px;
  color: var(--text-muted);
  line-height: 1.45;
}

.victory .unlocked:not(:empty) {
  margin: 12px 0;
  padding: 10px;
  border-radius: 12px;
  background: rgba(157, 232, 181, 0.12);
  color: #9de8b5;
}

.victory .row {
  display: flex;
  gap: 8px;
  justify-content: center;
  margin-top: 14px;
}
