/* The handwriting ships with the game: no network round trip, no fallback to a system sans. */
@font-face { font-family: "Patrick Hand"; src: url("fonts/PatrickHand.woff2") format("woff2"); font-display: block; }
@font-face { font-family: "Caveat"; src: url("fonts/Caveat.woff2") format("woff2"); font-weight: 400 700; font-display: block; }

/* The DOM layer is only the login sheet, chat input and toasts. Everything else is drawn on canvas. */
:root {
  --paper: #f6f2e4; --ink: #20366e; --ink-soft: #4a5f9e; --pencil: #4a4a4a; --red: #c8302f; --rule: #b9c7e8;
  --hand: "Patrick Hand", "Comic Sans MS", cursive; --pen: "Caveat", cursive;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--paper); color: var(--ink); font-family: var(--hand); -webkit-font-smoothing: antialiased; }
#game { display: block; position: fixed; inset: 0; touch-action: none; cursor: crosshair; }

#notes { position: fixed; bottom: 92px; left: 50%; transform: translateX(-50%); z-index: 6; display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; max-width: min(520px, 86vw); }
.note {
  padding: 8px 15px; font-size: 16px; text-align: center; color: var(--ink); background: rgba(255,255,255,0.88);
  border: 1.5px solid var(--ink); border-radius: 14px 4px 16px 6px; box-shadow: 2px 3px 0 rgba(32,54,110,0.18);
  animation: pop 0.25s ease-out;
}
.note.quest { color: var(--red); border-color: var(--red); }
.note.loot { color: #2f7d45; border-color: #2f7d45; }
.note.level { color: #b4841f; border-color: #b4841f; font-family: var(--pen); font-size: 22px; }
@keyframes pop { from { transform: translateY(8px) rotate(-1deg); opacity: 0; } }
body.touch #notes { bottom: 150px; }
body.bag-open #notes, body.hero-open #notes { opacity: 0; transition: opacity 0.15s; }
body.hero-open.touch #touch { opacity: 0.25; }

#conn { position: fixed; top: 8px; right: 12px; z-index: 6; font-size: 14px; color: var(--red); }

#chat-box { position: fixed; left: 16px; bottom: 16px; z-index: 6; width: min(420px, 70vw); opacity: 0; pointer-events: none; transition: opacity 0.15s; }
#chat-box.on { opacity: 1; pointer-events: auto; }
#chat-input {
  width: 100%; padding: 8px 12px; font: 16px var(--hand); color: var(--ink); background: rgba(255,255,255,0.9);
  border: none; border-bottom: 2px solid var(--ink); outline: none;
}

/* the login sheet is a page torn out of the same notebook */
#login { position: fixed; inset: 0; z-index: 10; display: grid; place-items: center; padding: 20px; overflow: auto;
  background: repeating-linear-gradient(var(--paper) 0 33px, var(--rule) 33px 34px); transition: opacity 0.45s; }
