/* Astral Duelist's page on Flame Multiplayer Games: the stage the game plays in, and the strip of keys and links
   under it. Laid out like the site's other games' pages. */
:root {
  color-scheme: dark;
  --bg: #05070f;
  --stage: #020617;
  --text: #e8edf2;
  --muted: #8b97a3;
  --line: #1e293b;
  /* The game's cyan and amber. */
  --p1: #22d3ee;
  --p2: #fbbf24;
  --footer-height: 44px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  overflow: hidden;
}

#app {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
}

/* 16:9 stage that fits the window above the footer. */
#stage {
  position: relative;
  width: min(100%, calc((100vh - var(--footer-height) - 42px) * 16 / 9));
  aspect-ratio: 16 / 9;
  background: var(--stage);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
}

#stage:fullscreen {
  width: 100vw;
  height: 100vh;
  aspect-ratio: auto;
  border-radius: 0;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--stage);
}

#loader {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--stage);
}

#loader[hidden], #start[hidden] { display: none; }

/* Touch screens: one tap over the whole stage before the game, which lets it go full screen. */
#start {
  position: absolute;
  inset: 0;
  width: 100%;
  border: 0;
  background: rgba(2, 6, 23, 0.6);
  color: var(--text);
  font: inherit;
  font-size: clamp(20px, 3vw, 32px);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

#start:focus-visible { outline: 3px solid var(--p1); outline-offset: -6px; }

.logo {
  font-size: clamp(28px, 6vw, 64px);
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--p1);
}

.logo span { color: var(--p2); }

.bar {
  width: min(360px, 60%);
  height: 8px;
  background: var(--line);
  border-radius: 999px;
  overflow: hidden;
}

#bar-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--p1), var(--p2));
  transition: width 0.2s ease-out;
}

#loader-text { color: var(--muted); font-variant-numeric: tabular-nums; }

#footer {
  width: min(100%, calc((100vh - var(--footer-height) - 42px) * 16 / 9));
  min-height: var(--footer-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--muted);
  font-size: 13px;
}

.keys { display: flex; flex-wrap: wrap; gap: 6px 18px; }

kbd {
  display: inline-block;
  min-width: 1.6em;
  margin: 0 1px;
  padding: 1px 5px;
  border: 1px solid var(--line);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: #0f172a;
  color: var(--text);
  font: inherit;
  font-size: 12px;
  text-align: center;
}

.footer-buttons { display: flex; flex: none; gap: 8px; }

#fullscreen,
#more-games,
#contact {
  padding: 7px 14px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #0f172a;
  color: var(--text);
  font: inherit;
  text-decoration: none;
  cursor: pointer;
}

#fullscreen:hover:not(:disabled),
#more-games:hover,
#contact:hover { background: #172036; }
#fullscreen:disabled { opacity: 0.5; cursor: default; }
#fullscreen:focus-visible,
#more-games:focus-visible,
#contact:focus-visible { outline: 2px solid var(--p1); outline-offset: 2px; }

#rotate-note {
  display: none;
  position: absolute;
  inset: 0;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--stage);
  font-size: 20px;
  font-weight: 700;
  text-align: center;
}

/* Playing a friend online: a button in the stage's corner (out of the way of the hangar, and hidden during a
   match), the panel it opens, and a line of news at the top. They come before the loader in the page, which so
   covers them. */
#online-button {
  position: absolute;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(12px, env(safe-area-inset-bottom));
  padding: 8px 14px;
  border: 1px solid var(--p1);
  border-radius: 999px;
  background: rgba(8, 15, 33, 0.92);
  color: var(--p1);
  font: inherit;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), 0 0 14px rgba(34, 211, 238, 0.25);
}

#online-button:hover { background: #10203a; }
#online-button.on { border-color: var(--p2); color: var(--p2); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.6), 0 0 14px rgba(251, 191, 36, 0.25); }

#online-panel {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  background: rgba(2, 6, 23, 0.78);
}

#online-button[hidden], #online-panel[hidden], #online-toast[hidden],
#online-start[hidden], .online-card [hidden] { display: none; }

.online-card {
  width: min(420px, 100%);
  max-height: 100%;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 18px 20px;
  border: 1px solid #155e75;
  border-radius: 14px;
  background: #0b1224;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.7);
  text-align: center;
}

.online-card h2 {
  margin: 0;
  color: var(--p1);
  font-size: 17px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.online-card p { margin: 0; color: #cbd5e1; }
#online-note { color: var(--p2); font-weight: 600; overflow-wrap: anywhere; }

#online-code {
  color: var(--p2);
  font: 800 clamp(30px, 7vw, 44px)/1.1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.18em;
  user-select: all;
}

#online-start { display: flex; flex-direction: column; gap: 10px; }
#online-join { display: flex; gap: 8px; }

#online-code-box {
  flex: 1;
  min-width: 0;
  padding: 9px 12px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #020617;
  color: var(--text);
  /* 16px or more, or iPhones zoom the page in when the box is tapped. */
  font: 700 18px/1.2 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.14em;
  text-align: center;
  text-transform: uppercase;
}

#online-code-box::placeholder { color: #475569; }

.online-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }

.online-card button {
  padding: 9px 16px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #0f172a;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.online-card button:hover { background: #172036; }
#online-host, #online-join button, #online-copy { border-color: var(--p1); background: var(--p1); color: #020617; }
#online-host:hover, #online-join button:hover, #online-copy:hover { background: #67e8f9; }
#online-host { padding: 11px 16px; letter-spacing: 0.06em; text-transform: uppercase; }

#online-button:focus-visible, .online-card button:focus-visible,
#online-code-box:focus-visible { outline: 2px solid var(--p2); outline-offset: 2px; }

#online-toast {
  position: absolute;
  top: max(10px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  max-width: calc(100% - 24px);
  padding: 8px 16px;
  border: 1px solid var(--p2);
  border-radius: 999px;
  background: rgba(8, 15, 33, 0.94);
  color: var(--p2);
  font-weight: 600;
  text-align: center;
  pointer-events: none;
}

@media (max-width: 640px) {
  #app { justify-content: flex-start; }
  #footer { flex-direction: column; align-items: flex-start; }
}

/* Phones and tablets: the game fills the screen, and its on-screen controls replace the keyboard legend. */
@media (pointer: coarse) {
  #app { padding: 0; gap: 0; }
  #stage {
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    aspect-ratio: auto;
    border-radius: 0;
    box-shadow: none;
  }
  #footer { display: none; }
}

@media (pointer: coarse) and (orientation: portrait) {
  #rotate-note { display: flex; }
}
