:root {
  --bg: #121417;
  --bg-2: #1b1f24;
  --text: #e8e6e1;
  --muted: #a3a8ae;
  --accent: #ff5a36;
  --casing-1: #4a4e53;
  --casing-2: #2c2f33;
  --panel: #6b7077;
  --panel-dark: #33373c;
  --edge: #24272b;
  --c-red: #d7322e;
  --c-white: #f4f4f0;
  --c-blue: #2160e0;
  --c-yellow: #f3c623;
  --c-black: #1a1a1a;
  --c-green: #2fb35a;
  --led-off: #3a2626;
  --led-red: #ff2a1f;
  --led-green: #35e06a;
  --font-mono: 'Share Tech Mono', ui-monospace, Menlo, Consolas, monospace;
  --font-display: 'Black Ops One', Impact, 'Arial Black', sans-serif;
  --font-digital: 'Share Tech Mono', ui-monospace, Menlo, monospace;
  --font-symbols: 'Noto Sans', 'Noto Sans Arabic', 'Segoe UI Symbol', 'DejaVu Sans', 'Arial Unicode MS', sans-serif;
  --font-ui: 'Noto Sans', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: radial-gradient(ellipse at 50% 20%, #23282e 0%, var(--bg) 70%);
  color: var(--text);
  font-family: var(--font-ui);
}

body {
  min-height: 100vh;
}

button,
input,
select {
  font: inherit;
}

kbd {
  font-family: var(--font-mono);
  background: #000;
  border: 1px solid #555;
  border-radius: 3px;
  padding: 0 4px;
}

/* ---------- képernyők ---------- */

.screen {
  display: none;
  min-height: 100vh;
}

.screen.is-active {
  display: block;
}

#screen-game.is-active {
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
  position: relative;
  isolation: isolate; /* a 3D háttérvászon z-index: -1 értéke ezen a képernyőn belül marad */
}

/* 3D háttér (ui/scene3d/stage.js): teljes képernyős vászon a bombanézet mögött, nem fog egeret. */
.stage3d {
  position: absolute;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.stage3d canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* ---------- gombok, kártyák ---------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 16px;
  border-radius: 6px;
  border: 1px solid #555b62;
  background: linear-gradient(#3b4047, #2c3036);
  color: var(--text);
  cursor: pointer;
  text-decoration: none;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.btn:hover {
  filter: brightness(1.15);
}

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

.btn-primary {
  background: linear-gradient(#ff6a45, #d8401f);
  border-color: #ff8a6a;
  color: #fff;
}

.btn-danger {
  border-color: #a33;
  color: #ffb3a8;
}

.btn-ghost {
  background: transparent;
}

.btn-small {
  padding: 6px 10px;
  font-size: 0.85rem;
}

.card {
  background: linear-gradient(160deg, #23282e, #1a1d21);
  border: 1px solid #343a41;
  border-radius: 10px;
  padding: 18px 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.card h2 {
  margin: 0 0 12px;
  font-family: var(--font-display);
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #ffd2c4;
}

.hint {
  color: var(--muted);
  font-size: 0.85rem;
}

/* ---------- menü ---------- */

.menu-header {
  text-align: center;
  padding: 40px 16px 10px;
}

.logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(2.6rem, 8vw, 5rem);
  letter-spacing: 0.08em;
  color: var(--accent);
  text-shadow: 0 0 24px rgba(255, 90, 54, 0.45), 0 3px 0 #5a1a0c;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 1.1rem;
}

/* Nyelvváltó a menü fejlécében (csak a menüben, játék közben nincs). */
.lang-switch {
  display: inline-flex;
  margin-bottom: 14px;
  border: 1px solid #555b62;
  border-radius: 6px;
  overflow: hidden;
}

.lang-btn {
  padding: 5px 12px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  cursor: pointer;
}

.lang-btn + .lang-btn {
  border-left: 1px solid #555b62;
}

.lang-btn[aria-pressed='true'] {
  background: linear-gradient(#3b4047, #2c3036);
  color: var(--text);
}

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

.menu-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 18px;
  max-width: 1200px;
  margin: 24px auto 40px;
  padding: 0 16px;
}

.roles p {
  line-height: 1.5;
}

.mission-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  gap: 10px;
}

.mission-list button {
  width: 100%;
  text-align: left;
  display: block;
  padding: 12px 14px;
}

.mission-list .mission-desc {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.85rem;
  margin-top: 2px;
}

.custom-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 12px;
}

.custom-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 0.85rem;
  color: var(--muted);
}

.custom-form input,
.custom-form select {
  background: #0f1113;
  color: var(--text);
  border: 1px solid #3c434b;
  border-radius: 5px;
  padding: 7px 8px;
}

.custom-form .wide {
  grid-column: 1 / -1;
}

.custom-form fieldset {
  border: 1px solid #343a41;
  border-radius: 6px;
  padding: 6px 10px 10px;
}

.custom-form legend {
  color: var(--muted);
  font-size: 0.8rem;
  padding: 0 4px;
}

.pool {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 12px;
}

.pool label {
  flex-direction: row;
  align-items: center;
  color: var(--text);
}

/* ---------- játék ---------- */

.game-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  padding: 8px 12px;
  background: rgba(0, 0, 0, 0.35);
  border-bottom: 1px solid #2a2f35;
  flex: 0 0 auto;
  position: relative;
  z-index: 2; /* a 3D nézet teljes képernyős rétege fölött marad */
}

