/* ===========================================================================
   BlaGTroN - styles.

   Two colour themes, selected on the front page: dark (the default, a DOS /
   VGA look) and light. Each theme is just a set of CSS variables. The
   --arena-* and --p1..--p4 variables are also read by js/arena.js to draw
   the game, so the page and the arena always use the same colours.

   Fonts (in ../fonts/, SIL Open Font License, see the OFL-*.txt files there):
     Orbitron - titles, headings, buttons and short game texts ("Tron" look)
     Exo 2    - everything meant to be read: menus, explanations, key caps
   =========================================================================== */

/* ------------------------------ Fonts ------------------------------------- */

@font-face {
  font-family: "Orbitron";
  src: url("../fonts/orbitron-latin.woff2") format("woff2");
  font-weight: 400 900;          /* variable font: any weight in this range */
  font-display: swap;
}
@font-face {
  font-family: "Exo 2";
  src: url("../fonts/exo2-latin.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

/* ------------------------------ Themes ------------------------------------ */

body.theme-dark {
  /* Arena (read by js/arena.js) */
  --arena-background: #000000;
  --arena-wall: #FFFFFF;          /* border */
  --arena-head: #FFFFFF;          /* the moving head of each player */
  /* Players: the bright EGA/VGA colours, easier to see than the original dark ones */
  --p1: #55FF55;                  /* green   */
  --p2: #55FFFF;                  /* cyan    */
  --p3: #FF5555;                  /* red     */
  --p4: #FF55FF;                  /* magenta */

  /* Page */
  --page-background: #000000;
  --text: #AAAAAA;
  --strong: #FFFFFF;
  --accent: #FFFF55;
  --muted: #777777;
  --line: #555555;
  --key-background: #111111;
  --key-border: #333333;
  --button-background: #AAAAAA;
  --button-text: #000000;
  --button-hover: #FFFFFF;
  --start-background: #FFFF55;
  --start-text: #000000;
  --panel-background: #0000AA;    /* DOS-style blue window */
  --panel-text: #FFFFFF;
  --panel-border: #FFFFFF;
  --badge-background: #000000;    /* behind player names in the window */
  --banner-background: rgba(0, 0, 0, 0.75);
}

body.theme-light {
  /* Arena (read by js/arena.js) */
  --arena-background: #FFFFFF;
  --arena-wall: #000000;
  --arena-head: #000000;
  /* Players: strong, clearly different colours on white */
  --p1: #008A00;                  /* green  */
  --p2: #0057D8;                  /* blue   */
  --p3: #D80000;                  /* red    */
  --p4: #A100B8;                  /* purple */

  /* Page */
  --page-background: #F2F0EA;
  --text: #333333;
  --strong: #000000;
  --accent: #0000AA;
  --muted: #777777;
  --line: #AAAAAA;
  --key-background: #FFFFFF;
  --key-border: #CCCCCC;
  --button-background: #E0E0E0;
  --button-text: #000000;
  --button-hover: #FFFFFF;
  --start-background: #0000AA;
  --start-text: #FFFFFF;
  --panel-background: #FFFFFF;
  --panel-text: #000000;
  --panel-border: #000000;
  --badge-background: transparent;
  --banner-background: rgba(255, 255, 255, 0.85);
}

/* ------------------------------ Basics ------------------------------------ */

:root {
  --key-size: 3.1rem;
  /* Keep these two in sync with STATUS_FONT / LABEL_FONT in js/config.js. */
  --font-display: "Orbitron", "Segoe UI", system-ui, sans-serif;
  --font-text: "Exo 2", "Segoe UI", system-ui, sans-serif;
  font-family: var(--font-text);
  font-size: 17px;
  line-height: 1.4;
}

html, body { margin: 0; }
body {
  background: var(--page-background);
  color: var(--text);
}
[hidden] { display: none !important; }

.p1 { --pc: var(--p1); }
.p2 { --pc: var(--p2); }
.p3 { --pc: var(--p3); }
.p4 { --pc: var(--p4); }

kbd {
  font-family: var(--font-text);
  font-weight: 700;
  color: var(--strong);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 0 0.35em;
}
small { color: var(--muted); font-size: 0.9rem; }

/* ---------------------------- Front page ---------------------------------- */

#menu {
  max-width: 66rem;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

.title { text-align: center; }
.title p { margin: 0.3rem 0; }
.banner { font-family: var(--font-display); font-size: 2.3rem; color: var(--strong); margin-bottom: 0.6rem !important; }
.banner .name { color: var(--accent); font-weight: 900; margin: 0 0.5em; letter-spacing: 0.06em; }
.banner .stars { color: var(--text); font-size: 1.4rem; vertical-align: middle; }
.author { font-size: 1.05rem; }
.rules { margin-top: 1rem !important; color: var(--strong); font-size: 1.1rem; }

h2 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--accent);
  font-size: 1.2rem;
  letter-spacing: 0.04em;
  margin: 1.5rem 0 0.8rem;
}

