/* Terminal style, matching pcniado.github.io: black, white, Hack monospace, [ bracket ] buttons, dashed rules. */
:root {
  --bg: #000;
  --text: #fff;
  --dim: #888;
  --border: #333;
  --font: 'Hack', ui-monospace, 'Cascadia Mono', Consolas, monospace;
  --nav-h: 60px;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
html, body { background: var(--bg); color: var(--text); max-width: 100%; overflow-x: hidden; }
body { margin: 0; font: 16px/1.4 var(--font); overflow-x: hidden; }
::selection { background: var(--text); color: var(--bg); }
a { color: var(--text); text-decoration: none; border-bottom: 1px solid transparent; }
a:hover { border-bottom-color: var(--text); }
:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }

/* Top bar, as on the main site */
.top-nav { position: sticky; top: 0; z-index: 5; height: var(--nav-h); display: flex; align-items: center;
  justify-content: space-between; padding: 0 2rem; background: var(--bg); }
.top-nav .logo { letter-spacing: 1px; }
.top-nav .links { display: flex; }
.top-nav .links a { display: inline-block; padding: 0 1rem; }
.contact-row { display: flex; align-items: center; gap: 14px; margin: 12px 0; }
.ico { position: relative; display: inline-flex; border-bottom: 0; }
.ico svg { fill: currentColor; shape-rendering: crispEdges; display: block; }
.ico.discord, .ico.twitter { color: var(--text); }
.ico:hover { opacity: 0.8; }
.ico.copied::after { content: 'Copied'; position: absolute; left: 100%; top: 50%; transform: translateY(-50%); margin-left: 8px; padding: 2px 6px;
  background: var(--text); color: var(--bg); font-size: 11px; text-transform: uppercase; white-space: nowrap; }

main { max-width: 1000px; margin: 0 auto; padding: 0 2rem 4rem; position: relative; z-index: 1; }

/* Drifting ASCII field + blinking cursor + [+]/[-] toggles, as on pcniado.github.io */
#particle-canvas { position: fixed; top: 0; left: 0; width: 100%; height: 100%; z-index: 0; opacity: 0.3; pointer-events: none; }
body.fs #particle-canvas { display: none; }
footer { position: relative; z-index: 1; background: var(--bg); }
.top-nav { z-index: 1000; }
.cursor-blink { display: inline-block; width: 0.5em; height: 0.85em; background: var(--text); margin-left: 0.3em;
  vertical-align: baseline; animation: blink 1s step-end infinite; }
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
summary { list-style: none; font-size: 0.85rem; padding: 0.6rem 0; }
summary::-webkit-details-marker { display: none; }
summary::before { content: '[+] '; }
details[open] > summary::before { content: '[-] '; }
details { border-top: 1px solid var(--border); margin: 0; }
#panels details:last-of-type { border-bottom: 1px solid var(--border); }
#setup details, #panels details { padding: 0 0 0.4rem; }
@media (prefers-reduced-motion: reduce) { .cursor-blink { animation: none; } }

h1.mark { margin: 4rem 0 3rem; font-size: 4rem; font-weight: 400; line-height: 1;
  text-transform: uppercase; letter-spacing: 2px; }
h1.mark .b, h1.mark .w { color: var(--text); }
.sub { margin: 0 0 24px; color: var(--dim); }
h2 { font-size: 1rem; font-weight: 400; text-transform: uppercase; letter-spacing: 2px; color: var(--text); margin: 18px 0 6px; }

#setup { padding: 0 0 1.5rem; }
#panels { padding: 0.5rem 0 3rem; border-top: 1px dashed var(--dim); }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin: 10px 0; }

/* [ BUTTON ] */
button, .button { background: transparent; color: var(--text); border: 0; border-radius: 0; padding: 0.6rem 1rem;
  font: inherit; font-size: 0.9rem; text-transform: uppercase; cursor: pointer; transition: all 0.2s; }
