:root {
  color-scheme: light;
  --ink: #171512;
  --muted: #6a6258;
  --paper: #fff8ea;
  --panel: #ffffff;
  --line: #d8c9a9;
  --accent: #f2c94c;
  --accent-strong: #b07612;
  --blue: #1f6f8b;
  --green: #357b4c;
  --shadow: 0 18px 50px rgba(28, 22, 14, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(255, 248, 234, 0.86), rgba(230, 243, 238, 0.9)),
    #f5efe3;
  color: var(--ink);
}

body.home-page {
  min-height: 100vh;
  background:
    linear-gradient(120deg, rgba(255, 248, 234, 0.94), rgba(226, 241, 236, 0.92)),
    #f7efe2;
}

button,
input {
  font: inherit;
}

.home-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  align-content: center;
  gap: 34px;
  padding: 32px 18px;
}

.brand {
  display: grid;
  gap: 14px;
  justify-items: center;
  text-align: center;
}

.brand p {
  max-width: 620px;
  margin: 0;
  color: var(--muted);
  font-size: 1.08rem;
  line-height: 1.45;
}

.logo {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  color: var(--ink);
  text-decoration: none;
}

.flag-mark {
  width: 72px;
  height: 48px;
  display: grid;
  overflow: hidden;
  border: 3px solid var(--ink);
  border-radius: 8px;
  box-shadow: 8px 8px 0 rgba(23, 21, 18, 0.12);
  transform: rotate(-2deg);
}

.flag-indonesia span:first-child {
  background: #d82027;
}

.flag-indonesia span:last-child {
  background: #ffffff;
}

.flag-japan {
  place-items: center;
  background: #ffffff;
}

.flag-japan i {
  display: block;
  width: 42%;
  aspect-ratio: 1;
  border-radius: 999px;
  background: #bc002d;
}

.dual-flag-mark {
  position: relative;
  width: 120px;
  height: 72px;
  display: block;
}

.dual-flag-mark .flag-mark {
  position: absolute;
  margin: 0;
}

.dual-flag-mark .flag-indonesia {
  left: 0;
  top: 4px;
  transform: rotate(-5deg);
}

.dual-flag-mark .flag-japan {
  right: 0;
  bottom: 0;
  transform: rotate(4deg);
}

.language-logo {
  align-items: center;
}

.language-links {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  width: min(920px, 100%);
  margin: 0 auto;
}

.language-card {
  min-height: 230px;
  display: grid;
  place-items: center;
  gap: 18px;
  padding: 28px 20px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.95);
  color: var(--ink);
  text-align: center;
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.language-card:hover,
.language-card:focus-visible {
  outline: none;
  transform: translateY(-3px);
  box-shadow: 0 22px 54px rgba(28, 22, 14, 0.22);
}

.language-card .flag-mark {
  width: 132px;
  height: 88px;
  transform: rotate(-2deg);
}

.language-card strong,
.language-card em {
  display: block;
  font-style: normal;
  letter-spacing: 0;
}

.language-card strong {
  font-size: clamp(1.6rem, 3vw, 2.4rem);
  line-height: 1.05;
}

.language-card em {
  margin-top: 6px;
  color: var(--muted);
  line-height: 1.3;
}

.logo strong,
.logo em {
  display: block;
  font-style: normal;
  line-height: 0.96;
  letter-spacing: 0;
}

.logo strong {
  font-size: clamp(2.3rem, 6vw, 5.25rem);
  font-weight: 900;
}

.logo em {
  margin-top: 5px;
  color: var(--accent-strong);
  font-size: clamp(1.35rem, 3vw, 2.35rem);
  font-weight: 800;
}

.comic-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}

.comic-card {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
  min-height: 100%;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.95);
  color: var(--ink);
  text-decoration: none;
  box-shadow: var(--shadow);
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.comic-card:hover,
.comic-card:focus-visible {
  outline: none;
  transform: translateY(-3px);
  box-shadow: 0 22px 54px rgba(28, 22, 14, 0.22);
}

.comic-card img {
  display: block;
  width: 100%;
  aspect-ratio: 3 / 2;
  object-fit: cover;
  border-bottom: 2px solid var(--ink);
}

.comic-card span {
  display: grid;
  align-content: start;
  gap: 6px;
  padding: 16px;
}

.comic-card strong,
.comic-card em {
  display: block;
  font-style: normal;
  letter-spacing: 0;
}

.comic-card strong {
  font-size: clamp(1.15rem, 2vw, 1.55rem);
  line-height: 1.12;
}

.comic-card em {
  color: var(--muted);
  line-height: 1.35;
}

.app-shell {
  width: min(1600px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  padding: 18px;
}

.comic-workspace,
.glossary {
  min-width: 0;
}

.glossary-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
}

.back-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.back-link:hover,
.back-link:focus-visible {
  border-color: var(--accent-strong);
  outline: none;
}

h1,
h2 {
  margin: 0;
  line-height: 1.05;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.35rem, 2vw, 2.2rem);
}

