:root {
  --ink: #15121f;
  --brass: #c09c5a;
  --brass-d: #8a6a3c;
  --panel: #1f1b31;
  --amber: #ffbf45;
  --text: #e8e2f4;
  --muted: #9b94b8;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  overscroll-behavior: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

input, textarea, select {
  user-select: text;
  -webkit-user-select: text;
}

body {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  background:
    radial-gradient(ellipse at 50% 28%, #2b2447 0%, #17132c 52%, #0b0914 100%);
  font: 13px/1.45 ui-monospace, "Cascadia Mono", Consolas, "Courier New", monospace;
}

.app {
  position: fixed;
  inset: 0;
  background: #000;
}

[hidden] { display: none !important; }

.logo {
  margin: 0 0 14px;
  line-height: 0;
  text-align: center;
}

#logo {
  display: inline-block;
  max-width: 100%;
  height: auto;
  image-rendering: pixelated;
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.55));
}

.btn {
  flex: none;
  padding: 8px 14px;
  border: 0;
  background: #2f2a50;
  color: #ffe9a8;
  font: 700 12px/1 ui-monospace, "Cascadia Mono", Consolas, monospace;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow:
    0 0 0 2px var(--ink),
    inset 2px 2px 0 #6a6296,
    inset -2px -2px 0 #1a1630,
    0 0 0 4px var(--brass-d);
  transition: background 0.12s, transform 0.08s;
}

.btn:hover { background: #3d3768; }

.btn:active {
  transform: translateY(1px);
  background: #231f3d;
  box-shadow:
    0 0 0 2px var(--ink),
    inset 2px 2px 0 #1a1630,
    inset -2px -2px 0 #4a4474,
    0 0 0 4px var(--brass-d);
}

.btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 5px; }

.stage {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  overflow: hidden;
}

#game {
  display: block;
  image-rendering: pixelated;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  background: var(--ink);
  cursor: default;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
}

.btn-icon {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  padding: 0;
  font-size: 18px;
  line-height: 36px;
  opacity: 0.8;
  z-index: 5;
}

.btn-icon:hover { opacity: 1; }

.menu {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 16px;
  overflow: auto;
  background:
    radial-gradient(ellipse at 50% 35%, rgba(43, 36, 71, 0.82) 0%, rgba(11, 9, 20, 0.92) 100%);
}

.menu[hidden] { display: none; }

.panel {
  width: min(460px, 100%);
  max-height: 100%;
  margin: auto;
  padding: 22px 24px 24px;
  background: var(--panel);
  box-shadow:
    0 0 0 2px var(--brass-d),
    0 0 0 4px var(--ink),
    0 0 0 6px #5a4129,
    0 16px 48px rgba(0, 0, 0, 0.65);
}

.page {
  display: grid;
  gap: 16px;
  justify-items: stretch;
}

.page h2 {
  margin: 0;
  color: #ffe9a8;
  font-size: 16px;
  letter-spacing: 0.12em;
  text-align: center;
  text-transform: uppercase;
}

.status {
  margin: 0;
  min-height: 1.4em;
  color: var(--muted);
  text-align: center;
}

.btn.big { padding: 13px 14px; font-size: 14px; margin: 0 6px; }

.row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--text);
}

.row > span { flex: 1; }
.row input[type="range"] { flex: 0 0 150px; accent-color: var(--amber); }
.row input[type="checkbox"] { width: 20px; height: 20px; accent-color: var(--amber); }
.row output { flex: 0 0 48px; color: var(--amber); text-align: right; }

