@font-face {
  font-family: "Pixelify Sans";
  src: url("assets/fonts/PixelifySans.ttf") format("truetype");
  font-display: swap;
}

:root {
  --blue: #091f9d;
  --bright-blue: #1026ad;
  --purple: #650077;
  --green: #087016;
  --pink: #ed2e86;
  --yellow: #fff232;
  --orange: #e55019;
  --paper: #eee9d6;
  --panel: #f5f1df;
  --ink: #111111;
  --silver: #c7c7c7;
  --link: #0000ee;
  --visited: #551a8b;
  --c64-blue: #40318d;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 12px; }

body {
  min-width: 0;
  margin: 0;
  color: var(--ink);
  background: #b8b8b8;
  font-family: Arial, Helvetica, sans-serif;
  font-size: 18px;
  font-weight: 500;
  line-height: 1.5;
}

button, input, select { font: inherit; }
button, select { min-height: 42px; }
button { color: var(--ink); }
a { color: var(--link); text-decoration: underline; }
a:visited { color: var(--visited); }
a:hover { color: #d00072; }
:focus-visible { outline: 3px dotted #d10072; outline-offset: 3px; }
img { display: block; max-width: 100%; }
[hidden] { display: none !important; }

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: fixed;
  z-index: 1000;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  border: 3px outset #fff;
  background: var(--yellow);
  color: #000080;
  font-weight: 800;
  transform: translateY(-150%);
}

.skip-link:focus { transform: translateY(0); }
.desktop, .browser-shell { width: 100%; }

.browser-shell {
  max-width: 1200px;
  margin: 0 auto;
  border: 2px outset #eee;
  background: var(--silver);
  box-shadow: 0 0 28px rgba(0, 0, 0, 0.28);
}

.network-strip {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 5px 9px;
  border-top: 1px solid #fff;
  border-bottom: 2px ridge #ddd;
  color: #111459;
  background: var(--yellow);
  font-family: "Courier New", monospace;
  font-size: 13px;
  font-weight: 700;
}

.ticker-window { min-width: 0; flex: 1; overflow: hidden; white-space: nowrap; }
.ticker-track { display: inline-block; min-width: max-content; animation: ticker 18s linear infinite; }
#connectionLabel { flex: 0 0 auto; color: #b0005d; white-space: nowrap; }
.is-connecting #connectionLabel { animation: old-web-blink 0.65s steps(1, end) infinite; }

#mainContent {
  background-color: var(--paper);
  background-image: radial-gradient(#c8bca1 0.75px, transparent 0.75px);
  background-size: 5px 5px;
}

.noscript {
  margin: 0;
  padding: 12px;
  border: 3px double #800000;
  color: #800000;
  background: #fff9bd;
  text-align: center;
  font-weight: 800;
}

.construction-zone {
  display: grid;
  grid-template-columns: 150px 1fr 190px;
  align-items: center;
  gap: 16px;
  margin: 0;
  padding: 12px 20px;
  border-top: 4px double #13269e;
  border-bottom: 4px double #13269e;
  background: #fffce0;
  text-align: center;
}

.construction-zone div { display: grid; gap: 1px; }
.construction-zone strong {
  color: #d70071;
  font-family: "Pixelify Sans", "Courier New", monospace;
  font-size: clamp(20px, 2.5vw, 29px);
  line-height: 1.1;
}
.construction-zone span { color: #142064; font-size: 15px; font-weight: 700; }
.construction-gif, .construction-still { width: 130px; height: 98px; object-fit: contain; image-rendering: pixelated; }
.construction-still { display: none; }
.motion-button { min-height: 42px; padding: 6px 9px; border: 3px outset #eee; color: #101c83; background: #d6d6d6; font-size: 13px; font-weight: 900; cursor: pointer; }
.motion-button:active { border-style: inset; }

.masthead {
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  align-items: center;
  gap: 18px;
  padding: 24px 32px 22px;
}

.hero-copy { min-width: 0; }
.brand-logo {
  display: block;
  width: min(430px, 100%);
  aspect-ratio: 2079 / 756;
  background: #ffe11a;
  filter: drop-shadow(3px 3px 0 #174c29);
  -webkit-mask: url("assets/bugg-wordmark-mask.png") center / contain no-repeat;
  mask: url("assets/bugg-wordmark-mask.png") center / contain no-repeat;
}

.hero-copy h1 {
  display: inline-block;
  margin: 5px 0 8px;
  color: #ff2f91;
  font-size: clamp(31px, 4.1vw, 48px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  text-shadow: 3px 3px 0 #000, -1px -1px 0 #000;
  overflow-wrap: anywhere;
}

.hero-copy p {
  display: inline-block;
  margin: 0;
  padding: 6px 11px;
  color: #ffe92d;
  background: #111;
  font-size: 18px;
  font-weight: 800;
  line-height: 1.25;
}

.hero-product { position: relative; min-width: 0; margin: 0; }
.hero-pack-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 1746 / 1331;
  border: 4px ridge #e32789;
  background: #eee;
  transform: rotate(1.5deg);
  animation: packet-jitter 2.4s steps(2, end) infinite;
}

.hero-pack {
  position: absolute;
  top: -100%;
  left: 0;
  width: 200%;
  max-width: none;
  height: auto;
  mix-blend-mode: multiply;
}

.burst {
  position: absolute;
  z-index: 2;
  top: 6px;
  right: -18px;
  display: grid;
  width: 150px;
  height: 150px;
  place-content: center;
  padding: 18px;
  clip-path: polygon(50% 0, 61% 20%, 80% 7%, 83% 30%, 100% 32%, 88% 50%, 100% 67%, 81% 70%, 78% 94%, 60% 80%, 50% 100%, 40% 80%, 21% 94%, 20% 70%, 0 67%, 12% 50%, 0 32%, 18% 29%, 20% 7%, 39% 20%);
  color: #ffe930;
  background: #d6207b;
  text-align: center;
  text-shadow: 2px 2px #000;
  transform: rotate(5deg);
  animation: burst-jump 1.2s steps(2, end) infinite;
}

.burst strong { font-size: 40px; line-height: 0.82; }
.burst small { font-size: 17px; font-weight: 900; text-transform: uppercase; }
.burst em { display: block; font-size: 20px; font-style: normal; font-weight: 900; }

.page-columns {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 18px;
  padding: 0 20px 22px;
}

.directory {
  align-self: start;
  padding: 11px 13px;
  border: 3px ridge #a14a91;
  color: #fff;
  background: #16051c;
}

.directory h2 { margin: 0 0 13px; color: #70ff24; font-size: 18px; text-align: center; }
.directory nav { display: flex; flex-direction: column; gap: 9px; padding-bottom: 16px; border-bottom: 1px solid #8b778d; }
.directory a, .directory a:visited { color: #ff70bb; font-size: 15px; font-weight: 800; }
.directory a:hover, .directory a.active { color: #fff127; }
.new-badge { display: inline-block; margin-left: 3px; color: #7dff38; font-family: "Courier New", monospace; font-size: 11px; text-decoration: none; }
.didyouknow { padding-top: 10px; }
.didyouknow h3 { margin: 5px 0 8px; color: #ffef22; font-size: 16px; }
.didyouknow p { margin: 0; font-size: 15px; font-weight: 500; line-height: 1.45; }
.didyouknow img {
  width: 100%;
  height: 105px;
  margin-top: 7px;
  object-fit: contain;
  mix-blend-mode: screen;
  transform-origin: 50% 84%;
  animation: sidebar-wiggle 0.72s steps(2, end) infinite alternate;
}
.best-viewed { margin: 18px 0 3px; color: #ddd; font-family: "Times New Roman", serif; font-size: 13px; line-height: 1.35; text-align: center; }
.content-column { min-width: 0; }

.panel, .module, .webmaster-box {
  margin: 0 0 15px;
  border: 3px ridge #ddd;
  background: var(--panel);
  box-shadow: 3px 4px 0 rgba(0, 0, 0, 0.24);
}

.section-bar, .result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 34px;
  padding: 5px 10px;
  color: #fff;
  background: var(--purple);
  text-shadow: 1px 1px #000;
}

.section-bar h2, .result-header h3 { margin: 0; font-size: 18px; line-height: 1.15; }
.section-bar > span, .result-header > span { font-family: "Courier New", monospace; font-size: 13px; font-weight: 800; white-space: nowrap; }
.calculator-body { padding: 18px 22px 20px; }

.year-form {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: end;
  gap: 10px 18px;
  padding: 4px 18px 20px;
}

.year-form > label { grid-column: 1 / -1; font-size: 20px; font-weight: 900; }
.select-line { display: flex; align-items: stretch; gap: 14px; }
.select-line select { min-width: 250px; padding: 7px 10px; border: 3px inset #eee; background: #fff; font-size: 20px; font-weight: 800; }

.calculate-button, .result-actions button, .game-buttons button, .touch-controls button, .preset-row button, .poll-form > button {
  border: 3px outset #eee;
  background: #d6d6d6;
  font-weight: 900;
  cursor: pointer;
}

.calculate-button { padding: 7px 18px; color: #d32b82; font-size: 20px; }
.calculate-button:active, .result-actions button:active, .game-buttons button:active, .touch-controls button:active, .preset-row button:active, .poll-form > button:active { border-style: inset; transform: translateY(1px); }
#yearHelp { grid-column: 1 / -1; margin: 0; color: #343434; font-size: 15px; }

.preset-row {
  grid-column: 1 / -1;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 7px;
  padding-top: 4px;
  border-top: 1px dotted #777;
  font-size: 14px;
  font-weight: 700;
}

.preset-row button { min-height: 34px; padding: 3px 10px; color: #000080; font-size: 14px; }
.preset-row button[aria-pressed="true"] { border-style: inset; background: #ffc8e1; }
.result-board { margin: 0; box-shadow: none; }
.result-header { background: var(--green); }

.result-screen {
  display: grid;
  grid-template-columns: 1fr 1.25fr;
  gap: 0;
  min-height: 240px;
  padding: 16px 18px;
  background: #f8f5e8;
}

.main-result { display: flex; flex-direction: column; justify-content: center; gap: 8px; padding: 10px 22px 10px 8px; border-right: 1px solid #666; }
.main-result span { font-size: 17px; font-weight: 700; }
.main-result strong { color: #d1267b; font-size: clamp(38px, 5vw, 58px); line-height: 1; }
.main-result em { color: #25257d; font-size: 16px; font-style: normal; font-weight: 800; }

.result-facts { display: grid; grid-template-columns: repeat(3, 1fr); align-items: stretch; gap: 0; margin: 0; padding: 7px 0 7px 14px; }
.result-facts div { display: flex; flex-direction: column; justify-content: center; gap: 9px; min-width: 0; padding: 8px 13px; border-right: 1px solid #9b978b; }
.result-facts div:last-child { border-right: 0; }
.result-facts dt { font-size: 14px; font-weight: 700; line-height: 1.3; }
.result-facts dd { margin: 0; color: #1627a8; font-size: 21px; font-weight: 900; line-height: 1.1; overflow-wrap: anywhere; }
.result-screen.is-updating .main-result strong { animation: result-pop 0.65s steps(3, end); }

.result-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 9px 12px; border-top: 2px ridge #eee; background: #d9d9d9; }
.result-actions button { min-height: 37px; padding: 4px 10px; color: #172699; font-size: 13px; }
#actionStatus { color: #286700; font-size: 14px; font-weight: 800; }

.poll-bar { background: #b90067; }
.poll-form { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 12px 16px; padding: 15px 18px 17px; }
.poll-form fieldset { min-width: 0; margin: 0; padding: 8px 12px 12px; border: 2px groove #eee; }
.poll-form legend { padding: 0 6px; color: #18258f; font-size: 19px; font-weight: 900; }
.poll-options { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 7px; }
.poll-options label { display: flex; align-items: center; gap: 6px; min-height: 43px; padding: 6px 9px; border: 2px outset #eee; background: #fffbd3; font-weight: 800; cursor: pointer; }
.poll-options label:has(input:checked) { color: #fff; background: #17269b; }
.poll-options input { width: 19px; height: 19px; accent-color: #d1267b; }
.poll-form > button { min-width: 112px; padding: 7px 16px; color: #b00065; font-size: 18px; }
.poll-form p { grid-column: 1 / -1; margin: 0; color: #363636; font-size: 14px; }
.archive-bar, .time-bar { background: var(--bright-blue); }
.about-bar { background: #25307f; }
.game-bar { background: var(--c64-blue); }
.module-lead { margin: 0; padding: 14px 18px 10px; font-size: 16px; line-height: 1.5; }
.table-scroll { max-width: 100%; overflow-x: auto; padding: 5px 15px 15px; }

table { width: 100%; min-width: 590px; border-collapse: collapse; background: #fffdf4; font-size: 16px; }
caption { padding: 6px; color: #202b86; font-weight: 800; text-align: left; }
th, td { padding: 8px 10px; border: 1px solid #555; text-align: center; }
th { background: #e9e3cd; }
tbody tr:nth-child(even) { background: #f6eefa; }
tbody tr.is-selected th, tbody tr.is-selected td { background: #f596c3; font-weight: 900; }
.examples-table input { width: 116px; min-height: 38px; padding: 4px 7px; border: 2px inset #eee; background: #fff; font-weight: 700; text-align: right; }
.examples-table td:last-child { color: #15269f; font-weight: 900; }

.game-layout { display: grid; grid-template-columns: minmax(0, 1.65fr) minmax(190px, 0.65fr); gap: 16px; padding: 17px; background: #d4cfbb; }
.c64-computer { padding: 14px; border: 5px outset #e9e2c7; border-radius: 7px 7px 16px 16px; background: #b9ab8a; }
.game-status { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px 16px; padding: 7px 10px; border: 3px inset #b7ad94; color: #fff; background: var(--c64-blue); font-family: "Courier New", monospace; font-size: 15px; font-weight: 700; }
.game-status b { color: #fff46b; }
#buggGame { display: block; width: 100%; height: auto; margin-top: 8px; border: 9px inset #8f8369; background: var(--c64-blue); image-rendering: pixelated; touch-action: none; }
.game-buttons, .touch-controls { display: flex; flex-wrap: wrap; justify-content: center; gap: 9px; margin-top: 10px; }
.game-buttons button, .touch-controls button { min-width: 135px; padding: 5px 12px; color: #202572; font-size: 14px; }
.game-buttons button:disabled { color: #777; cursor: default; }
.touch-controls button { flex: 1; min-height: 50px; font-size: 16px; user-select: none; -webkit-user-select: none; }
.game-manual { align-self: start; padding: 13px; border: 2px dashed #70684f; color: #17165a; background: #fffbd0; font-family: "Courier New", monospace; }
.game-manual h3 { margin: 0 0 10px; color: #b00065; font-size: 18px; text-align: center; }
.game-manual p { margin: 10px 0; font-size: 14px; font-weight: 700; line-height: 1.45; }
kbd { padding: 1px 5px; border: 2px outset #eee; background: #ddd; font-family: inherit; }
.game-tip { color: #d30071; text-align: center; }

.about-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0; padding: 15px 16px; }
.about-grid > div { padding: 3px 16px; border-right: 1px solid #777; }
.about-grid > div:last-child { border-right: 0; }
.about-grid h3 { margin: 0 0 8px; color: #14269e; font-size: 18px; }
.about-grid p, .source-details { font-size: 15px; font-weight: 500; line-height: 1.5; }
.source-details { margin: 0 16px 17px; padding: 9px 11px; border: 2px inset #eee; background: #fffdf4; }
.source-details summary { color: #17269b; font-weight: 800; cursor: pointer; }
.source-details li { margin: 8px 0; }
.independent-note { margin: 0 16px 17px; color: #555; font-size: 13px; }

.webmaster-box { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; padding: 12px 17px 18px; background: #fffbd2; }
.webmaster-box p { margin: 0; font-size: 15px; }
.mailbox { display: block; font-size: 44px; animation: mailbox-flag 0.8s steps(2, end) infinite; }
.rainbow-rule { grid-column: 1 / -1; height: 6px; background: repeating-linear-gradient(90deg, #ff1f87 0 28px, #fff125 28px 56px, #21c950 56px 84px, #1332ae 84px 112px); }

.browser-statusbar { display: flex; justify-content: space-between; gap: 14px; align-items: center; min-height: 46px; padding: 8px 14px; border-top: 2px ridge #999; color: #67ff19; background: #171717; font-family: "Courier New", monospace; font-size: 13px; }
.browser-statusbar span:last-child { color: #fff33b; }

.toast {
  position: fixed;
  z-index: 100;
  right: 18px;
  bottom: 18px;
  max-width: min(390px, calc(100vw - 36px));
  padding: 11px 15px;
  border: 3px outset #eee;
  color: #fff;
  background: #17268f;
  font-weight: 800;
  opacity: 0;
  transform: translateY(18px);
  pointer-events: none;
  transition: opacity 0.15s, transform 0.15s;
}

.toast.is-visible { opacity: 1; transform: translateY(0); }
.blink { animation: old-web-blink 0.9s steps(1, end) infinite; }
.motion-paused *, .motion-paused *::before, .motion-paused *::after { animation-play-state: paused !important; scroll-behavior: auto !important; }
.motion-paused .construction-gif { display: none; }
.motion-paused .construction-still { display: block; }

@keyframes old-web-blink { 0%, 48% { visibility: visible; } 49%, 100% { visibility: hidden; } }
@keyframes ticker { from { transform: translateX(0); } to { transform: translateX(-50%); } }
@keyframes packet-jitter { 0%, 80% { transform: rotate(1.5deg) translateX(0); } 81% { transform: rotate(0deg) translateX(-2px); } 100% { transform: rotate(1.5deg) translateX(2px); } }
@keyframes burst-jump { from { transform: rotate(4deg) scale(1); } to { transform: rotate(7deg) scale(1.04); } }
@keyframes result-pop { 0% { transform: scale(0.96); color: #1326a5; } 100% { transform: scale(1); color: #d1267b; } }
@keyframes mailbox-flag { from { transform: rotate(-4deg); } to { transform: rotate(4deg); } }
@keyframes sidebar-wiggle {
  0% { transform: translateX(-3px) rotate(-2.5deg); }
  50% { transform: translateY(-2px) rotate(1deg); }
  100% { transform: translateX(3px) rotate(2.5deg); }
}

@media (max-width: 980px) {
  .page-columns { grid-template-columns: 190px minmax(0, 1fr); gap: 13px; padding-inline: 13px; }
  .result-screen, .game-layout { grid-template-columns: 1fr; }
  .main-result { border-right: 0; border-bottom: 1px solid #777; }
  .poll-options { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 760px) {
  body { font-size: 17px; }
  .network-strip { display: block; padding: 5px; text-align: center; }
  #connectionLabel { display: block; margin-top: 2px; }
  .construction-zone { grid-template-columns: 110px 1fr; padding-inline: 10px; }
  .construction-gif, .construction-still { width: 100px; height: 75px; }
  .motion-button { grid-column: 1 / -1; justify-self: center; }
  .construction-zone strong { font-size: 18px; }
  .construction-zone span { font-size: 12px; }
  .masthead { grid-template-columns: 1fr; padding: 18px; }
  .hero-product { width: 100%; max-width: 540px; margin: 0 auto; }
  .burst { right: -4px; width: 118px; height: 118px; }
  .burst strong { font-size: 30px; }
  .page-columns { grid-template-columns: 1fr; padding-inline: 10px; }
  .directory nav { display: grid; grid-template-columns: 1fr 1fr; }
  .didyouknow { display: grid; grid-template-columns: 1fr 100px; gap: 7px 12px; align-items: center; }
  .didyouknow h3 { grid-column: 1 / -1; }
  .didyouknow img { height: 80px; margin: 0; }
  .year-form { grid-template-columns: 1fr; padding-inline: 0; }
  .select-line { display: grid; grid-template-columns: 1fr; }
  .select-line select { width: 100%; min-width: 0; }
  .result-facts { grid-template-columns: 1fr; padding-left: 0; }
  .result-facts div, .result-facts div:last-child { border-right: 0; border-bottom: 1px dotted #8a8479; }
  .poll-form { grid-template-columns: 1fr; }
  .poll-form > button { justify-self: start; }
  .about-grid { grid-template-columns: 1fr; }
  .about-grid > div { padding: 10px 5px; border-right: 0; border-bottom: 1px dotted #777; }
  .about-grid > div:last-child { border-bottom: 0; }
  .browser-statusbar { grid-template-columns: 1fr; gap: 2px; }
}

@media (max-width: 430px) {
  .hero-copy h1 {
    font-size: clamp(20px, 6.3vw, 27px);
    overflow-wrap: normal;
    white-space: nowrap;
  }
  .hero-copy p { font-size: 16px; }
  .burst { top: 2px; right: -3px; width: 96px; height: 96px; }
  .burst small { font-size: 14px; }
  .burst strong { font-size: 27px; }
  .burst em { font-size: 17px; }
  .directory nav { grid-template-columns: 1fr; }
  .calculator-body, .result-screen, .game-layout { padding: 12px; }
  .poll-options { grid-template-columns: 1fr; }
  .game-status { font-size: 12px; }
  .touch-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .game-buttons button, .touch-controls button { min-width: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation-duration: 0.001ms !important; animation-iteration-count: 1 !important; transition-duration: 0.001ms !important; }
  .blink { visibility: visible !important; }
  .didyouknow img { transform: none; }
  .construction-gif { display: none; }
  .construction-still { display: block; }
}

@media print {
  body { background: #fff; }
  .network-strip, .construction-zone, .directory, .result-actions, .game-panel, .webmaster-box, .browser-statusbar, .toast { display: none !important; }
  .browser-shell, .panel, .module { max-width: none; border: 1px solid #444; box-shadow: none; }
  .page-columns { display: block; padding: 0; }
}
