/* =============================================================
 * style.css — HUD + RPG dialogue windows.
 * The pixel font is loaded from a CDN with a graceful fallback,
 * so the page still looks right offline / behind a firewall.
 * ============================================================= */

@font-face {
  font-family: 'PressStart';
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url('https://cdn.jsdelivr.net/npm/@fontsource/press-start-2p/files/press-start-2p-latin-400-normal.woff2') format('woff2');
}

:root {
  --ink:   #0c0e18;
  --win:   #1b2039;
  --win2:  #262d4d;
  --edge:  #4d5680;
  --gold:  #e0b34c;
  --goldL: #f6dc93;
  --txt:   #e9e7de;
  --dim:   #99a0bb;

  --pixel: 'PressStart', 'Courier New', monospace;
  --mono:  ui-monospace, 'Cascadia Mono', 'Segoe UI Mono', Consolas,
           'Microsoft YaHei', 'Noto Sans CJK SC', monospace;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: #06060b;
  color: var(--txt);
  font-family: var(--mono);
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}

/* radial vignette behind the play area */
body::before {
  content: '';
  position: fixed; inset: 0;
  background: radial-gradient(circle at 50% 45%, #16182a 0%, #06060b 78%);
  z-index: 0;
}

#stage {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100%;
}

#frame { position: relative; line-height: 0; }

#game {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #0b0b12;
  box-shadow: 0 0 0 2px #000, 0 0 0 4px #2b3050, 0 18px 60px rgba(0, 0, 0, .7);
}

.hidden { display: none !important; }

/* ---------------- HUD ---------------- */
#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  line-height: 1.4;
  font-family: var(--pixel);
  font-size: 10px;
  letter-spacing: .5px;
}

#location {
  position: absolute;
  top: 10px; left: 12px;
  padding: 6px 10px;
  background: rgba(12, 14, 24, .72);
  border: 2px solid rgba(77, 86, 128, .8);
  color: var(--goldL);
  text-shadow: 0 2px 0 #000;
}

#nowplaying {
  position: absolute;
  top: 10px; right: 12px;
  max-width: 46%;
  padding: 6px 10px;
  background: rgba(12, 14, 24, .72);
  border: 2px solid rgba(77, 86, 128, .8);
  color: #cfe0ff;
  font-family: var(--mono);
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#hint {
  position: absolute;
  bottom: 12px; left: 50%;
  transform: translateX(-50%);
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(12, 14, 24, .78);
  border: 2px solid rgba(77, 86, 128, .8);
  white-space: nowrap;
}
#hint .key {
  padding: 3px 6px;
  background: var(--gold);
  color: #241a05;
  border-radius: 2px;
}
#hint-action { color: var(--txt); }

/* ---------------- dialogue window ---------------- */
#panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4%;
  background: rgba(4, 5, 10, .55);
  line-height: normal;
  z-index: 5;
}

.win {
  width: min(560px, 100%);
  max-height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--win);
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--edge),
              0 0 0 6px var(--ink), 0 14px 40px rgba(0, 0, 0, .6);
  /* scale only — never animate opacity here, or an interrupted animation
     can leave the window stuck semi-transparent */
  animation: pop .13s steps(3) both;
}
@keyframes pop { from { transform: scale(.92); } to { transform: scale(1); } }

.win-top {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 9px 12px;
  background: var(--win2);
  border-bottom: 2px solid var(--ink);
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--goldL);
  letter-spacing: .5px;
}
#win-close {
  background: none; border: 0; cursor: pointer;
  color: var(--dim); font-size: 20px; line-height: 1;
  padding: 0 2px;
}
#win-close:hover { color: var(--goldL); }

.win-body {
  padding: 16px 18px;
  overflow-y: auto;
  font-size: 13px;
  line-height: 1.65;
}
.win-body::-webkit-scrollbar { width: 8px; }
.win-body::-webkit-scrollbar-thumb { background: var(--edge); }
.win-body::-webkit-scrollbar-track { background: var(--ink); }

.win-foot {
  padding: 7px 12px;
  border-top: 2px solid var(--ink);
  background: rgba(0, 0, 0, .22);
  color: var(--dim);
  font-family: var(--pixel);
  font-size: 8px;
  text-align: right;
  letter-spacing: .5px;
}

