/* ==================================================================
   BAKUNAWA ISLES · THE COMPLETE DESIGN
   A readable, phone-safe design volume opened from the title screen
   and from the help panel. It never covers the game permanently.
   ================================================================== */

.design-overlay {
  position: fixed;
  inset: 0;
  z-index: 240;
  display: flex;
  padding: min(18px, 2.2vh);
  background: rgba(4, 14, 22, 0.78);
  -webkit-backdrop-filter: blur(5px);
  backdrop-filter: blur(5px);
}

.design-sheet {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(1120px, 100%);
  height: min(940px, 100%);
  margin: auto;
  overflow: hidden;
  background: #f7ead0;
  border: 3px solid #6b3d1f;
  border-radius: 24px;
  box-shadow: 0 18px 0 rgba(20, 8, 3, 0.3), 0 34px 70px rgba(0, 0, 0, 0.45);
  color: #33200f;
}

.design-top {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 18px;
  color: #fff6dd;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.08), rgba(0, 0, 0, 0.08)),
    #0b3a44;
  border-bottom: 3px solid #6b3d1f;
}

.design-kicker {
  display: block;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.18em;
  color: #ffd265;
}

.design-top strong {
  display: block;
  font-family: var(--font-display);
  font-size: clamp(17px, 2vw, 23px);
  font-weight: 800;
  line-height: 1.1;
  color: #fff6d8;
}

.design-close {
  flex: 0 0 auto;
  min-width: 44px;
  min-height: 44px;
  padding: 0 14px;
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #3a2116;
  background: linear-gradient(#fff8e8, #f0cf8e);
  border: 2px solid #6b3d1f;
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(58, 33, 22, 0.3);
  cursor: pointer;
}

.design-close:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(58, 33, 22, 0.3);
}

.design-scroll {
  flex: 1 1 auto;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  scrollbar-color: #c89a55 #f0d6a6;
}

.design-body {
  display: grid;
  grid-template-columns: 210px minmax(0, 1fr);
  gap: 30px;
  width: 100%;
  max-width: 1040px;
  margin: 0 auto;
  padding: 24px 28px 88px;
}

.design-toc {
  position: sticky;
  top: 0;
  align-self: start;
  padding: 10px 0 14px;
}

.design-toc-label {
  margin: 0 0 8px;
  font-family: var(--font-display);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #8a5a2b;
}

.design-toc-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.design-toc button {
  display: flex;
  gap: 8px;
  width: 100%;
  padding: 6px 8px;
  text-align: left;
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
  color: #56371f;
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.design-toc button:hover,
.design-toc button:focus-visible {
  background: #efd6ab;
  color: #1d5a55;
  outline: none;
}

.design-toc .toc-num {
  flex: 0 0 18px;
  font-family: var(--font-num);
  font-size: 10px;
  color: #a55818;
}

.design-article {
  min-width: 0;
  max-width: 78ch;
}

.design-lead {
  margin: 0 0 10px;
  font-family: var(--font-display);
  font-size: clamp(19px, 2.4vw, 26px);
  font-weight: 800;
  line-height: 1.25;
  color: #173f46;
}

.design-note {
  margin: 14px 0 24px;
  padding: 12px 15px;
  font-size: 13px;
  line-height: 1.6;
  color: #4a2e17;
  background: #f1d7a9;
  border-left: 6px solid #c98a3c;
  border-radius: 0 10px 10px 0;
}

.design-note b {
  color: #8a3d0b;
}

.design-article section {
  padding-top: 10px;
  margin: 0 0 34px;
  scroll-margin-top: 12px;
}

.design-article h2 {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin: 0 0 10px;
  padding-bottom: 7px;
  font-family: var(--font-display);
  font-size: clamp(22px, 2.7vw, 30px);
  font-weight: 800;
  line-height: 1.1;
  color: #0b3a44;
  border-bottom: 3px solid #d8b270;
}

.design-article h2 .d-num {
  flex: 0 0 auto;
  font-family: var(--font-num);
  font-size: 13px;
  letter-spacing: 0.08em;
  color: #b85b14;
}

.design-article h3 {
  margin: 22px 0 8px;
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
  color: #1d5a55;
}

.design-article h4 {
  margin: 16px 0 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 800;
  color: #8a3d0b;
}

.design-article p {
  margin: 0 0 11px;
  font-size: 14.5px;
  line-height: 1.68;
}

.design-article ul,
.design-article ol {
  margin: 0 0 13px;
  padding-left: 20px;
}

.design-article li {
  margin: 0 0 6px;
  font-size: 14.5px;
  line-height: 1.6;
}

.design-article li > b {
  color: #1d5a55;
}

.design-article a {
  color: #0f6f68;
}

.design-article strong {
  color: #3a2116;
}

.design-callout {
  margin: 14px 0 18px;
  padding: 12px 15px;
  font-size: 13px;
  line-height: 1.6;
  color: #224b45;
  background: #e3f0e1;
  border-left: 6px solid #4fa65b;
  border-radius: 0 10px 10px 0;
}

.design-callout b {
  color: #245d2c;
}

.design-table-wrap {
  width: 100%;
  margin: 10px 0 16px;
  overflow-x: auto;
  border: 2px solid #d8b270;
  border-radius: 12px;
  background: #fff5e2;
}

.design-article table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 12.5px;
  line-height: 1.5;
}

.design-article th,
.design-article td {
  padding: 7px 10px;
  text-align: left;
  vertical-align: top;
  border-bottom: 1px solid #e4c995;
}

.design-article th {
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #fff6dd;
  background: #1d5a55;
}

.design-article tr:last-child td {
  border-bottom: 0;
}