h2 {
  font-size: 1.1rem;
}

.comic-frame {
  position: relative;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #efe4cb;
  box-shadow: var(--shadow);
}

.comic-frame img {
  display: block;
  width: 100%;
  height: auto;
}

.mobile-panels {
  display: none;
}

.mobile-panel {
  position: relative;
  width: 100%;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background-color: #efe4cb;
  box-shadow: var(--shadow);
}

.mobile-panel canvas {
  display: block;
  width: 100%;
  height: auto;
}

.hotspot-layer,
.hotspot {
  position: absolute;
}

.hotspot-layer {
  inset: 0;
}

.hotspot {
  border: 0;
  padding: 0;
  border-radius: 8px;
  background: rgba(242, 201, 76, 0);
  cursor: help;
  transition:
    background-color 160ms ease,
    box-shadow 160ms ease,
    outline-color 160ms ease;
}

.hotspot::after {
  content: attr(data-short);
  position: absolute;
  left: 4px;
  top: 4px;
  max-width: calc(100% - 8px);
  padding: 2px 5px;
  border-radius: 5px;
  background: rgba(23, 21, 18, 0.8);
  color: #fffdf7;
  font-size: clamp(0.48rem, 0.85vw, 0.78rem);
  line-height: 1.1;
  opacity: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  pointer-events: none;
}

.hotspot:hover,
.hotspot:focus-visible,
.hotspot.is-active {
  outline: 3px solid var(--blue);
  background: rgba(31, 111, 139, 0.16);
  box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.7);
}

.glossary {
  align-self: start;
  max-height: calc(100vh - 36px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.93);
  box-shadow: var(--shadow);
  padding: 16px;
}

#clear-selection {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
}

#clear-selection:hover,
#clear-selection:focus-visible {
  border-color: var(--accent-strong);
  outline: none;
}

.glossary-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.glossary-item {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  color: inherit;
  text-align: left;
  padding: 10px;
  cursor: pointer;
}

.glossary-item:hover,
.glossary-item:focus-visible,
.glossary-item.is-active {
  border-color: var(--blue);
  outline: none;
  box-shadow: inset 4px 0 0 var(--blue);
}

.glossary-item strong {
  display: block;
  font-size: 0.98rem;
  line-height: 1.2;
  margin-bottom: 3px;
}

.glossary-item span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.3;
}

.tooltip {
  position: fixed;
  z-index: 20;
  max-width: min(360px, calc(100vw - 24px));
  padding: 12px 14px;
  border: 1px solid rgba(23, 21, 18, 0.22);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.98);
  box-shadow: 0 14px 38px rgba(28, 22, 14, 0.22);
  opacity: 0;
  transform: translate(-50%, calc(-100% - 14px));
  pointer-events: none;
  transition: opacity 120ms ease;
}

.tooltip.has-close {
  pointer-events: auto;
}

.tooltip[data-placement="below"] {
  transform: translate(-50%, 14px);
}

.tooltip.is-visible {
  opacity: 1;
}

.tooltip b,
.tooltip span {
  display: block;
}

.tooltip b {
  margin-bottom: 4px;
  font-size: 1rem;
}

.tooltip span {
  color: var(--muted);
  line-height: 1.3;
}

.tooltip-close {
  position: absolute;
  right: 8px;
  top: 8px;
  width: 26px;
  height: 26px;
  border: 1px solid rgba(23, 21, 18, 0.18);
  border-radius: 999px;
  background: #fffdf7;
  color: var(--ink);
  cursor: pointer;
  font-size: 18px;
  line-height: 20px;
}

.tooltip-close:hover,
.tooltip-close:focus-visible {
  border-color: var(--accent-strong);
  outline: none;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .language-links {
    grid-template-columns: 1fr;
  }

  .glossary {
    max-height: none;
  }

  .glossary-list {
    grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  }
}

@media (max-width: 560px) {
  .home-shell {
    align-content: start;
    padding-top: 22px;
  }

  .logo {
    align-items: flex-start;
  }

  .flag-mark {
    width: 52px;
    height: 36px;
    border-width: 2px;
  }

  .dual-flag-mark {
    width: 84px;
    height: 54px;
  }

  .language-card .flag-mark {
    width: 112px;
    height: 74px;
    border-width: 3px;
  }

  .app-shell {
    padding: 10px;
    gap: 12px;
  }

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .comic-scroll {
    display: none;
  }

  .mobile-panels {
    display: grid;
    gap: 10px;
  }

  .tooltip b {
    padding-right: 28px;
  }

  .tooltip,
  .tooltip[data-placement="below"] {
    left: 50% !important;
    top: 62vh !important;
    bottom: auto;
    width: min(360px, calc(100vw - 24px));
    max-height: min(45vh, 360px);
    overflow: auto;
    transform: translate(-50%, -50%);
  }

  .hotspot::after {
    display: none;
  }
}

@media (min-width: 561px) {
  .tooltip.has-close {
    pointer-events: none;
  }

  .tooltip-close {
    display: none;
  }
}
