:root {
  color-scheme: dark;
  --bg: #000033;
  --panel: #c0c0c0;
  --panel-dark: #808080;
  --panel-light: #ffffff;
  --ink: #000000;
  --text: #ffffcc;
  --link: #00ffff;
  --visited: #ff66ff;
  --hot: #ff0099;
  --lime: #33ff33;
  --yellow: #ffff00;
  --title-bar: linear-gradient(90deg, #000080, #1084d0);
  --font-fun: "Comic Sans MS", "Comic Sans", "Chalkboard SE", cursive;
  --font-serif: "Times New Roman", Times, serif;
  --font-mono: "Courier New", Courier, monospace;
  --font-ui: Tahoma, Verdana, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html { background: var(--bg); }

body {
  margin: 0;
  color: var(--text);
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.4;
  /* Tiled starfield, built with gradients so there are no image requests. */
  background-color: var(--bg);
  background-image:
    radial-gradient(1px 1px at 10px 15px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 60px 70px, #ff0 50%, transparent 51%),
    radial-gradient(2px 2px at 110px 30px, #fff 50%, transparent 51%),
    radial-gradient(1px 1px at 150px 120px, #0ff 50%, transparent 51%),
    radial-gradient(1px 1px at 30px 140px, #fff 50%, transparent 51%);
  background-size: 170px 170px;
}

a { color: var(--link); }
a:visited { color: var(--visited); }
a:hover { color: var(--yellow); background: var(--hot); }

.page {
  max-width: 980px;
  margin: 0 auto;
  padding: 0 16px 24px;
}

/* Header */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 0;
}
.logo { text-decoration: none; display: flex; flex-direction: column; }
.logo:hover { background: none; }
.logo-big {
  font-family: var(--font-fun);
  font-size: clamp(1.6rem, 5vw, 2.6rem);
  font-weight: bold;
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f, #f00);
  background-size: 200% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-shadow: none;
  animation: rainbow 4s linear infinite;
}
.logo-small { color: var(--lime); font-family: var(--font-mono); font-size: 0.8rem; }

@keyframes rainbow { to { background-position: 200% 0; } }

.ad-banner {
  width: 468px;
  max-width: 100%;
  min-height: 60px;
  border: 2px inset var(--panel);
  background: #111;
  display: grid;
  place-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  overflow: hidden;
}
.ad-banner img { display: block; width: 100%; height: auto; image-rendering: pixelated; }
.ad-banner a:hover { background: none; }

.construction {
  font-family: var(--font-mono);
  font-weight: bold;
  color: #000;
  text-align: center;
  padding: 4px;
  background: repeating-linear-gradient(45deg, #ff0 0 16px, #000 16px 32px);
}
.construction span { background: #ff0; padding: 0 8px; }

/* Nav: classic beveled buttons */
.menu {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 0;
}
.menu a {
  font-family: var(--font-ui);
  font-size: 0.9rem;
  color: var(--ink);
  background: var(--panel);
  border: 3px outset var(--panel-light);
  padding: 4px 10px;
  text-decoration: none;
}
.menu a:active { border-style: inset; }
.menu a:hover { background: var(--yellow); color: var(--ink); }
.menu a[aria-current="page"] { background: var(--hot); color: #fff; border-style: inset; }

/* Windows 98 style window */
.window {
  background: var(--panel);
  color: var(--ink);
  border: 3px outset var(--panel-light);
  margin: 12px 0;
  font-family: var(--font-ui);
}
.window > h2, .window > .title {
  margin: 0;
  padding: 3px 6px;
  font-size: 0.95rem;
  color: #fff;
  background: var(--title-bar);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.window > h2::after { content: "_ □ ×"; font-family: var(--font-mono); letter-spacing: 4px; font-size: 0.8rem; }
.window .body { padding: 10px; overflow-x: auto; }
.window a { color: #0000ee; }
.window a:visited { color: #551a8b; }
.window a:hover { color: var(--yellow); }

/* Layout */
.grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 220px;
  gap: 16px;
}
@media (max-width: 760px) {
  .grid { grid-template-columns: minmax(0, 1fr); }
}

h1, h2, h3 { font-family: var(--font-fun); }
h1 { color: var(--yellow); text-align: center; font-size: clamp(1.5rem, 4vw, 2.2rem); }
.blink { animation: blink 1s steps(1) infinite; }
@keyframes blink { 50% { visibility: hidden; } }

.neon { color: var(--lime); text-shadow: 0 0 6px var(--lime); }
.hot { color: var(--hot); }
.center { text-align: center; }
.tiny { font-size: 0.75rem; }
.muted { color: #555; }

hr.rainbow {
  border: 0;
  height: 6px;
  background: linear-gradient(90deg, #f00, #ff0, #0f0, #0ff, #00f, #f0f);
}

/* Forms */
label { display: block; margin: 8px 0 2px; font-weight: bold; }
input[type="text"], input[type="url"], input[type="password"], input[type="number"], textarea, select {
  font: 1rem var(--font-mono);
  width: 100%;
  padding: 4px;
  background: #fff;
  color: #000;
  border: 2px inset var(--panel-light);
}
textarea { min-height: 90px; resize: vertical; }
input:user-invalid, textarea:user-invalid { outline: 2px solid #f00; }
button, .button {
  font: bold 0.95rem var(--font-ui);
  color: var(--ink);
  background: var(--panel);
  border: 3px outset var(--panel-light);
  padding: 4px 14px;
  cursor: pointer;
  margin-top: 8px;
}
button:active { border-style: inset; }
button:disabled { color: var(--panel-dark); cursor: not-allowed; }
.form-msg { min-height: 1.4em; font-weight: bold; }
.form-msg.error { color: #c00; }
.form-msg.ok { color: #060; }

/* Hit counter: odometer digits */
.counter { display: inline-flex; gap: 2px; }
.counter span {
  font: bold 1.3rem var(--font-mono);
  background: #000;
  color: var(--lime);
  border: 1px solid #444;
  padding: 0 4px;
}

/* 88x31 wall */
.button-wall { display: flex; flex-wrap: wrap; gap: 4px; justify-content: center; }
.button-wall a, .button-wall .empty {
  width: 88px;
  height: 31px;
  display: block;
}
.button-wall img { display: block; width: 88px; height: 31px; image-rendering: pixelated; }
.button-wall .empty {
  border: 1px dashed #888;
  color: #666;
  font: 9px/29px var(--font-mono);
  text-align: center;
  text-decoration: none;
}
.button-wall .empty:hover { color: #000; background: var(--yellow); }

/* Marquee */
.ad-marquee {
  overflow: hidden;
  white-space: nowrap;
  background: #000;
  border: 2px inset var(--panel);
  color: var(--yellow);
  font: bold 1rem var(--font-mono);
  padding: 4px 0;
}
.ad-marquee .track { display: inline-block; padding-left: 100%; animation: marquee 30s linear infinite; }
.ad-marquee a { color: var(--yellow); margin-right: 3em; }
@keyframes marquee { to { transform: translateX(-100%); } }

/* Footer */
.bottom { margin-top: 24px; text-align: center; }
.webring { font-family: var(--font-mono); }
.badges { display: flex; flex-wrap: wrap; gap: 6px; justify-content: center; }
.badge {
  display: inline-block;
  width: 88px;
  height: 31px;
  font: bold 8px/1.1 var(--font-mono);
  padding: 4px 2px;
  color: #fff;
  background: linear-gradient(#336, #003);
  border: 1px solid #99f;
  overflow: hidden;
}
.badge.alt { background: linear-gradient(#630, #300); border-color: #f90; }

/* Tables */
table.retro { border-collapse: collapse; width: 100%; background: #fff; color: #000; }
table.retro th { background: #000080; color: #fff; }
table.retro th, table.retro td { border: 1px solid #808080; padding: 3px 6px; text-align: left; }
table.retro tr:nth-child(even) td { background: #eef; }

/* Dialog (native <dialog>, per Modern Web Guidance) */
dialog {
  padding: 0;
  max-width: min(560px, calc(100vw - 32px));
  width: 100%;
}
dialog:modal { overscroll-behavior: contain; }
dialog::backdrop {
  background: rgb(0 0 51 / 0.85);
  overflow: hidden;
  overscroll-behavior: contain;
}

.sparkle {
  position: fixed;
  pointer-events: none;
  font-size: 12px;
  z-index: 9999;
  animation: fall 0.9s ease-out forwards;
}
@keyframes fall { to { transform: translateY(30px); opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; }
  .ad-marquee .track { padding-left: 0; white-space: normal; }
  .sparkle { display: none; }
}

/* Header: coin balance and language switch */
.top-right { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; max-width: 100%; }
.userbar { margin: 0; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.coin-widget, .lang-switch {
  font: bold 0.85rem var(--font-ui);
  color: var(--ink);
  background: var(--yellow);
  border: 2px outset #fff;
  padding: 2px 8px;
  text-decoration: none;
}
.lang-switch { background: var(--panel); }
.coin-widget:visited, .lang-switch:visited { color: var(--ink); }

a.button {
  display: inline-block;
  font: bold 0.95rem var(--font-ui);
  color: var(--ink);
  background: var(--panel);
  border: 3px outset var(--panel-light);
  padding: 4px 14px;
  text-decoration: none;
}
a.button:visited { color: var(--ink); }
button.golden, .golden-box h2 { background: linear-gradient(#fff6a0, #e0b000); }
button.mini { font-size: 0.7rem; padding: 1px 6px; margin: 0; border-width: 2px; }
button.primary { background: var(--yellow); }
.inline-form { display: flex; flex-wrap: wrap; align-items: end; gap: 6px; margin-bottom: 8px; }
.inline-form label { margin: 0; flex-basis: 100%; }
.inline-form input, .inline-form select { width: auto; flex: 1 1 140px; }
.inline-form button { margin: 0; }

/* The million bar */
.million-numbers { margin: 0 0 6px; font-size: 1.1rem; text-align: center; }
.million-bar {
  height: 22px;
  background: #000;
  border: 2px inset var(--panel-light);
  overflow: hidden;
  margin: 6px 0;
}
.million-bar span {
  display: block;
  height: 100%;
  width: 0.3%;
  background: repeating-linear-gradient(90deg, #0f0 0 8px, #0a0 8px 10px);
  transition: width 0.8s ease-out;
}

/* Throne */
.king-name { font: bold 1.6rem var(--font-fun); margin: 4px 0; color: #800080; }
.king-phrase { font: italic 1.2rem var(--font-serif); margin: 4px 0; overflow-wrap: anywhere; }
.throne-big .crown { font-size: 3rem; margin: 0; }
.throne-home .body, .throne-big .body { background: linear-gradient(#fff9c4, #c0c0c0); }

/* Novel */
.novel-tail, .novel-text { font: 1rem/1.6 var(--font-serif); overflow-wrap: anywhere; }
.novel-text span:hover { background: var(--yellow); }

/* Visitor certificate */
.certificate {
  border: 6px double #806000;
  background: linear-gradient(135deg, #fffbe6, #f0e0a0);
  padding: 12px;
  text-align: center;
  margin: 10px 0;
  font-family: var(--font-serif);
}
.cert-head { font-weight: bold; letter-spacing: 2px; margin: 0; }
.cert-number { font: bold 2.2rem var(--font-serif); margin: 6px 0; }
.certificate.claimed { border-color: #008000; }

/* Coin packs */
.packs { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.pack { display: flex; flex-direction: column; align-items: center; gap: 2px; margin: 0; padding: 8px 4px; }
.pack-coins { font-size: 1.05rem; }
.pack-price { font-size: 0.9rem; }
.pack-bonus { font-size: 0.7rem; color: #060; }
td.plus { color: #060; font-weight: bold; }
td.minus { color: #a00; }

/* Jar */
.jar { font-size: 3.5rem; text-align: center; margin: 0; }
.jar-mini { font-weight: bold; }
.plain-rules li { margin-bottom: 6px; }
table.retro th[scope="row"] { text-align: left; width: 60%; }

/* Guestbook golden entries */
.entry.golden { background: linear-gradient(#fff9c4, #ffe680); border: 2px solid #c90; padding: 4px; }

/* Game tabs */
.tabs { display: flex; gap: 4px; margin: 0 0 6px; }
.tabs button { margin: 0; }
.tabs button[aria-pressed="true"] { border-style: inset; background: #000080; color: #fff; }
.prize { font-weight: bold; background: var(--yellow); padding: 4px; }

/* Spend confirmation dialog */
dialog.confirm .window { margin: 0; }
dialog.confirm h1 { font-size: 0.95rem; }

/* Payment progress window */
.pay-dialog .window { margin: 0; }
.pay-dialog h1 { font-size: 1rem; }
.pay-progress {
  height: 20px;
  border: 2px inset var(--panel-light);
  background: #fff;
  overflow: hidden;
  margin-bottom: 10px;
}
.pay-progress span {
  display: block;
  height: 100%;
  width: 40%;
  background: repeating-linear-gradient(90deg, #000080 0 10px, transparent 10px 13px);
  animation: pay-slide 1.2s linear infinite;
}
@keyframes pay-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
.pay-steps { list-style: none; padding: 0; font: bold 1rem var(--font-ui); }
.pay-steps li { padding: 6px 4px 6px 30px; position: relative; color: #777; }
.pay-steps li::before { content: '○'; position: absolute; left: 6px; }
.pay-steps li.active { color: #000080; }
.pay-steps li.active::before { content: '⏳'; animation: blink 1s steps(1) infinite; }
.pay-steps li.done { color: #060; }
.pay-steps li.done::before { content: '✔'; }
.pay-steps li.failed { color: #a00; }
.pay-steps li.failed::before { content: '✘'; }

/* The party */
dialog.party {
  border: 0;
  background: transparent;
  max-width: min(640px, calc(100vw - 32px));
}
dialog.party::backdrop { background: rgb(0 0 40 / 0.85); }
.party-box {
  text-align: center;
  padding: 20px 16px;
  border: 6px ridge #ffd700;
  background: radial-gradient(circle at 50% 30%, #3a0066, #000033 70%);
  color: #fff;
}
.wordart {
  font: 900 clamp(2rem, 8vw, 3.6rem)/1 "Impact", "Arial Black", var(--font-fun);
  margin: 8px 0;
  background: linear-gradient(180deg, #fff700 0%, #ff8a00 45%, #ff0066 55%, #9b00ff 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  -webkit-text-stroke: 1px #fff;
  filter: drop-shadow(4px 4px 0 #000);
  transform: perspective(300px) rotateX(12deg) skewX(-6deg);
  animation: party-pulse 0.8s ease-in-out infinite alternate;
}
@keyframes party-pulse { to { transform: perspective(300px) rotateX(12deg) skewX(-6deg) scale(1.06); } }
.party-coins { font: 900 clamp(2.5rem, 10vw, 4.5rem)/1 var(--font-mono); color: #0f0; text-shadow: 0 0 12px #0f0; margin: 6px 0 0; }
.party-sub { font: bold 1.2rem var(--font-mono); color: #0f0; margin: 0 0 12px; letter-spacing: 6px; }
.party-stars { color: #ffd700; font-size: 1.4rem; animation: blink 0.6s steps(1) infinite; margin: 0; }
.party-thanks { font: 1.1rem var(--font-fun); color: var(--yellow); }
.party-balance { font-family: var(--font-mono); }
.party-ideas a.button { margin: 3px 0; }
canvas.confetti { position: fixed; inset: 0; pointer-events: none; z-index: 2147483647; }

.review-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 8px; }
.review-grid .window { margin: 0; }
.review-img { display: block; max-width: 100%; max-height: 220px; margin: 0 auto; }
