@font-face {
  font-family: "Pixelify Sans"; src: url("../fonts/PixelifySans.woff2") format("woff2");
  font-weight: 400 700; font-display: swap;
}
:root {
  --ink: #3b2a1a;
  --paper: #f6e7c6;
  --paper-2: #ecd7ab;
  --wood: #8b5a2b;
  --wood-dk: #4a2c14;
  --sky: #95BEE0;
  --gold: #EFA544;
  --night: #14263a;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --pixel: "Pixelify Sans", ui-monospace, "SF Mono", Menlo, monospace;
  --serif: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night); }
body { font-family: var(--pixel); color: var(--ink); -webkit-font-smoothing: antialiased; }
canvas#world, canvas#fx { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; image-rendering: pixelated; }
canvas#fx { display: none; }
canvas#mini { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; pointer-events: none; z-index: 1; }
body.fx canvas#fx { display: block; }
body.fx canvas#world { display: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }

/* Pixel frame: parchment inside a two-tone wooden border */
.px-box {
  background: var(--paper);
  border: 4px solid var(--wood);
  box-shadow: 0 0 0 4px var(--wood-dk), inset 0 0 0 2px var(--paper-2), 0 10px 0 4px #0003;
  border-radius: 2px;
}
.px-box.small { border-width: 3px; box-shadow: 0 0 0 3px var(--wood-dk), inset 0 0 0 2px var(--paper-2); }

/* HUD */
.hud { position: fixed; top: 14px; left: 14px; right: 14px; display: flex; justify-content: space-between; pointer-events: none; z-index: 5; }
.hud-l, .hud-r { padding: 6px 12px; font-size: 14px; display: flex; gap: 10px; align-items: center; }
.hud-l b { letter-spacing: .25em; }
.party { display: flex; gap: 3px; }
.party img { width: 24px; height: 34px; image-rendering: pixelated; }
.party i { width: 24px; height: 34px; display: block; background: #0000000f; border-radius: 3px; }
.lbl { font-size: 11px; letter-spacing: .1em; text-transform: uppercase; opacity: .7; }

/* Node prompt */
.prompt {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  display: flex; gap: 12px; align-items: baseline; padding: 10px 16px;
  font-size: 14px; max-width: calc(100vw - 32px); z-index: 5;
}
.p-id { color: var(--wood); font-weight: 700; font-size: 16px; }
.p-name { font-family: var(--serif); font-size: 16px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-key { font-size: 13px; opacity: .75; white-space: nowrap; }
.prompt.shake { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(calc(-50% - 6px)); } 75% { transform: translateX(calc(-50% + 6px)); } }

/* Dialog */
.dialog {
  position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%);
  width: min(760px, calc(100vw - 28px)); max-height: min(52vh, 460px);
  display: flex; flex-direction: column; padding: 14px 20px 10px; z-index: 6;
  cursor: pointer;
}
.dialog header { display: flex; justify-content: space-between; font-size: 12px; letter-spacing: .12em; text-transform: uppercase; color: var(--wood); font-weight: 700; margin-bottom: 8px; }
.dialog p { margin: 0; overflow-y: auto; font: 18px/1.6 var(--serif); white-space: pre-wrap; }
.dialog footer { text-align: right; font-size: 12px; color: var(--wood); height: 16px; }
.blink { animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Toast */
.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); padding: 8px 16px; font-size: 15px; z-index: 7; animation: pop .25s steps(3); }
@keyframes pop { from { transform: translate(-50%, -8px); opacity: 0; } }

