:root {
  --navy: #00145f;
  --blue: #0645d6;
  --cyan: #00b7b7;
  --yellow: #ffe11a;
  --pink: #ff3e9e;
  --red: #c9152f;
  --paper: #fffde8;
  --panel: #f3f0d3;
  --ink: #161616;
  --muted: #55534d;
  --line: #77735f;
  --shadow: #202020;
  --link: #0000c8;
}

* {
  box-sizing: border-box;
}

html {
  color-scheme: light;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-width: 300px;
  color: var(--ink);
  font-family: "PMingLiU", "MingLiU", "Times New Roman", serif;
  font-size: 16px;
  line-height: 1.55;
  background-color: #0d7395;
  background-image:
    linear-gradient(45deg, rgba(255, 255, 255, 0.12) 25%, transparent 25%, transparent 75%, rgba(255, 255, 255, 0.12) 75%),
    linear-gradient(45deg, rgba(0, 0, 0, 0.09) 25%, transparent 25%, transparent 75%, rgba(0, 0, 0, 0.09) 75%);
  background-position: 0 0, 12px 12px;
  background-size: 24px 24px;
}

body[data-theme="bbs"] {
  --paper: #05120b;
  --panel: #071d13;
  --ink: #b5ffbd;
  --muted: #76c984;
  --line: #268c43;
  --shadow: #000;
  --link: #71e4ff;
  color-scheme: dark;
  background-color: #020604;
  background-image: linear-gradient(rgba(33, 255, 100, 0.035) 1px, transparent 1px);
  background-size: 100% 4px;
}

