:root {
  --bg: #0d0b09;
  --panel: #18140f;
  --panel-2: #211b14;
  --line: #3a2f22;
  --text: #e9dfc8;
  --muted: #a8977a;
  --gold: #d6a84a;
  --gold-2: #f0cd7a;
  --red: #c4483e;
  --green: #5fa35a;
  --blue: #4f86c6;
  --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: radial-gradient(ellipse at top, #241b12 0%, var(--bg) 60%) fixed, var(--bg);
  color: var(--text);
  font-family: "EB Garamond", Georgia, "Times New Roman", serif;
  font-size: 17px;
}

/* wide screens: the story, travel and gear, and a full-height column for
   the other adventurers and chat */
#app {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px minmax(320px, 400px);
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  grid-template-areas:
    "top top top"
    "event event event"
    "stats side social"
    "story side social"
    "hint hint hint";
  position: relative;
  z-index: 1;
  gap: 12px;
  height: 100vh;
  max-width: 1760px;
  margin: 0 auto;
  padding: 12px 16px;
}

/* the adventurers and the chat; the chat takes all the room it can */
.social { grid-area: social; display: flex; flex-direction: column; gap: 12px; min-height: 0; }
.social .panel { padding: 12px; }

/* middle widths: chat sits under travel and gear, beside the story */
@media (max-width: 1299px) and (min-width: 861px) {
  #app {
    grid-template-columns: minmax(0, 1fr) 320px;
    grid-template-rows: auto auto auto minmax(0, 1fr) minmax(340px, 52vh) auto;
    grid-template-areas:
      "top top"
      "event event"
      "stats side"
      "story side"
      "story social"
      "hint hint";
  }
  .social .players-panel { max-height: 26%; }
}

.panel {
  background: linear-gradient(180deg, var(--panel-2), var(--panel));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.35), inset 0 1px 0 rgba(255, 220, 160, 0.04);
}

h2 {
  font-family: "Cinzel", serif;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold);
  margin: 0 0 8px;
}
h2 small { color: var(--muted); letter-spacing: 0; }

/* ---------- top bar ---------- */

.topbar {
  grid-area: top;
  display: flex;
  align-items: center;
  gap: 18px;
}

.brand {
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 26px;
  color: var(--gold-2);
  text-decoration: none;
  text-shadow: 0 0 18px rgba(214, 168, 74, 0.35);
  white-space: nowrap;
}
.brand span { color: var(--red); font-size: 0.72em; letter-spacing: 0.04em; }

.whereabouts { flex: 1; min-width: 0; }
#title-head {
  font-family: "Cinzel", serif;
  font-size: 18px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#title-tail { color: var(--muted); font-size: 15px; }
.world-status { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 5px; }
.world-status .chip { font-size: 12.5px; line-height: 1; padding: 4px 9px; border-radius: 999px;
  border: 1px solid var(--line); background: rgba(0, 0, 0, 0.25); color: var(--muted); white-space: nowrap; }