button::before, .button::before { content: '[ '; }
button::after, .button::after { content: ' ]'; }
button:hover, .button:hover { background: var(--text); color: var(--bg); }
button.big { font-size: 1.1rem; padding: 0.8rem 2rem; }
/* Play is the main thing on the page */
.play { display: flex; flex-direction: column; align-items: flex-start; gap: 10px; padding: 0.5rem 0 1.5rem; }
#start.big { font-size: 1.7rem; padding: 1.1rem 4rem; letter-spacing: 3px; }
button:disabled, button:disabled:hover, .button:has(input:disabled), .button:has(input:disabled):hover { color: #555; background: transparent; cursor: default; }

input[type=password], input[type=text], input[type=url], select, textarea {
  background: var(--bg); color: var(--text); border: 1px solid var(--border); border-radius: 0; padding: 6px 8px;
  font: inherit; max-width: 100%; }
input:focus { border-color: var(--text); outline: none; }
#pw { width: 16em; }
#aes-key { width: 36em; }
#remote-url { width: 28em; }
textarea { width: 100%; }

.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; color: var(--dim); cursor: pointer; }
.check input { accent-color: #fff; margin: 0; }
.check:hover { color: var(--text); }
.files { margin: 6px 0; padding: 0 0 0 18px; max-height: 150px; overflow: auto; font-size: 13px; color: #bbb; }
.muted { color: var(--dim); }
.grid { display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.grid label { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; color: var(--dim); }
details { margin: 16px 0 0; }
summary { cursor: pointer; color: var(--dim); text-transform: uppercase; letter-spacing: 1px; }
summary:hover { color: var(--text); }
details[open] summary { color: var(--text); margin-bottom: 6px; }

.ctl { list-style: none; margin: 6px 0; padding: 0; color: var(--dim); font-size: 0.9rem; }
.ctl li { margin: 4px 0; }
.ctl b { color: var(--text); font-weight: 400; margin-right: 0.6em; }
#panels p { margin: 6px 0; font-size: 0.9rem; }
/* Paged slot grid in the style of the game's Data Save screen: 5 x 4 cells per page */
.slotgrid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px 6px; margin: 8px 0; }
.cell { cursor: pointer; min-width: 0; outline-offset: 2px; }
.cell .no { font-size: 11px; color: #6cf; margin-bottom: 2px; }
.cell .thumb { width: 100%; }
.cell.empty .thumb { background: #1a1a1a; color: #666; border-style: dashed; font-size: 10px; letter-spacing: 1px; text-align: center; }
.cell:hover .thumb { border-color: var(--dim); }
.cell.sel .thumb { border: 2px solid var(--text); box-shadow: 0 0 8px #fff8; }
.cell.sel .no { color: var(--text); }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 0; }
.tabs button { font-size: 0.75rem; padding: 0.3rem 0.5rem; color: var(--dim); }
.tabs button.on { color: var(--text); }
.thumb { width: 128px; aspect-ratio: 16 / 9; flex: none; border: 1px solid var(--border); background: #111; display: flex;
  align-items: center; justify-content: center; color: var(--dim); font-size: 11px; overflow: hidden; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
#slot-picker .check { align-items: center; }
.pick-row { display: flex; align-items: center; gap: 12px; margin: 6px 0 10px; color: var(--text); }
#slot-picker { border: 1px dashed var(--dim); padding: 0.5rem 1rem; margin: 10px 0; }
#slot-picker h2 { margin-top: 6px; }
#panels b { color: var(--text); font-weight: 400; }
#game { padding: 16px 0; }
/* SDL sets pixel sizes on the canvas; in the page (not fullscreen) it always fits the column. */
body:not(.fs) #canvas { width: 100% !important; height: auto !important; }
#canvas { display: block; width: 100%; max-width: 1280px; aspect-ratio: 16 / 9; background: #000; outline: none;
  margin: 8px 0; border: 1px solid var(--border);
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent; }
#log { background: var(--bg); color: #aaa; border: 1px dashed var(--dim); padding: 8px; height: 220px; overflow: auto;
  font: 12px/1.4 var(--font); white-space: pre-wrap; margin: 6px 0 0; }
footer { text-align: center; padding: 4rem 2rem; border-top: 1px solid var(--border); color: var(--dim); font-size: 0.8rem; }
footer p { margin: 0; }

/* Fullscreen: real (Fullscreen API) or pseudo (iPhone Safari has no element fullscreen): the canvas fills the
   screen inside the safe area, letterboxed to 16:9 by app.js. */
body.fs { overflow: hidden; overscroll-behavior: none; }
body.fs > *:not(main), body.fs main > *:not(#game) { display: none !important; }
body.fs main { max-width: none; padding: 0; }
body.fs #game { position: fixed; inset: 0; z-index: 10; background: #000; margin: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  display: flex; align-items: center; justify-content: center; }
body.fs #game .row { display: none; }
body.fs #canvas { margin: 0; max-width: none; aspect-ratio: auto; border: 0; }
#fs-exit { position: fixed; z-index: 11; top: calc(env(safe-area-inset-top) + 6px); right: calc(env(safe-area-inset-right) + 6px);
  padding: 3px 8px; font-size: 12px; background: #000; color: var(--text); border: 1px solid var(--border); transition: opacity .35s; }
#fs-exit::before, #fs-exit::after { content: ''; }
#fs-exit .fs-x { display: none; }
/* PC: hidden until the mouse goes to the top-right corner (Esc always works). */
@media (hover: hover) and (pointer: fine) {
  #fs-exit { opacity: 0; pointer-events: none; }
  #fs-exit.show { opacity: .9; pointer-events: auto; }
}
/* Touch: a small X in the top-right corner. */
@media (hover: none), (pointer: coarse) {
  #fs-exit { width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; opacity: .6; border-color: transparent; top: calc(env(safe-area-inset-top) + 4px); right: calc(env(safe-area-inset-right) + 4px); }
  #fs-exit .fs-text { display: none; }
  #fs-exit .fs-x { display: block; width: 12px; height: 12px; }
}

@media (max-width: 768px) {
  :root { --nav-h: 48px; }
  .top-nav { padding: 0 max(0.75rem, env(safe-area-inset-right)) 0 max(0.75rem, env(safe-area-inset-left));
    border-bottom: 1px solid var(--border); }
  .top-nav .logo { font-size: 0.85rem; }
  .top-nav .links a { font-size: 0.72rem; padding: 0.9rem 0.3rem; }
  main { padding: 0 1rem 3rem; }
  h1.mark { margin: 2.5rem 0 2rem; font-size: 2.1rem; letter-spacing: 1px; }
  #start.big { width: 100%; font-size: 1.4rem; padding: 1.1rem 1rem; }
  main > section, #slot-picker, .grid-wrap { min-width: 0; max-width: 100%; }
  #panels .row, #game .row, #setup .row { gap: 4px; }
  #panels .row > *, #game .row > * { flex: 1 1 auto; text-align: center; padding: 0.7rem 0.5rem; }
  .slotgrid { gap: 6px 4px; }
  .cell .no { font-size: 9px; }
  .cell.empty .thumb { font-size: 8px; letter-spacing: 0; }
  .tabs button { flex: 1; }
  #slot-picker { padding: 0.5rem; }
  #canvas { border-left: 0; border-right: 0; }
  footer { padding: 2.5rem 1rem calc(2.5rem + env(safe-area-inset-bottom)); }
}