a {
  color: var(--link);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

a:hover {
  color: var(--red);
  background: var(--yellow);
}

a:focus-visible,
button:focus-visible {
  outline: 3px dotted var(--pink);
  outline-offset: 3px;
}

img {
  max-width: 100%;
  height: auto;
}

.skip-link {
  position: absolute;
  z-index: 100;
  top: -80px;
  left: 10px;
  padding: 8px 12px;
  color: #000;
  background: var(--yellow);
  border: 3px outset #fff;
}

.skip-link:focus {
  top: 10px;
}

.site-shell {
  width: min(1040px, calc(100% - 24px));
  margin: 14px auto;
  background: var(--paper);
  border: 4px ridge #ded9b8;
  box-shadow: 8px 8px 0 rgba(0, 0, 0, 0.42);
}

.site-header {
  color: #fff;
  background:
    radial-gradient(circle at 86% 25%, #fff 0 1px, transparent 2px),
    radial-gradient(circle at 72% 66%, #fff 0 1px, transparent 2px),
    linear-gradient(135deg, #00104a 0%, #052ab4 50%, #74165f 100%);
  background-size: 47px 43px, 61px 59px, auto;
  border-bottom: 4px solid var(--yellow);
}

.brand-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 118px;
  padding: 14px 20px;
}

.brand-kicker {
  margin: 0 0 2px;
  color: #9ffff4;
  font-family: "Courier New", monospace;
  font-size: 13px;
  letter-spacing: 0.18em;
}

.brand-title {
  margin: 0;
  color: #fff;
  font-family: "Courier New", "PMingLiU", monospace;
  font-size: clamp(34px, 7vw, 68px);
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: -0.07em;
  text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 #00102b;
}

.brand-subtitle {
  margin: 8px 0 0;
  color: var(--yellow);
  font-weight: bold;
  letter-spacing: 0.08em;
}

.header-badge {
  flex: 0 0 142px;
  padding: 10px 8px;
  color: #00104a;
  text-align: center;
  font-family: "Courier New", monospace;
  font-weight: bold;
  line-height: 1.2;
  background: var(--yellow);
  border: 4px outset #fff46f;
  transform: rotate(2deg);
}

.header-badge strong {
  display: block;
  font-size: 24px;
}

.ticker {
  overflow: hidden;
  color: #111;
  background: var(--yellow);
  border-top: 2px solid #fff489;
  white-space: nowrap;
}

.ticker span {
  display: inline-block;
  min-width: 100%;
  padding: 3px 0;
  font-weight: bold;
  animation: ticker 20s linear infinite;
}

@keyframes ticker {
  from { transform: translateX(100%); }
  to { transform: translateX(-100%); }
}

.top-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
  padding: 4px;
  background: #b8b39a;
  border-bottom: 2px solid #4a473b;
}

.top-nav a {
  flex: 1 1 90px;
  min-width: max-content;
  padding: 6px 10px;
  color: #080808;
  text-align: center;
  font-weight: bold;
  text-decoration: none;
  background: #e9e6d4;
  border: 3px outset #fff;
}

.top-nav a:hover,
.top-nav a[aria-current="page"] {
  color: #fff;
  background: var(--navy);
  border-style: inset;
}

.home-grid {
  display: grid;
  grid-template-columns: 178px minmax(0, 1fr) 184px;
  gap: 8px;
  padding: 8px;
}

.content-grid {
  display: grid;
  grid-template-columns: 188px minmax(0, 1fr);
  gap: 10px;
  padding: 10px;
}

.sidebar,
.main-column,
.content-column {
  min-width: 0;
}

.box {
  margin-bottom: 9px;
  color: var(--ink);
  background: var(--panel);
  border: 2px solid var(--line);
  box-shadow: 2px 2px 0 var(--shadow);
}

.box-title {
  margin: 0;
  padding: 3px 7px;
  color: #fff;
  font-family: "Courier New", "PMingLiU", monospace;
  font-size: 15px;
  font-weight: bold;
  background: var(--navy);
  border-bottom: 2px solid var(--line);
}

body[data-theme="bbs"] .box-title {
  color: #07130b;
  background: #7cfb8e;
}

.box-body {
  padding: 9px;
}

.box-body > :first-child {
  margin-top: 0;
}

.box-body > :last-child {
  margin-bottom: 0;
}

.side-menu {
  margin: 0;
  padding: 0;
  list-style: none;
}

.side-menu li + li {
  border-top: 1px dotted var(--line);
}

.side-menu a {
  display: block;
  padding: 5px 7px;
  text-decoration: none;
}

.side-menu a::before {
  content: "▶ ";
  color: var(--pink);
  font-size: 10px;
}

.status-light {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 5px;
  background: #28e94b;
  border: 1px solid #075814;
  border-radius: 50%;
  box-shadow: 0 0 7px #28e94b;
}

.counter {
  display: block;
  margin: 6px auto;
  padding: 4px 7px;
  width: fit-content;
  color: #39ff5a;
  font-family: "Courier New", monospace;
  font-size: 20px;
  letter-spacing: 0.12em;
  background: #050505;
  border: 3px inset #bbb;
}

.small-note {
  color: var(--muted);
  font-size: 13px;
}

.hero-welcome {
  position: relative;
  overflow: hidden;
  padding: 18px;
  color: #061341;
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.76), rgba(255, 255, 255, 0.34)),
    repeating-linear-gradient(135deg, #61e8de 0 10px, #ffe65b 10px 20px, #ff72b7 20px 30px);
  border: 4px double var(--navy);
}

.hero-welcome h1,
.page-heading h1 {
  margin: 0 0 6px;
  font-size: clamp(25px, 5vw, 40px);
  line-height: 1.15;
}

.hero-welcome p {
  max-width: 560px;
  margin: 0;
  font-size: 18px;
  font-weight: bold;
}

.under-construction {
  display: inline-block;
  margin-top: 12px;
  padding: 3px 7px;
  color: #000;
  font-family: "Courier New", monospace;
  font-weight: bold;
  background: var(--yellow);
  border: 2px dashed #000;
}

.section-heading {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 16px 0 8px;
  padding: 4px 8px;
  color: #fff;
  font-size: 19px;
  background: var(--navy);
  border-left: 10px solid var(--pink);
  border-bottom: 3px solid var(--yellow);
}

.section-heading::before {
  content: "◆";
  color: var(--yellow);
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mini-card,
.meme-card,
.food-card,
.post-card {
  padding: 10px;
  background: var(--paper);
  border: 3px outset #d9d4b4;
}

.mini-card h3,
.meme-card h2,
.food-card h2,
.post-card h2 {
  margin: 0 0 5px;
  color: var(--navy);
  font-size: 19px;
  line-height: 1.3;
}

body[data-theme="bbs"] .mini-card h3,
body[data-theme="bbs"] .meme-card h2,
body[data-theme="bbs"] .food-card h2,
body[data-theme="bbs"] .post-card h2 {
  color: #7cfb8e;
}

.tag {
  display: inline-block;
  margin: 2px 2px 2px 0;
  padding: 1px 5px;
  color: #111;
  font-size: 12px;
  font-weight: bold;
  background: var(--yellow);
  border: 1px solid #7c7100;
}

.page-heading {
  margin-bottom: 12px;
  padding: 14px;
  color: #fff;
  background: linear-gradient(90deg, var(--navy), #137e98);
  border: 4px double var(--yellow);
}

.page-heading p {
  margin: 0;
  color: #eaffff;
}

.filter-bar,
.theme-controls,
.era-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
  padding: 8px;
  background: #cac5ad;
  border: 3px inset #eee;
}

button,
.button-link {
  display: inline-block;
  padding: 6px 10px;
  color: #111;
  font: bold 15px "PMingLiU", "MingLiU", serif;
  text-decoration: none;
  background: #ece9d8;
  border: 3px outset #fff;
  cursor: pointer;
}

button:hover,
.button-link:hover,
button[aria-pressed="true"] {
  color: #fff;
  background: var(--navy);
  border-style: inset;
}

.meme-list,
.food-list,
.post-list {
  display: grid;
  gap: 14px;
}

.meme-placeholder {
  display: grid;
  place-items: center;
  min-height: 250px;
  margin-bottom: 10px;
  padding: 24px;
  color: #f9fffa;
  text-align: center;
  font-family: "Courier New", monospace;
  font-weight: bold;
  background:
    linear-gradient(45deg, transparent 48%, #16346c 48% 52%, transparent 52%),
    linear-gradient(-45deg, transparent 48%, #16346c 48% 52%, transparent 52%),
    #78d6d1;
  background-size: 36px 36px;
  border: 5px inset #d8d8d8;
}

.meme-placeholder span {
  padding: 10px;
  color: #fff;
  background: #00145f;
  border: 2px solid var(--yellow);
}

.meta-line {
  margin: 5px 0;
  color: var(--muted);
  font-size: 14px;
}

.detail-list {
  display: grid;
  grid-template-columns: 90px 1fr;
  margin: 8px 0;
  border-top: 1px dotted var(--line);
}

.detail-list dt,
.detail-list dd {
  margin: 0;
  padding: 4px 2px;
  border-bottom: 1px dotted var(--line);
}

.detail-list dt {
  font-weight: bold;
}

.rating {
  color: #e08a00;
  letter-spacing: 0.08em;
}

.article-body {
  max-width: 720px;
  margin: 0 auto;
  padding: clamp(16px, 4vw, 34px);
  background: var(--paper);
  border: 2px solid var(--line);
  box-shadow: 4px 4px 0 var(--shadow);
}

.article-body h1 {
  margin-top: 0;
  color: var(--navy);
  border-bottom: 4px double var(--line);
}

body[data-theme="bbs"] .article-body h1 {
  color: #7cfb8e;
}

.article-body p {
  margin: 1em 0;
}

.article-nav {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 24px;
  padding-top: 12px;
  border-top: 2px dotted var(--line);
}

.terminal {
  min-height: 250px;
  padding: 14px;
  color: #82ff9b;
  font-family: "Courier New", "MingLiU", monospace;
  background: #020b05;
  border: 8px ridge #8a8a82;
  box-shadow: inset 0 0 28px rgba(48, 255, 93, 0.2);
}

.terminal p {
  margin: 0.3em 0;
}

.terminal .prompt::before {
  content: "C:\\X97> ";
  color: #fff;
}

.modem-panel {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 12px 0;
  padding: 8px 10px;
  color: #111;
  font-family: "Courier New", monospace;
  background: #bcb8a7;
  border: 4px outset #eee;
}

.modem-light {
  width: 13px;
  height: 13px;
  background: #15361d;
  border: 2px inset #777;
  border-radius: 50%;
  animation: blink 1.2s steps(1) infinite;
}

.modem-light:nth-child(2) { animation-delay: 0.25s; }
.modem-light:nth-child(3) { animation-delay: 0.65s; }
.modem-light:nth-child(4) { animation-delay: 0.95s; }

@keyframes blink {
  0%, 45% { background: #16371e; box-shadow: none; }
  46%, 100% { background: #38ff5a; box-shadow: 0 0 8px #38ff5a; }
}

.era-panel {
  margin-bottom: 10px;
}

.era-panel[hidden],
[hidden] {
  display: none !important;
}

.time-table {
  width: 100%;
  margin: 10px 0;
  border-collapse: collapse;
}

.time-table th,
.time-table td {
  padding: 6px;
  text-align: left;
  vertical-align: top;
  border: 1px solid var(--line);
}

.time-table th {
  color: #fff;
  background: var(--navy);
}

.link-button-grid {
  display: grid;
  grid-template-columns: repeat(2, 88px);
  justify-content: center;
  gap: 7px;
}

.web-button {
  display: grid;
  place-items: center;
  width: 88px;
  height: 31px;
  padding: 1px;
  color: #fff;
  text-align: center;
  font: bold 10px/1.05 "Arial Narrow", sans-serif;
  text-decoration: none;
  background: linear-gradient(135deg, #00145f 0 50%, #ff3e9e 50%);
  border: 2px outset #fff;
}

.web-button.alt {
  color: #00145f;
  background: repeating-linear-gradient(45deg, #ffe11a 0 5px, #58efe2 5px 10px);
}

.web-button:hover {
  color: #000;
  background: #fff;
}

.update-list {
  margin: 0;
  padding-left: 20px;
}

.update-list li + li {
  margin-top: 5px;
}

.site-footer {
  padding: 12px;
  color: #fff;
  text-align: center;
  font-family: "Courier New", "MingLiU", monospace;
  font-size: 13px;
  background: var(--navy);
  border-top: 4px solid var(--yellow);
}

.site-footer a {
  color: #fff76b;
}

.site-footer a:hover {
  color: #00145f;
}

.error-page {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.error-box {
  width: min(680px, 100%);
  padding: 28px;
  color: #fff;
  text-align: center;
  background: #00145f;
  border: 8px ridge #eee;
  box-shadow: 10px 10px 0 rgba(0, 0, 0, 0.4);
}

.error-code {
  margin: 0;
  color: var(--yellow);
  font: 900 clamp(72px, 20vw, 150px)/0.85 "Courier New", monospace;
  text-shadow: 5px 5px 0 var(--pink);
}

.no-script {
  margin: 8px;
  padding: 8px;
  color: #000;
  background: #fff3ad;
  border: 2px solid #8d7000;
}

@media (max-width: 860px) {
  .home-grid {
    grid-template-columns: 170px minmax(0, 1fr);
  }

  .home-grid .right-sidebar {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
  }

  .right-sidebar .box {
    margin-bottom: 0;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 15px;
  }

  .site-shell {
    width: calc(100% - 10px);
    margin: 5px auto;
    border-width: 3px;
    box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.38);
  }

  .brand-row {
    min-height: auto;
    padding: 14px 12px;
  }

  .header-badge {
    display: none;
  }

  .brand-title {
    font-size: 39px;
  }

  .top-nav a {
    flex-basis: calc(33.333% - 4px);
    min-width: 0;
    padding-inline: 4px;
  }

  .home-grid,
  .content-grid {
    display: block;
    padding: 6px;
  }

  .home-grid .right-sidebar {
    display: block;
  }

  .right-sidebar .box {
    margin-bottom: 9px;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .sidebar .side-menu {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }

  .side-menu li + li {
    border-top: 0;
  }

  .side-menu li {
    border: 1px dotted var(--line);
  }

  .detail-list {
    grid-template-columns: 78px 1fr;
  }

  .article-nav {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }

  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .ticker span {
    transform: none;
    white-space: normal;
  }
}