.world-status.state-blighted .chip.region { color: #ffb0a0; border-color: #7a2a22; background: rgba(120, 20, 20, 0.25); }
.world-status.state-liberated .chip.region { color: #b8f0b0; border-color: #2f6a2a; background: rgba(30, 90, 30, 0.2); }
.world-status.state-overrun .chip.region { color: #ffb0a0; border-color: #a02a22; }
.world-status .chip.call { color: #ffd59a; border-color: #8a5a1a; background: rgba(140, 80, 20, 0.22); }
.world-status .chip.call.here { color: #1a1208; background: linear-gradient(180deg, #f6d98c, #c8952f); border-color: #f0cd7a; font-weight: 600; }

/* a siege on the throne */
body.event-siege {
  --gold: #e0a070; --gold-2: #ffd0a0; --line: #4a3020;
  --event-bg: linear-gradient(90deg, rgba(110, 40, 20, 0.6), rgba(40, 20, 14, 0.65));
  --event-edge: #c0602a; --event-glow: rgba(220, 110, 40, 0.45); --event-title: #ffc890;
  background: radial-gradient(ellipse at top, #301608 0%, #100804 65%) fixed, #100804;
}
body.event-siege .panel { border-color: #4a3020; }
.arrival.event-siege { background: #0a0604;
  --c-rank: #ffd0a0; --c-glow: rgba(240, 120, 40, 0.7); --c-metal: #e0a070; }
.arrival.event-siege .flash { background: #ffb070; }
.arrival.event-siege .card { margin-top: 150px; }

.conn {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  color: var(--muted);
  white-space: nowrap;
}
.conn i {
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 0 8px currentColor;
}
.conn.online i { background: var(--green); }
.conn.offline i { background: var(--red); }
.conn.connecting i { animation: pulse 1s infinite alternate; }
@keyframes pulse { from { opacity: 0.3; } to { opacity: 1; } }

/* ---------- stats ---------- */

.stats {
  grid-area: stats;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.bars { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.bar-label { display: flex; justify-content: space-between; font-size: 14px; color: var(--muted); }
.bar-label b { color: var(--text); font-variant-numeric: tabular-nums; }
.track {
  position: relative;
  height: 10px;
  margin-top: 4px;
  background: #0b0907;
  border: 1px solid var(--line);
  border-radius: 6px;
  overflow: hidden;
}
.fill {
  position: absolute; inset: 0 auto 0 0;
  width: 0%;
  transition: width 0.35s ease;
  border-radius: 6px;
}
.energy .fill { background: linear-gradient(90deg, #8d2a22, var(--red)); }
.energy .fill.extra { background: rgba(79, 134, 198, 0.55); height: 3px; top: auto; }
.strength .fill { background: linear-gradient(90deg, #8a6420, var(--gold)); }
.speed .fill { background: linear-gradient(90deg, #2c5a8f, var(--blue)); }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 10px 3px 8px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.25);
  font-size: 14px;
}
.chip em { font-style: normal; }
.chip span { color: var(--muted); }
.chip b { font-variant-numeric: tabular-nums; }

.items { display: flex; gap: 6px; }
.item {
  font-size: 20px;
  width: 34px; height: 34px;
  display: grid; place-items: center;
  border-radius: 8px;
  border: 1px solid var(--line);
  filter: grayscale(1) brightness(0.45);
  transition: filter 0.3s, box-shadow 0.3s;
}
.item.on {
  filter: none;
  border-color: var(--gold);
  box-shadow: 0 0 12px rgba(214, 168, 74, 0.45);
}

/* ---------- story ---------- */

.story {
  grid-area: story;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.log {
  flex: 1;
  overflow-y: auto;
  padding: 14px 18px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  scrollbar-color: var(--line) transparent;
}
.log p { margin: 0 0 4px; }
.log p.sep { height: 6px; }
.log p.old { opacity: 0.55; }

/* what each line of the game log is about */
.log p.k-announce { color: var(--gold-2); font-weight: 600; }
.log p.k-hurt { color: #ff8f80; }
.log p.k-foe { color: #ff6f6f; font-weight: 600; }
.log p.k-deal { color: #ffb768; }
.log p.k-heal { color: #7fe0c8; }
.log p.k-reward { color: #9ee08a; }
.log p.k-world { color: #8fb8ff; }
.log p.k-item { color: var(--muted); }
.log .gitem { font-weight: 600; }
.log .gitem.t0 { color: #9c9182; } .log .gitem.t1 { color: var(--text); }
.log .gitem.t2 { color: #7fc97a; } .log .gitem.t3 { color: #6aa6e8; }
.log .gitem.t4 { color: #c58cf0; } .log .gitem.t5 { color: var(--gold-2); }

.actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line);
}

button {
  font: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.action {
  position: relative;
  min-height: 44px;
  padding: 8px 10px 8px 26px;
  border-radius: 8px;
  border: 1px solid #5a4528;
  color: var(--text);
  background: linear-gradient(180deg, #3a2c1b, #261d12);
  font-family: "Cinzel", serif;
  font-size: 14px;
  font-weight: 600;
  text-align: left;
  transition: transform 0.06s, border-color 0.15s, background 0.15s;
}
.action:hover:not(:disabled) { border-color: var(--gold); background: linear-gradient(180deg, #4a3822, #2d2215); }
.action:active:not(:disabled) { transform: translateY(1px); }
.action:disabled { opacity: 0.28; cursor: default; }
.action.empty { visibility: hidden; }
.actions-bar { display: flex; align-items: center; justify-content: flex-end; gap: 14px;
  padding: 6px 12px 0; border-top: 1px solid var(--line); font-size: 13px; min-height: 30px; }
.actions-bar + .actions { border-top: 0; padding-top: 6px; }
.arrange-hint { flex: 1; color: var(--gold-2); font-style: italic; }
.arrange-link { background: none; border: 0; padding: 2px 0; color: var(--muted); font-family: "Cinzel", serif;
  font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; }
.arrange-link:hover { color: var(--gold-2); }
.arrange-link.on { color: #1a1208; background: linear-gradient(180deg, #f6d98c, #c8952f); padding: 3px 12px; border-radius: 999px; }
.actions.arranging .action { cursor: grab; border-style: dashed; opacity: 1; }
.actions.arranging .action.slot-empty { visibility: visible; background: transparent; border-color: var(--line); }
.actions.arranging .action.picked { border: 2px solid var(--gold-2); box-shadow: 0 0 14px rgba(240, 205, 122, 0.5);
  background: linear-gradient(180deg, #5a4426, #33271a); }
.action kbd {
  position: absolute; left: 8px; top: 50%; transform: translateY(-50%);
  font-family: ui-monospace, monospace; font-size: 11px; color: var(--gold);
  background: none; border: 0; padding: 0;
}

/* ---------- side ---------- */

.side {
  grid-area: side;
  display: flex;
  flex-direction: column;
  gap: 12px;
  min-height: 0;
}
.side .panel { padding: 12px; }

.compass { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.compass button {
  height: 42px;
  border-radius: 8px;
  border: 1px solid #5a4528;
  background: #241b12;
  color: var(--text);
  font-family: "Cinzel", serif;
  font-weight: 700;
  font-size: 13px;
}
.compass button.rest { color: var(--gold); }
.compass button:hover:not(:disabled) { border-color: var(--gold); }
.compass button:disabled { opacity: 0.28; cursor: default; }

.players-panel { flex: 0 1 auto; min-height: 90px; max-height: 32%; display: flex; flex-direction: column; }
.players {
  list-style: none; margin: 0; padding: 0;
  overflow-y: auto; flex: 1; min-height: 0;
}
.players li {
  padding: 5px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  display: flex; justify-content: space-between; gap: 8px;
}
.players li:hover { background: rgba(214, 168, 74, 0.1); }
.players li b { font-weight: 600; }
.players li span { color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.chat-panel { display: flex; flex-direction: column; flex: 1; min-height: 220px; }
.chat-log {
  flex: 1; min-height: 0; overflow-y: auto;
  font-size: 16px; line-height: 1.4;
  padding-right: 4px;
  white-space: pre-wrap; word-wrap: break-word;
}
.chat-log p { margin: 0 0 3px; }
.chat-log p.c-announce { color: var(--gold-2); font-weight: 600; padding: 3px 7px; margin: 4px 0;
  border-left: 3px solid var(--gold); background: rgba(214, 168, 74, 0.08); border-radius: 0 6px 6px 0; }
.chat-log p.c-news { color: #ffcf8a; }
.chat-log p.c-system { color: var(--muted); font-style: italic; }
.chat-log p.c-other { opacity: 0.8; }
.chat-log p.c-other .chan { color: var(--muted); font-size: 0.9em; }
.chat-log p.c-proclaim { font-weight: 600; }
.chat-log p.c-mention { background: rgba(240, 205, 122, 0.12); border-radius: 4px; padding: 0 4px; }
.chat-log .who { font-weight: 700; }
.chat-form { display: flex; gap: 6px; margin-top: 8px; }

input[type="text"], input[type="password"], input[type="number"], select {
  font: inherit;
  font-size: 16px;
  color: var(--text);
  background: #0b0907;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 0;
}
input:focus, select:focus { outline: none; border-color: var(--gold); }
#chat-input { flex: 1; }

.chat-form button, .modal-buttons button {
  padding: 8px 14px;
  border-radius: 8px;
  border: 1px solid #5a4528;
  background: linear-gradient(180deg, #3a2c1b, #261d12);
  color: var(--text);
  font-family: "Cinzel", serif;
  font-weight: 600;
  font-size: 14px;
}
.modal-buttons button.primary { border-color: var(--gold); color: var(--gold-2); }
.chat-form button:disabled { opacity: 0.35; cursor: default; }

.hint {
  grid-area: hint;
  text-align: center;
  font-size: 13px;
  color: var(--muted);
}
kbd {
  font-family: ui-monospace, monospace;
  font-size: 11px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #0b0907;
}

/* ---------- gear ---------- */

.side { overflow-y: auto; scrollbar-color: var(--line) transparent; }
.gear-panel { flex: none; }
.doll-row { display: flex; gap: 10px; align-items: center; }
.doll { width: 104px; height: 148px; flex: none; }
.doll .body > * { fill: #2a2219; stroke: #4a3c2b; stroke-width: 1.2; }
.doll .gear-layer { display: none; stroke: rgba(0, 0, 0, 0.55); stroke-width: 1; }
.doll .gear-layer.on { display: inline; }
.doll .gear-layer .trim { fill: none; stroke: rgba(0, 0, 0, 0.45); stroke-width: 1.4; }
.doll .gear-layer.art { filter: url(#glow); }
.doll .gear-layer.regal { fill: #f0cd7a; stroke: #7a5212; stroke-width: 0.8; filter: url(#glow); cursor: default; }
.doll .gear-layer.regal.halo ellipse { stroke: #fff2b0; }
.doll .gear-layer.regal:hover { filter: url(#glow); }
.gear li.regalia { cursor: default; }
.gear li.regalia .slot { color: #f0cd7a; }
.doll-row .gear { flex: 1; min-width: 0; }
.doll-row .gear li { padding: 2px 0; }
.doll-row .gear li .slot { width: 50px; font-size: 11px; }
.doll-row .gear li .gname { font-size: 13px; }

.bag-head { margin: 10px 0 6px; font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; }
.bag-head span { color: var(--gold); font-family: "Cinzel", serif; font-weight: 600; }
.bag { display: grid; grid-template-columns: repeat(10, 1fr); gap: 3px; }
.bag .cell { aspect-ratio: 1; border-radius: 4px; border: 1px solid #2c241a; background: #0f0c09;
  display: grid; place-items: center; }
.bag .cell svg { width: 78%; height: 78%; }
.bag .cell.full { border-color: #4a3c2b; background: #1d1711; cursor: pointer; transition: transform 0.08s, border-color 0.15s; }
.bag .cell.full:hover { border-color: var(--gold); transform: translateY(-1px); }
.doll .gear-layer.on { cursor: pointer; }
.doll .gear-layer.on:hover { filter: brightness(1.25); }
.doll-row .gear li.worn { cursor: pointer; border-radius: 4px; }
.doll-row .gear li.worn:hover { background: rgba(214, 168, 74, 0.1); }
.bag .cell.full.c5 { border-color: var(--gold); box-shadow: 0 0 6px rgba(214, 168, 74, 0.5); }

.gear { list-style: none; margin: 0; padding: 0; font-size: 14px; }
.gear li { display: flex; gap: 8px; padding: 3px 0; align-items: baseline; }
.gear li .slot { color: var(--muted); width: 58px; flex: none; font-size: 12px;
  text-transform: uppercase; letter-spacing: 0.06em; }
.gear li .gname { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gear li.empty { color: var(--muted); font-style: italic; }
.gear .t0 { color: #9c9182; }                       /* worn */
.gear .t1 { color: var(--text); }                   /* common */
.gear .t2 { color: #7fc97a; }                       /* fine */
.gear .t3 { color: #6aa6e8; }                       /* masterwork */
.gear .t4 { color: #c58cf0; }                       /* enchanted */
.gear .t5 { color: var(--gold-2); font-weight: 600;
  text-shadow: 0 0 10px rgba(214, 168, 74, 0.5); }  /* artifact */
.gear-hint { margin-top: 6px; font-size: 12px; color: var(--muted); }

/* ---------- modal ---------- */

.modal {
  position: fixed; inset: 0;
  background: rgba(5, 4, 3, 0.7);
  backdrop-filter: blur(3px);
  display: grid; place-items: center;
  padding: 16px;
  z-index: 10;
}
.modal[hidden] { display: none; }
.modal-card {
  width: min(460px, 100%);
  max-height: 90vh;
  overflow: auto;
  background: linear-gradient(180deg, #2a2117, #1a150f);
  border: 1px solid #5a4528;
  border-radius: 14px;
  padding: 20px 22px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}
.modal-card.wide { width: min(760px, 100%); }
.modal-card h3 {
  font-family: "Cinzel", serif;
  color: var(--gold-2);
  margin: 0 0 12px;
  font-size: 18px;
}
#modal-body p { margin: 0 0 12px; line-height: 1.4; }
#modal-body label { display: block; color: var(--muted); font-size: 14px; margin: 8px 0 4px; }
#modal-body input, #modal-body select { width: 100%; }
#modal-body pre {
  font-family: ui-monospace, "Cascadia Mono", Consolas, monospace;
  font-size: 13px;
  white-space: pre-wrap;
  margin: 0;
  color: var(--text);
}
.facts { display: grid; grid-template-columns: auto 1fr; gap: 3px 14px; font-size: 15px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.facts .gap { grid-column: 1 / -1; height: 6px; }
.modal-buttons { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- world events ---------- */

.event-banner {
  grid-area: event;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--event-edge);
  background: var(--event-bg);
  box-shadow: 0 0 24px var(--event-glow), inset 0 0 18px var(--event-glow);
  animation: banner-in 0.6s ease-out;
}
.event-banner[hidden] { display: none; }
.event-icon { font-size: 26px; line-height: 1; filter: drop-shadow(0 0 6px var(--event-glow)); }
.event-text { flex: 1; min-width: 0; }
.event-text b { font-family: "Cinzel", serif; font-size: 17px; color: var(--event-title); letter-spacing: 0.04em; margin-right: 6px; }
.event-text span { color: var(--text); }
.event-time { font-family: "Cinzel", serif; font-weight: 700; color: var(--event-title); white-space: nowrap; font-variant-numeric: tabular-nums; }
@keyframes banner-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }

.event-fx { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; display: none; }
body.event-on .event-fx { display: block; }

/* Blood Moon: a red sky, a rising moon, a pulsing red edge */
body.event-blood {
  --gold: #e0645a; --gold-2: #ff9a8a; --line: #4a2220;
  --event-bg: linear-gradient(90deg, rgba(120, 18, 18, 0.55), rgba(40, 8, 8, 0.6));
  --event-edge: #a32a22; --event-glow: rgba(200, 30, 30, 0.45); --event-title: #ff8f80;
  background: radial-gradient(ellipse at top, #3a0d0b 0%, #120505 65%) fixed, #120505;
}
body.event-blood .panel { border-color: #4a2220; box-shadow: 0 6px 24px rgba(0,0,0,.4), 0 0 18px rgba(160, 20, 20, 0.15); }
body.event-blood .event-fx::before {
  content: ""; position: absolute; top: 4%; right: 6%; width: 150px; height: 150px; border-radius: 50%;
  background: radial-gradient(circle at 38% 35%, #ff7a5c 0%, #c21f12 45%, #5a0705 100%);
  box-shadow: 0 0 60px 20px rgba(200, 30, 20, 0.45), 0 0 140px 60px rgba(150, 10, 10, 0.25);
  opacity: 0.55; animation: moon-rise 2.5s ease-out;
}
body.event-blood .event-fx::after {
  content: ""; position: absolute; inset: 0;
  box-shadow: inset 0 0 160px 40px rgba(150, 0, 0, 0.45);
  animation: blood-pulse 4s ease-in-out infinite;
}
@keyframes moon-rise { from { transform: translateY(80px); opacity: 0; } to { transform: none; opacity: 0.55; } }
@keyframes blood-pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }

/* Gold Rush: golden light and drifting coins */
body.event-gold {
  --gold: #f2c14e; --gold-2: #ffe08a; --line: #5a4718;
  --event-bg: linear-gradient(90deg, rgba(120, 90, 10, 0.5), rgba(50, 36, 6, 0.55));
  --event-edge: #d4a72c; --event-glow: rgba(240, 190, 60, 0.4); --event-title: #ffd866;
  background: radial-gradient(ellipse at top, #33280b 0%, #0f0c05 65%) fixed, #0f0c05;
}
body.event-gold .panel { border-color: #5a4718; box-shadow: 0 6px 24px rgba(0,0,0,.4), 0 0 18px rgba(240, 190, 60, 0.12); }
body.event-gold .event-fx::after {
  content: ""; position: absolute; inset: -50%;
  background: linear-gradient(115deg, transparent 40%, rgba(255, 215, 100, 0.07) 50%, transparent 60%);
  animation: shimmer 6s linear infinite;
}
.coin {
  position: absolute; top: -30px; width: 14px; height: 14px; border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #fff3b0, #f2c14e 45%, #a5761a);
  box-shadow: 0 0 8px rgba(255, 210, 80, 0.6);
  animation: coin-fall linear infinite;
  opacity: 0.75;
}
@keyframes coin-fall {
  from { transform: translateY(0) rotateY(0deg); }
  to { transform: translateY(110vh) rotateY(720deg); }
}
@keyframes shimmer { from { transform: translateX(-30%); } to { transform: translateX(30%); } }

/* Champion Hunt: heraldic crimson and violet, torchlight at the edges */
body.event-hunt {
  --gold: #d07be8; --gold-2: #f0b2ff; --line: #3e2347;
  --event-bg: linear-gradient(90deg, rgba(90, 20, 60, 0.55), rgba(40, 14, 60, 0.6));
  --event-edge: #9b3fb5; --event-glow: rgba(170, 60, 200, 0.4); --event-title: #f0b2ff;
  background: radial-gradient(ellipse at top, #241034 0%, #0c0710 65%) fixed, #0c0710;
}
body.event-hunt .panel { border-color: #3e2347; }
body.event-hunt .event-fx::before, body.event-hunt .event-fx::after {
  content: ""; position: absolute; bottom: 0; width: 260px; height: 70vh;
  background: radial-gradient(ellipse at bottom, rgba(255, 140, 40, 0.28), transparent 70%);
  animation: torch 1.8s ease-in-out infinite alternate;
}
body.event-hunt .event-fx::before { left: -60px; }
body.event-hunt .event-fx::after { right: -60px; animation-delay: 0.7s; }
@keyframes torch { from { opacity: 0.55; transform: scaleY(0.96); } to { opacity: 1; transform: scaleY(1.04); } }

/* the 3D event scene behind the game: the flat effects step aside and
   the panels turn slightly glassy so it glows through */
.event-fx .event3d { position: absolute; inset: 0; width: 100%; height: 100%; display: block; animation: arrival-in 1.2s ease-out; }
body.event-3d .event-fx::before, body.event-3d .event-fx::after, body.event-3d .coin { display: none; }
body.event-3d { background: #000; }
body.event-3d .panel {
  background: linear-gradient(180deg, rgba(30, 24, 18, 0.80), rgba(16, 12, 9, 0.84));
  -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px);
}

/* event announcements: the card in the event's colours */
.arrival.event-blood { background: #0a0204;
  --c-rank: #ffb0a0; --c-glow: rgba(230, 40, 30, 0.75); --c-metal: #e0645a;
  --c-name: linear-gradient(180deg, #fff1ec 0%, #ffb3a3 38%, #d2372a 62%, #ffd2c8 78%, #7a120c 100%); }
.arrival.event-blood .flash { background: #ff3020; }
.arrival.event-gold { background: #0e0904; --c-glow: rgba(255, 200, 80, 0.75); }
.arrival.event-gold .flash { background: #fff0c0; }
.arrival.event-hunt { background: #07040a;
  --c-rank: #f0c8ff; --c-glow: rgba(200, 110, 240, 0.7); --c-metal: #c88ae0;
  --c-name: linear-gradient(180deg, #fff6ff 0%, #f0c8ff 38%, #a85bd0 62%, #ffe8ff 78%, #5a2378 100%); }
.arrival.event-hunt .flash { background: #ffd8a0; }
.arrival.event-gold .card, .arrival.event-hunt .card { margin-top: 150px; }

@media (prefers-reduced-motion: reduce) {
  .event-fx *, .event-fx::before, .event-fx::after, .event-banner { animation: none !important; }
  .coin { display: none; }
}

/* ---------- ceremonies: a wizard arrives, a title is won ---------- */

.arrival {
  position: fixed; inset: 0; z-index: 50;
  display: grid; place-items: center;
  overflow: hidden; cursor: pointer;
  animation: arrival-in 0.4s ease-out, arrival-out 0.9s ease-in 5.2s forwards;
}
.arrival::after {                       /* vignette over everything */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  box-shadow: inset 0 0 220px 60px rgba(0, 0, 0, 0.85);
}

/* -- the title card, shared -- */
.arrival .card {
  position: relative; z-index: 3; text-align: center;
  padding: 34px 64px 30px; min-width: min(560px, 86vw);
  animation: card-in 1s cubic-bezier(.2, 1.3, .4, 1) 0.45s both;
}
.arrival .card::before {                /* a dark glass plate */
  content: ""; position: absolute; inset: 0; z-index: -1; border-radius: 6px;
  background: radial-gradient(ellipse at center, rgba(10, 8, 6, 0.72), rgba(10, 8, 6, 0.35) 70%, transparent);
}
.arrival .corner {                      /* gilded flourishes at the corners */
  position: absolute; width: 74px; height: 74px; color: var(--c-metal, #d9ad52);
  filter: drop-shadow(0 0 6px rgba(0, 0, 0, 0.8));
}
.arrival .corner.tl { top: -6px; left: -6px; }
.arrival .corner.tr { top: -6px; right: -6px; transform: scaleX(-1); }
.arrival .corner.bl { bottom: -6px; left: -6px; transform: scaleY(-1); }
.arrival .corner.br { bottom: -6px; right: -6px; transform: scale(-1, -1); }
.arrival .rank {
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-family: "Cinzel", serif; font-weight: 600; font-size: 15px;
  letter-spacing: 0.42em; text-transform: uppercase; padding-left: 0.42em;
  color: var(--c-rank, #f0cd7a); text-shadow: 0 0 12px var(--c-glow, rgba(240, 205, 122, 0.7));
}
.arrival .rank .orn { font-size: 22px; letter-spacing: 0; padding: 0; opacity: 0.9; }
.arrival .rank .orn.flip { transform: scaleX(-1); display: inline-block; }
.arrival .who {
  font-family: "Cinzel", serif; font-weight: 700; line-height: 1.05;
  font-size: clamp(42px, 8vw, 92px); margin: 8px 0 4px; padding: 0 0.05em;
  background: var(--c-name, linear-gradient(180deg, #fffbe9 0%, #ffe39a 38%, #e0a83a 62%, #fff2c2 78%, #b9801f 100%));
  background-size: 100% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 2px 0 rgba(70, 45, 8, 0.9)) drop-shadow(0 0 22px var(--c-glow, rgba(255, 200, 90, 0.75)));
  position: relative;
}
.arrival .who::after {                  /* a shine that sweeps across the name */
  content: attr(data-name); position: absolute; inset: 0; padding: 0 0.05em;
  background: linear-gradient(105deg, transparent 35%, rgba(255, 255, 255, 0.95) 50%, transparent 65%);
  background-size: 250% 100%; background-position: 130% 0;
  -webkit-background-clip: text; background-clip: text; color: transparent;
  animation: name-shine 2.4s ease-in-out 1.1s 2;
}
.arrival .rule {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  color: var(--c-metal, #d9ad52); font-size: 16px; margin: 6px auto 10px; width: 70%;
}
.arrival .rule span { flex: 1; height: 1px;
  background: linear-gradient(90deg, transparent, var(--c-metal, #d9ad52), transparent); }
.arrival .what {
  font-family: "EB Garamond", serif; font-style: italic; font-size: 22px;
  color: #efe4c8; text-shadow: 0 1px 8px rgba(0, 0, 0, 0.9);
}

/* -- the 3D scene (ceremonies3d.js): replaces the flat scenery once loaded -- */
.arrival .ceremony3d {
  position: absolute; inset: 0; width: 100%; height: 100%; z-index: 0;
  display: block; animation: arrival-in 0.5s ease-out;
}
.arrival.has3d > :not(.card):not(.ceremony3d):not(.flash) { display: none; }
.arrival.loading3d { background: rgba(4, 3, 10, 0.88); }
.arrival.loading3d > :not(.card):not(.ceremony3d) { visibility: hidden; }
.arrival.has3d .flash { z-index: 1; }

@keyframes arrival-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes arrival-out { to { opacity: 0; visibility: hidden; } }
@keyframes card-in { from { transform: scale(0.7) translateY(20px); opacity: 0; filter: blur(6px); }
                     to { transform: none; opacity: 1; filter: none; } }
@keyframes name-shine { from { background-position: 130% 0; } to { background-position: -30% 0; } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes spin-back { to { transform: rotate(-360deg); } }

/* -- wizard: lightning and an arcane sigil -- */
.arrival.wizard { background: radial-gradient(circle at 50% 46%, #2a2150 0%, #120d26 45%, #040309 80%);
  --c-rank: #c3d2ff; --c-glow: rgba(140, 170, 255, 0.75); --c-metal: #9fb4ff; }
.arrival.apprentice { background: radial-gradient(circle at 50% 46%, #2c2c34 0%, #121216 50%, #050506 85%);
  --c-rank: #dcdce6; --c-glow: rgba(210, 210, 230, 0.6); --c-metal: #b9b9c8;
  --c-name: linear-gradient(180deg, #ffffff, #d7d9e6 45%, #8f93a8 70%, #f3f4fa); }
.arrival .flash { position: absolute; inset: 0; z-index: 4; background: #e8f0ff; opacity: 0; animation: flash 0.9s ease-out; pointer-events: none; }
.arrival .bolt { position: absolute; z-index: 2; top: -2%; left: 50%; width: 150px; height: 64vh; transform: translateX(-50%);
  filter: drop-shadow(0 0 14px #9fc4ff) drop-shadow(0 0 36px #6f8cff); opacity: 0; animation: bolt 1.1s ease-out; }
.arrival .sigil { position: absolute; z-index: 1; width: min(720px, 92vw); aspect-ratio: 1;
  color: rgba(150, 175, 255, 0.55); animation: spin 40s linear infinite, arrival-in 1.5s ease-out; }
.arrival .sigil.inner { width: min(520px, 70vw); color: rgba(190, 210, 255, 0.4); animation: spin-back 28s linear infinite, arrival-in 1.5s ease-out; }
.arrival .smoke { position: absolute; left: 50%; top: 46%; width: 420px; height: 420px; margin: -210px 0 0 -210px; border-radius: 50%;
  background: radial-gradient(circle, rgba(210, 210, 220, 0.55), rgba(140, 140, 160, 0.15) 55%, transparent 70%);
  animation: smoke 2.6s ease-out forwards; }
.arrival .spark { position: absolute; z-index: 2; left: 50%; top: 46%; width: 6px; height: 6px; border-radius: 50%;
  background: #fff4c2; box-shadow: 0 0 10px 3px rgba(255, 210, 120, 0.9); animation: spark 1.6s ease-out forwards; }
@keyframes flash { 0% { opacity: 0.95; } 15% { opacity: 0.1; } 25% { opacity: 0.7; } 100% { opacity: 0; } }
@keyframes bolt { 0% { opacity: 1; } 12% { opacity: 0.2; } 22% { opacity: 1; } 100% { opacity: 0; } }
@keyframes smoke { from { transform: scale(0.2); opacity: 1; } to { transform: scale(1.7); opacity: 0; } }
@keyframes spark { from { transform: translate(0, 0) scale(1); opacity: 1; } to { transform: translate(var(--dx), var(--dy)) scale(0.3); opacity: 0; } }

/* -- steward: silk banners on gilded rods -- */
.arrival.steward { background: radial-gradient(circle at 50% 45%, #163b25 0%, #0a1d12 45%, #030805 85%);
  --c-glow: rgba(240, 205, 122, 0.6); }
.arrival .pennant { position: absolute; z-index: 2; top: 0; width: min(190px, 18vw);
  transform-origin: 50% 0; animation: drop 1.1s cubic-bezier(.3, 1.25, .5, 1) both, sway 4.5s ease-in-out 1.2s infinite alternate;
  filter: drop-shadow(0 12px 18px rgba(0, 0, 0, 0.7)); }
.arrival .pennant.left { left: 8%; }
.arrival .pennant.right { right: 8%; animation-delay: 0.15s, 1.4s; }
@keyframes drop { from { transform: translateY(-110%); } to { transform: none; } }
@keyframes sway { from { transform: rotate(-1.6deg); } to { transform: rotate(1.6deg); } }

/* -- king / queen: the crown and gold leaf -- */
.arrival.king { background: radial-gradient(circle at 50% 40%, #4a3510 0%, #1d1406 45%, #070502 85%); }
.arrival .rays { position: absolute; z-index: 1; left: 50%; top: 40%; width: 1800px; height: 1800px; margin: -900px 0 0 -900px;
  background: repeating-conic-gradient(rgba(255, 215, 110, 0.16) 0deg 5deg, transparent 5deg 15deg);
  -webkit-mask: radial-gradient(circle, #000 0%, transparent 58%); mask: radial-gradient(circle, #000 0%, transparent 58%);
  animation: spin 36s linear infinite, arrival-in 1s ease-out; }
.arrival .crown { position: absolute; z-index: 2; left: 50%; top: 9%; width: min(230px, 40vw); transform: translateX(-50%);
  filter: drop-shadow(0 0 22px rgba(255, 205, 90, 0.8)) drop-shadow(0 10px 14px rgba(0, 0, 0, 0.6));
  animation: crown-down 1.4s cubic-bezier(.2, 1.25, .4, 1) both; }
.arrival.king .card { margin-top: 170px; }
.arrival .leaf { position: absolute; z-index: 2; top: -20px; width: 10px; height: 14px; border-radius: 2px 8px;
  background: linear-gradient(135deg, #fff1b0, #e2b13c 50%, #a8761b);
  animation: leaf linear forwards; }
@keyframes crown-down { from { transform: translate(-50%, -280px) rotate(-10deg); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes leaf { from { transform: translateY(0) rotate(0deg); } to { transform: translateY(110vh) rotate(720deg) translateX(40px); } }

/* -- valar: the heavens open -- */
.arrival.valar { background: radial-gradient(circle at 50% 40%, #2b3266 0%, #10142f 45%, #02030a 85%);
  --c-rank: #e6ecff; --c-glow: rgba(190, 210, 255, 0.85); --c-metal: #cdd8ff;
  --c-name: linear-gradient(180deg, #ffffff 0%, #eef2ff 40%, #aab8f0 62%, #ffffff 78%, #7f8bc0 100%); }
.arrival .pillar { position: absolute; z-index: 1; top: 0; left: 50%; width: 46vw; height: 100%; transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.55), rgba(210, 225, 255, 0.18) 55%, transparent 85%);
  -webkit-mask: linear-gradient(90deg, transparent, #000 35%, #000 65%, transparent); mask: linear-gradient(90deg, transparent, #000 35%, #000 65%, transparent);
  animation: pillar 1.6s ease-out both; }
.arrival .runes { position: absolute; z-index: 1; width: min(640px, 88vw); aspect-ratio: 1; color: rgba(220, 230, 255, 0.75);
  filter: drop-shadow(0 0 8px rgba(170, 195, 255, 0.9)); animation: spin 60s linear infinite, arrival-in 2s ease-out; }
.arrival .star { position: absolute; z-index: 0; width: 3px; height: 3px; border-radius: 50%; background: #fff;
  box-shadow: 0 0 6px 2px rgba(200, 220, 255, 0.9); animation: twinkle 1.6s ease-in-out infinite alternate; }
@keyframes pillar { from { transform: translateX(-50%) scaleX(0.05); opacity: 0; } to { transform: translateX(-50%); opacity: 1; } }
@keyframes twinkle { from { opacity: 0.2; transform: scale(0.6); } to { opacity: 1; transform: scale(1.3); } }

#app.shake { animation: shake 0.6s ease-in-out 0.15s; }
@keyframes shake {
  0%, 100% { transform: none; } 20% { transform: translate(-6px, 3px); } 40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, 2px); } 80% { transform: translate(3px, -2px); }
}

@media (prefers-reduced-motion: reduce) {
  .arrival *, .arrival::after { animation: none !important; }
  .arrival .flash, .arrival .bolt, .arrival .spark, .arrival .smoke, .arrival .leaf { display: none; }
  #app.shake { animation: none; }
}

/* ---------- small screens ---------- */

@media (max-width: 860px) {
  #app {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    grid-template-areas: "top" "event" "stats" "story" "side" "social" "hint";
    height: auto;
    min-height: 100vh;
  }
  .story { height: 70vh; }
  .bars { grid-template-columns: minmax(0, 1fr); gap: 6px; }
  .actions { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .brand { font-size: 20px; }
  .players-panel { max-height: 240px; }
  .chat-panel { height: 60vh; flex: none; }
  .hint { display: none; }
  .stats { padding: 10px 12px; gap: 8px; }
  .chip { padding: 2px 8px 2px 6px; font-size: 13px; }
  .chip span { display: none; }
  .item { width: 30px; height: 30px; font-size: 17px; }
  .action.empty { display: none; }
  .whereabouts #title-head { font-size: 15px; }
}