.goal { margin: 0; color: var(--muted); text-align: center; }
.goal b { color: #ffe9a8; }

.touch-title {
  margin: 0;
  color: #ffe9a8;
  font-size: 13px;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
}

.touch-help {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
}

.touch-help li + li { margin-top: 4px; }
.touch-help b { color: #ffe9a8; }

.status.small { font-size: 11px; opacity: 0.8; }
.lobby-status { color: #ffe9a8; min-height: 2.8em; white-space: pre-line; }

.field {
  flex: 0 0 200px;
  min-width: 0;
  padding: 7px 8px;
  border: 0;
  background: #15121f;
  color: var(--text);
  font: inherit;
  box-shadow: 0 0 0 2px var(--brass-d), inset 2px 2px 0 #0b0914;
}

.field:focus { outline: 2px solid var(--amber); outline-offset: 2px; }
.field:disabled { opacity: 0.5; }

.keys {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}

kbd {
  display: inline-block;
  min-width: 18px;
  padding: 1px 4px;
  margin-right: 6px;
  border-radius: 2px;
  background: #2f2a50;
  color: #ffe9a8;
  font: 700 11px/14px ui-monospace, "Cascadia Mono", Consolas, monospace;
  text-align: center;
  box-shadow: 0 0 0 1px var(--ink), inset 1px 1px 0 #6a6296, 0 2px 0 1px #0d0a17;
}

@media (max-height: 560px) {
  .panel { padding: 12px 16px 14px; }
  .page { gap: 10px; }
  .logo { margin-bottom: 8px; }
}

/* ---------- výběr mapy a online místnosti ---------- */
.panel.wide { width: min(920px, 100%); }

.lobby {
  display: grid;
  grid-template-columns: 190px minmax(0, 1fr) 230px;
  gap: 18px;
  align-items: start;
}

.maps, .slots, .rooms { display: grid; gap: 10px; }
.rooms { max-height: 190px; overflow: auto; padding: 4px; }

.map-item, .room {
  display: grid;
  gap: 2px;
  padding: 9px 11px;
  border: 0;
  background: #2f2a50;
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--brass-d);
}

.map-item:hover:not(:disabled), .room:hover:not(:disabled) { background: #3d3768; }
.map-item.selected { background: #4a3a2c; color: #ffe9a8; box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--amber); }
.map-item:disabled, .room:disabled { cursor: default; opacity: 0.7; }
.map-item.selected:disabled { opacity: 1; }
.map-item:focus-visible, .room:focus-visible { outline: 2px solid var(--amber); outline-offset: 5px; }
.map-name { font-weight: 700; }
.map-tag { color: var(--muted); font-size: 11px; }

.detail { display: grid; gap: 8px; min-width: 0; }

.preview {
  width: 100%;
  height: auto;
  aspect-ratio: 16 / 10;
  background: #0b0914;
  box-shadow: 0 0 0 2px var(--ink), 0 0 0 4px var(--brass-d);
}

.detail h3 {
  margin: 6px 0 0;
  color: #ffe9a8;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.desc { margin: 0; color: var(--text); font-size: 12px; }
.meta { margin: 0; color: var(--muted); font-size: 11px; }

.slot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #15121f;
  box-shadow: inset 0 0 0 1px #2f2a50;
}

.slot .swatch { flex: none; width: 12px; height: 12px; box-shadow: 0 0 0 1px var(--ink); }
.slot-team { flex: 1; min-width: 0; }
.slot .field { flex: 0 0 112px; }
.slot-who { color: #ffe9a8; }
.slot-who.muted { color: var(--muted); }

.actions { display: flex; gap: 12px; }
.actions .btn { flex: 1; }

@media (max-width: 800px) {
  .lobby { grid-template-columns: 1fr; }
}

@media (max-height: 560px) {
  .panel { padding: 12px 16px 14px; }
  .page { gap: 10px; }
  .logo { margin-bottom: 8px; }
}

/* ---------- ozdoby hlavního menu ---------- */
.stage { background: var(--ink); }

.menu {
  grid-template-rows: 1fr auto;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(90, 60, 140, 0.35) 0%, transparent 60%),
    linear-gradient(180deg, rgba(11, 9, 20, 0.55) 0%, rgba(11, 9, 20, 0.88) 100%);
}

.menu::before,
.menu::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-repeat: repeat;
}

.menu::before {
  background-image:
    radial-gradient(2px 2px at 12% 20%, #ffe9a8 50%, transparent 52%),
    radial-gradient(2px 2px at 38% 68%, #fff 50%, transparent 52%),
    radial-gradient(2px 2px at 63% 14%, #ffe9a8 50%, transparent 52%),
    radial-gradient(2px 2px at 82% 56%, #fff 50%, transparent 52%),
    radial-gradient(2px 2px at 91% 86%, #ffe9a8 50%, transparent 52%),
    radial-gradient(2px 2px at 24% 90%, #fff 50%, transparent 52%);
  background-size: 420px 340px;
  opacity: 0.5;
  animation: twinkle 4s ease-in-out infinite alternate;
}

.menu::after {
  background-image:
    radial-gradient(3px 3px at 20% 100%, #ff9a3c 50%, transparent 55%),
    radial-gradient(3px 3px at 55% 100%, #ffbf45 50%, transparent 55%),
    radial-gradient(3px 3px at 80% 100%, #ff7a2c 50%, transparent 55%);
  background-size: 360px 360px;
  animation: embers 9s linear infinite;
  opacity: 0.7;
}

@keyframes twinkle { from { opacity: 0.25; } to { opacity: 0.65; } }
@keyframes embers {
  from { background-position: 0 0; }
  to { background-position: 40px -360px; }
}

.panel {
  position: relative;
  z-index: 1;
  background: linear-gradient(180deg, #2a2347 0%, var(--panel) 38%, #181428 100%);
  animation: rise 0.45s ease-out both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}

.tagline {
  margin: -6px 0 18px;
  color: var(--muted);
  font-size: 12px;
  letter-spacing: 0.06em;
  text-align: center;
}

#panel-main:not([hidden]) .btn.big {
  animation: rise 0.4s ease-out both;
}
#panel-main .btn.big:nth-of-type(2) { animation-delay: 0.05s; }
#panel-main .btn.big:nth-of-type(3) { animation-delay: 0.1s; }
#panel-main .btn.big:nth-of-type(4) { animation-delay: 0.15s; }
#panel-main .btn.big:nth-of-type(5) { animation-delay: 0.2s; }

#m-online, #m-play {
  background: #4a3a22;
  color: #fff3c4;
  box-shadow:
    0 0 0 2px var(--ink),
    inset 2px 2px 0 #c09c5a,
    inset -2px -2px 0 #2a1d0e,
    0 0 0 4px var(--brass);
}
#m-online:hover, #m-play:hover { background: #6a5230; }

.btn.big:hover { transform: translateY(-1px); }

.footer {
  position: relative;
  z-index: 1;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 11px;
  opacity: 0.7;
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .menu::before, .menu::after, .panel, #panel-main .btn.big { animation: none; }
}

#menu-status:empty { display: none; }

/* ---------- animovaná scéna v pozadí menu ---------- */
.menubg {
  display: none;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}

.menu.scene .menubg { display: block; }

.menu.scene {
  background: radial-gradient(ellipse at 50% 45%, rgba(11, 9, 20, 0.55) 0%, rgba(11, 9, 20, 0.1) 70%);
}

.menu.scene::before,
.menu.scene::after { display: none; }

.menu.scene .panel {
  background: linear-gradient(180deg, rgba(42, 35, 71, 0.86) 0%, rgba(31, 27, 49, 0.8) 100%);
}

/* ---------- ikona celé obrazovky ---------- */
.fs-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 20;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #ffe9a8;
  opacity: 0.55;
  cursor: pointer;
  transition: opacity 0.12s;
}

.fs-btn:hover { opacity: 1; }
.fs-btn:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

.btn-icon { right: 54px; }

.step { display: grid; gap: 16px; }

.footer a { color: #c09c5a; text-decoration: none; }
.footer a:hover { color: #f0d088; text-decoration: underline; }
