/* main.css
   Design tokens and the core shell: header, buttons, title, setup, chapter
   selector and hub, overlays, toast, and the celebration effects. The story
   screens lean dark and Norse; the activity screens are bright and friendly.
   Tap targets are kept large for small hands. */

:root {
  /* Story palette */
  --navy: #0a0e2e;
  --near-black: #06080f;
  --gold: #c9a84c;
  --gold-bright: #ffe08a;
  --rune-red: #8b1a1a;

  /* Activity palette */
  --amber: #f5a623;
  --sky: #4a90d9;
  --forest: #2d7a2d;
  --cream: #fdf6e3;

  --ink: #1c2233;
  --panel: rgba(255, 255, 255, 0.06);
  --radius: 16px;
  --tap: 64px;

  --font-head: 'Cinzel', 'MedievalSharp', Georgia, 'Times New Roman', serif;
  --font-rune: 'MedievalSharp', Georgia, serif;
  --font-body: 'Lato', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;

  --shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--near-black);
  color: var(--cream);
  font-family: var(--font-body);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: contain;
}

body {
  background:
    radial-gradient(1200px 800px at 50% -10%, #16204e 0%, rgba(22, 32, 78, 0) 60%),
    linear-gradient(180deg, var(--navy) 0%, var(--near-black) 100%);
  background-attachment: fixed;
}

#app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
}

h1, h2, h3 { font-family: var(--font-head); font-weight: 700; }

