/* Path To Glory: parchment, dark wood and gold, with a blackletter pixel font for titles. */
@font-face { font-family: "Jacquarda Bastarda 9"; src: url(vendor/fonts/jacquarda-bastarda-9-latin-400-normal.woff2) format("woff2"); font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url(vendor/fonts/pixelify-sans-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Pixelify Sans"; src: url(vendor/fonts/pixelify-sans-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --ink: #3a2814;
  --ink-soft: #6c5434;
  --parch: #f1e3c0;
  --parch-dark: #e2cc98;
  --wood: #4a2e18;
  --wood-dark: #2c1a0c;
  --gold: #d4a234;
  --gold-light: #f8d878;
  --blood: #9c2a20;
  --night: #121828;
  --black: "Jacquarda Bastarda 9", "Pixelify Sans", serif;
  --pixel: "Pixelify Sans", "Trebuchet MS", sans-serif;
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--night); }
body { font: 16px/1.4 var(--pixel); color: var(--ink); overflow: hidden; }
[hidden] { display: none !important; }
button, input, select { font: inherit; color: inherit; }
a { color: var(--blood); }

.parchment {
  background:
    radial-gradient(120% 80% at 30% 20%, rgba(255, 255, 255, 0.35), transparent 60%),
    repeating-linear-gradient(0deg, rgba(120, 80, 30, 0.04) 0 2px, transparent 2px 5px),
    var(--parch);
  border: 4px solid var(--wood);
  border-radius: 6px;
  box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 24px rgba(120, 80, 30, 0.3), 0 6px 0 var(--wood-dark), 0 10px 30px rgba(0, 0, 0, 0.5);
  padding: 16px 18px;
}
.parchment h3, .parchment h4 { font-family: var(--black); font-weight: 400; margin: 0 0 8px; color: var(--wood); letter-spacing: 0.5px; }
.parchment h3 { font-size: 30px; line-height: 1; }
.parchment h3 small { font-family: var(--pixel); font-size: 13px; color: var(--ink-soft); margin-left: 8px; letter-spacing: 0; }
.parchment h4 { font-size: 22px; }
.btn {
  border: 3px solid var(--wood); border-radius: 5px; background: linear-gradient(180deg, var(--gold-light), var(--gold)); color: var(--wood-dark);
  font-weight: 700; padding: 6px 16px; cursor: pointer; box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 3px 0 var(--wood-dark); text-shadow: 0 1px 0 rgba(255, 255, 255, 0.4);
}
.btn:hover:not(:disabled) { filter: brightness(1.08); }
.btn:active:not(:disabled) { transform: translateY(2px); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.6), 0 1px 0 var(--wood-dark); }
.btn:disabled { opacity: 0.55; cursor: default; }
.btn.big { font-size: 20px; padding: 8px 22px; }
.btn.small { font-size: 13px; padding: 2px 8px; }
.btn.ghost { background: var(--parch); }
input, select { background: #fbf3dc; border: 2px solid var(--ink-soft); border-radius: 4px; padding: 6px 9px; }
input:focus, select:focus { outline: none; border-color: var(--blood); }
.row { display: flex; gap: 8px; align-items: center; }
.row input { flex: 1; min-width: 0; }
.spacer { flex: 1; }
.hint { color: var(--ink-soft); font-size: 14px; margin: 4px 0 10px; }
.dim { color: var(--ink-soft); }
.swatch { display: inline-block; width: 14px; height: 14px; border: 2px solid var(--wood-dark); border-radius: 3px; vertical-align: -2px; }

.screen { position: fixed; inset: 0; }
.logo { font-family: var(--black); font-weight: 400; color: var(--gold-light); text-shadow: 3px 3px 0 var(--wood-dark), 0 0 18px rgba(248, 216, 120, 0.4); margin: 0; letter-spacing: 1px; }
.logo span { font-size: 0.6em; color: #f0e0b0; }
.logo.small { font-size: 34px; }
.bar { display: flex; align-items: center; gap: 16px; padding: 10px 20px; background: linear-gradient(180deg, #5a3820, var(--wood)); border-bottom: 4px solid var(--wood-dark); box-shadow: inset 0 -2px 0 var(--gold); color: var(--parch); }
.me, .room-title { color: var(--parch); font-size: 17px; }
.code-chip { background: var(--wood-dark); border: 2px solid var(--gold); border-radius: 5px; padding: 2px 10px; color: var(--parch); }
.code-chip b { color: var(--gold-light); letter-spacing: 3px; }

/* ---------- title ---------- */
.title-screen { display: grid; place-items: center; }
.title-art { position: absolute; inset: 0; }
#title-canvas { width: 100%; height: 100%; image-rendering: pixelated; display: block; filter: saturate(1.05); }
.title-screen::after { content: ""; position: absolute; inset: 0; background: radial-gradient(60% 60% at 50% 50%, transparent, rgba(10, 12, 24, 0.65)); pointer-events: none; }
.title-card { position: relative; z-index: 1; width: min(560px, calc(100vw - 32px)); text-align: center; }
.title-card .logo { font-size: clamp(56px, 9vw, 92px); line-height: 0.95; color: var(--wood); text-shadow: 3px 3px 0 var(--gold), 6px 6px 0 rgba(0, 0, 0, 0.15); }
.title-card .logo span { color: var(--blood); }
.tagline { margin: 10px 0 18px; font-size: 18px; color: var(--ink-soft); }
.name-form { display: grid; grid-template-columns: 1fr auto; gap: 8px; text-align: left; }
.name-form label { grid-column: 1 / -1; font-family: var(--black); font-size: 22px; color: var(--wood); }
.lore { text-align: left; margin-top: 16px; color: var(--ink-soft); font-size: 15px; }
.lore summary { cursor: pointer; font-family: var(--black); font-size: 20px; color: var(--wood); }

/* ---------- lobby ---------- */
.lobby-screen { background: radial-gradient(80% 60% at 50% 0%, #2a2440, var(--night)); overflow-y: auto; }
.lobby-grid { display: grid; grid-template-columns: minmax(280px, 420px) minmax(320px, 620px); gap: 22px; justify-content: center; padding: 30px 20px; }
.lobby-grid h3:not(:first-child) { margin-top: 18px; }
.code { text-transform: uppercase; letter-spacing: 4px; font-weight: 700; }
.room-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.room-list li { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 0 10px; padding: 8px 10px; background: rgba(255, 255, 255, 0.35); border: 2px solid var(--parch-dark); border-radius: 5px; }
.room-list small { color: var(--ink-soft); grid-column: 1; }
.room-list button { grid-row: 1 / 3; grid-column: 2; }
.room-name { font-weight: 700; }
.empty { color: var(--ink-soft); }

/* ---------- war room ---------- */
.room-screen { background: radial-gradient(80% 60% at 50% 0%, #2a2440, var(--night)); overflow-y: auto; }
.room-grid { display: grid; grid-template-columns: minmax(380px, 1.2fr) minmax(300px, 1fr) minmax(260px, 0.8fr); gap: 18px; padding: 20px; max-width: 1500px; margin: 0 auto; align-items: start; }
.seats { list-style: none; margin: 0; padding: 0; display: grid; gap: 5px; }
.seat { display: grid; grid-template-columns: auto 1fr auto auto; align-items: center; gap: 10px; padding: 5px 8px; border-radius: 5px; background: rgba(255, 255, 255, 0.3); border: 2px solid transparent; min-height: 40px; }
.seat.mine { border-color: var(--gold); background: rgba(255, 240, 190, 0.7); }
.seat.kind-closed { opacity: 0.55; }
.seat i { font-style: normal; font-size: 12px; color: var(--ink-soft); border: 1px solid var(--ink-soft); border-radius: 3px; padding: 0 4px; margin-left: 4px; }
.seat i.ally { color: #2c6c2c; border-color: #2c6c2c; }
.seat-god { display: inline-flex; align-items: center; gap: 6px; font-size: 14px; }
.seat-god img { width: 21px; height: 21px; image-rendering: pixelated; }
.seat-ctl { display: flex; gap: 6px; }
.seat-ctl select { padding: 2px 4px; font-size: 13px; }
.room-settings { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 14px; padding-top: 12px; border-top: 2px dashed var(--parch-dark); }
.room-settings label { font-size: 14px; display: flex; gap: 6px; align-items: center; }
.gods { display: grid; gap: 8px; }
.god {
  display: grid; grid-template-columns: 54px 1fr; grid-template-rows: auto auto auto auto; column-gap: 12px; text-align: left; cursor: pointer;
  padding: 8px 10px; border-radius: 6px; border: 3px solid var(--parch-dark); background: rgba(255, 255, 255, 0.35);
}
.god img { grid-row: 1 / 5; width: 54px; height: 54px; image-rendering: pixelated; background: var(--god); border: 3px solid var(--wood-dark); border-radius: 6px; padding: 6px; }
.god b { font-family: var(--black); font-weight: 400; font-size: 24px; line-height: 1; color: var(--god); filter: brightness(0.8); }
.god small { color: var(--ink-soft); }
.god span { font-size: 13px; }
.god em { font-size: 12px; color: #2c6c2c; font-style: normal; }
.god:hover { border-color: var(--god-light); }
.god.chosen { border-color: var(--god); background: rgba(255, 245, 210, 0.9); box-shadow: 0 0 0 2px var(--gold); }
.chat { list-style: none; margin: 0 0 8px; padding: 0; height: 360px; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.chat .sys { color: var(--ink-soft); font-style: italic; }

/* ---------- the world ---------- */
.game-screen { background: #0e162c; }
#world { position: absolute; inset: 0; width: 100%; height: 100%; image-rendering: pixelated; cursor: crosshair; display: block; }
.hud { position: absolute; z-index: 2; }
.hud.top {
  top: 0; left: 0; right: 0; display: flex; align-items: center; gap: 16px; padding: 6px 14px; color: var(--parch);
  background: linear-gradient(180deg, rgba(74, 46, 24, 0.96), rgba(44, 26, 12, 0.92)); border-bottom: 3px solid var(--gold); flex-wrap: wrap;
}
.world-name b { font-family: var(--black); font-weight: 400; font-size: 26px; color: var(--gold-light); }
.world-name small { margin-left: 8px; color: #e8d8b0; }
.favor { display: flex; align-items: center; gap: 8px; }
.favor-label { font-family: var(--black); font-size: 22px; color: var(--gold-light); }
.favor-bar { width: 160px; height: 14px; border: 2px solid var(--gold); background: var(--wood-dark); border-radius: 3px; overflow: hidden; }
.favor-bar i { display: block; height: 100%; background: linear-gradient(180deg, #fff2a0, #e8a820); transition: width 0.25s; }
.favor b { color: var(--gold-light); min-width: 36px; }
.tribes-mini { display: flex; flex-wrap: wrap; gap: 6px; flex: 1; justify-content: flex-end; }
.tm { display: inline-flex; align-items: center; gap: 4px; font-size: 13px; background: rgba(0, 0, 0, 0.3); border-radius: 4px; padding: 1px 6px 1px 2px; color: #f0e0c0; }
.tm i { display: grid; place-items: center; width: 16px; height: 16px; border-radius: 3px; }
.tm img { width: 7px; height: 7px; image-rendering: pixelated; }
.tm b { font-weight: 700; }
.tm.me { outline: 2px solid var(--gold-light); }
.tm.fallen { opacity: 0.4; text-decoration: line-through; }
.icon-btn { width: 34px; height: 34px; border: 2px solid var(--gold); border-radius: 5px; background: var(--wood-dark); color: var(--gold-light); cursor: pointer; font-size: 18px; }
.icon-btn.off { opacity: 0.45; }
.hud.left { left: 12px; top: 64px; width: 200px; padding: 10px 12px; }
.my-god { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.my-god img { width: 40px; height: 40px; image-rendering: pixelated; border: 3px solid var(--wood-dark); border-radius: 5px; padding: 4px; }
.my-god b { font-family: var(--black); font-weight: 400; font-size: 22px; display: block; line-height: 1; }
.my-god small { display: block; color: var(--ink-soft); font-size: 12px; }
.my-god em { display: block; font-style: normal; font-size: 11px; color: #2c6c2c; }
.might { position: relative; margin: -2px 0 10px; padding: 4px 8px 6px; border: 2px solid var(--wood); border-radius: 5px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.might b { font-size: 15px; color: var(--blood); }
.might small { display: block; font-size: 12px; color: var(--ink-soft); }
.might i { position: absolute; left: 0; bottom: 0; height: 3px; background: linear-gradient(90deg, var(--gold), var(--blood)); }
.modes, .tools { display: grid; grid-template-columns: 1fr 1fr; gap: 5px; margin-bottom: 10px; }
.tools { grid-template-columns: 1fr 1fr 1fr; }
.mode, .tool {
  display: grid; justify-items: center; gap: 0; padding: 5px 2px; border: 2px solid var(--ink-soft); border-radius: 5px; background: rgba(255, 255, 255, 0.4); cursor: pointer; font-size: 13px;
}
.mode i, .tool i { font-style: normal; font-size: 20px; line-height: 1.1; }
.mode.active { background: var(--blood); color: #fff; border-color: var(--wood-dark); }
.tool.active { background: var(--gold); border-color: var(--wood-dark); }
.tool-help { font-size: 12px; color: var(--ink-soft); margin: 0; min-height: 50px; }
.hud.right { right: 12px; top: 64px; width: 280px; display: grid; gap: 10px; }
.mini-card { padding: 8px; }
#minimap { width: 100%; image-rendering: pixelated; display: block; cursor: pointer; background: #0e162c; border: 2px solid var(--wood); }
.log-card { padding: 10px 12px; max-height: calc(100vh - 360px); display: flex; flex-direction: column; }
.log { list-style: none; margin: 0; padding: 0; overflow-y: auto; font-size: 13px; display: grid; gap: 4px; }
.log li { border-bottom: 1px dashed var(--parch-dark); padding-bottom: 3px; }
.log .omen { font-weight: 700; text-shadow: 1px 1px 0 rgba(0, 0, 0, 0.6); }
.log .strike { color: var(--blood); }
.log .good { color: #2c6c2c; }
.log .bad { color: var(--blood); font-weight: 700; }
.log .sys, .log .chat { color: var(--ink-soft); }
.omen-banner {
  position: absolute; z-index: 3; top: 64px; left: 50%; transform: translateX(-50%); display: flex; gap: 12px; align-items: center; cursor: pointer;
  background: linear-gradient(180deg, #2c2238, #1a1424); border: 3px solid var(--god, var(--gold)); border-radius: 6px; padding: 8px 16px; color: #f0e8ff;
  box-shadow: 0 0 24px var(--god, transparent), 0 6px 0 rgba(0, 0, 0, 0.5); animation: omenIn 0.4s ease-out;
}
@keyframes omenIn { from { transform: translate(-50%, -30px); opacity: 0; } }
.omen-banner img { width: 28px; height: 28px; image-rendering: pixelated; }
.omen-banner b { font-family: var(--black); font-weight: 400; font-size: 26px; display: block; line-height: 1; }
.omen-banner small { color: #d8d0e8; }
.hover-info { position: absolute; z-index: 3; pointer-events: none; background: var(--parch); border: 2px solid var(--wood); border-radius: 4px; padding: 3px 8px; font-size: 13px; }
.hover-info small { display: block; color: var(--ink-soft); }
.game-chat { position: absolute; z-index: 2; left: 230px; bottom: 12px; width: min(420px, 40vw); }
.game-chat input { width: 100%; background: rgba(241, 227, 192, 0.85); }
.game-chat input:not(:focus) { opacity: 0.55; }
.game-menu { position: absolute; z-index: 4; top: 52px; right: 12px; display: grid; gap: 6px; padding: 10px; }

.results { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: rgba(10, 12, 24, 0.6); }
.results-card { width: min(720px, calc(100vw - 32px)); text-align: center; }
.results-card h2 { font-family: var(--black); font-weight: 400; font-size: 60px; margin: 0; color: var(--wood); text-shadow: 2px 2px 0 var(--gold); }
.results-table { width: 100%; border-collapse: collapse; margin: 14px 0; font-size: 15px; }
.results-table th { font-family: var(--black); font-weight: 400; font-size: 18px; color: var(--wood); border-bottom: 2px solid var(--wood); }
.results-table td { padding: 4px 6px; border-bottom: 1px dashed var(--parch-dark); }
.results-table tr.won td { background: rgba(212, 162, 52, 0.25); font-weight: 700; }
.results-actions { justify-content: center; }

.modal { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; background: rgba(10, 12, 24, 0.6); }
.help-card { width: min(680px, calc(100vw - 32px)); max-height: calc(100vh - 40px); overflow-y: auto; }
.help-card h2 { font-family: var(--black); font-weight: 400; font-size: 46px; margin: 0 0 8px; color: var(--wood); }
.help-list { padding-left: 18px; display: grid; gap: 8px; }
.toast { position: fixed; z-index: 20; left: 50%; bottom: 30px; transform: translateX(-50%); background: var(--wood-dark); color: var(--parch); border: 2px solid var(--gold); border-radius: 5px; padding: 8px 16px; }

@media (max-width: 1100px) {
  .room-grid { grid-template-columns: 1fr 1fr; }
  .chat-card { grid-column: 1 / -1; }
  .lobby-grid { grid-template-columns: 1fr; }
  .hud.right { width: 220px; }
  /* The standings become a strip under the bar that scrolls sideways. */
  .hud.top { row-gap: 4px; }
  .world-name { flex: 1; }
  .tribes-mini { order: 9; flex: 1 0 100%; flex-wrap: nowrap; overflow-x: auto; justify-content: flex-start; scrollbar-width: none; gap: 4px; }
  .tribes-mini::-webkit-scrollbar { display: none; }
  .tm { flex: none; font-size: 12px; }
  .hud.left, .hud.right { top: 84px; }
}

/* ---------- touch screens ---------- */
#world, #minimap { touch-action: none; }
.game-screen { user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { -webkit-tap-highlight-color: transparent; }
.touch-only, .small-only { display: none; }
body.touch .tool.touch-only { display: grid; }
body.touch .tool.mouse-only { display: none; }
body.touch .tools { grid-template-columns: 1fr 1fr; }
.icon-btn.on { background: var(--gold); color: var(--wood-dark); }

@media (max-width: 760px) {
  .room-grid { grid-template-columns: 1fr; padding: 12px; gap: 14px; }
  .lobby-grid { padding: 16px 12px; }
  .bar { flex-wrap: wrap; gap: 6px 12px; padding: 8px 12px; }
  .logo.small { font-size: 26px; }
  .parchment { padding: 12px 12px; }
  .parchment h3 { font-size: 25px; }
  .parchment h3 small { display: block; margin: 4px 0 0; }
  .seat { gap: 4px 8px; }
  /* An AI seat's god and cunning pickers move to their own line. */
  .seat:has(.seat-ctl > :nth-child(2)) { grid-template-columns: auto 1fr auto; }
  .seat:has(.seat-ctl > :nth-child(2)) .seat-ctl { grid-column: 1 / -1; justify-content: flex-end; }
  .chat { height: 220px; }
  .god b { font-size: 21px; }
}

/* Phones (portrait, or landscape with little height): the world fills the screen, the orders
   and tools dock at the bottom, the minimap and chronicle open from buttons in the top bar. */
@media (max-width: 760px), (max-height: 520px) {
  .small-only { display: inline-block; }
  .hud.top { gap: 4px 8px; padding: 4px 8px; padding-top: max(4px, env(safe-area-inset-top)); }
  .world-name { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1; }
  .world-name b { font-size: 19px; }
  .world-name small { display: block; margin: 2px 0 0; font-size: 11px; }
  .favor { gap: 5px; }
  .favor-label { display: none; }
  .favor-bar { width: 64px; height: 12px; }
  .favor b { min-width: 26px; font-size: 14px; }
  .icon-btn { width: 32px; height: 32px; font-size: 16px; }

  .hud.left {
    left: 0; right: 0; bottom: 0; top: auto; width: auto; border-radius: 6px 6px 0 0; border-bottom: 0;
    padding: 6px 8px; padding-bottom: max(6px, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: 1fr; gap: 5px;
  }
  .hud.left h4, .hud.left .my-god { display: none; }
  .might { margin: 0; padding: 2px 8px 4px; display: flex; gap: 8px; align-items: baseline; }
  .might b { font-size: 13px; white-space: nowrap; }
  .might small { font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .modes, .tools, body.touch .tools { grid-template-columns: repeat(4, 1fr); margin: 0; }
  body:not(.touch) .tools { grid-template-columns: repeat(3, 1fr); }
  .mode, .tool { min-height: 44px; padding: 3px 2px; font-size: 12px; align-content: center; }
  .mode i, .tool i { font-size: 18px; }
  .tool-help { min-height: 0; font-size: 11px; line-height: 1.25; text-align: center; }

  .hud.right { top: auto; right: 8px; width: min(280px, calc(100vw - 16px)); top: 74px; gap: 8px; }
  body:not(.show-mini):not(.show-log) .hud.right { display: none; }
  body:not(.show-mini) .mini-card, body:not(.show-log) .log-card { display: none; }
  .log-card { max-height: 48vh; }
  .log-card .game-chat { position: static; width: auto; margin-top: 8px; }
  .log-card .game-chat input:not(:focus) { opacity: 1; }
  .game-chat { display: none; }
  .log-card .game-chat { display: block; }

  .omen-banner { top: 76px; max-width: calc(100vw - 16px); padding: 6px 10px; gap: 8px; }
  .omen-banner b { font-size: 20px; }
  .omen-banner small { font-size: 12px; }
  .game-menu { top: 46px; right: 8px; }
  .toast { bottom: auto; top: 110px; max-width: calc(100vw - 24px); text-align: center; }
  .results-card { max-height: calc(100vh - 24px); overflow-y: auto; }
  .results-card h2 { font-size: 40px; }
  .results-table { display: block; overflow-x: auto; font-size: 13px; }
  .results-actions { flex-wrap: wrap; }
  .help-card h2 { font-size: 32px; }
}
/* Landscape phones: orders and tools side by side in one low dock. */
@media (max-height: 520px) and (min-width: 561px) {
  .hud.left { grid-template-columns: 1fr 1fr; column-gap: 10px; padding-top: 4px; }
  .might, .tool-help { display: none !important; }
  .mode, .tool { min-height: 40px; }
  .hud.right { top: 70px; max-height: calc(100vh - 140px); overflow-y: auto; }
  .log-card { max-height: calc(100vh - 160px); }
}

/* PixelLab god medallions: no coloured tile behind them. */
img.art-icon.ui-icon { width: 1.5em; height: 1.5em; display: block; margin: 0 auto; image-rendering: auto; } /* scales with the glyph it replaces; smooth, since it's shrunk by an odd amount */
img.art-icon { background: none !important; padding: 0 !important; border: 0 !important; image-rendering: pixelated; object-fit: contain; }
