/*
 * Slag — page chrome only.
 *
 * Everything the player actually looks at is painted on the canvas by
 * `src/render.js`. This file just makes the page a distraction free, black,
 * non-scrolling, non-selectable frame around it, and styles the two HTML
 * overlays (the opening gate and the error report).
 */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  background: #000;
  color: #e5e7eb;
  overflow: hidden;
  /* A game pad, not a document: no text selection, no drag, no pinch zoom,
     no double-tap-to-zoom, and no long-press callout on touch devices. */
  touch-action: none;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
    "Noto Sans", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

/* `hidden` must win over the flex display of the overlays. */
[hidden] {
  display: none !important;
}

/* ------------------------------------------------------------------------- *
 * The canvas
 * ------------------------------------------------------------------------- */

#game {
  position: fixed;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  background: #000;
  /* The renderer letterboxes with black bars, so nothing here may stretch. */
  image-rendering: auto;
  outline: none;
}

/* Toggled by main.js after two seconds without pointer movement. */
body.cursor-hidden,
body.cursor-hidden #game {
  cursor: none;
}

/* ------------------------------------------------------------------------- *
 * Overlays (opening gate, error report, noscript)
 * ------------------------------------------------------------------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(120% 120% at 50% 30%, rgba(30, 41, 59, 0.92) 0%, rgba(0, 0, 0, 0.96) 70%);
  opacity: 1;
  transition: opacity 420ms ease;
  cursor: pointer;
}

/* Fade-out state set by main.js on the first click. */
.overlay.is-gone {
  opacity: 0;
  pointer-events: none;
}

.panel {
  max-width: 640px;
  width: 100%;
  padding: 32px 36px;
  text-align: center;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 16px;
  background: rgba(2, 6, 23, 0.78);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.6);
}

.brand {
  margin: 0;
  font-size: clamp(48px, 12vw, 96px);
  font-weight: 800;
  letter-spacing: 0.18em;
  /* Letter-spacing also trails the LAST glyph, which drags the centred word
     half a step to the left; the padding puts it back on the axis. */
  padding-left: 0.18em;
  color: #f8fafc;
  text-shadow: 0 0 28px rgba(56, 189, 248, 0.45);
}

.tagline {
  margin: 4px 0 26px;
  font-size: clamp(14px, 2.4vw, 18px);
  color: #94a3b8;
  letter-spacing: 0.04em;
}

.cta {
  margin: 0 0 18px;
  font-size: clamp(20px, 4vw, 30px);
  font-weight: 700;
  color: #fbbf24;
  animation: pulse 1.9s ease-in-out infinite;
}

.note {
  margin: 0;
  font-size: 14px;
  color: #94a3b8;
}

.keys {
  margin: 22px auto 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  font-size: 14px;
  color: #cbd5e1;
}

.keys b {
  color: #f8fafc;
  font-weight: 700;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Respect the "reduce motion" preference: keep the text perfectly still. */
@media (prefers-reduced-motion: reduce) {
  .cta {
    animation: none;
  }

  .overlay {
    transition: none;
  }
}

/* ------------------------------------------------------------------------- *
 * Error report — deliberately loud, it must never be missed
 * ------------------------------------------------------------------------- */

.overlay.error {
  z-index: 20;
  background: rgba(69, 10, 10, 0.94);
  cursor: default;
}

.overlay.error .panel {
  max-width: 860px;
  text-align: left;
  border-color: rgba(248, 113, 113, 0.7);
  background: rgba(24, 4, 4, 0.92);
}

.overlay.error h2 {
  margin: 0 0 14px;
  font-size: 24px;
  color: #fecaca;
}

.overlay.error pre {
  margin: 0 0 16px;
  padding: 14px 16px;
  max-height: 42vh;
  overflow: auto;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.55);
  color: #fca5a5;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-break: break-word;
  user-select: text;
  -webkit-user-select: text;
}

.overlay.error .note {
  color: #fca5a5;
}