/* Keyboard diagram */
.keyboards {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;           /* bottom rows line up, like on a real keyboard */
  justify-content: center;
  gap: 2rem;
}
.key-row { display: flex; }
.key {
  position: relative;
  box-sizing: border-box;
  width: calc(var(--key-size) - 0.3rem);
  height: calc(var(--key-size) - 0.3rem);
  margin: 0.15rem;
  border: 2px solid var(--key-border);
  border-radius: 6px;
  background: var(--key-background);
  display: flex;
  align-items: center;
  justify-content: center;
}
.key-label {
  position: absolute;
  top: 1px;
  left: 5px;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}
.key[data-player] { border-color: var(--pc); }
.key[data-player] .key-label { color: var(--strong); }
.key-symbol { color: var(--pc); font-size: 1.4rem; font-weight: bold; margin-top: 0.3rem; }
.key.centre { border-style: dashed; }
.key.centre .key-symbol { margin: 0 0.45rem 0.25rem 0; }   /* leave room for the tag */
/* Player tag in the corner of each centre key (S, G, K, 5) */
.key-tag {
  position: absolute;
  right: 4px;
  bottom: 1px;
  font-family: var(--font-display);
  font-size: 0.6rem;
  font-weight: 800;
  color: var(--pc);
}
.inactive { opacity: 0.25; }

.legend {
  list-style: none;
  padding: 0;
  margin: 1.2rem 0 0;
  display: grid;
  grid-template-columns: repeat(2, auto);
  justify-content: center;
  gap: 0.3rem 3rem;
}
.legend b { color: var(--pc); }
.keys-note { text-align: center; margin: 0.8rem 0 0; }
.keys-note b { color: var(--strong); }

/* Options */
.choices {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
  align-items: flex-start;
  margin-top: 1.5rem;
}
fieldset {
  border: 1px solid var(--line);
  padding: 0.6rem 1rem 0.8rem;
  margin: 0;
}
fieldset:first-child { flex: 1 1 24rem; }
legend { color: var(--accent); padding: 0 0.4rem; font-weight: 700; font-size: 1.05rem; }
fieldset label { display: block; padding: 0.2rem 0; cursor: pointer; }
.option-title { margin: 0.6rem 0 0.1rem; }
input { accent-color: var(--accent); }

button {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--button-text);
  background: var(--button-background);
  border: 2px solid var(--strong);
  padding: 0.55rem 1.6rem;
  cursor: pointer;
}
button:hover { background: var(--button-hover); }
button:focus-visible, input:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
#start {
  align-self: center;
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 0.7rem 2.5rem;
  color: var(--start-text);
  background: var(--start-background);
}

/* ------------------------------ Game -------------------------------------- */

#arena {
  display: block;
  image-rendering: pixelated;      /* keep 1-pixel trails sharp on high-DPI screens */
}

.overlay {
  position: fixed;
  left: 50%;
  top: 45%;
  transform: translate(-50%, -50%);
}

.banner-box {
  font-family: var(--font-display);
  color: var(--accent);
  font-size: 2.4rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  background: var(--banner-background);
  padding: 0.5rem 1.8rem;
  pointer-events: none;
}

/* Windows over the arena: scores, "Really quit?" */
.panel {
  min-width: 24rem;
  max-width: 90vw;
  background: var(--panel-background);
  color: var(--panel-text);
  border: 4px double var(--panel-border);
  padding: 1rem 2rem 1.5rem;
  text-align: center;
  font-size: 1.1rem;
  box-shadow: 0.6rem 0.6rem 0 rgba(0, 0, 0, 0.5);
}
.panel:focus { outline: none; }
.panel h2 { font-family: var(--font-display); color: var(--panel-text); font-size: 1.4rem; line-height: 1.5; margin: 0.5rem 0 1rem; }
.panel kbd { color: var(--panel-text); border-color: var(--panel-text); }
.panel .player-name {
  font-family: var(--font-text);
  color: var(--pc);
  font-weight: 800;
  background: var(--badge-background);   /* keeps player colours readable on the blue window */
  padding: 0 0.3em;
}
.scores { list-style: none; padding: 0; margin: 0 0 1rem; }
.scores li { display: flex; justify-content: space-between; align-items: baseline; gap: 2rem; padding: 0.2rem 0; }
.scores .score { font-family: var(--font-display); color: var(--accent); font-weight: 900; font-size: 1.3rem; }
.hint { opacity: 0.85; }
.buttons { display: flex; gap: 1rem; justify-content: center; }
