﻿/* pkmn-web hub: styled after FireRed's own front end (night sky, flames, GBA text windows, the red ▶ menu cursor).
   Pure CSS, no game art (that is the player's own data) and no web fonts (strict CSP). */
:root {
  --bg: #101018; --fg: #f4f0e8; --dim: #9a96a8; --accent: #e8572a; --blb-handoff: #101018; /* = the html background (blb-site handoff.css) */
  --ink: #383838; --ink2: #6e6e80; --paper: #f8f8f8; --line: #c8c8d4;
  --red: #e03a22; --red-d: #8e1a0e; --yel: #ffcb05; --blu: #2a3a9c; --navy: #1c2438;
  --pix: ui-monospace, "Cascadia Mono", "Lucida Console", Consolas, "Courier New", monospace;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--fg); font: 16px/1.4 system-ui, sans-serif; }
body { display: grid; place-items: center; overflow: hidden; background: transparent; }
[hidden] { display: none !important; }

/* ---------------- start screen ---------------- */
#start { position: relative; z-index: 1; width: min(520px, calc(100vw - 24px)); max-height: 100vh; overflow-y: auto; overflow-x: hidden;
  padding: 28px 4px 24px; text-align: center; scrollbar-width: thin; }

/* the scene behind it: night sky, a flame glow rising from the bottom, embers drifting up */
#scene { position: fixed; inset: 0; z-index: -1; pointer-events: none; overflow: hidden;
  background:
    radial-gradient(ellipse 90% 55% at 50% 112%, #ffb02e 0%, #ff6a1a 22%, #c4281a 48%, transparent 72%),
    radial-gradient(ellipse 60% 40% at 15% 108%, #ff7a1a88, transparent 70%),
    radial-gradient(ellipse 60% 40% at 85% 108%, #ff7a1a88, transparent 70%),
    linear-gradient(#0a0a14 0%, #1a1020 55%, #2a0e14 100%); }
#scene::before { content: ""; position: absolute; inset: auto 0 0 0; height: 46%; opacity: .9;
  background: radial-gradient(ellipse 50% 100% at 50% 100%, #ffd24a66, transparent 70%); animation: flicker 1.1s steps(2) infinite; }
#scene::after { content: ""; position: absolute; inset: 0; /* GBA-ish scanlines */
  background: repeating-linear-gradient(transparent 0 2px, rgba(0, 0, 0, .18) 2px 3px); }
#scene i { position: absolute; left: 0; top: 0; width: 4px; height: 4px; background: #ffb02e; opacity: .85; animation: rise 11s linear infinite; }
#scene i:nth-child(2) { width: 3px; height: 3px; background: #ff7a1a; animation-duration: 15s; animation-delay: -6s; }
#scene i:nth-child(1) { box-shadow: 8vw 130vh #ff7a1a, 22vw 160vh #ffd24a, 37vw 112vh #ffb02e, 51vw 175vh #ff7a1a, 64vw 140vh #ffd24a, 78vw 118vh #ffb02e, 91vw 190vh #ff7a1a, 15vw 195vh #ffd24a, 44vw 150vh #ff7a1a; }
#scene i:nth-child(2) { box-shadow: 4vw 170vh #ffb02e, 30vw 125vh #ff7a1a, 58vw 185vh #ffd24a, 72vw 135vh #ffb02e, 85vw 160vh #ff7a1a, 96vw 115vh #ffd24a, 12vw 145vh #ffb02e, 47vw 105vh #ffd24a; }
@keyframes rise { to { transform: translateY(-200vh); } }
@keyframes flicker { 50% { opacity: .65; } }

/* logo: the yellow/blue Pokémon wordmark, FireRed in flame colours, a Soul Link plate */
.logo { margin: 0 0 6px; display: flex; flex-direction: column; align-items: center; line-height: 1; font-family: "Arial Black", Impact, "Segoe UI Black", system-ui, sans-serif; }
.logo .pk { font-size: clamp(26px, 7vw, 40px); letter-spacing: .05em; color: var(--yel); font-weight: 900;
  -webkit-text-stroke: 7px var(--blu); paint-order: stroke fill; text-shadow: 0 4px 0 #14206a; transform: rotate(-2deg); }
.logo .fr { margin-top: 2px; font-size: clamp(52px, 15vw, 88px); font-weight: 900; font-style: italic; letter-spacing: -.02em; padding: 0 .08em;
  color: transparent; background: linear-gradient(#fff2a0 0%, #ffb02e 30%, #ff5a1a 62%, #b8180e 100%); -webkit-background-clip: text; background-clip: text;
  filter: drop-shadow(0 0 1px #2a0604) drop-shadow(3px 3px 0 #2a0604) drop-shadow(-2px -2px 0 #2a0604) drop-shadow(2px -2px 0 #2a0604) drop-shadow(-2px 2px 0 #2a0604); }
.logo .sl { position: relative; margin-top: 12px; padding: 7px 22px 6px; font: 800 clamp(12px, 3.4vw, 15px)/1 var(--pix); letter-spacing: .5em; text-indent: .5em; text-transform: uppercase;
  color: var(--paper); background: var(--navy); border: 3px solid var(--paper); border-radius: 6px; box-shadow: 0 0 0 3px var(--navy), 3px 6px 0 3px #00000066; }
.ball { display: inline-block; vertical-align: -.12em; width: 1.1em; height: 1.1em; margin: 0 .55em; border-radius: 50%; border: .1em solid #202028;
  background: linear-gradient(#e8281c 0 44%, #202028 44% 56%, #f8f8f8 56%); position: relative; }
.ball::after { content: ""; position: absolute; left: 50%; top: 50%; width: .36em; height: .36em; margin: -.18em 0 0 -.18em; border-radius: 50%;
  background: #f8f8f8; border: .08em solid #202028; }

/* shared GBA text window: white, dark outline, salmon inner ring */
#status, #modes, #lobby, .drop, #quit .card, #over .card, #charPick .card {
  background: var(--paper); color: var(--ink); text-shadow: 1px 1px 0 #c8c8d0;
  border: 4px solid #383848; border-radius: 10px; box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 5px #e8806a, 3px 6px 0 #00000066;
  font-family: var(--pix); }

/* the status line is the battle-style message box: dark navy, white border */
#status { margin: 18px 0 0; min-height: 0; padding: 12px 16px 12px 34px; position: relative; text-align: left; font-size: 14px; line-height: 1.5;
  background: var(--navy); color: var(--paper); border-color: var(--paper); box-shadow: 0 0 0 3px var(--navy), 3px 8px 0 3px #00000066; text-shadow: 1px 1px 0 #000; }
#status:empty { display: none; }
#status::before { content: "\25B6"; position: absolute; left: 13px; top: 12px; font-size: 12px; color: var(--yel); animation: nudge .8s steps(2) infinite; }
#status.error { color: #ffb0a0; }
#status.error::before { color: #ff6a5a; }
@keyframes nudge { 50% { transform: translateX(3px); } }
#start > * + #status, #start > .logo + #status { margin-top: 18px; }

/* ROM drop: the "NEW GAME" window */
.drop { display: block; margin-top: 16px; padding: 26px 18px; cursor: pointer; text-align: center; }
.drop:hover, .drop.over { box-shadow: inset 0 0 0 3px var(--paper), inset 0 0 0 5px var(--red), 3px 6px 0 #00000066; }
.drop input { display: none; }
.drop strong { display: block; margin-bottom: 8px; font-size: 16px; text-transform: uppercase; letter-spacing: .04em; }
.drop:hover strong::before, .drop.over strong::before { content: "\25B6\00a0"; color: var(--red); }
.drop small { color: var(--ink2); font-size: 12px; line-height: 1.5; }

/* buttons */
button { font: inherit; margin-top: 16px; padding: 10px 36px; border: 0; border-radius: 8px; background: var(--accent); color: #fff; font-weight: 600; cursor: pointer; }
button.link { display: block; margin: 12px auto 0; padding: 4px; background: none; color: var(--dim); font-weight: 400; text-decoration: underline; }
button.primary, button.secondary { display: block; width: 100%; margin: 18px 0 0; padding: 12px; font: 800 15px/1.2 var(--pix); letter-spacing: .08em; text-transform: uppercase;
  border: 3px solid var(--red-d); border-radius: 6px; }
button.primary { background: linear-gradient(#ff6a4a, var(--red) 55%, #c42a14); color: #fff; text-shadow: 1px 1px 0 #6a0e04; box-shadow: 0 4px 0 var(--red-d), 0 6px 0 #00000055; }
button.primary:hover, button.primary:focus-visible { background: linear-gradient(#ff8466, #ee4a30 55%, #d23418); outline: 0; }
button.primary:active { transform: translateY(4px); box-shadow: 0 0 0 var(--red-d); }
button.secondary { background: #e8e8f0; color: var(--ink); border-color: #6a6a80; text-shadow: none; box-shadow: 0 4px 0 #6a6a80, 0 6px 0 #00000033; }
button.secondary:hover, button.secondary:focus-visible { background: #fff; outline: 0; }
button.secondary:active { transform: translateY(4px); box-shadow: 0 0 0 #6a6a80; }
button.primary::before { content: "\25B6\00a0"; }

/* Host / Join / Solo: one window, the three modes are its menu */
#modes { margin-top: 18px; text-align: left; overflow: hidden; }
.tabs { display: flex; padding: 10px 10px 0; border-bottom: 3px solid var(--line); }
.tabs .tab { flex: 1; margin: 0; padding: 10px 0 12px; background: none; border-radius: 0; color: var(--ink2); font: 800 15px/1 var(--pix); letter-spacing: .1em; text-transform: uppercase; text-shadow: inherit; }
.tabs .tab::before { content: "\25B6"; display: inline-block; width: 1.1em; color: var(--red); visibility: hidden; font-size: .8em; }
.tabs .tab:hover { color: var(--ink); }
.tabs .tab:hover::before { visibility: visible; opacity: .5; }
.tabs .tab[aria-selected=true] { color: var(--ink); box-shadow: inset 0 -4px 0 var(--red); }
.tabs .tab[aria-selected=true]::before { visibility: visible; opacity: 1; animation: nudge .8s steps(2) infinite; }
.tabs .tab:focus-visible { outline: 2px dotted var(--red); outline-offset: -4px; }
.tabpanel { margin: 0; padding: 16px 18px 20px; }
.hint { margin: 0 0 14px; color: var(--ink2); font-size: 13px; line-height: 1.5; }
.field { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.field > span:first-child { flex: 0 0 5.5em; color: var(--ink2); font-size: 13px; text-transform: uppercase; letter-spacing: .06em; }
.field input, .field select, .field .inline { flex: 1; min-width: 0; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline select { flex: 1; min-width: 0; }
input, select { font: 14px var(--pix); padding: 9px 10px; border-radius: 4px; border: 3px solid #6a6a80; background: #fff; color: var(--ink); text-shadow: none; }
input:focus-visible, select:focus-visible { outline: 0; border-color: var(--red); }
select { color-scheme: light; }
option { background: #fff; color: var(--ink); text-shadow: none; }
option:checked, option:hover { background: var(--red); color: #fff; }
::placeholder { color: #9a9aa8; }
.check { display: flex; align-items: center; gap: 8px; margin-top: 12px; color: var(--ink); font-size: 13px; cursor: pointer; }
.check input { width: auto; accent-color: var(--red); }
.joinrow { display: flex; justify-content: center; }
input.code { width: 100%; font-size: 1.7rem; font-weight: 800; letter-spacing: .3em; text-indent: .3em; text-align: center; text-transform: uppercase; }
#runDel, #modes button.link { margin: 0; padding: 4px; white-space: nowrap; color: var(--red-d); font-size: 12px; }
.or { display: flex; align-items: center; gap: 12px; margin-top: 18px; color: var(--ink2); font-size: 12px; text-transform: uppercase; letter-spacing: .1em; }
.or::before, .or::after { content: ""; flex: 1; height: 3px; background: var(--line); }
.or + button.secondary { margin-top: 14px; }
#lobbyList { list-style: none; margin: 10px 0 0; padding: 0; }
#lobbyList li { display: flex; justify-content: space-between; align-items: center; gap: 12px; padding: 6px 10px; border: 3px solid var(--line); border-radius: 6px; margin-top: 6px; font-size: 13px; }
#lobbyList li button { margin: 0; padding: 4px 16px; font: 800 12px var(--pix); text-transform: uppercase; background: var(--red); border: 2px solid var(--red-d); border-radius: 4px; }

/* waiting for a partner */
#lobby { margin-top: 18px; padding: 20px; }
#lobby .hint { margin: 0; text-transform: uppercase; letter-spacing: .1em; }
#lobby strong { display: block; margin: 6px 0 8px; font-size: 2.8rem; letter-spacing: .2em; text-indent: .2em; color: var(--red); user-select: all; text-shadow: 2px 2px 0 #f0b8a8; }
#lobby small { color: var(--ink2); font-size: 12px; line-height: 1.5; }
#lobby button.secondary { width: auto; margin: 14px auto 0; padding: 8px 24px; }
#start > button.link { color: #d8d4e4; text-shadow: 1px 1px 0 #000; }
#cancelBtn { margin-top: 18px; }

/* EXIT sits in the corner, not in the centred column (handoff.css styles the link itself) */
#start > .blb-exit { position: fixed; top: 14px; left: 14px; margin: 0; z-index: 2; }

/* ---------------- in game ---------------- */
#stage { position: fixed; inset: 0; display: grid; place-items: center; background: #000; }
#screen { image-rendering: pixelated; width: calc(240px * var(--scale, 3)); height: calc(160px * var(--scale, 3)); }

#hud { position: fixed; top: 8px; right: 8px; min-width: 220px; padding: 8px 10px; border-radius: 8px; border: 2px solid #f8f8f880;
  background: #1c2438ee; font-size: 13px; }
#hud table { width: 100%; border-collapse: collapse; margin: 6px 0; }
#hud th { text-align: left; color: var(--dim); font-weight: 600; }
#hud td, #hud th { padding: 2px 6px 2px 0; }
#hud tr.dead td { color: #ff8a7a; text-decoration: line-through; }
#hudState { font-weight: 600; color: #8fe08f; }
#hudState.bad, #hudWarn { color: #ff8a7a; }
#hudWarn { white-space: pre-line; }
#hudNet { color: var(--dim); margin-bottom: 4px; }
#hud small { color: var(--dim); }
#hudGate { margin: 4px 0; font-weight: 600; color: #8fe08f; }
#hudGate.wait { color: #ffd27a; }
#hudGate.bad { color: #ff8a7a; }

#banner { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); max-width: 90vw; padding: 10px 18px;
  border-radius: 8px; background: var(--navy); border: 3px solid #ff8a7a; color: var(--fg); font-weight: 600; text-align: center; }
#banner.ok { border-color: #8fe08f; }
#ffBadge { position: fixed; left: 50%; top: 10px; transform: translateX(-50%); max-width: 92vw; padding: 6px 14px; border-radius: 8px;
  font: 700 13px/1.3 var(--pix, monospace); text-align: center; pointer-events: none; z-index: 3; }
#ffBadge.on { background: #ffd27af2; color: #2a1c00; border: 3px solid #b8860b; }
#ffBadge.hint { background: #1c2438d9; color: #f0eef8; border: 2px solid #f8f8f860; font-weight: 600; }
#menuBtn { position: fixed; top: 8px; left: 8px; margin: 0; padding: 4px 12px; font-size: 13px; opacity: .35; background: #2a2838; }
#stats { position: fixed; left: 8px; bottom: 8px; margin: 0; padding: 6px 8px; border-radius: 6px; background: #000000b0;
  color: #8fe08f; font: 12px/1.4 monospace; pointer-events: none; }
#menuBtn:hover, #menuBtn:focus-visible { opacity: 1; }
#over, #quit { position: fixed; inset: 0; display: grid; place-items: center; background: #000000d9; }
#over .card, #quit .card { width: min(420px, calc(100vw - 32px)); padding: 26px 24px; text-align: center; }
#over h2 { margin: 0 0 12px; font-size: 1.8rem; letter-spacing: .08em; text-transform: uppercase; color: var(--red); text-shadow: 2px 2px 0 #f0b8a8; }
#over p { margin: 6px 0; }
#overTally, #quitNote { color: var(--ink2); }
#quit p { margin: 6px 0; }
#quit hr { border: 0; border-top: 3px solid var(--line); margin: 18px 0 8px; }
.setrow { display: flex; align-items: center; gap: 12px; }
.setrow input[type=range] { flex: 1; min-width: 0; padding: 0; border: 0; background: none; accent-color: var(--red); }
.setrow output { width: 4ch; text-align: right; color: var(--ink2); }
#quit button.primary, #quit button.secondary { margin-top: 14px; }
#quit h2 { margin: 0 0 12px; font-size: 1.5rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); }
#over button:not(.link), #quit button.link { margin-top: 14px; }
#over button:not(.link) { padding: 10px 24px; font: 800 14px var(--pix); text-transform: uppercase; background: var(--red); border: 3px solid var(--red-d); }
#over button.link, #quit button.link { color: var(--ink2); }

#fail { position: fixed; inset: 16px; margin: 0; padding: 16px; overflow: auto; background: #200; color: #fcc;
  white-space: pre-wrap; font: 13px/1.4 ui-monospace, monospace; }

@media (max-width: 420px) { .field { flex-wrap: wrap; gap: 4px; } .field > span:first-child { flex-basis: 100%; } .tabs .tab { font-size: 13px; letter-spacing: .04em; } }
@media (prefers-reduced-motion: reduce) { #scene::before, #scene i, #status::before, .tabs .tab::before { animation: none !important; } }

/* team panel (T) */
#teams { position: fixed; top: 44px; left: 8px; width: min(380px, calc(100vw - 16px)); max-height: calc(100vh - 56px); overflow: auto; padding: 8px 10px;
  border-radius: 8px; border: 2px solid #f8f8f880; background: #1c2438ee; font-size: 13px; z-index: 2; }
#teams .trow { display: grid; grid-template-columns: 1fr 22px 1fr; align-items: center; gap: 4px; padding: 3px 0; border-bottom: 1px solid #f8f8f820; }
#teams .thead { color: var(--dim); font-weight: 700; border-bottom: 2px solid #f8f8f840; }
#teams .trow.linked { background: #8fe08f12; }
#teams .tlink { text-align: center; color: #8fe08f; font-weight: 700; }
#teams .tcell { display: flex; align-items: center; gap: 4px; min-width: 0; }
#teams .tcell.empty { min-height: 36px; }
#teams .tcell.fainted { opacity: .55; filter: grayscale(1); }
#teams .ticon { width: 48px; height: 48px; image-rendering: pixelated; flex: none; }
#teams .tname { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#teams small { color: var(--dim); display: block; }
#teams meter { width: 100%; height: 8px; display: block; }
#teams .tnone { margin: 8px 0; color: var(--dim); }

/* outfit colour picker */
#charPick { position: fixed; inset: 0; display: grid; place-items: center; background: #000000d9; z-index: 5; overflow: auto; }
#charPick .card { width: min(520px, calc(100vw - 24px)); padding: 20px 18px; text-align: center; max-height: 100vh; overflow: auto; }
#charPick h2 { margin: 0 0 8px; font-size: 1.5rem; text-transform: uppercase; letter-spacing: .08em; color: var(--ink); }
#charEdit { display: flex; gap: 14px; align-items: flex-start; justify-content: center; text-align: left; margin: 12px 0; }
#charPrevs { display: flex; gap: 6px; flex: none; padding: 6px; background: #0002; border-radius: 6px; }
#charPrevs canvas { width: 64px; height: 128px; image-rendering: pixelated; }
#charEdit > div:last-child { flex: 1; min-width: 0; }
#charEdit .setrow { margin: 10px 0; }
#charPresets, #charSwatches { display: flex; flex-wrap: wrap; gap: 5px; margin: 6px 0; }
#charPresets button { width: 28px; height: 28px; padding: 0; margin: 0; border-radius: 50%; border: 3px solid transparent; cursor: pointer; box-shadow: 0 0 0 1px var(--ink2); }
#charPresets button[aria-pressed=true] { border-color: var(--ink); }
#charSwatches button { width: 22px; height: 22px; padding: 0; margin: 0; border-radius: 4px; border: 3px solid var(--ink2); cursor: pointer; }
#charSwatches button[aria-pressed=false] { border-style: dashed; opacity: .55; }
#charPick button.primary { margin-top: 10px; }
#charPick button.link { margin-top: 6px; color: var(--ink2); }
#charBtn { margin: 12px auto 0; width: auto; padding: 8px 24px; }
#charBtn2 { margin-top: 10px; }
/* gamepad focus ring on the page menus (app.js "gamepad on the page menus"); hidden again on mouse use */
body.pad button:focus, body.pad input:focus, body.pad select:focus, body.pad summary:focus, body.pad a:focus { outline: 3px solid #ffd23f; outline-offset: 2px; }
details.controls { margin: 8px 0; }
details.controls summary { cursor: pointer; font-weight: 700; }
details.controls table { width: 100%; border-collapse: collapse; margin-top: 6px; font-size: 13px; }
details.controls th, details.controls td { text-align: left; padding: 3px 6px; border-bottom: 1px solid rgba(0, 0, 0, .15); }
