/* Wormhole X-Treme! — VHS / CRT estetika roku 2001. Vše je kreslené v canvasu,
   CSS řeší jen scaling, overlaye a scanline vrstvu. */

:root {
  --bg: #05070a;
  --ink: #cfe6f5;
  --accent: #59d0ff;
  --amber: #ffb648;
  --red: #ff4d5e;
  --panel: rgba(8, 14, 22, 0.92);
}

* { box-sizing: border-box; }

html, body {
  margin: 0; padding: 0; height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Courier New", ui-monospace, monospace;
  overflow: hidden;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}

#stage {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background:
    radial-gradient(ellipse at center, #0d1622 0%, #05070a 70%);
}

#game {
  width: min(100vw, calc(100vh * 16 / 9));
  height: min(100vh, calc(100vw * 9 / 16));
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  background: #05070a;
  box-shadow: 0 0 0 1px #1d2b3a, 0 0 60px rgba(30, 90, 140, 0.35);
  touch-action: none;
}

/* CRT vrstva — scanlines + vinětace + lehká chromatická aberace */
#scanlines {
  position: fixed; inset: 0; pointer-events: none; z-index: 5;
  background:
    repeating-linear-gradient(to bottom,
      rgba(0,0,0,0.22) 0px, rgba(0,0,0,0.22) 1px,
      rgba(0,0,0,0) 1px, rgba(0,0,0,0) 3px),
    radial-gradient(ellipse at center, rgba(0,0,0,0) 55%, rgba(0,0,0,0.6) 100%);
  mix-blend-mode: multiply;
  animation: flick 5.5s steps(1) infinite;
}
body.nocrt #scanlines { display: none; }

@keyframes flick {
  0%, 96%, 100% { opacity: 1; }
  97% { opacity: 0.82; }
  98.5% { opacity: 1; }
}

/* --- Overlaye ------------------------------------------------------------ */
.overlay {
  position: fixed; inset: 0; z-index: 20;
  display: grid; place-items: center;
  background: rgba(3, 5, 8, 0.86);
  backdrop-filter: blur(2px);
  padding: 16px;
}
.overlay[hidden] { display: none; }

.panel {
  width: min(680px, 94vw);
  max-height: 92vh; overflow-y: auto;
  background: var(--panel);
  border: 1px solid #1f3648;
  border-left: 3px solid var(--accent);
  padding: 22px 26px;
  box-shadow: 0 20px 70px rgba(0,0,0,0.7);
}

.kicker {
  font-size: 11px; letter-spacing: 3px; color: var(--amber);
  text-transform: uppercase; margin-bottom: 6px;
}

h1 {
  margin: 0 0 4px; font-size: clamp(28px, 6vw, 52px);
  letter-spacing: 2px; line-height: 0.95;
  text-shadow: 2px 0 0 rgba(255,77,94,0.55), -2px 0 0 rgba(89,208,255,0.55);
}
h1 span { display: block; color: var(--accent); font-style: italic; }
h2 { margin: 0 0 14px; letter-spacing: 2px; font-size: 22px; }

.sub { color: #9fbdd2; margin: 10px 0 14px; font-size: 15px; }
.hint { font-size: 13px; color: #7f9bb0; line-height: 1.65; margin: 8px 0; }
.hint b { color: var(--ink); }
.warn { font-size: 11px; color: #5d7387; margin-top: 16px; line-height: 1.5; }
a { color: var(--accent); }

button {
  font-family: inherit; font-size: 15px; letter-spacing: 2px;
  background: var(--accent); color: #04202e; border: 0;
  padding: 12px 22px; margin: 12px 8px 4px 0; cursor: pointer;
  font-weight: bold; text-transform: uppercase;
}
button:hover { background: #8ce0ff; }
button.ghost { background: transparent; color: #8fb2c8; border: 1px solid #2b465c; }
button.ghost:hover { background: #10202c; color: var(--ink); }

.row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; margin: 10px 0; font-size: 13px; color: #9fbdd2;
}
.row input[type=range] { flex: 1; max-width: 240px; accent-color: var(--accent); }

/* --- Dialogové okno ------------------------------------------------------ */
.dialogBox {
  position: fixed; z-index: 15;
  left: 50%; transform: translateX(-50%);
  bottom: max(4vh, 18px);
  width: min(760px, 92vw);
  background: rgba(5, 10, 16, 0.94);
  border: 1px solid #26405a; border-left: 3px solid var(--amber);
  padding: 14px 18px 12px;
}
.dialogBox[hidden] { display: none; }
.dialogBox .who { color: var(--amber); font-size: 12px; letter-spacing: 3px; margin-bottom: 6px; }
.dialogBox .what { font-size: 15px; line-height: 1.55; min-height: 3em; }
.dialogBox .more { text-align: right; font-size: 11px; color: #5d7387; margin-top: 8px; }

/* --- Dotykové ovládání --------------------------------------------------- */
#touch { position: fixed; inset: 0; z-index: 12; pointer-events: none; }
#touch[hidden] { display: none; }
#dpad {
  position: absolute; left: max(3vw, 14px); bottom: max(4vh, 16px);
  width: 156px; height: 156px;
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
}
#dpad button:nth-child(1) { grid-area: 1 / 2; }
#dpad button:nth-child(2) { grid-area: 2 / 1; }
#dpad button:nth-child(3) { grid-area: 2 / 3; }
#dpad button:nth-child(4) { grid-area: 3 / 2; }
#btns {
  position: absolute; right: max(3vw, 14px); bottom: max(4vh, 16px);
  display: flex; gap: 12px; align-items: flex-end;
}
#touch button {
  pointer-events: auto; margin: 0;
  background: rgba(20, 40, 58, 0.55);
  border: 1px solid rgba(89, 208, 255, 0.4);
  color: var(--accent);
  font-size: 13px; padding: 0;
  width: 100%; height: 100%;
  border-radius: 8px;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
}
#btns button { width: 74px; height: 74px; border-radius: 50%; font-size: 12px; }
#touch button:active { background: rgba(89, 208, 255, 0.35); color: #04202e; }

/* --- Portrét na mobilu: hra je 16:9, na výšku by z ní byl proužek ------- */
#rotate { display: none; }

@media (orientation: portrait) and (max-width: 900px) {
  #rotate {
    position: fixed; inset: 0; z-index: 30;
    display: grid; place-items: center; text-align: center;
    background: #05070a; padding: 24px;
  }
  #rotate h2 { color: var(--accent); margin: 10px 0; }
  #touch, #stage, .overlay, .dialogBox { visibility: hidden; }
}
