/* Lanternfall. The whole thing is a cyanotype: paper-white on Prussian blue,
   one warm amber for things that give off light, and nothing else.
   Type is a 17th-century face for headings and a typewriter for everything else. */

:root {
  --blue: #20478c;
  --blue-deep: #0b1d44;
  --blue-dim: rgba(8, 20, 50, 0.72);
  --paper: #e8eee6;
  --paper-dim: rgba(232, 238, 230, 0.72);
  --paper-faint: rgba(232, 238, 230, 0.28);
  --amber: #f2a93b;
  --fell: 'IM Fell English', Georgia, 'Times New Roman', serif;
  --type: 'Courier Prime', 'Courier New', Courier, monospace;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--blue);
  color: var(--paper);
  font-family: var(--type);
  font-size: 15px;
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#game { position: fixed; inset: 0; display: block; touch-action: none; }
body.hide-cursor, body.hide-cursor #game { cursor: none; }

.hidden { display: none !important; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; text-align: left; }
button:focus-visible { outline: 1px dashed var(--amber); outline-offset: 4px; }

.touch-only { display: none !important; }
body.touch .touch-only { display: grid !important; }
body.touch .desktop-only { display: none !important; }

h1, h2 { font-family: var(--fell); font-weight: 400; }
b { font-weight: 700; }

.overline { font-family: var(--fell); font-style: italic; font-size: 17px; color: var(--paper-dim); }
.prose { line-height: 1.6; color: var(--paper-dim); max-width: 60ch; }
.prose.small { font-size: 13px; }
.prose b { color: var(--paper); }

/* ------------------------------------------------------------ buttons */

/* The main action is words with a pen line under them, nothing more. */
.begin {
  font-family: var(--fell); font-style: italic;
  font-size: 30px; line-height: 1.2;
  padding: 2px 0 6px;
  background-image: linear-gradient(var(--paper), var(--paper));
  background-size: 100% 1px;
  background-position: 0 100%;
  background-repeat: no-repeat;
  transition: background-size 0.25s ease, color 0.15s;
}
.begin span { font-style: normal; font-family: var(--type); font-size: 0.8em; display: inline-block; transition: transform 0.2s; }
.begin:hover { color: var(--amber); background-image: linear-gradient(var(--amber), var(--amber)); background-size: 100% 2px; }
.begin:hover span { transform: translateY(4px); }
.begin.small { font-size: 23px; }

.plain { font-size: 14px; color: var(--paper-dim); text-decoration: underline; text-underline-offset: 4px; text-decoration-thickness: 1px; }
.plain:hover { color: var(--paper); }

.switches { display: flex; gap: 18px; flex-wrap: wrap; font-size: 13px; }
.switch { color: var(--paper-dim); }
.switch .state { color: var(--paper); text-decoration: underline; text-underline-offset: 3px; }
.switch.off .state { color: var(--paper-faint); text-decoration: line-through; }
.switch:hover .state { color: var(--amber); }

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

.screen {
  position: fixed; inset: 0;
  /* children centre themselves with margin: auto, so tall content scrolls instead of being clipped at the top */
  display: flex; flex-direction: column; align-items: center; justify-content: flex-start;
  padding: calc(28px + var(--safe-t)) 16px calc(28px + var(--safe-b));
  background: rgba(8, 20, 50, 0.55);
  overflow-y: auto;
  touch-action: pan-y;
  animation: fade 0.4s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

/* A sheet is a printed plate: a darker field inside a double rule. */
.sheet {
  display: flex; flex-direction: column; gap: 16px;
  width: min(560px, 100%);
  margin: auto 0;
  padding: 30px 30px 26px;
  background: var(--blue-dim);
  border: 1px solid var(--paper-faint);
  outline: 1px solid var(--paper-faint);
  outline-offset: 5px;
}
.sheet h2 { font-size: 36px; line-height: 1.1; }
.actions { display: flex; align-items: baseline; gap: 26px; flex-wrap: wrap; margin-top: 6px; }

/* ------------------------------------------------------------ title page */

.menu { background: linear-gradient(90deg, rgba(8, 20, 50, 0.7), rgba(8, 20, 50, 0.25) 60%, rgba(8, 20, 50, 0.45)); }

.title-page {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  grid-template-areas: 'mast notes' 'board book';
  column-gap: 64px; row-gap: 34px;
  width: 100%; max-width: 1080px;
  margin: auto 0;
}
.masthead { grid-area: mast; align-self: end; display: flex; flex-direction: column; align-items: flex-start; gap: 18px; }
.notes { grid-area: notes; display: flex; flex-direction: column; gap: 12px; }
.book { grid-area: book; }
.board { grid-area: board; align-self: start; max-width: 480px; }

/* A plain strip held at the foot of the title page, so the advert is clearly not part of the log.
   It stays on screen because CrazyGames only fills a banner that is wholly visible. */
.ad-banner {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); z-index: 5;
  width: min(100%, 728px);
  padding: 4px 0 calc(4px + var(--safe-b));
  background: rgba(8, 20, 50, 0.9);
}
.ad-label { font-size: 10px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--paper-dim); margin-bottom: 3px; text-align: center; }
.ad-slot { width: 100%; height: 90px; border: 1px solid var(--paper-faint); overflow: hidden; }
/* room at the bottom, so nothing on the title page is hidden behind the strip */
.menu:has(.ad-banner:not(.hidden)) { padding-bottom: calc(130px + var(--safe-b)); }