/* body typography */
.win-body h3 {
  margin: 0 0 10px;
  font-family: var(--pixel);
  font-size: 12px;
  line-height: 1.7;
  color: var(--goldL);
}
.win-body p { margin: 0 0 9px; }
.win-body p.gap { height: 8px; margin: 0; }
.authors  { color: #cdd3e6; font-size: 12px; }
.venue    { color: var(--dim); font-size: 12px; font-style: italic; }
.abstract { color: #d5d3ca; }
.abstract.dim  { color: var(--dim); font-size: 12px; }
.abstract.note { color: #b9c2dd; font-style: italic; border-left: 2px solid var(--edge); padding-left: 10px; }
.mono p   { color: #d5d3ca; }
.tag {
  display: inline-block;
  margin: 0 0 10px;
  padding: 3px 8px;
  background: rgba(224, 179, 76, .16);
  border: 1px solid var(--gold);
  color: var(--goldL);
  font-size: 11px;
}
code {
  background: rgba(0, 0, 0, .38);
  border: 1px solid #333c60;
  padding: 1px 5px;
  color: #ffd98a;
  font-size: 11px;
}

.links { margin-top: 14px !important; }
.links a { color: #8fc4ff; text-decoration: none; border-bottom: 1px dotted #52709c; }
.links a:hover { color: var(--goldL); border-bottom-color: var(--gold); }
.links .sep { color: var(--dim); margin: 0 8px; }

/* altar text — centred and quiet */
.altar { text-align: center; }
.altar p { color: var(--goldL); letter-spacing: .4px; }

/* visitor fountain */
.kind-visitor .win {
  background:
    radial-gradient(circle at 50% 115%, rgba(71, 128, 186, .32), transparent 55%),
    var(--win);
}
.kind-visitor .win-top { background: #172b42; }
.visitor-card { text-align: center; padding: 2px 0; }
.visitor-summary { padding: 5px 4px 13px; }
.visitor-kicker {
  margin-bottom: 14px !important;
  color: #8fd8ff;
  font-family: var(--pixel);
  font-size: 11px;
  letter-spacing: 1px;
}
.visitor-label {
  margin: 0 !important;
  color: #b8cde0;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: .8px;
}
.visitor-number {
  margin: 9px 0 12px !important;
  color: var(--goldL);
  font-family: var(--pixel);
  font-size: clamp(20px, 6vw, 34px);
  line-height: 1.3;
  text-shadow: 0 2px 0 #463414, 0 0 18px rgba(255, 217, 138, .28);
}
.visitor-total { margin-top: 18px !important; color: #a9cce4; font-size: 12px; }
.visitor-wish { color: #d5d3ca; font-style: italic; }
.visitor-muted { padding: 18px 4px 12px; color: #d5d3ca; }
.visitor-loading .visitor-kicker { animation: fountain-pulse 1.1s steps(3) infinite; }
@keyframes fountain-pulse { 50% { opacity: .48; } }
.guestbook {
  margin-top: 2px;
  padding-top: 14px;
  border-top: 2px solid rgba(143, 216, 255, .2);
  text-align: left;
}
.guestbook-heading {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 9px;
}
.guestbook-title {
  margin: 0 !important;
  color: #8fd8ff;
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: .8px;
}
.guestbook-heading > span {
  color: #6f92ad;
  font-family: var(--pixel);
  font-size: 7px;
}
.guestbook-list {
  max-height: min(220px, 32vh);
  margin: 0;
  padding: 0 5px 0 0;
  overflow-y: auto;
  list-style: none;
  scrollbar-color: #527a98 rgba(0, 0, 0, .2);
  scrollbar-width: thin;
}
.guestbook-list li {
  margin: 0 0 7px;
  padding: 8px 10px;
  border-left: 2px solid #527a98;
  background: rgba(5, 17, 29, .35);
}
.guestbook-list li > span {
  display: block;
  margin-bottom: 4px;
  color: #86a9c2;
  font-family: var(--pixel);
  font-size: 7px;
  letter-spacing: .35px;
}
.guestbook-list li > p {
  margin: 0;
  color: #e2e6e5;
  overflow-wrap: anywhere;
}
.guestbook-empty,
.guestbook-notice {
  margin: 5px 0 0 !important;
  color: #91a9ba;
  font-size: 12px;
  font-style: italic;
  text-align: center;
}
.guestbook-notice {
  margin-top: 11px !important;
  color: #a9cce4;
}
.guestbook-form {
  margin-top: 12px;
  padding-top: 11px;
  border-top: 1px solid rgba(143, 216, 255, .16);
}
.guestbook-form label {
  display: block;
  margin-bottom: 7px;
  color: #a9cce4;
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: .5px;
}
.guestbook-compose { display: flex; gap: 7px; }
.guestbook-compose input {
  min-width: 0;
  flex: 1;
  padding: 8px 9px;
  border: 2px solid #456984;
  outline: 0;
  background: rgba(3, 10, 18, .68);
  color: var(--txt);
  font: 12px/1.4 var(--mono);
}
.guestbook-compose input::placeholder { color: #667f92; }
.guestbook-compose input:focus {
  border-color: #8fd8ff;
  box-shadow: 0 0 0 2px rgba(143, 216, 255, .12);
}
.guestbook-compose button {
  padding: 7px 11px;
  border: 0;
  background: #8fd8ff;
  box-shadow: 0 0 0 2px #0c1823, 0 3px 0 #d4f1ff inset;
  color: #102437;
  cursor: pointer;
  font-family: var(--pixel);
  font-size: 8px;
}
.guestbook-compose button:hover { background: #c5edff; }
.guestbook-compose button:disabled { cursor: wait; filter: saturate(.35); opacity: .7; }
.guestbook-form-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  min-height: 16px;
  margin: 5px 0 0 !important;
  color: #66859d;
  font-size: 10px;
}
.guestbook-form-meta > span:first-child { color: #e3bd72; }
.guestbook-form-meta b { color: #9fc3db; font-weight: normal; }

/* record player */
#viz {
  display: block;
  width: 100%;
  height: 46px;
  margin: 14px 0 12px;
  background: rgba(0, 0, 0, .34);
  border: 2px solid var(--ink);
  image-rendering: pixelated;
}
.controls { display: flex; align-items: center; gap: 14px; }
.rpg-btn {
  font-family: var(--pixel);
  font-size: 10px;
  padding: 9px 14px;
  color: #241a05;
  background: var(--gold);
  border: 0;
  box-shadow: 0 0 0 2px var(--ink), 0 3px 0 var(--goldL) inset;
  cursor: pointer;
}
.rpg-btn:hover { background: var(--goldL); }
.rpg-btn:active { transform: translateY(1px); }
.volume-control {
  display: flex;
  flex: 1;
  align-items: center;
  gap: 7px;
  min-width: 0;
  cursor: pointer;
}
.volume-icon {
  width: 20px;
  height: 16px;
  flex: 0 0 auto;
  fill: var(--goldL);
  filter: drop-shadow(1px 1px 0 var(--ink));
  shape-rendering: crispEdges;
}
#rec-vol { flex: 1; min-width: 0; accent-color: var(--gold); cursor: pointer; }
.rec-state { color: var(--dim); font-size: 12px; }
.rec-state.warn { color: #ffb27a; }
.rec-embed {
  display: block;
  width: 100%;
  height: 175px;
  margin: 14px 0 8px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(0, 0, 0, .34);
}

/* favorite game terminal */
.kind-game .win {
  width: min(620px, 100%);
  background: #11151c;
  border: 0;
  box-shadow: 0 0 0 2px #080a0e, 0 0 0 4px #596171,
              0 0 0 6px #080a0e, 0 18px 46px rgba(0, 0, 0, .76);
}
.kind-game .win-top { background: #1b202a; }
.kind-game .win-body { padding: 0; }
.game-card {
  --game-accent: #5fd3f0;
  position: relative;
  background:
    linear-gradient(90deg, color-mix(in srgb, var(--game-accent) 8%, transparent), transparent 45%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, .018) 0 1px, transparent 1px 4px),
    #11151c;
}
.game-card::before {
  content: '';
  position: absolute;
  z-index: 1;
  inset: 0 auto 0 0;
  width: 3px;
  background: var(--game-accent);
  box-shadow: 0 0 16px var(--game-accent);
}
.game-teaser {
  position: relative;
  aspect-ratio: 460 / 215;
  overflow: hidden;
  background: #080a0e;
  border-bottom: 2px solid #080a0e;
}
.game-teaser::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  box-shadow: inset 0 -24px 30px rgba(8, 10, 14, .22);
}
.game-teaser img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.game-copy { padding: 16px 20px 18px; }
.game-kicker {
  margin: 0 0 7px !important;
  color: var(--game-accent);
  font-family: var(--pixel);
  font-size: 8px;
  letter-spacing: 1.4px;
}
.game-card h3 { margin-bottom: 5px; color: #f2eee4; font-size: 14px; }
.game-meta {
  margin-bottom: 12px !important;
  color: #aeb5c4;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .4px;
}
.game-desc { max-width: 60ch; margin-bottom: 15px !important; }
.game-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 11px;
  color: #f5f2e9;
  background: color-mix(in srgb, var(--game-accent) 15%, #151a22);
  border: 1px solid color-mix(in srgb, var(--game-accent) 66%, #596171);
  font-family: var(--pixel);
  font-size: 9px;
  letter-spacing: .5px;
  text-decoration: none;
}
.game-link:hover,
.game-link:focus-visible {
  color: #080a0e;
  background: var(--game-accent);
  outline: none;
}

@supports not (color: color-mix(in srgb, white, black)) {
  .game-card { background: #11151c; }
  .game-link { background: #202734; border-color: var(--game-accent); }
}

@media (max-width: 520px), (max-height: 520px) {
  #panel.kind-game {
    position: fixed;
    inset: 0;
    z-index: 10;
    padding: 16px;
  }
  .kind-game .win { max-height: calc(100dvh - 32px); }
  .game-copy { padding: 12px 14px 14px; }
  .game-desc { font-size: 12px; line-height: 1.5; }
  .game-link { padding: 8px 10px; }
}

/* ---------------- touch controls ---------------- */
#touch { position: absolute; inset: 0; pointer-events: none; z-index: 4; }
#touch button {
  pointer-events: auto;
  position: absolute;
  background: rgba(27, 32, 57, .66);
  border: 2px solid rgba(120, 132, 180, .7);
  color: #dfe4f5;
  font-size: 18px;
  width: 52px; height: 52px;
  border-radius: 6px;
  touch-action: none;
  user-select: none;
}
.dpad [data-dir="up"]    { left: 74px;  bottom: 130px; }
.dpad [data-dir="down"]  { left: 74px;  bottom: 20px; }
.dpad [data-dir="left"]  { left: 18px;  bottom: 75px; }
.dpad [data-dir="right"] { left: 130px; bottom: 75px; }
.abtn {
  right: 28px; bottom: 62px;
  width: 66px !important; height: 66px !important;
  border-radius: 50% !important;
  font-family: var(--pixel);
  font-size: 14px !important;
  color: #241a05 !important;
  background: rgba(224, 179, 76, .88) !important;
}

/* ---------------- title card ---------------- */
#boot {
  position: absolute;
  inset: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #141a33 0%, #06060d 80%);
  line-height: normal;
  text-align: center;
  padding: 6%;
}
.boot-inner { max-width: 460px; }
#boot h1 {
  margin: 0 0 14px;
  font-family: var(--pixel);
  font-size: clamp(15px, 3.4vmin, 26px);
  color: var(--goldL);
  text-shadow: 0 3px 0 #000, 0 0 22px rgba(224, 179, 76, .35);
  letter-spacing: 1px;
}
#boot-sub { margin: 0 0 18px; color: var(--dim); font-size: 13px; }
.boot-rule {
  height: 2px; margin: 0 auto 18px; width: 70%;
  background: linear-gradient(90deg, transparent, var(--edge), transparent);
}
.boot-keys {
  margin: 0 0 26px;
  color: var(--dim);
  font-size: 11px;
  display: flex; flex-wrap: wrap; gap: 6px 10px; justify-content: center;
}
.boot-keys span {
  font-family: var(--pixel);
  font-size: 9px;
  padding: 4px 7px;
  background: rgba(77, 86, 128, .28);
  border: 1px solid var(--edge);
  color: #cdd3e6;
}
.boot-press {
  margin: 0;
  font-family: var(--pixel);
  font-size: 10px;
  color: var(--gold);
  animation: blink 1.15s steps(2, end) infinite;
}
@keyframes blink { 50% { opacity: .15; } }

/* ---------------- fade ---------------- */
#fade {
  position: absolute;
  inset: 0;
  background: #05050a;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s linear;
  z-index: 3;
}