/* ---- header ---- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  padding-top: max(10px, env(safe-area-inset-top));
  background: rgba(6, 8, 15, 0.82);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(201, 168, 76, 0.35);
}
.app-crest {
  font-size: 26px;
  color: var(--gold);
  background: none;
  border: none;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
}
.app-title {
  font-family: var(--font-head);
  font-size: 16px;
  color: var(--gold);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sync-indicator {
  font-size: 12px;
  color: #9fb0d8;
  min-width: 0;
}
.sync-indicator.status-synced { color: #6fcf97; }
.sync-indicator.status-syncing { color: var(--amber); }
.sync-indicator.status-offline { color: #d68b8b; }
.btn-icon {
  background: rgba(255, 255, 255, 0.08);
  color: var(--cream);
  border: 1px solid rgba(201, 168, 76, 0.4);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 12px;
  min-height: 40px;
  cursor: pointer;
}

.app-screen {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  padding-bottom: calc(24px + env(safe-area-inset-bottom));
}

/* ---- buttons ---- */
.btn-amber, .btn-small, .btn-complete {
  font-family: var(--font-body);
  cursor: pointer;
  border: none;
  border-radius: 14px;
  font-weight: 700;
}
.btn-amber {
  background: linear-gradient(180deg, #ffc05a, var(--amber));
  color: #3a2300;
  padding: 14px 18px;
  min-height: var(--tap);
  font-size: 17px;
  box-shadow: 0 6px 0 #b9760f;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}
.btn-amber:active { transform: translateY(4px); box-shadow: 0 2px 0 #b9760f; }
.btn-amber.big { width: 100%; font-size: 19px; margin-top: 14px; }
.btn-small {
  background: rgba(255, 255, 255, 0.1);
  color: var(--cream);
  border: 1px solid rgba(201, 168, 76, 0.45);
  padding: 10px 12px;
  min-height: 44px;
  font-size: 14px;
}
.btn-small.on { background: var(--forest); color: #fff; }
.btn-complete {
  width: 100%;
  margin-top: 18px;
  background: linear-gradient(180deg, #2f9b4f, var(--forest));
  color: #fff;
  padding: 16px;
  min-height: var(--tap);
  font-size: 18px;
  box-shadow: 0 6px 0 #1c5a1c;
}
.btn-complete:active { transform: translateY(4px); box-shadow: 0 2px 0 #1c5a1c; }
.big-tap { min-height: var(--tap); }

/* ---- begin overlay ---- */
.begin-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  background:
    radial-gradient(900px 600px at 50% 30%, #1a2a66 0%, rgba(10, 14, 46, 0) 70%),
    linear-gradient(180deg, var(--navy), var(--near-black));
  animation: pulse-bg 4s ease-in-out infinite;
}
.begin-title { font-size: 34px; color: var(--gold); margin: 0 0 10px; text-shadow: 0 2px 16px rgba(0,0,0,0.7); }
.begin-subtitle { font-family: var(--font-head); font-style: italic; color: var(--gold); font-size: 16px; margin: 4px 0 14px; opacity: 0.92; }
.begin-sub { color: var(--cream); font-size: 18px; letter-spacing: 1px; opacity: 0.85; animation: blink 1.6s ease-in-out infinite; }
@keyframes blink { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }
@keyframes pulse-bg { 0%, 100% { filter: brightness(1); } 50% { filter: brightness(1.15); } }

/* ---- title ---- */
.title-screen { text-align: center; padding: 12px 4px; }
.title-art {
  height: 200px;
  border-radius: var(--radius);
  background:
    url('../assets/images/scenery/mountains.svg') center bottom / cover no-repeat,
    linear-gradient(180deg, #16245e, #0a0e2e);
  box-shadow: var(--shadow);
  border: 1px solid rgba(201, 168, 76, 0.4);
  margin-bottom: 16px;
  overflow: hidden;
}
.title-name { font-size: 34px; color: var(--gold); margin: 6px 0 2px; }
.title-subtitle { font-family: var(--font-head); font-style: italic; color: #cdd6ef; font-size: 17px; margin: 0 0 18px; }
.title-sub { color: #cdd6ef; margin: 0 0 18px; }
.content-pending {
  background: rgba(139, 26, 26, 0.25);
  border: 1px solid var(--rune-red);
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  color: #f3c9c9;
  margin: 0 auto 16px;
  max-width: 520px;
}

/* ---- setup ---- */
.setup-screen, .panel-wrap, .backup-screen { max-width: 720px; margin: 0 auto; }
.panel-title { color: var(--gold); font-size: 24px; margin: 6px 0 10px; }
.panel-sub { color: var(--amber); font-size: 18px; margin: 18px 0 8px; }
.panel-note { color: #cdd6ef; font-size: 14px; margin: 0 0 14px; }
.setup-session, .setup-add { display: flex; flex-direction: column; gap: 8px; background: var(--panel); border: 1px solid rgba(201,168,76,0.25); border-radius: var(--radius); padding: 14px; margin-bottom: 16px; }
.setup-session label, .setup-add label, .avatar-label, .restore-label, .cert-label { font-size: 13px; color: #aebbe0; }
.f-input {
  width: 100%;
  background: rgba(255,255,255,0.92);
  color: var(--ink);
  border: 2px solid rgba(201,168,76,0.6);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 16px;
  min-height: 48px;
}
.viking-row { display: flex; gap: 8px; }
.viking-row .f-input { flex: 1; }
.setup-code { color: var(--gold); font-weight: 700; margin-top: 6px; }
.setup-players { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.setup-player { display: flex; align-items: center; justify-content: space-between; gap: 8px; background: var(--panel); border-radius: 12px; padding: 10px 12px; border-left: 6px solid var(--gold); }
.avatar-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.avatar-opt { min-height: var(--tap); border-radius: 12px; border: 2px solid rgba(201,168,76,0.4); background: rgba(255,255,255,0.08); color: var(--cream); text-transform: capitalize; cursor: pointer; font-weight: 700; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; padding: 8px; }
.avatar-opt.chosen { border-color: var(--amber); background: rgba(245,166,35,0.22); }
.avatar-opt .avatar-img { width: 40px; height: 40px; }
.avatar-opt-label { display: inline-block; }

/* image art added to setup, journal, player-switch and inventory */
.avatar-img {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: contain;
  vertical-align: middle;
  background: rgba(255,255,255,0.06);
}
.rune-img { width: 40px; height: 40px; object-fit: contain; display: block; margin: 0 auto; }
.rune-glyph-char { display: block; }
.relic-img { width: 40px; height: 40px; object-fit: contain; vertical-align: middle; }
.staff-img { width: 40px; height: 40px; object-fit: contain; vertical-align: middle; }
.coin-icon { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; margin-right: 4px; }
.icon-img { width: 22px; height: 22px; object-fit: contain; vertical-align: middle; }
.gm-check { display: flex; align-items: center; gap: 8px; font-size: 15px; }

/* avatar accent colours */
.avatar-viking { border-left-color: var(--sky); }
.avatar-raven { border-left-color: #6b6f86; }
.avatar-rune-keeper { border-left-color: var(--gold); }
.avatar-troll-hunter { border-left-color: var(--forest); }

/* ---- chapters ---- */
.chapters-screen { max-width: 720px; margin: 0 auto; display: flex; flex-direction: column; gap: 12px; }
.chapter-card {
  text-align: left;
  border: none;
  border-radius: var(--radius);
  padding: 16px;
  color: var(--cream);
  cursor: pointer;
  box-shadow: var(--shadow);
  border-left: 8px solid var(--gold);
  background: linear-gradient(135deg, #16204e, #0c1130);
}
.chapter-card.locked { opacity: 0.55; filter: grayscale(0.4); }
.chapter-card.done { border-left-color: #6fcf97; }
.cc-n { font-family: var(--font-head); color: var(--gold); font-size: 14px; letter-spacing: 1px; }
.cc-loc { font-size: 20px; font-weight: 700; margin: 2px 0; }
.cc-meta { font-size: 13px; color: #aebbe0; }
.cc-teaser { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 13px; font-style: italic; color: #cdd6ef; }
.cc-lock { width: 18px; height: 18px; flex: 0 0 auto; }
.empty-note { font-style: italic; }
.hub-saga { width: 100%; margin-top: 10px; }

/* god theming */
.god-odin { border-left-color: var(--sky); }
.god-thor { border-left-color: var(--rune-red); }
.god-loki { border-left-color: var(--forest); }
.god-freya { border-left-color: var(--amber); }

/* ---- chapter hub ---- */
.chapter-host { max-width: 760px; margin: 0 auto; }
.chapter-hub { display: flex; flex-direction: column; gap: 14px; }
.hub-head { text-align: center; }
.hub-chapter { font-family: var(--font-head); color: var(--gold); letter-spacing: 2px; }
.hub-location { font-size: 26px; margin: 4px 0; }
.hub-rune { color: var(--amber); font-size: 14px; }
.hub-tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; }
.hub-tile {
  border: 2px solid rgba(201,168,76,0.4);
  background: linear-gradient(160deg, rgba(74,144,217,0.18), rgba(255,255,255,0.05));
  color: var(--cream);
  border-radius: var(--radius);
  padding: 18px 14px;
  min-height: 96px;
  cursor: pointer;
  text-align: left;
}
.hub-tile.done { border-color: #6fcf97; background: linear-gradient(160deg, rgba(111,207,151,0.2), rgba(255,255,255,0.05)); }
.hub-tile-label { font-family: var(--font-head); font-size: 18px; color: var(--gold); }
.hub-tile-sub { font-size: 13px; color: #cdd6ef; margin-top: 6px; }

.sub-bar { display: flex; align-items: center; gap: 12px; margin-bottom: 12px; }
.sub-title { font-family: var(--font-head); color: var(--gold); font-size: 18px; }
.sub-body { max-width: 760px; margin: 0 auto; }
.map-body { padding: 0; }

/* ---- overlays ---- */
.overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: rgba(4, 6, 12, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 24px 14px;
  overflow-y: auto;
}
.overlay-card {
  width: 100%;
  max-width: 620px;
  background: linear-gradient(180deg, #11173a, #0a0e2e);
  border: 1px solid rgba(201,168,76,0.4);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}
.menu-card { max-width: 460px; display: flex; flex-direction: column; gap: 10px; }
.menu-item { width: 100%; text-align: left; min-height: var(--tap); background: rgba(255,255,255,0.08); color: var(--cream); border: 1px solid rgba(201,168,76,0.4); border-radius: 12px; padding: 12px 14px; font-size: 16px; cursor: pointer; }
.menu-item.danger { border-color: var(--rune-red); color: #f3c9c9; background: rgba(139,26,26,0.18); }

/* ---- Game Master panel ---- */
.gm-card { max-width: 680px; }
.gm-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.gm-head .panel-title { flex: 1; }
.gm-warn { width: 100%; color: #f3c9c9; font-size: 13px; background: rgba(139,26,26,0.25); border: 1px solid var(--rune-red); border-radius: 10px; padding: 8px; }
.gm-section { border-top: 1px solid rgba(201,168,76,0.25); padding-top: 12px; margin-top: 12px; }
.gm-section h3 { color: var(--amber); font-size: 16px; margin: 0 0 8px; }
.gm-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 6px 0; }
.gm-row-label { flex: 1; font-size: 14px; }
.gm-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 8px; }
.gm-select { min-height: 44px; border-radius: 10px; padding: 8px; font-size: 15px; }
.gm-spot-list { margin-top: 8px; }

/* ---- admin configuration ---- */
.admin-config { max-width: 760px; margin: 0 auto; }
.admin-section {
  background: var(--panel);
  border: 1px solid rgba(201, 168, 76, 0.3);
  border-radius: var(--radius);
  padding: 14px;
  margin-bottom: 16px;
}
.admin-section.danger-zone { border-color: var(--rune-red); }
.admin-toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 15px; }
.admin-field { display: flex; flex-direction: column; gap: 6px; margin-top: 10px; font-size: 14px; color: #cdd6ef; }
.admin-field .f-input { max-width: 360px; }
.admin-num { width: 110px; }
.admin-chapter { border-top: 1px solid rgba(201, 168, 76, 0.2); padding-top: 10px; margin-top: 10px; }
.admin-chapter-head { font-family: var(--font-head); color: var(--amber); margin-bottom: 8px; }
.admin-journey-row { display: flex; align-items: center; gap: 8px; padding: 4px 0; }
.admin-journey-row.off { opacity: 0.5; }
.admin-journey-row .admin-label { flex: 1; min-width: 0; }
.admin-enable { display: flex; align-items: center; min-height: 44px; }
.admin-points { display: flex; align-items: center; gap: 4px; font-size: 12px; color: #aebbe0; }
.admin-points .admin-num { width: 64px; }
.admin-code { color: var(--gold); font-weight: 700; margin: 8px 0; }
.btn-danger {
  background: linear-gradient(180deg, #c0392b, var(--rune-red));
  color: #fff;
  border: none;
  border-radius: 14px;
  padding: 14px 18px;
  min-height: var(--tap);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
}

/* ---- player switch ---- */
.ps-list { display: flex; flex-direction: column; gap: 10px; margin: 12px 0; }
.ps-player { text-align: left; border-radius: 12px; border: 2px solid rgba(201,168,76,0.4); background: rgba(255,255,255,0.06); color: var(--cream); padding: 12px; cursor: pointer; border-left-width: 8px; }
.ps-player.active { border-color: var(--amber); }
.ps-name { font-family: var(--font-head); color: var(--gold); font-size: 18px; }
.ps-real { font-size: 13px; color: #cdd6ef; }
.ps-current { font-size: 12px; color: var(--amber); }

/* ---- backup ---- */
.backup-screen { display: flex; flex-direction: column; gap: 12px; }

/* ---- toast ---- */
#toast {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(120%);
  background: rgba(6, 8, 15, 0.95);
  color: var(--cream);
  border: 1px solid var(--gold);
  border-radius: 12px;
  padding: 12px 18px;
  font-size: 15px;
  max-width: 90vw;
  z-index: 120;
  transition: transform 0.3s ease;
  box-shadow: var(--shadow);
}
#toast.show { transform: translateX(-50%) translateY(0); }

/* ---- effects ---- */
#fx-layer { position: fixed; inset: 0; pointer-events: none; z-index: 130; overflow: hidden; }
.fx-particle {
  position: absolute;
  width: 10px;
  height: 10px;
  margin: -5px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--gold-bright), var(--amber));
  animation: particle 0.9s ease-out forwards;
}
@keyframes particle {
  to { transform: translate(var(--dx), var(--dy)) scale(0.2); opacity: 0; }
}
.fx-confetti {
  position: absolute;
  top: -20px;
  width: 10px;
  height: 16px;
  border-radius: 2px;
  animation: confetti-fall linear forwards;
}
@keyframes confetti-fall {
  to { transform: translateY(110vh) rotate(540deg); opacity: 0.9; }
}

/* ---- responsive ---- */
@media (min-width: 720px) {
  .app-title { font-size: 20px; }
  .hub-tiles { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; transition-duration: 0.001s !important; }
}