.logo {
  font-size: clamp(64px, 10vw, 128px);
  line-height: 0.9;
  letter-spacing: -0.01em;
  margin-left: -4px;
}
.lede { font-size: 16px; line-height: 1.65; max-width: 42ch; }
.record { font-size: 13px; color: var(--paper-dim); padding-top: 12px; border-top: 1px solid var(--paper-faint); width: min(100%, 42ch); }
.masthead .begin { margin-top: 6px; }

.notes h2, .book h2, .board h2 {
  font-size: 22px; font-style: italic;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--paper-faint);
}
.notes h2:not(:first-child) { margin-top: 10px; }
.notes .prose { font-size: 13.5px; }
.notes .switches { margin-top: 8px; }

.handling { display: grid; grid-template-columns: auto 1fr; column-gap: 20px; row-gap: 6px; font-size: 13.5px; }
.handling dt { color: var(--paper); }
.handling dd { color: var(--paper-dim); }

.count { font-family: var(--type); font-style: normal; font-size: 13px; color: var(--paper-dim); margin-left: 8px; }

.plate-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px 10px; margin-top: 14px; }
.plate { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.plate canvas { width: 70px; height: 70px; }
.plate figcaption { font-family: var(--fell); font-style: italic; font-size: 13px; text-align: center; line-height: 1.15; }
.plate.unknown figcaption { color: var(--paper-faint); font-family: var(--type); font-style: normal; font-size: 11px; }

/* ------------------------------------------------------------ the deepest dives */

.board-list { list-style: none; margin-top: 8px; font-size: 13.5px; }
.board-list li { display: grid; grid-template-columns: 26px 1fr auto auto; gap: 14px; align-items: baseline; padding: 5px 0; border-bottom: 1px dotted var(--paper-faint); }
.board-list .n { color: var(--paper-dim); }
.board-list .who { font-family: var(--fell); font-style: italic; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board-list .dep { color: var(--paper-dim); text-align: right; }
.board-list .pts { text-align: right; min-width: 64px; }
.board-list li.me .who, .board-list li.me .pts { color: var(--amber); }
.board-list li.board-note { display: block; color: var(--paper-dim); border: 0; }

.sign { display: flex; flex-direction: column; gap: 8px; padding-top: 12px; border-top: 1px solid var(--paper-faint); font-size: 13px; color: var(--paper-dim); }
.sign-row { display: flex; align-items: baseline; gap: 16px; }
.sign input {
  flex: 1; min-width: 0;
  font-family: var(--fell); font-style: italic; font-size: 22px;
  color: var(--paper);
  background: none; border: 0; border-bottom: 1px solid var(--paper-dim);
  padding: 2px 0 4px;
  user-select: text; -webkit-user-select: text;
}
.sign input::placeholder { color: var(--paper-faint); }
.sign input:focus { outline: none; border-bottom-color: var(--amber); }
.sign-status { min-height: 1.2em; color: var(--paper); }
.sign-status.err { color: var(--amber); }
.sign.done .sign-row, .sign.done label { display: none; }
.board .sign { margin-top: 14px; }
.signed-as { margin-top: 10px; font-size: 13px; color: var(--paper-dim); }
.signed-as b { font-family: var(--fell); font-style: italic; font-weight: normal; font-size: 16px; color: var(--paper); }
.link { font-size: 13px; color: var(--paper-dim); text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; }
.link:hover { color: var(--paper); }
.board-list li.gap { display: block; color: var(--paper-faint); border: 0; padding: 0; text-align: center; }

/* ------------------------------------------------------------ dock */

.dock-sheet h2 { margin-top: -6px; }
.purse-line { font-size: 14px; color: var(--paper-dim); display: flex; align-items: center; gap: 7px; }
.purse-line b { color: var(--paper); font-size: 18px; }

.shop { display: flex; flex-direction: column; border-top: 1px solid var(--paper-faint); }
.item {
  display: grid; grid-template-columns: 24px 1fr auto; align-items: baseline; gap: 12px;
  width: 100%; padding: 11px 6px;
  border-bottom: 1px solid var(--paper-faint);
  transition: background 0.15s;
}
.item:hover { background: rgba(232, 238, 230, 0.07); }
.item .letter { color: var(--paper-dim); }
.item-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.item-text b { font-family: var(--fell); font-weight: 400; font-size: 19px; }
.item-text small { font-size: 12.5px; color: var(--paper-dim); line-height: 1.4; }
.price { font-size: 13px; white-space: nowrap; }
.item:hover .price { color: var(--amber); }
.item.cant { opacity: 0.45; }
.item.maxed { opacity: 0.45; cursor: default; }
.item.maxed:hover, .item.cant:hover { background: none; }
.dock-sheet .begin { align-self: flex-end; }

/* ------------------------------------------------------------ last entry */

.last-entry h2 { font-style: italic; font-size: 38px; }
.score-line { font-size: 15px; padding-top: 12px; border-top: 1px solid var(--paper-faint); }
.score-line b { font-family: var(--fell); font-weight: 400; font-size: 30px; margin-left: 6px; }

/* ------------------------------------------------------------ small pearl mark */

.pearl {
  flex: none; display: inline-block; width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--paper);
  box-shadow: inset -2px -2px 0 rgba(32, 71, 140, 0.45);
}

/* ------------------------------------------------------------ HUD */

#hud {
  position: fixed; inset: 0; pointer-events: none;
  text-shadow: 0 1px 0 var(--blue-deep), 0 0 6px rgba(8, 20, 50, 0.8);
}
.hud-top {
  position: absolute; top: calc(12px + var(--safe-t)); left: calc(16px + var(--safe-l)); right: calc(12px + var(--safe-r));
  display: flex; align-items: flex-start; justify-content: space-between; gap: 10px;
}
.hud-score { font-size: 13px; color: var(--paper-dim); padding-top: 6px; }
.hud-score span { font-family: var(--fell); font-size: 26px; color: var(--paper); margin-right: 4px; }
.hud-depth {
  position: absolute; left: 50%; transform: translateX(-50%);
  font-family: var(--fell); font-style: italic; font-size: 26px; white-space: nowrap;
}
.hud-right { display: flex; gap: 10px; align-items: flex-start; }
.hud-stock { display: flex; align-items: center; gap: 16px; font-size: 13px; color: var(--paper-dim); padding-top: 9px; }
.stock-item { display: inline-flex; align-items: center; gap: 6px; }
.purse { color: var(--paper); gap: 5px; }
.marks { display: inline-flex; align-items: center; gap: 3px; }
.marks b { margin-left: 3px; color: var(--paper); font-weight: 400; }
.hull i { width: 9px; height: 11px; background: var(--paper); }
.sonars i { width: 10px; height: 10px; border: 1px solid var(--paper); border-radius: 50%; box-shadow: inset 0 0 0 2px var(--blue), inset 0 0 0 3px var(--paper); }

