:root {
  --ink: #f8f8f2;
  --paper: #050505;
  --surface: #111111;
  --muted: #272727;
  --mint: #45c7a5;
  --coral: #f06b57;
  --lemon: #ffd54d;
  --sky: #83c7ee;
  --violet: #7058c8;
  --page-width: 1120px;
  --page-gap: 34px;
}

* {
  box-sizing: border-box;
}

body {
  background: var(--paper);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  margin: 0;
}

body.dark {
  --ink: #211d1a;
  --paper: #fff7e8;
  --surface: #ffffff;
  --muted: #efe6d4;
}

button,
input {
  font: inherit;
}

.reader-header {
  align-items: center;
  background: rgba(0, 0, 0, .94);
  border-bottom: 3px solid var(--ink);
  display: flex;
  gap: 22px;
  justify-content: space-between;
  padding: 14px clamp(16px, 4vw, 44px);
  position: sticky;
  top: 0;
  z-index: 30;
}

.logo,
.reader-header a,
.tool-link {
  color: var(--ink);
  text-decoration: none;
}

.reader-header .logo,
.reader-header a {
  color: #fff;
}

.reader-header .icon-button {
  background: #050505;
  border-color: #fff;
  color: #fff;
}

.logo {
  width: min(220px, 52vw);
}

.logo img {
  display: block;
  height: auto;
  width: 100%;
}

.reader-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  justify-content: center;
}

.reader-header nav a {
  font-weight: 800;
}

.icon-button,
.toolbar button,
.tool-link,
.mode-tabs button,
.page-controls button,
.choice-row button {
  background: var(--surface);
  border: 3px solid var(--ink);
  color: var(--ink);
  cursor: pointer;
  font-weight: 900;
}

.icon-button {
  height: 42px;
  width: 42px;
}

.reader {
  padding: 18px clamp(12px, 3vw, 42px) 54px;
}

.toolbar {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 0 auto 14px;
  max-width: 960px;
}

.toolbar button,
.tool-link {
  align-items: center;
  display: flex;
  gap: 10px;
  justify-content: center;
  min-height: 54px;
  padding: 10px;
}

.toolbar span {
  font-size: 1.25rem;
}

.comfort-panel {
  background: var(--surface);
  border: 3px solid var(--ink);
  display: none;
  gap: 16px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin: 0 auto 14px;
  max-width: 960px;
  padding: 14px;
}

.comfort-panel.open {
  display: grid;
}

.comfort-panel label {
  display: grid;
  font-size: .9rem;
  font-weight: 900;
  gap: 8px;
}

.comfort-note {
  align-self: center;
  font-size: .9rem;
  font-weight: 900;
  margin: 0;
}

.mode-tabs {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin: 0 auto 12px;
  max-width: 760px;
}

.mode-tabs button {
  flex: 1;
  padding: 12px 10px;
}

.mode-tabs button.active,
.page-controls button,
.choice-row button.active {
  background: var(--lemon);
  color: #211d1a;
}

.reader-status {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin: 0 auto 18px;
  max-width: 960px;
}

.reader-status span {
  background: var(--surface);
  border: 3px solid var(--ink);
  font-weight: 900;
  padding: 8px 10px;
}

.pages {
  align-items: center;
  display: grid;
  gap: var(--page-gap);
  justify-content: center;
  margin: 0 auto;
  max-width: min(var(--page-width), 100%);
}

.comic-page {
  aspect-ratio: 4 / 3;
  background: var(--surface);
  border: 4px solid #211d1a;
  box-shadow: 8px 8px 0 #211d1a;
  color: #211d1a;
  display: grid;
  grid-template-rows: auto auto 1fr;
  max-width: min(var(--page-width), 100%);
  min-height: 420px;
  overflow: hidden;
  padding: clamp(24px, 4vw, 48px);
  position: relative;
  width: var(--page-width);
}

.image-page {
  aspect-ratio: auto;
  background: #000;
  display: block;
  height: auto;
  min-height: auto;
  overflow: visible;
  padding: 0;
}

.image-page img {
  display: block;
  height: auto;
  object-fit: contain;
  width: 100%;
}

.comic-page.is-dimmed {
  opacity: 1;
}

.mode-single,
.mode-double {
  min-height: 520px;
}

.mode-single .comic-page,
.mode-double .comic-page {
  display: none;
}

.mode-single .comic-page.visible,
.mode-double .comic-page.visible {
  display: grid;
}

.mode-single .image-page.visible,
.mode-double .image-page.visible {
  display: block;
}

.mode-double {
  align-items: stretch;
  grid-template-columns: repeat(2, minmax(280px, calc(var(--page-width) / 2)));
}

.mode-double .comic-page {
  min-height: 480px;
  width: min(100%, calc(var(--page-width) / 2));
}

.mode-double .image-page {
  align-self: center;
  min-height: auto;
}

.cover-page {
  background: #000;
  color: #fff;
}

.yellow-page {
  background: var(--lemon);
}

.sky-page {
  background: var(--sky);
}

.night-page {
  background: #263252;
  color: #fff7e8;
}

.split-page {
  background: linear-gradient(135deg, var(--mint) 0 50%, var(--coral) 50% 100%);
}