.design-article tr:nth-child(even) td {
  background: rgba(240, 214, 166, 0.34);
}

.design-small {
  font-size: 12px;
  color: #6b4a2c;
}

.design-rule {
  height: 2px;
  margin: 26px 0;
  background: repeating-linear-gradient(90deg, #d8b270 0 8px, transparent 8px 14px);
}

.design-tasks {
  margin: 0;
  padding: 0;
  list-style: none;
  counter-reset: task;
}

.design-tasks li {
  counter-increment: task;
  position: relative;
  margin: 0 0 9px;
  padding: 9px 12px 9px 44px;
  background: #fff5e2;
  border: 2px solid #e4c995;
  border-radius: 10px;
  font-size: 13.5px;
  line-height: 1.5;
}

.design-tasks li::before {
  content: counter(task, decimal-leading-zero);
  position: absolute;
  top: 9px;
  left: 11px;
  font-family: var(--font-num);
  font-size: 11px;
  color: #b85b14;
}

.design-back {
  display: block;
  width: 100%;
  margin: 28px 0 0;
  padding: 12px;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.04em;
  color: #3a2116;
  background: linear-gradient(#fff8e8, #f0cf8e);
  border: 2px solid #6b3d1f;
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(58, 33, 22, 0.3);
  cursor: pointer;
}

body.design-open {
  overflow: hidden;
}

@media (max-width: 820px) {
  .design-overlay {
    padding: 0;
  }

  .design-sheet {
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
    border-radius: 0;
  }

  .design-body {
    grid-template-columns: minmax(0, 1fr);
    gap: 0;
    padding: 14px 16px 64px;
  }

  .design-toc {
    position: static;
    padding: 0 0 12px;
    overflow: visible;
  }

  .design-toc-list {
    flex-direction: row;
    gap: 6px;
    overflow-x: auto;
    padding-bottom: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .design-toc button {
    flex: 0 0 auto;
    width: auto;
    padding: 7px 10px;
    white-space: nowrap;
    font-size: 11px;
    background: #efd6ab;
  }

  .design-toc .toc-num {
    flex-basis: auto;
  }

  .design-article {
    max-width: none;
  }

  .design-article p,
  .design-article li {
    font-size: 14px;
  }

  .design-article table {
    min-width: 460px;
  }
}

@media (max-height: 520px) {
  .design-overlay {
    padding: 0;
  }

  .design-top {
    padding: 8px 14px;
  }

  .design-top strong {
    font-size: 16px;
  }

  .design-lead {
    font-size: 18px;
  }

  .design-article section {
    margin-bottom: 24px;
  }
}

/* Title and help entry points for the design volume. */
.design-open-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 20px;
  color: #fff2cf;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: rgba(11, 58, 68, 0.72);
  border: 2px solid #ffc247;
  border-radius: 999px;
  box-shadow: 0 4px 0 rgba(3, 10, 22, 0.45), inset 0 0 0 1px rgba(255, 242, 207, 0.18);
  cursor: pointer;
}

.design-open-btn::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #ffc247;
  box-shadow: 0 0 0 3px rgba(255, 194, 71, 0.22);
}

.design-open-btn:hover,
.design-open-btn:focus-visible {
  border-color: #fff2cf;
  color: #ffffff;
  outline: none;
}

.design-open-btn:active {
  transform: translateY(2px);
  box-shadow: 0 2px 0 rgba(3, 10, 22, 0.45);
}

.help-design {
  display: block;
  width: 100%;
  margin: 14px 0 0;
  padding: 10px 12px;
  color: #3a2116;
  font-family: var(--font-display);
  font-size: 13px;
  font-weight: 800;
  background: #ffd98a;
  border: 2px solid #6b3d1f;
  border-radius: 10px;
  box-shadow: 0 3px 0 rgba(58, 33, 22, 0.28);
  cursor: pointer;
}

.help-design:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(58, 33, 22, 0.28);
}

@media (max-width: 640px) {
  .design-open-btn {
    margin-top: 8px;
    padding: 8px 16px;
    font-size: 12px;
  }
}

@media (max-width: 700px) {
  .design-table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }

  .design-article table {
    display: block;
    min-width: 0;
    width: 100%;
    font-size: 13px;
  }

  .design-article thead {
    display: none;
  }

  .design-article tbody,
  .design-article tr,
  .design-article td {
    display: block;
    width: 100%;
  }

  .design-article tr {
    margin: 0 0 10px;
    padding: 9px 11px;
    background: #fff5e2;
    border: 2px solid #e4c995;
    border-radius: 10px;
  }

  .design-article tr:nth-child(even) td {
    background: transparent;
  }

  .design-article td {
    padding: 5px 0;
    border: 0;
  }

  .design-article td::before {
    content: attr(data-label);
    display: block;
    margin-bottom: 1px;
    font-family: var(--font-display);
    font-size: 9px;
    font-weight: 800;
    letter-spacing: 0.09em;
    text-transform: uppercase;
    color: #a55818;
  }

  .design-article td:first-child {
    padding-bottom: 7px;
    margin-bottom: 5px;
    border-bottom: 1px solid #e4c995;
    font-family: var(--font-display);
    font-size: 15px;
    font-weight: 800;
    color: #0b3a44;
  }

  .design-article td:first-child::before {
    display: none;
  }

  .design-article td + td {
    font-size: 13px;
    line-height: 1.55;
  }
}

.design-top-toggle {
  top: calc(max(10px, env(safe-area-inset-top)) + 38px);
  right: 12px;
  letter-spacing: 0.06em;
}

@media (max-height: 780px) {
  .design-open-btn {
    display: none;
  }
}