#login.gone { opacity: 0; pointer-events: none; }
.sheet {
  position: relative; width: min(460px, 100%); padding: 26px 28px 22px; background: rgba(255,255,255,0.72);
  border: 2px solid var(--ink); border-radius: 22px 6px 20px 8px; box-shadow: 4px 6px 0 rgba(32,54,110,0.16);
}
.sheet::before { content: ""; position: absolute; left: 46px; top: 0; bottom: 0; width: 2px; background: rgba(200,48,47,0.5); }
.sheet h1 { margin: 0; font: 700 54px/1 var(--pen); color: var(--ink); transform: rotate(-1.4deg); }
.sub { margin: 4px 0 18px; font-size: 15px; color: var(--pencil); }
.row { display: flex; align-items: baseline; gap: 10px; margin: 0 0 12px; }
.row span { width: 86px; font-size: 15px; color: var(--pencil); }
.row input { flex: 1; padding: 6px 4px; font: 18px var(--hand); color: var(--ink); background: transparent; border: none; border-bottom: 2px solid var(--ink); outline: none; }
.row input:focus { border-color: var(--red); }
.lbl { margin: 14px 0 6px; font-size: 14px; color: var(--pencil); }
.picks { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.cls {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 8px 10px; font: 17px var(--hand);
  color: var(--ink); background: transparent; border: 2px solid rgba(32,54,110,0.35); border-radius: 12px 4px 14px 5px; cursor: pointer;
}
.cls em { font-size: 12px; font-style: normal; color: var(--pencil); }
.cls.on { border-color: var(--red); color: var(--red); box-shadow: 2px 2px 0 rgba(200,48,47,0.2); }
.cls.on em { color: var(--red); }
.inks { display: flex; gap: 8px; }
.ink { width: 30px; height: 30px; padding: 0; background: var(--c); border: 2px solid rgba(0,0,0,0.25); border-radius: 50% 45% 55% 48%; cursor: pointer; }
.ink.on { outline: 2px solid var(--red); outline-offset: 3px; }
.go {
  width: 100%; margin-top: 18px; padding: 12px; font: 700 26px var(--pen); color: var(--paper); background: var(--ink);
  border: none; border-radius: 16px 6px 18px 8px; cursor: pointer; transform: rotate(-0.5deg);
}
.go:hover { background: #2b4890; }
#login-error { min-height: 18px; margin: 8px 0 0; font-size: 15px; color: var(--red); }
.keys { margin: 6px 0 0; font-size: 13px; color: var(--pencil); }

#bag-btn { position: fixed; right: 20px; bottom: 20px; z-index: 7; min-width: 96px; }


/* on-screen buttons, only on touch devices, drawn like the rest of the notebook */
#touch { display: none; }
body.touch #touch { display: grid; position: fixed; right: calc(12px + env(safe-area-inset-right, 0px)); bottom: calc(86px + env(safe-area-inset-bottom, 0px)); z-index: 7; grid-template-columns: auto auto; gap: 8px; justify-items: end; }

/* the tool tabs: paper cards with a drawn icon, the way the page's own margins are drawn */
#tools {
  position: fixed; z-index: 8; display: flex; gap: 8px; align-items: flex-end;
  right: calc(14px + env(safe-area-inset-right, 0px)); bottom: calc(14px + env(safe-area-inset-bottom, 0px));
}
.tool {
  display: flex; flex-direction: column; align-items: center; gap: 2px; width: 62px; padding: 7px 4px 5px;
  font: 13px var(--hand); color: var(--ink); background: rgba(255,253,246,0.94);
  border: 1.8px solid var(--ink); border-radius: 12px 5px 13px 6px;
  box-shadow: 2px 3px 0 rgba(32,54,110,0.2); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tool svg { width: 30px; height: 27px; fill: none; stroke: var(--ink); stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.tool span { line-height: 1; letter-spacing: 0.2px; }
.tool:active { transform: translate(1px, 2px); box-shadow: none; }
.tool.on { background: rgba(255,244,214,0.97); border-color: var(--red); color: var(--red); }
.tool.on svg { stroke: var(--red); }
@media (max-width: 760px) {
  .tool { width: 52px; padding: 6px 3px 4px; font-size: 11px; }
  .tool svg { width: 25px; height: 22px; }
}
body.touch .desk { display: none; }
.tb {
  min-width: 74px; padding: 10px 12px; font: 16px var(--hand); line-height: 1.05; color: var(--ink);
  background: rgba(255,255,255,0.86); border: 2px solid var(--ink); border-radius: 14px 5px 16px 6px;
  box-shadow: 2px 3px 0 rgba(32,54,110,0.2); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.tb:active { transform: translate(1px, 2px); box-shadow: none; }
.tb.big { grid-row: span 2; align-self: stretch; min-width: 92px; font: 20px var(--pen); color: var(--red); border-color: var(--red); }
@media (max-width: 760px) {
  .note { font-size: 14px; padding: 6px 12px; }
  #notes { gap: 4px; }
  #chat-box { width: calc(100vw - 150px); left: 10px; bottom: calc(10px + env(safe-area-inset-bottom, 0px)); }
  .sheet h1 { font-size: 44px; }
}


/* the settings scrap */
#settings { position: fixed; inset: 0; z-index: 9; display: none; align-items: center; justify-content: center; background: rgba(32,54,110,0.12); }
#settings.on { display: flex; }
.sheet.small { width: min(330px, 86vw); padding: 20px 22px 18px; }
.sheet.small h2 { margin: 0 0 12px; font: 30px var(--pen); color: var(--ink); }
.opt { display: flex; align-items: center; gap: 10px; margin: 9px 0; font: 16px var(--hand); color: var(--ink); cursor: pointer; }
.opt input { width: 18px; height: 18px; accent-color: #2a4b9b; }
.ghost { margin-top: 14px; width: 100%; padding: 9px; font: 15px var(--hand); color: var(--red); background: transparent;
  border: 1.6px dashed var(--red); border-radius: 12px 4px 13px 5px; cursor: pointer; }


/* the character preview on the entry sheet */
#who {
  display: block; width: 170px; height: 115px; margin: 2px auto 6px;
  background: rgba(255,255,255,0.5); border: 1.6px solid rgba(32,54,110,0.35);
  border-radius: 14px 5px 15px 6px;
}
@media (min-width: 761px) {
  #who { float: right; width: 190px; height: 130px; margin: 0 0 4px 12px; background: transparent; border: none; }
}