/* Place banner: an area-title card */
.place {
  position: fixed; left: 50%; top: 26%; transform: translateX(-50%); z-index: 6; pointer-events: none;
  display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center;
  color: #fff3d6; animation: place 3.4s ease both;
}
.place small { font: 500 13px/1 var(--pixel); letter-spacing: .45em; text-transform: uppercase; color: #ffe2a8; text-shadow: 0 2px 0 #0009; }
.place b {
  font: 700 clamp(30px, 5.4vw, 56px)/1 var(--pixel); letter-spacing: .01em; white-space: nowrap;
  text-shadow: 0 3px 0 #2a1a10, 3px 0 0 #2a1a10, -3px 0 0 #2a1a10, 0 -3px 0 #2a1a10, 0 7px 0 #0007, 0 0 28px #0008;
}
.place .orn { position: relative; width: min(340px, 70vw); height: 2px; margin-top: 4px; background: linear-gradient(90deg, transparent, #EFA544 25%, #EFA544 75%, transparent); box-shadow: 0 2px 0 #0007; }
.place .orn::after { content: ""; position: absolute; left: 50%; top: 50%; width: 9px; height: 9px; background: #EFA544; border: 2px solid #2a1a10; transform: translate(-50%, -50%) rotate(45deg); }
@keyframes place { 0% { opacity: 0; transform: translate(-50%, 8px); } 14%, 76% { opacity: 1; transform: translate(-50%, 0); } 100% { opacity: 0; transform: translate(-50%, -4px); } }

/* Ending */
.closing {
  position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%);
  transition: opacity 2s, top 1s;
  width: min(30vmin, 340px); margin: 0; text-align: center; z-index: 4;
  font: italic clamp(13px, 2.2vmin, 22px)/1.45 var(--serif); color: #f6e7c6;
  text-shadow: 0 2px 0 #0008; opacity: 0;
}
.closing.up { top: calc(50% - 9vmin); }
.closing.show { opacity: 1; }
.menu {
  position: fixed; left: 50%; top: calc(50% + 7vmin); transform: translateX(-50%);
  padding: 12px 18px; text-align: center; z-index: 7; animation: pop .3s steps(3);
}
.menu h2 { margin: 0 0 10px; font: 700 clamp(15px, 2.1vmin, 20px)/1.2 var(--pixel); white-space: nowrap; }
.menu-btns { display: flex; gap: 14px; justify-content: center; }
.menu button { background: none; border: 0; padding: 4px 10px; font-size: 17px; }
.menu button.sel, .menu button:hover { background: var(--ink); color: var(--paper); }
.corner { position: fixed; right: 16px; bottom: 16px; z-index: 6; }
.corner button { padding: 8px 12px; font-size: 13px; }

/* Title: logo over the world drifting by */
.title {
  position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: space-between; align-items: center;
  padding: clamp(80px, 16vh, 170px) 20px clamp(40px, 8vh, 80px); text-align: center;
  background:
    linear-gradient(180deg, #0b1622d9 0%, #0b162200 34%, #0b162200 62%, #0b1622e6 100%),
    radial-gradient(ellipse at center, #0000 40%, #0b162299 100%);
}
.logo { animation: rise .9s cubic-bezier(.2,.8,.2,1) both; }
.presents { margin: 0 0 14px; font: 500 14px/1 var(--pixel); letter-spacing: .5em; text-transform: uppercase; color: var(--sky); text-shadow: 0 2px 0 #0009; }
.logo-t {
  margin: 0; font: 700 clamp(44px, 9vw, 112px)/.95 var(--pixel); letter-spacing: -.01em; color: #fff3d6;
  text-shadow:
    0 4px 0 #2a1a10, 4px 0 0 #2a1a10, -4px 0 0 #2a1a10, 0 -4px 0 #2a1a10,
    4px 4px 0 #2a1a10, -4px 4px 0 #2a1a10, 4px -4px 0 #2a1a10, -4px -4px 0 #2a1a10,
    0 8px 0 #c47e22, 4px 8px 0 #c47e22, -4px 8px 0 #c47e22,
    0 12px 0 #2a1a10, 4px 12px 0 #2a1a10, -4px 12px 0 #2a1a10,
    0 18px 30px #000a, 0 0 60px #EFA54455;
}
.t-by { margin: 22px 0 0; font: italic 18px/1.3 var(--serif); color: #f6e7c6; text-shadow: 0 2px 4px #000c; }
.t-bottom { display: flex; flex-direction: column; align-items: center; gap: 14px; animation: rise 1.1s .25s cubic-bezier(.2,.8,.2,1) both; }
.start {
  font: 700 20px/1 var(--pixel); letter-spacing: .08em; text-transform: uppercase;
  color: #2a1a10; background: var(--gold); border: 0; padding: 14px 28px;
  box-shadow: 0 0 0 3px #2a1a10, inset 0 -4px 0 #c47e22, inset 0 3px 0 #ffd38a, 0 6px 0 3px #0008;
  animation: soft 1.4s ease-in-out infinite;
}
.start:hover { filter: brightness(1.08); transform: translateY(-1px); }
.start:active { transform: translateY(2px); box-shadow: 0 0 0 3px #2a1a10, inset 0 -2px 0 #c47e22, 0 3px 0 3px #0008; }
.t-help { margin: 0; font: 14px/1.4 var(--pixel); color: #f6e7c6cc; text-shadow: 0 2px 0 #0009; }
.t-links { margin: 0; font: 14px/1 var(--pixel); }
.t-links a { color: #ffe2a8; text-decoration: none; border-bottom: 2px solid #ffe2a855; }
.t-links a:hover { color: #fff; border-color: #fff; }
@keyframes soft { 50% { opacity: .82; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } }

/* Attract mode (landing-page background): just the world */
body.attract .title, body.attract .hud, body.attract .pad, body.attract .prompt, body.attract .toast, body.attract .place { display: none !important; }

/* Touch pad */
.pad { display: none; }
@media (hover: none) and (pointer: coarse) {
  /* Netlify's free-plan badge is a fixed 216x92 iframe in the bottom-right that can't be hidden; keep controls above it */
  .pad { position: fixed; left: 0; right: 0; bottom: calc(104px + env(safe-area-inset-bottom)); display: flex; justify-content: space-between; padding: 0 18px; z-index: 8; pointer-events: none; }
  .pad button { pointer-events: auto; width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--wood-dk); background: var(--paper); font-size: 20px; opacity: .9; }
  .pad .act { background: var(--gold); font-weight: 700; }
  .pad button:nth-child(1) { margin-right: auto; }
  .pad button:nth-child(2) { order: 3; margin-left: 12px; }
  .prompt, .dialog { bottom: calc(178px + env(safe-area-inset-bottom)); }
  .corner { bottom: calc(172px + env(safe-area-inset-bottom)); }
}

@media (max-width: 640px) {
  .hud { top: 10px; left: 10px; right: 10px; }
  .hud-l b, .lbl { display: none; }
  .hud-l, .hud-r { padding: 5px 8px; font-size: 11px; }
  .party { gap: 2px; }
  .party img, .party i { width: 15px; height: 21px; }
  .toast { top: 112px; }
  .dialog p { font-size: 16px; }
}