/* ------------------------------------------------------------------------- *
 * No JavaScript
 * ------------------------------------------------------------------------- */

.overlay.noscript {
  z-index: 30;
  cursor: default;
}

.overlay.noscript h2 {
  margin: 0 0 12px;
  font-size: 22px;
  color: #f8fafc;
}

/* ------------------------------------------------------------------------- *
 * Online szoba
 *
 * A lobbi fölött lebegő panel. Nem a canvasra rajzoljuk, mert itt valódi
 * szövegmező és vágólap kell — canvasból egyik sem megy rendesen.
 * ------------------------------------------------------------------------- */

.online {
  position: fixed;
  top: 12px;
  right: 12px;
  z-index: 20;
  width: min(320px, calc(100vw - 24px));
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: #e2e8f0;
}

.online-tab {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid rgba(129, 140, 248, 0.55);
  border-radius: 10px;
  background: rgba(12, 16, 26, 0.92);
  color: #c7d2fe;
  font: inherit;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 0.02em;
  cursor: pointer;
}

.online-tab:hover,
.online-tab:focus-visible {
  border-color: rgba(165, 180, 252, 0.9);
  color: #e0e7ff;
}

.online-tab.live {
  border-color: rgba(34, 197, 94, 0.8);
  color: #86efac;
}

.online-body {
  margin-top: 8px;
  padding: 14px;
  border: 1.5px solid rgba(148, 163, 184, 0.28);
  border-radius: 12px;
  background: rgba(9, 13, 21, 0.96);
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.55);
}

.online-block + .online-block {
  margin-top: 12px;
}

.online-status {
  margin: 0 0 12px;
  font-size: 13px;
  line-height: 1.45;
  color: rgba(226, 232, 240, 0.82);
}

.online-label {
  margin: 12px 0 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(148, 163, 184, 0.9);
}

.online-code {
  margin: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: #f8fafc;
}

.online-row {
  display: flex;
  gap: 6px;
  align-items: stretch;
}

.online-row input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 8px 10px;
  border: 1.5px solid rgba(148, 163, 184, 0.35);
  border-radius: 8px;
  background: rgba(2, 6, 14, 0.85);
  color: #e2e8f0;
  font: inherit;
  font-size: 13px;
  user-select: text;
  -webkit-user-select: text;
}

.online-row input:focus-visible {
  outline: 2px solid rgba(129, 140, 248, 0.9);
  outline-offset: 1px;
}

.online-join label {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  color: rgba(148, 163, 184, 0.9);
}

.online-btn {
  padding: 8px 12px;
  border: 1.5px solid rgba(148, 163, 184, 0.4);
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.9);
  color: #e2e8f0;
  font: inherit;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
}

.online-btn:hover,
.online-btn:focus-visible {
  border-color: rgba(226, 232, 240, 0.75);
}

.online-btn[disabled] {
  opacity: 0.5;
  cursor: default;
}

.online-btn.primary {
  width: 100%;
  border-color: rgba(34, 197, 94, 0.7);
  background: rgba(20, 83, 45, 0.55);
  color: #bbf7d0;
}

.online-btn.danger {
  width: 100%;
  margin-top: 12px;
  border-color: rgba(239, 68, 68, 0.6);
  background: rgba(69, 10, 10, 0.5);
  color: #fecaca;
}

.online-note {
  margin: 10px 0 0;
  font-size: 11.5px;
  line-height: 1.45;
  color: rgba(148, 163, 184, 0.75);
}

.online-error {
  margin: 10px 0 0;
  padding: 8px 10px;
  border: 1.5px solid rgba(239, 68, 68, 0.6);
  border-radius: 8px;
  background: rgba(69, 10, 10, 0.4);
  color: #fecaca;
  font-size: 12.5px;
  line-height: 1.4;
}

/* Meccs közben ne takarjon: összecsukva, halványan. */
.online.playing {
  opacity: 0.35;
}

.online.playing:hover,
.online.playing:focus-within {
  opacity: 1;
}
