* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 12px;
  background: #c0c0c0;
  font-family: "Times New Roman", Times, serif;
  font-size: 16px;
  color: #000;
}

.window { max-width: 1100px; margin: 0 auto; border: 2px outset #fff; background: #c0c0c0; }

.title-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  background: #000080;
  color: #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-weight: bold;
  padding: 6px 10px;
}
.filed { font-weight: normal; white-space: nowrap; }
.counter {
  display: inline-block;
  font-family: "Courier New", monospace;
  background: #000;
  color: #0f0;
  padding: 1px 4px;
}

.button {
  display: inline-block;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
  background: #c0c0c0;
  color: #000;
  border: 2px outset #fff;
  padding: 4px 12px;
  cursor: pointer;
}
.button:active, .button[aria-pressed="true"] { border-style: inset; }
.button:disabled { color: #808080; cursor: default; }
.button.hover-turn { background: #ffffcc; }

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: #d4d0c8;
  border-bottom: 2px groove #fff;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 14px;
}
.spacer { flex: 1; }
.page-label { min-width: 110px; text-align: center; }
.hint { margin: 0; padding: 0 10px 10px; font-size: 14px; color: #333; }

/* Stockbook */
.book {
  display: flex;
  justify-content: center;
  margin: 8px;
  padding: 14px;
  background: #808080;
  border: 2px inset #fff;
  perspective: 1800px;
}
.page {
  flex: 1 1 0;
  min-width: 0;
  max-width: 520px;
  container-type: inline-size;
  background: #151515;
  border: 1px solid #000;
}
.page.left { border-right: 3px solid #000; box-shadow: inset -14px 0 16px -10px rgba(255, 255, 255, 0.14); }
.page.right { box-shadow: inset 14px 0 16px -10px rgba(255, 255, 255, 0.14); }
.strips { padding: 2cqw 0 0; }
.strip {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 1.5cqw;
  height: 19cqw;
  padding: 0 2cqw 1.2cqw;
}
/* The clear band that holds the stamps */
.strip::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 7cqw;
  background: linear-gradient(rgba(255, 255, 255, 0.3), rgba(255, 255, 255, 0.1));
  border-top: 1px solid rgba(255, 255, 255, 0.6);
  border-bottom: 1px solid #000;
  pointer-events: none;
  z-index: 2;
}
.strip.target { background: #26264a; }
.strip.full { animation: full 0.4s; }
@keyframes full { 50% { background: #6b1a14; } }
.page-no { padding: 1.5cqw 2cqw; font: 3cqw "Courier New", monospace; color: #8a8a8a; text-align: center; }

.slotted { flex: none; height: 15cqw; cursor: grab; touch-action: none; }
.slotted.ghost { visibility: hidden; }
.marker { flex: none; align-self: stretch; width: 2px; margin: 3cqw -1px 0; background: #ffff66; }

.slotted img, .loose img {
  display: block;
  width: 100%;
  height: 100%;
  user-select: none;
  -webkit-user-drag: none;
  -webkit-touch-callout: none;
}

/* Page turn */
.book.out-next .page:last-child { transform-origin: left center; animation: fold-out-next 0.17s ease-in forwards; }
.book.in-next .page:first-child { transform-origin: right center; animation: fold-in-next 0.17s ease-out; }
.book.out-prev .page:first-child { transform-origin: right center; animation: fold-out-prev 0.17s ease-in forwards; }
.book.in-prev .page:last-child { transform-origin: left center; animation: fold-in-prev 0.17s ease-out; }
@keyframes fold-out-next { to { transform: rotateY(-90deg); } }
@keyframes fold-in-next { from { transform: rotateY(90deg); } }
@keyframes fold-out-prev { to { transform: rotateY(90deg); } }
@keyframes fold-in-prev { from { transform: rotateY(-90deg); } }

/* Loose stamps */
#loose { position: fixed; inset: 0; overflow: hidden; pointer-events: none; z-index: 30; }
.loose {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: auto;
  cursor: grab;
  touch-action: none;
  will-change: transform;
  filter: drop-shadow(1px 2px 2px rgba(0, 0, 0, 0.45));
}
.loose.held { pointer-events: none; z-index: 2; filter: drop-shadow(5px 9px 6px rgba(0, 0, 0, 0.5)); }
body.dragging, body.dragging * { cursor: grabbing !important; }

/* Inspection window */
.zoom { margin: auto; padding: 0; max-width: min(92vw, 460px); }
.zoom::backdrop { background: rgba(0, 0, 0, 0.45); }
.zoom .close { padding: 0 6px; font-weight: bold; }
.zoom-body { padding: 12px; background: #fff; border: 2px inset #fff; margin: 8px; text-align: center; }
.zoom-body img { max-width: 100%; max-height: 62vh; }
.zoom-caption { margin: 10px 0 0; font-family: Arial, Helvetica, sans-serif; font-size: 15px; font-weight: bold; }

/* Inside cover */
.cover { display: flex; align-items: center; justify-content: center; }
.ex-libris {
  width: 62cqw;
  padding: 5cqw 4cqw;
  background: #fffdf0;
  border: 3px double #000080;
  color: #000080;
  text-align: center;
  font-size: 3.4cqw;
  transform: rotate(-2deg);
}
.ex-libris img { display: block; width: 26cqw; height: auto; margin: 0 auto 3cqw; image-rendering: pixelated; }
.ex-libris em { display: block; margin-top: 3cqw; color: #000; }
.ex-libris b { display: block; font-size: 6cqw; letter-spacing: 0.5cqw; }
.ex-libris small { display: block; margin-top: 3cqw; color: #333; font-size: 2.8cqw; }

/* The Ambassador's cat */
.cat { position: fixed; left: 0; top: 0; width: 122px; height: 88px; z-index: 60; pointer-events: none; image-rendering: pixelated; }
.cat[hidden] { display: none; }

/* Decorations and other notices */
.toast { position: fixed; right: 12px; bottom: 12px; width: 280px; max-width: calc(100vw - 24px); margin: 0; z-index: 80; cursor: pointer; font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.toast[hidden] { display: none; }
.toast-body { display: flex; align-items: center; gap: 10px; padding: 10px; }
.medal { font-size: 30px; line-height: 1; color: #b8860b; text-shadow: 1px 1px 0 #fff; }
.medal.warning { color: #b3261e; font-weight: bold; font-family: Arial, Helvetica, sans-serif; }
.medal[hidden], .toast-image[hidden] { display: none; }
.toast-image { width: 44px; height: auto; flex: none; image-rendering: pixelated; }
.decoration-list { list-style: none; margin: 8px; padding: 6px 10px; background: #fff; border: 2px inset #fff; font-family: Arial, Helvetica, sans-serif; font-size: 14px; }
.decoration-list li { display: flex; gap: 8px; align-items: baseline; padding: 5px 0; border-bottom: 1px dotted #999; }
.decoration-list li:last-child { border-bottom: 0; }
.decoration-list .locked { color: #808080; }
.decoration-scroll { max-height: 70vh; overflow-y: auto; }
.decoration-heading { margin: 10px 10px 0; font-family: Arial, Helvetica, sans-serif; font-size: 14px; font-weight: bold; }
.decoration-list .progress { margin-left: auto; font-family: "Courier New", monospace; white-space: nowrap; }
.decoration-list .medal { font-size: 18px; text-shadow: none; }
.decoration-list .locked .medal { color: #b0b0b0; }

@media (max-width: 700px) {
  body { padding: 4px; }
  .title-bar { font-size: 13px; }
  .book { margin: 4px; padding: 6px; }
  .page { max-width: none; }
  .page.left, .page.right { border-right: 1px solid #000; box-shadow: none; }
  .cover { aspect-ratio: 1 / 1.04; }
  .toolbar .button { padding: 4px 8px; }
  .spacer { flex-basis: 100%; height: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .book .page { animation: none !important; }
}