.pause-btn {
  pointer-events: auto;
  width: 38px; height: 38px;
  display: grid; place-items: center;
  font-size: 20px; line-height: 1;
  border: 1px solid var(--paper-faint);
}
.pause-btn:hover { border-color: var(--paper); }

.hud-bottom {
  position: absolute; left: calc(16px + var(--safe-l)); bottom: calc(14px + var(--safe-b));
  display: flex; flex-direction: column; gap: 6px;
}
.hud-weapon { font-family: var(--fell); font-style: italic; font-size: 21px; }
.hud-air { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--paper-dim); }
.air-cells { display: inline-flex; gap: 4px; }
.air-cells i { width: 10px; height: 10px; border-radius: 50%; border: 1px solid var(--paper-dim); }
.air-cells i.on { background: var(--paper); border-color: var(--paper); }
.hud-air.low { color: var(--amber); }
.hud-air.low .air-cells i.on { background: var(--amber); border-color: var(--amber); animation: blink 0.5s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0.25; } }

.sonar-btn {
  display: none;
  position: absolute; right: calc(16px + var(--safe-r)); bottom: calc(18px + var(--safe-b));
  pointer-events: auto;
  width: 70px; height: 70px; border-radius: 50%;
  flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  background: var(--blue-dim);
  border: 1px solid var(--paper);
  outline: 1px solid var(--paper-faint); outline-offset: 4px;
  text-align: center;
  font-size: 12px;
}
.sonar-btn b { font-weight: 700; font-size: 20px; line-height: 1; }
.sonar-btn:active { background: rgba(242, 169, 59, 0.25); }
body.touch .sonar-btn { display: flex; }

