/* MejaPi0 on the web. The menu and games are pixel-art canvases; the
   forms around them borrow the launcher's palette and chunky boxes. */

:root {
  --black: #000000;
  --navy: #1d2b53;
  --purple: #7e2553;
  --dgrey: #5f574f;
  --lgrey: #c2c3c7;
  --white: #fff1e8;
  --red: #ff004d;
  --orange: #ffa300;
  --yellow: #ffec27;
  --green: #00e436;
  --blue: #29adff;
  --lavender: #83769c;
  --font: ui-monospace, "Cascadia Mono", "DejaVu Sans Mono", Menlo, Consolas, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--black);
  color: var(--white);
  font: 16px/1.45 var(--font);
  -webkit-text-size-adjust: 100%;
}

#app { height: 100%; }

.loading { text-align: center; padding: 3rem 1rem; color: var(--lgrey); }

a { color: var(--blue); }
a:hover { color: var(--yellow); }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

canvas { image-rendering: pixelated; image-rendering: crisp-edges; }

/* ---- menu and player: a canvas centred on black ---------------------- */
.menu, .player-root, .player, .stage {
  width: 100%;
  height: 100%;
}

.menu, .stage {
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

.menu-canvas:focus { outline: none; }

/* The toolbar has its own strip above the game, so it never covers a
   game's own buttons (Master of Xeno has BACK in its top-right corner). */
.player {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--black);
}

.stage { position: relative; flex: 1; height: auto; min-height: 0; }

.screen { display: block; touch-action: none; }

.status {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 0.75rem 1.25rem;
  background: var(--navy);
  border: 3px solid var(--yellow);
  color: var(--yellow);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  pointer-events: none;
}
.status[hidden] { display: none; }

.toolbar {
  order: -1;
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  padding: max(4px, env(safe-area-inset-top)) max(6px, env(safe-area-inset-right)) 4px 6px;
}

.tool {
  font: bold 12px/1 var(--font);
  padding: 5px 9px;
  background: var(--black);
  color: var(--lgrey);
  border: 2px solid var(--dgrey);
  cursor: pointer;
}
.tool:hover, .tool:focus-visible { background: var(--purple); color: var(--white); border-color: var(--white); }
.tool.exit:hover { background: var(--red); }
.tool[hidden] { display: none; }

.rotate-hint { display: none; }
@media (orientation: portrait) and (pointer: coarse) {
  .rotate-hint {
    display: block;
    position: absolute;
    bottom: max(16px, env(safe-area-inset-bottom));
    left: 16px;
    right: 16px;
    text-align: center;
    color: var(--lavender);
    font-size: 0.9rem;
    pointer-events: none;
  }
}

/* Off screen but focusable, so phones open their keyboard for it. */
.text-input {
  position: absolute;
  left: 0;
  bottom: 0;
  width: 1px;
  height: 1px;
  opacity: 0;
  font-size: 16px; /* stops iOS zooming in */
  border: 0;
  padding: 0;
}

/* ---- forms: login, sign-up, settings ------------------------------------ */
.page {
  min-height: 100%;
  padding: 24px 16px 48px;
  background: var(--black) url("/sky.png") center / cover no-repeat fixed;
  image-rendering: pixelated;
}

.panel {
  max-width: 34rem;
  margin: 0 auto;
  padding: 20px;
  background: var(--navy);
  border: 4px solid var(--blue);
  box-shadow: 0 0 0 4px var(--black);
  image-rendering: auto;
}

.pixel-heading {
  display: block;
  height: auto;
  max-width: 100%;
  margin: 4px auto 16px;
}

.lead { color: var(--lgrey); text-align: center; margin-top: 0; }
.small { font-size: 0.85rem; color: var(--lgrey); text-align: center; }

form { display: grid; gap: 14px; }
form.inline { grid-template-columns: 1fr auto; align-items: end; }
form.inline .error { grid-column: 1 / -1; }

.field { display: grid; gap: 4px; }
.field > span { color: var(--yellow); font-weight: bold; font-size: 0.9rem; text-transform: uppercase; }
.field small { color: var(--lavender); }

input, select {
  font: inherit;
  width: 100%;
  min-width: 0;
  padding: 9px 10px;
  color: var(--white);
  background: var(--black);
  border: 2px solid var(--dgrey);
  border-radius: 0;
}
input:focus, select:focus { outline: none; border-color: var(--yellow); }
input[type="checkbox"], input[type="radio"] { width: 22px; height: 22px; padding: 0; accent-color: var(--green); margin: 0; flex: none; }

button, a.button {
  font: bold 0.95rem/1 var(--font);
  padding: 11px 16px;
  color: var(--white);
  background: var(--purple);
  border: 3px solid var(--white);
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button:hover, a.button:hover { background: var(--red); color: var(--white); }
button:disabled { opacity: 0.5; cursor: wait; }
button.big { font-size: 1.1rem; padding: 14px; }
button.logout { background: var(--black); border-color: var(--dgrey); color: var(--lgrey); width: 100%; }

.error {
  margin: 0;
  padding: 8px 10px;
  color: var(--white);
  background: var(--purple);
  border-left: 4px solid var(--red);
}
.error[hidden] { display: none; }

.top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.saved { margin: 0; color: var(--green); font-size: 0.9rem; min-height: 1.3em; }

section { margin-top: 26px; display: grid; gap: 12px; }
h2 {
  margin: 0;
  padding-bottom: 4px;
  font-size: 1rem;
  color: var(--orange);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-bottom: 2px dashed var(--dgrey);
}

.programs { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.programs label {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px;
  background: rgba(0, 0, 0, 0.35);
  cursor: pointer;
}
.programs label:hover { background: var(--purple); }
.icon { width: 32px; height: 32px; flex: none; }
.pname { display: grid; }
.pname small { color: var(--lgrey); font-size: 0.8rem; }
.person { display: grid; gap: 6px; }
.password { margin: 4px 0; padding: 12px; font-size: 1.4rem; letter-spacing: 0.05em; text-align: center;
  color: var(--yellow); background: rgba(0, 0, 0, 0.45); border: 2px dashed var(--orange); user-select: all; }
.reveal-wrap { display: flex; gap: 6px; }
.reveal-wrap input { flex: 1; }
.reveal { flex: none; padding: 0 12px; }
.pw-picker { display: grid; gap: 8px; }
.pw-choices { display: grid; gap: 4px; }
.pw-choice { display: flex; align-items: center; justify-content: flex-start; gap: 10px; padding: 5px 10px;
  cursor: pointer; text-align: left; background: rgba(0, 0, 0, 0.35); }
.pw-choice input { flex: none; margin: 0; }
.pw-choice:hover, .pw-choice:has(input:checked) { background: var(--purple); }
.pw-choice span { color: var(--yellow); }
.invites { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.invites li { display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 6px 8px; background: rgba(0, 0, 0, 0.35); }
.invites small { color: var(--lgrey); }
.made { display: grid; gap: 6px; padding: 8px; border-left: 4px solid var(--green); background: rgba(0, 0, 0, 0.35); }
.made p { margin: 0; }
.made input { width: 100%; }
.person h3 { margin: 6px 0 0; font-size: 1rem; color: var(--white); }
.person h3 small { color: var(--lgrey); font-weight: normal; font-size: 0.8rem; }

@media (max-width: 420px) {
  .panel { padding: 14px; }
  form.inline { grid-template-columns: 1fr; }
}