.violet-page {
  background: var(--violet);
  color: #fff7e8;
}

.eyebrow,
.page-number {
  font-size: .82rem;
  font-weight: 900;
  margin: 0 0 12px;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  line-height: .86;
  margin-bottom: 14px;
}

.cover-logo {
  display: block;
  height: auto;
  max-width: 100%;
  width: min(700px, 92%);
}

h2 {
  font-size: clamp(2.1rem, 6vw, 4.7rem);
  line-height: .9;
  max-width: 680px;
}

.subtitle {
  font-size: 1.35rem;
  font-weight: 900;
}

.bubble {
  align-self: end;
  background: #fff;
  border: 3px solid #211d1a;
  border-radius: 0 18px 18px 18px;
  color: #211d1a;
  font-size: clamp(1rem, 2vw, 1.25rem);
  font-weight: 900;
  line-height: 1.25;
  max-width: 520px;
  padding: 15px;
  z-index: 3;
}

.treet {
  background: var(--mint);
  border: 4px solid #211d1a;
  border-radius: 50% 45% 52% 48%;
  display: inline-block;
  height: 112px;
  position: relative;
  width: 112px;
}

.treet::before,
.treet::after {
  background: #211d1a;
  border-radius: 50%;
  content: "";
  height: 12px;
  position: absolute;
  top: 36px;
  width: 12px;
}

.treet::before {
  left: 32px;
}

.treet::after {
  right: 32px;
}

.mint {
  background: var(--mint);
}

.coral {
  background: var(--coral);
}

.lemon {
  background: var(--lemon);
}

.small {
  height: 76px;
  width: 76px;
}

.large {
  height: 210px;
  width: 210px;
}

.crew,
.street-scene,
.window-scene,
.close-scene {
  bottom: 42px;
  position: absolute;
  right: 48px;
}

.crew .treet {
  margin-left: -20px;
}

.awning {
  background: repeating-linear-gradient(90deg, #fff 0 30px, var(--coral) 30px 60px);
  border: 4px solid #211d1a;
  display: block;
  height: 150px;
  width: 260px;
}

.street-scene .mint {
  bottom: -28px;
  left: -78px;
  position: absolute;
}

.street-scene .lemon {
  bottom: -24px;
  right: -34px;
  position: absolute;
}

.glass {
  background: linear-gradient(135deg, rgba(255,255,255,.86), rgba(255,255,255,.12));
  border: 4px solid #211d1a;
  display: block;
  height: 220px;
  transform: skew(-6deg);
  width: 320px;
}

.spark {
  background: var(--lemon);
  clip-path: polygon(50% 0, 62% 35%, 100% 50%, 62% 65%, 50% 100%, 38% 65%, 0 50%, 38% 35%);
  display: block;
  height: 76px;
  position: absolute;
  right: -26px;
  top: -28px;
  width: 76px;
}

.choice-row {
  align-self: end;
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 180px));
  z-index: 4;
}

.choice-row button {
  padding: 16px;
}

.page-controls {
  display: flex;
  gap: 14px;
  justify-content: center;
  margin-top: 22px;
}

.page-controls button {
  padding: 13px 18px;
}

.fullscreen-button {
  background: var(--lemon);
  border: 3px solid #211d1a;
  bottom: 18px;
  box-shadow: 4px 4px 0 #211d1a;
  color: #211d1a;
  cursor: pointer;
  font-size: 1.25rem;
  height: 52px;
  position: fixed;
  right: 18px;
  width: 52px;
  z-index: 40;
}

.favorites-drawer {
  background: var(--surface);
  border-right: 4px solid var(--ink);
  bottom: 0;
  box-shadow: 8px 0 0 rgba(0, 0, 0, .18);
  left: 0;
  padding: 18px;
  position: fixed;
  top: 0;
  transform: translateX(-105%);
  transition: transform .24s ease;
  width: min(340px, 88vw);
  z-index: 60;
}

.favorites-drawer.open {
  transform: translateX(0);
}

.drawer-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.drawer-head h2 {
  font-size: 1.6rem;
  margin-bottom: 0;
}

.favorites-list {
  display: grid;
  gap: 10px;
  margin-top: 18px;
}

.favorites-list button {
  background: var(--lemon);
  border: 3px solid var(--ink);
  color: #211d1a;
  cursor: pointer;
  font-weight: 900;
  padding: 10px;
  text-align: left;
}

@media (max-width: 820px) {
  .reader-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .toolbar,
  .comfort-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-double {
    grid-template-columns: 1fr;
  }

  .mode-double .comic-page {
    width: min(var(--page-width), 100%);
  }
}

@media (max-width: 560px) {
  .toolbar,
  .comfort-panel,
  .choice-row {
    grid-template-columns: 1fr;
  }

  .reader-status,
  .page-controls,
  .mode-tabs {
    align-items: stretch;
    flex-direction: column;
  }

  .comic-page {
    min-height: 520px;
  }

  .crew,
  .street-scene,
  .window-scene,
  .close-scene {
    bottom: 22px;
    right: 22px;
    transform: scale(.68);
    transform-origin: bottom right;
  }
}