/* ------------------------------------------------------------ first-dive notes */

.hint-line {
  position: fixed; z-index: 6;
  left: calc(16px + var(--safe-l)); bottom: calc(78px + var(--safe-b));
  width: max-content; max-width: min(420px, calc(100% - 110px));
  padding: 8px 14px 9px;
  background: var(--blue-dim);
  border-left: 1px solid var(--amber);
  font-size: 13.5px; line-height: 1.45;
  pointer-events: none;
  animation: hint-in 0.4s ease both;
}
.hint-mark { font-family: var(--fell); font-style: italic; font-size: 16px; color: var(--amber); margin-right: 6px; }
@keyframes hint-in { from { opacity: 0; transform: translateX(-8px); } to { opacity: 1; transform: none; } }

/* ------------------------------------------------------------ field-book plate */

.plate-toast {
  position: fixed; z-index: 5;
  top: calc(64px + var(--safe-t)); right: calc(16px + var(--safe-r));
  width: min(340px, calc(100% - 32px));
  display: grid; grid-template-columns: 76px 1fr; gap: 12px; align-items: start;
  padding: 14px 16px 14px 12px;
  background: var(--blue-dim);
  border: 1px solid var(--paper-faint);
  outline: 1px solid var(--paper-faint); outline-offset: 4px;
  pointer-events: none;
  animation: plate-in 0.45s ease both;
}
@keyframes plate-in { from { opacity: 0; transform: translateY(-8px); } to { opacity: 1; transform: none; } }
.plate-toast canvas { width: 76px; height: 76px; }
.toast-head { font-size: 11px; color: var(--amber); }
.latin { font-family: var(--fell); font-style: italic; font-size: 20px; line-height: 1.15; margin-top: 2px; }
.common { font-size: 12px; color: var(--paper-dim); margin-top: 2px; }
.toast-note { font-size: 12px; line-height: 1.45; margin-top: 6px; color: var(--paper); }

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

@media (max-width: 860px) {
  .title-page { grid-template-columns: minmax(0, 1fr); grid-template-areas: 'mast' 'board' 'notes' 'book'; row-gap: 40px; max-width: 540px; }
  .menu { background: rgba(8, 20, 50, 0.5); }
}

@media (max-width: 640px) {
  .sheet { padding: 24px 20px 22px; }
  .sheet h2 { font-size: 30px; }
  .last-entry h2 { font-size: 31px; }
  .begin { font-size: 26px; }
  .hud-depth { top: 44px; font-size: 21px; }
  .hud-score span { font-size: 21px; }
  .hud-stock { gap: 10px; font-size: 12px; }
  .stock-item.purse { display: none; }
  .hud-weapon { font-size: 18px; }
  .air-cells i { width: 8px; height: 8px; }
  .plate-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .plate canvas { width: 72px; height: 72px; }
  .plate-toast { top: calc(84px + var(--safe-t)); right: 16px; }
  .ad-slot { height: 50px; }
  .menu:has(.ad-banner:not(.hidden)) { padding-bottom: calc(90px + var(--safe-b)); }
  #hud.boss .hud-depth { display: none; }
}

@media (max-width: 380px) {
  .hud-stock .stock-item:not(.purse) { font-size: 0; gap: 0; }
  .hud-stock .stock-item:not(.purse) .marks { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .screen, .plate-toast { animation: none; }
}