.toolbar-info {
  flex: 1;
  color: var(--muted);
  font-family: var(--font-mono);
  font-size: 0.9rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bomb-viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.bomb-scaler {
  transform-origin: center center;
}

.bomb {
  position: relative;
  display: grid;
  grid-template-columns: 56px auto 56px;
  grid-template-rows: 56px auto 56px;
  gap: 0;
}

.bomb.is-shaking {
  animation: shake 0.35s linear;
}

@keyframes shake {
  0%, 100% { transform: translate(0, 0); }
  20% { transform: translate(-6px, 3px); }
  40% { transform: translate(5px, -4px); }
  60% { transform: translate(-4px, -2px); }
  80% { transform: translate(3px, 4px); }
}

.bomb-edge {
  background: linear-gradient(#26292d, #1c1e21);
  border: 2px solid #111;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 6px;
}

.edge-top { grid-column: 2; grid-row: 1; border-radius: 10px 10px 0 0; }
.edge-bottom { grid-column: 2; grid-row: 3; border-radius: 0 0 10px 10px; }
.edge-left { grid-column: 1; grid-row: 2; flex-direction: column; border-radius: 10px 0 0 10px; }
.edge-right { grid-column: 3; grid-row: 2; flex-direction: column; border-radius: 0 10px 10px 0; }

.edge-left .widget,
.edge-right .widget {
  transform: rotate(-90deg);
  margin: 24px 0;
}

.bomb-body {
  grid-column: 2;
  grid-row: 2;
  background: linear-gradient(145deg, var(--casing-1), var(--casing-2));
  border: 3px solid #15171a;
  padding: 14px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.05), 0 20px 50px rgba(0, 0, 0, 0.6);
  position: relative;
}

.bomb-face {
  display: none;
  grid-template-columns: repeat(3, 250px);
  grid-template-rows: repeat(2, 262px);
  gap: 12px;
}

.bomb-face.is-visible {
  display: grid;
}

.face-label {
  position: absolute;
  top: 1px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  line-height: 12px;
  color: var(--muted);
  letter-spacing: 0.2em;
}

/* ---------- 3D nézet (ui/bomb-view-3d.js): a lapok és peremek CSS3D-vel a fémházon ---------- */

/* A konténer a teljes képernyőt takarja (a CSS3D kamerája a háttérvászonéval azonos méretű), egeret nem fog. */
.bomb-viewport.view-3d {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: block;
  pointer-events: none;
}

/* Amíg a three.js be nem töltött és a ház fel nem épült, a nézet rejtett. */
.bomb-viewport.view-3d:not(.is-attached) {
  visibility: hidden;
}

.view-3d .css3d-root {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/* A CSS3D minden képkockában átírja az elemek `display` értékét, ezért az inaktív lap elrejtése
   `visibility`-vel megy (a flip() szinkron váltja az `is-visible` osztályt). */
.view-3d .bomb-face {
  display: grid;
  width: max-content; /* a lap mérete a modulrácsé (a méréshez és a ház méretezéséhez) */
  padding: 14px;
  border: 3px solid #15171a;
  border-radius: 4px;
  background: linear-gradient(145deg, var(--casing-1), var(--casing-2));
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.05), inset 0 6px 14px rgba(0, 0, 0, 0.45);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}

.view-3d .bomb-face:not(.is-visible) {
  visibility: hidden;
}

/* A peremcsíkok csak díszek: a CSS3DObject `pointer-events: auto` stílusát felülírjuk. */
.view-3d .bomb-edge {
  pointer-events: none !important;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  border-radius: 3px;
}

/* A felirat HUD: a képernyőhöz rögzített, nem forog a házzal. */
.view-3d .face-label {
  position: absolute;
  top: 62px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 0.8rem;
  line-height: 1;
  letter-spacing: 0.3em;
  color: var(--text);
  text-shadow: 0 1px 4px rgba(0, 0, 0, 0.9);
  pointer-events: none;
}

/* Szoba-esemény figyelmeztetése (ui/bomb-view-3d.js): rövid felirat a felirat alatt, nem kattintható. */
.view-3d .room-hint {
  position: absolute;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  padding: 6px 14px;
  border-radius: 4px;
  background: rgba(10, 6, 6, 0.82);
  color: #ffd27a;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0s linear 0.2s;
  z-index: 2;
}

.view-3d .room-hint.is-visible {
  opacity: 1;
  visibility: visible;
  transition: opacity 0.2s ease;
}

/* modulkeret */
.module {
  position: relative;
  width: 250px;
  height: 262px;
  padding: 22px 10px 10px;
  border-radius: 6px;
  background: linear-gradient(150deg, #7a8088, #50555b);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.25), inset 0 -2px 0 rgba(0, 0, 0, 0.35), 0 3px 6px rgba(0, 0, 0, 0.5);
}

.module::before,
.module::after {
  content: '';
  position: absolute;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #c9ced4, #555);
  bottom: 4px;
}

.module::before { left: 4px; }
.module::after { right: 4px; }

.module.empty {
  background: linear-gradient(150deg, #4c5157, #3a3e43);
}

.module-led {
  position: absolute;
  top: 5px;
  right: 8px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--led-off);
  border: 2px solid #222;
  box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.6);
  transition: background 0.15s;
}

.module.is-solved .module-led {
  background: var(--led-green);
  box-shadow: 0 0 10px var(--led-green);
}

.module.is-striking .module-led {
  background: var(--led-red);
  box-shadow: 0 0 12px var(--led-red);
}

.module.is-needy .module-led {
  display: none;
}

.module-name {
  position: absolute;
  top: 5px;
  left: 10px;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: rgba(0, 0, 0, 0.55);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.module-body {
  position: relative;
  width: 230px;
  height: 230px;
  border-radius: 4px;
  background: var(--panel-dark);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

.needy-timer {
  display: block;
  width: 52px;
  height: 28px;
  margin: 6px auto;
  background: #050505;
  color: #ff3b2f;
  font: 22px/28px var(--font-digital);
  text-align: center;
  border-radius: 3px;
  border: 1px solid #000;
  text-shadow: 0 0 6px rgba(255, 59, 47, 0.7);
}

/* időzítő modul */
.timer-module .module-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: linear-gradient(#3a3e44, #2a2d31);
}

.strike-indicator {
  display: flex;
  gap: 12px;
  padding: 6px 12px;
  background: #0a0a0a;
  border-radius: 4px;
  border: 1px solid #000;
}

.strike-lamp {
  width: 34px;
  height: 30px;
  font: 700 26px/30px var(--font-mono);
  text-align: center;
  color: #3a1010;
}

.strike-lamp.is-on {
  color: var(--led-red);
  text-shadow: 0 0 10px var(--led-red);
}

.timer-display {
  font: 64px/1 var(--font-digital);
  color: #ff3326;
  background: #060606;
  padding: 10px 14px 6px;
  border-radius: 5px;
  border: 2px solid #000;
  letter-spacing: 0.04em;
  text-shadow: 0 0 10px rgba(255, 51, 38, 0.8);
  min-width: 200px;
  text-align: center;
}

.timer-display.is-urgent {
  animation: blink 0.5s steps(2) infinite;
}

@keyframes blink {
  50% { opacity: 0.55; }
}

/* edgework */
.widget {
  flex: 0 0 auto;
  font-family: var(--font-mono);
}

.serial-tag {
  background: #f2f0e8;
  color: #111;
  border-radius: 3px;
  padding: 3px 8px;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.serial-tag small {
  display: block;
  font-size: 8px;
  letter-spacing: 0.15em;
  color: #a1281a;
}

.serial-tag strong {
  font-size: 20px;
  letter-spacing: 0.12em;
}

.battery-holder {
  display: flex;
  gap: 3px;
  padding: 3px;
  background: #0d0d0d;
  border-radius: 4px;
}

.battery {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  font-size: 10px;
  font-weight: 700;
  color: #111;
}

.battery-aa {
  width: 60px;
  height: 22px;
  font-size: 12px;
  background: linear-gradient(90deg, #d9a400 0 70%, #2b2b2b 70%);
}

.battery-d {
  width: 54px;
  height: 34px;
  background: linear-gradient(90deg, #b8b8b8 0 75%, #333 75%);
}

.indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 8px;
  background: #101010;
  border-radius: 4px;
  border: 1px solid #000;
}

.indicator-led {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: #333;
}

.indicator.is-lit .indicator-led {
  background: #fff8d0;
  box-shadow: 0 0 10px #fff3a0;
}

.indicator-label {
  color: #ddd;
  font-size: 15px;
  letter-spacing: 0.1em;
}

.port-plate {
  display: flex;
  gap: 5px;
  padding: 4px 6px;
  min-width: 40px;
  min-height: 34px;
  background: #8a8f95;
  border-radius: 3px;
  border: 1px solid #222;
  align-items: center;
}

.port {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  font-size: 7px;
  color: #111;
}

.port-shape {
  background: #1a1a1a;
  border: 1px solid #000;
}

.port-dvi .port-shape { width: 34px; height: 12px; border-radius: 2px 2px 6px 6px; background: #f2f2f2; }
.port-parallel .port-shape { width: 44px; height: 12px; border-radius: 2px 2px 6px 6px; background: #c2185b; }
.port-ps2 .port-shape { width: 16px; height: 16px; border-radius: 50%; background: #7b5ac9; }
.port-rj45 .port-shape { width: 16px; height: 14px; border-radius: 2px; background: #d8d8d8; }
.port-serial .port-shape { width: 30px; height: 12px; border-radius: 2px 2px 6px 6px; background: #1b6fd1; }
.port-rca .port-shape { width: 26px; height: 13px; border-radius: 6px; background: linear-gradient(90deg, #d32f2f 0 45%, transparent 45% 55%, #f2f2f2 55%); border: none; }

/* robbanás / siker villanás */
.flash {
  position: fixed;
  z-index: 5;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  background: #fff;
}

.flash.is-boom {
  animation: boom 1.4s ease-out forwards;
}

.flash.is-win {
  background: radial-gradient(circle, rgba(53, 224, 106, 0.35), transparent 70%);
  animation: win 1.2s ease-out forwards;
}

@keyframes boom {
  0% { opacity: 1; background: #fff; }
  25% { opacity: 1; background: #ffb347; }
  100% { opacity: 1; background: #050505; }
}

@keyframes win {
  0% { opacity: 1; }
  100% { opacity: 0; }
}

/* eredmény */
#screen-result.is-active {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

.result-card {
  max-width: 520px;
  width: 100%;
  text-align: center;
}

.result-title {
  font-size: 2.6rem;
}

.result-title.is-win {
  color: var(--led-green);
}

.result-title.is-loss {
  color: var(--accent);
}

.result-reason {
  color: var(--muted);
}

.result-stats {
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 16px;
  justify-content: center;
  font-family: var(--font-mono);
}

.result-stats dt {
  color: var(--muted);
  text-align: right;
}

.result-stats dd {
  margin: 0;
  text-align: left;
}

.result-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 18px;
}

@media (max-width: 640px) {
  .custom-form {
    grid-template-columns: 1fr;
  }
  .game-toolbar .toolbar-info {
    display: none;
  }
}

/* Forgatás húzással (ui/scene3d/drag-control.js): érintésnél a böngésző nem görget, húzás közben nincs kijelölés. */
.screen.can-rotate {
  touch-action: none;
}

.screen.is-rotating {
  cursor: grabbing;
  user-select: none;
  -webkit-user-select: none;
}
