/* Game page: gradient background and card-based layout */
body.gamePage {
  min-height: 100svh;
  padding-top: max(12px, env(safe-area-inset-top, 0px));
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  transition: background 0.3s ease;
  overflow-x: hidden; /* prevent horizontal scroll on narrow viewports */
  /* Subtle gradient: deep blue to soft purple, game-appropriate */
  background: linear-gradient(165deg, #0b1020 0%, #0f1629 25%, #141c35 50%, #0d1225 100%);
}
body.gamePage::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  background:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(122, 166, 255, 0.08) 0%, transparent 50%),
    radial-gradient(ellipse 60% 40% at 90% 80%, rgba(255, 175, 90, 0.06) 0%, transparent 50%);
  pointer-events: none;
}

body.gamePage.exploding {
  background: linear-gradient(135deg, rgba(255, 136, 0, 0.3) 0%, rgba(255, 85, 0, 0.3) 50%, rgba(255, 51, 0, 0.3) 100%);
  animation: explosionPulse 0.4s ease-in-out infinite alternate;
}

@keyframes explosionPulse {
  0% {
    background: linear-gradient(135deg, rgba(255, 136, 0, 0.2) 0%, rgba(255, 85, 0, 0.2) 50%, rgba(255, 51, 0, 0.2) 100%);
  }
  100% {
    background: linear-gradient(135deg, rgba(255, 136, 0, 0.5) 0%, rgba(255, 85, 0, 0.5) 50%, rgba(255, 51, 0, 0.5) 100%);
  }
}

/* Stress mode 90s countdown: upper left of main game card; above defuse overlay when task is open */
.gameGlobalTimer {
  position: absolute;
  top: 12px;
  left: 12px;
  font-size: clamp(20px, 4vw, 28px);
  font-weight: 700;
  color: var(--ink);
  z-index: 220;
  padding: 8px 16px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  border-radius: var(--radius);
  border: 1px solid rgba(255, 255, 255, 0.15);
  box-shadow: var(--shadow);
  min-width: 56px;
  text-align: center;
  opacity: 0;
  transition: opacity 0.3s;
}

.gameGlobalTimer.active {
  opacity: 1;
}

@media (max-width: 480px) {
  .gameGlobalTimer {
    top: 10px;
    left: 10px;
    padding: 6px 12px;
    min-width: 48px;
    font-size: clamp(18px, 4vw, 24px);
  }
}

/* Rotate prompt: smartphone portrait only – shown via body.smartphone-portrait (set by JS) */
.gameRotatePrompt {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(11, 16, 32, 0.96);
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
}
body.smartphone-portrait .gameRotatePrompt {
  display: flex;
}
.gameRotatePromptIcon {
  position: relative;
  width: 80px;
  height: 100px;
  margin-bottom: 24px;
  color: rgba(234, 240, 255, 0.9);
}
.gameRotatePhoneSvg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 48px;
  height: 96px;
  margin-left: -24px;
  margin-top: -48px;
  animation: gameRotatePhoneTilt 2s ease-in-out infinite;
}
.gameRotateArrowSvg {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 56px;
  height: 56px;
  margin-left: -28px;
  margin-top: -28px;
  animation: gameRotateArrowSpin 2.5s linear infinite;
  color: rgba(255, 175, 90, 0.9);
}
@keyframes gameRotatePhoneTilt {
  0%, 100% { transform: rotate(-30deg); }
  50% { transform: rotate(60deg); }
}
@keyframes gameRotateArrowSpin {
  0% { transform: rotate(0deg); opacity: 0.9; }
  100% { transform: rotate(360deg); opacity: 0.9; }
}
.gameRotatePromptText {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--ink);
  max-width: 280px;
  line-height: 1.4;
}

/* Top bar: only restart when visible; minimal strip */
.gameTopBar {
  justify-content: flex-end;
  align-items: center;
  padding-right: max(16px, env(safe-area-inset-right));
  z-index: 200;
}

/* Two-column layout: sidebar card + main card
   Breakpoints: desktop/tablet landscape 769px+ (2 cols), tablet portrait/small 768px and below (1 col),
   small phone 480px and below (tighter padding), very small 380px (minimal padding, safe areas) */
.gameWrap {
  width: min(1100px, 96vw);
  max-width: 100%;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(240px, 280px) 1fr;
  gap: 20px;
  padding: 16px 0;
  align-items: start;
}
@media (max-width: 768px) {
  .gameWrap {
    grid-template-columns: 1fr;
    width: 100%; /* avoid horizontal overflow; body padding defines inset */
    max-width: 560px;
    margin-left: auto;
    margin-right: auto;
    gap: 16px;
  }
}

/* Tablet/iPad portrait: sidebar above game card; title centered, then one row: gå tilbage + 4 buttons in 4 cols */
@media (orientation: portrait) and (min-width: 768px) and (max-width: 1024px) {
  .gameWrap {
    grid-template-columns: 1fr;
    width: 100%;
    max-width: 100%;
    gap: 16px;
  }
  .gameSidebarCard {
    position: static;
    display: grid;
    grid-template-columns: auto 1fr;
    grid-template-rows: auto auto;
    gap: 10px 12px;
    align-items: center;
  }
  .gameBackInCard {
    grid-column: 1;
    grid-row: 2;
  }
  .gamePracticeNav {
    display: contents;
  }
  .gamePracticeTitle {
    margin: 0;
    grid-column: 1 / -1;
    grid-row: 1;
    text-align: center;
  }
  /* Button wrapper spans rest of row 2; inner grid = 4 columns, 1 row */
  .gamePracticeButtons {
    grid-column: 2;
    grid-row: 2;
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr;
    gap: 8px;
    min-width: 0;
  }
  .gameSidebarCard .gamePracticeBtn {
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .gameWrap {
    gap: 12px;
    padding: 12px 0;
  }
}
@media (max-width: 380px) {
  body.gamePage {
    padding-left: max(8px, env(safe-area-inset-left));
    padding-right: max(8px, env(safe-area-inset-right));
  }
}

/* Smartphone landscape only: narrower menu card (-10%), wider game card (+10%), bomb 86% of card, toggle 86% and more compact */
@media (orientation: landscape) and (max-height: 640px) {
  .gameWrap {
    grid-template-columns: 25% 75%;
  }
  .gameMainCard {
    container-type: inline-size;
    container-name: game-main-card;
  }
  .gameModeToggle {
    width: 86%;
    max-width: 86%;
  }
  .gameModeOption {
    padding: 8px 10px;
    min-height: 56px;
  }
  .gameModeTitle {
    font-size: 0.95rem;
    line-height: 1.15;
  }
  .gameModeSubtitle {
    font-size: 0.65rem;
    line-height: 1.2;
  }
  /* Bomb area: 86% of card; assembly (490×270) scaled to fit, so bomb + fuses keep correct alignment */
  .gameBombArea {
    width: 86%;
    max-width: 86%;
    min-width: 0;
    margin-left: auto;
    margin-right: auto;
    position: relative;
    height: 0;
    padding-bottom: 55.1%; /* 270/490 aspect ratio */
  }
  .gameBombAssembly {
    position: absolute;
    left: 50%;
    top: 0;
    width: 490px;
    height: 270px;
    transform: translateX(-50%) scale(0.84);
    transform-origin: center top;
    margin: 0;
  }
}

/* Shared card look (semi-transparent, like index.html .card) */
.gameCard {
  position: relative;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.07), rgba(255, 255, 255, 0.03));
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px;
  min-width: 0;
}

.gameSidebarCard {
  position: sticky;
  top: max(60px, calc(12px + env(safe-area-inset-top)));
  display: flex;
  flex-direction: column;
  gap: 16px;
}
@media (max-width: 768px) {
  .gameSidebarCard {
    position: static;
  }
}

.gameBackInCard {
  align-self: flex-start;
}

.gameMainCard {
  padding: 24px;
}
@media (max-width: 600px) {
  .gameCard {
    padding: 16px;
  }
  .gameMainCard {
    padding: 18px;
  }
}

/* Close (X) button: upper right of main card, visible only when game has started */
.gameCardCloseBtn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  padding: 0;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 20;
  transition: background 0.2s, border-color 0.2s;
}
.gameCardCloseBtn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}
.gameCardCloseBtn.visible {
  display: flex;
}
@media (max-width: 480px) {
  .gameCardCloseBtn {
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    font-size: 1.35rem;
  }
}

.gamePracticeNav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
}

.gamePracticeTitle {
  margin: 0;
  font-size: clamp(0.85rem, 2vw, 1rem);
  font-weight: 600;
  color: var(--ink);
  text-align: left;
}

.gamePracticeButtons {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: stretch; /* full-width buttons for easier touch on all screen sizes */
}

.gamePracticeBtn {
  padding: 12px 16px;
  min-height: 44px; /* touch target for small screens (WCAG / iOS) */
  font-size: 0.9rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, border-color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.gamePracticeBtn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(122, 166, 255, 0.4);
}

.gameMain {
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding: 0;
  position: relative;
}

/* Mode toggle: Stress | Tænk */
.gameModeLabel {
  width: 100%;
  max-width: 420px;
  margin: 0 0 8px;
  font-size: clamp(0.95rem, 2.5vw, 1.1rem);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
}
.gameModeToggle {
  display: flex;
  width: 100%;
  max-width: 420px;
  margin-bottom: 24px;
  border-radius: 14px;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: rgba(0, 0, 0, 0.2);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.gameModeOption {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 14px 12px;
  min-height: 72px;
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: var(--ink);
  font-family: inherit;
  cursor: pointer;
  transition: background 0.2s ease, color 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}

.gameModeOption:hover {
  background: rgba(255, 255, 255, 0.1);
}

.gameModeOption[aria-pressed="true"] {
  background: rgba(122, 166, 255, 0.35);
  color: var(--ink);
  font-weight: 600;
}

.gameModeOption:first-of-type {
  border-right: 1px solid rgba(255, 255, 255, 0.15);
}

/* When game has started: lock toggle and grey out the other mode so it cannot be read or clicked */
.gameModeToggleLocked .gameModeOption[aria-pressed="false"] {
  opacity: 0.35;
  pointer-events: none;
  cursor: default;
  background: rgba(0, 0, 0, 0.25);
  color: rgba(255, 255, 255, 0.5);
}
.gameModeToggleLocked .gameModeOption[aria-pressed="false"] .gameModeTitle,
.gameModeToggleLocked .gameModeOption[aria-pressed="false"] .gameModeSubtitle {
  color: rgba(255, 255, 255, 0.45);
}

.gameModeTitle {
  font-size: clamp(1.1rem, 3.5vw, 1.35rem);
  font-weight: 700;
  line-height: 1.2;
}

.gameModeSubtitle {
  font-size: clamp(0.7rem, 2.2vw, 0.85rem);
  font-weight: 500;
  line-height: 1.25;
  opacity: 0.9;
  text-align: center;
}

.gameInstruction {
  font-size: clamp(16px, 3vw, 20px);
  font-weight: 600;
  color: var(--ink);
  text-align: center;
  margin: 0 0 20px;
  padding: 0 16px;
  position: relative;
  z-index: 1;
  overflow-wrap: break-word;
  word-wrap: break-word;
}
.gameInstruction.hidden {
  visibility: hidden;
  pointer-events: none;
  /* keep layout space so card and bomb stay in place when game starts */
}
@media (max-width: 480px) {
  .gameInstruction {
    padding: 0 8px;
    margin-bottom: 16px;
  }
}

/* Bomb area */
.gameBombArea {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
  margin-top: 24px;
  transform-origin: center top;
}

/* Assembly: bomb + fuses in a fixed 490×270 box so they scale together (bomb 210×270 at x=140, fuses extend ±140) */
.gameBombAssembly {
  position: relative;
  width: 490px;
  height: 270px;
  margin: 0 auto;
  overflow: visible;
}
.gameBombAssembly .bomb {
  position: absolute;
  left: 140px;
  top: 0;
}

/* Smartphone landscape: scale assembly so bomb + fuses fit (only when assembly is used) */
@media (orientation: landscape) and (max-height: 520px) {
  .gameBombAssembly {
    transform: translateX(-50%) scale(0.80);
    transform-origin: center top;
  }
}
@media (orientation: landscape) and (max-height: 450px) {
  .gameBombAssembly {
    transform: translateX(-50%) scale(0.70);
    transform-origin: center top;
  }
}
@media (orientation: landscape) and (max-height: 380px) {
  .gameBombAssembly {
    transform: translateX(-50%) scale(0.60);
    transform-origin: center top;
  }
}
@media (orientation: landscape) and (max-height: 320px) {
  .gameBombAssembly {
    transform: translateX(-50%) scale(0.50);
    transform-origin: center top;
  }
}

.bomb {
  position: relative;
  width: 210px;
  height: 270px;
}

.bombBody {
  position: absolute;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 165px;
  height: 165px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 50%, #2a2a2a, #1a1a1a);
  box-shadow:
    inset -12px -12px 30px rgba(0,0,0,.5),
    inset 6px 6px 18px rgba(255,255,255,.08),
    0 12px 36px rgba(0,0,0,.4);
  border: 3px solid rgba(255,255,255,.06);
}
.bomb.exploded .bombBody {
  animation: bombExplode 0.6s ease-out forwards;
}
@keyframes bombExplode {
  0% { transform: translateX(-50%) scale(1); opacity: 1; filter: brightness(1); }
  40% { transform: translateX(-50%) scale(1.3); opacity: 1; filter: brightness(2); }
  100% { transform: translateX(-50%) scale(2.5); opacity: 0; filter: brightness(3); }
}

/* Fuses: three fuses (20s, 40s, 60s) – meandering SVG paths */
.fuse {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
}

.fuseSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.fusePathBurned {
  stroke: #2a1a0e;
  stroke-width: 7;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: none;
}

.fusePathUnburned {
  stroke: #6b4423;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: stroke-dasharray 0.3s linear;
}

.fuse .fuseFire {
  transition: opacity .2s;
  opacity: 0;
}

/* Stress mode: show flames at end of fuses even before "start spil"; they only start moving after start */
body.gamePage:not(.gameMode-taenk) .fuse .fuseFire {
  opacity: 1;
}
/* Hide fire on defused fuses (Stress and Tænk); Stress needs same specificity as rule above */
body.gamePage:not(.gameMode-taenk) .fuse.defused .fuseFire,
.fuse.defused .fuseFire {
  opacity: 0;
}

.fuse.fireBurning .fuseFire {
  opacity: 1;
}

.fuse .flameCore {
  fill: #ffaa00;
  filter: drop-shadow(0 0 4px #ffaa00);
  animation: flameCoreFlicker 0.12s ease-in-out infinite alternate;
}

.fuse .flameOuter {
  fill: #ff6600;
  opacity: 0.7;
  filter: drop-shadow(0 0 8px #ff6600);
  animation: flameOuterFlicker 0.18s ease-in-out infinite alternate;
}

.fuse .flameSpark {
  fill: #ffdd00;
  opacity: 0.8;
  filter: drop-shadow(0 0 3px #ffdd00);
}

.fuse .flameSpark.spark1 {
  transform: translate(-4px, -3px);
  animation: sparkFloat1 0.4s ease-in-out infinite alternate;
}

.fuse .flameSpark.spark2 {
  transform: translate(3px, -5px);
  animation: sparkFloat2 0.35s ease-in-out infinite alternate;
  animation-delay: 0.1s;
}

.fuse .flameSpark.spark3 {
  transform: translate(-2px, -7px);
  animation: sparkFloat3 0.45s ease-in-out infinite alternate;
  animation-delay: 0.2s;
}

@keyframes flameCoreFlicker {
  0% {
    r: 5;
    fill: #ff9900;
    transform: scale(1);
  }
  50% {
    r: 7;
    fill: #ffbb00;
    transform: scale(1.15);
  }
  100% {
    r: 6;
    fill: #ffaa00;
    transform: scale(1.05);
  }
}

@keyframes flameOuterFlicker {
  0% {
    r: 8;
    fill: #ff5500;
    opacity: 0.6;
    transform: scale(1);
  }
  50% {
    r: 12;
    fill: #ff7700;
    opacity: 0.8;
    transform: scale(1.2);
  }
  100% {
    r: 10;
    fill: #ff6600;
    opacity: 0.7;
    transform: scale(1.1);
  }
}

@keyframes sparkFloat1 {
  0% {
    transform: translate(-4px, -3px) scale(1);
    opacity: 0.6;
  }
  100% {
    transform: translate(-6px, -6px) scale(1.3);
    opacity: 1;
  }
}

@keyframes sparkFloat2 {
  0% {
    transform: translate(3px, -5px) scale(1);
    opacity: 0.7;
  }
  100% {
    transform: translate(5px, -8px) scale(1.2);
    opacity: 1;
  }
}

@keyframes sparkFloat3 {
  0% {
    transform: translate(-2px, -7px) scale(1);
    opacity: 0.5;
  }
  100% {
    transform: translate(-3px, -10px) scale(1.4);
    opacity: 0.9;
  }
}
.fuse.defused { opacity: 0.35; pointer-events: none; }
.fuse.defused .defuseBtn { display: none; }
.fuse.defused .fusePathUnburned { stroke: #3d2817; }

/* Tænk mode: wires with white/light-blue "flame" at end; removed when wire is cut */
@keyframes flameCoreFlickerTaenk {
  0%   { r: 5; fill: #fff; transform: scale(1); }
  50%  { r: 7; fill: #f0f8ff; transform: scale(1.15); }
  100% { r: 6; fill: #fff; transform: scale(1.05); }
}
@keyframes flameOuterFlickerTaenk {
  0%   { r: 8; fill: rgba(200, 230, 255, 0.8); opacity: 0.7; transform: scale(1); }
  50%  { r: 12; fill: rgba(220, 240, 255, 0.95); opacity: 0.9; transform: scale(1.2); }
  100% { r: 10; fill: rgba(200, 230, 255, 0.9); opacity: 0.85; transform: scale(1.1); }
}

body.gameMode-taenk .fuse .fuseFire {
  opacity: 1;
  pointer-events: none;
}
body.gameMode-taenk .fuse.defused .fuseFire {
  opacity: 0;
}
body.gameMode-taenk .fuse .flameCore {
  fill: #fff;
  filter: drop-shadow(0 0 4px #fff);
  animation: flameCoreFlickerTaenk 0.12s ease-in-out infinite alternate;
}
body.gameMode-taenk .fuse .flameOuter {
  fill: rgba(200, 230, 255, 0.9);
  opacity: 0.85;
  filter: drop-shadow(0 0 8px rgba(180, 220, 255, 0.9));
  animation: flameOuterFlickerTaenk 0.18s ease-in-out infinite alternate;
}
body.gameMode-taenk .fuse .flameSpark {
  fill: #a8d4ff;
  opacity: 0.9;
  filter: drop-shadow(0 0 3px #a8d4ff);
}
body.gameMode-taenk .fusePathBurned,
body.gameMode-taenk .fusePathUnburned {
  transition: stroke 0.2s ease;
}
body.gameMode-taenk #fuse0 .fusePathBurned,
body.gameMode-taenk #fuse0 .fusePathUnburned {
  stroke: #c53030;
}
body.gameMode-taenk #fuse1 .fusePathBurned,
body.gameMode-taenk #fuse1 .fusePathUnburned {
  stroke: #3182ce;
}
body.gameMode-taenk #fuse2 .fusePathBurned,
body.gameMode-taenk #fuse2 .fusePathUnburned {
  stroke: #38a169;
}
body.gameMode-taenk #fuse0.defused .fusePathUnburned { stroke: #7b2d2d; }
body.gameMode-taenk #fuse1.defused .fusePathUnburned { stroke: #2c5282; }
body.gameMode-taenk #fuse2.defused .fusePathUnburned { stroke: #276749; }

/* Tænk mode: wire buttons – white with black text, same transparency; same narrow size as fuse 3 */
body.gameMode-taenk .defuseBtn {
  background: rgba(255, 255, 255, 0.5);
  color: #111;
  border-color: rgba(0, 0, 0, 0.18);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
  width: 80px;
  min-height: 44px;
  text-align: center;
  white-space: normal;
  line-height: 1.25;
  padding: 8px 6px;
}
body.gameMode-taenk .defuseBtn:hover {
  background: rgba(255, 255, 255, 0.65);
}

.defuseBtn {
  position: relative;
  z-index: 2;
  padding: 10px 14px;
  min-height: 44px; /* touch target on small screens */
  font-size: 0.85rem;
  border-radius: 10px;
  border: 1px solid rgba(255, 175, 90, 0.65);
  background: rgba(255, 200, 120, 0.5);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 8px rgba(255, 180, 100, 0.2);
}
.defuseBtn:hover { background: rgba(255, 200, 120, 0.65); }

/* Fuse positions and sizes – longer meandering paths */
.fuseLeft {
  top: calc(20px + 20vh);
  left: -140px;
  width: 180px;
  height: 80px;
}
.fuseRight {
  top: calc(20px + 20vh);
  right: -140px;
  width: 180px;
  height: 80px;
}

/* Tablet/desktop: side fuses halfway between top of bomb and smartphone position */
@media (min-height: 641px) {
  .fuseLeft,
  .fuseRight {
    top: calc(10px + 10vh);
  }
}

/* Desktop/laptop only: move bomb up 10px (tablets keep current position) */
@media (min-width: 1025px) {
  .gameBombAssembly .bomb {
    top: -10px;
  }
}

.fuseBottom {
  bottom: calc(115px + 5vh);
  left: 50%;
  transform: translateX(-50%);
  width: 80px;
  height: 200px;
}

.startSpilBtn {
  position: relative;
  z-index: 10; /* above bomb/fuses so button stays clickable when fuses overlap */
  padding: 12px 24px;
  min-height: 48px; /* comfortable touch target on all screen sizes */
  font-size: 1rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid rgba(255, 175, 90, 0.65);
  background: rgba(255, 200, 120, 0.5);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 2px 12px rgba(255, 180, 100, 0.2);
}
.startSpilBtn:hover { background: rgba(255, 200, 120, 0.65); }
.startSpilBtn.hidden {
  visibility: hidden;
  pointer-events: none;
}

/* Defuse overlay */
.gameDefuseOverlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(11, 16, 32, 0.92);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-top: max(56px, env(safe-area-inset-top));
  padding-bottom: max(20px, env(safe-area-inset-bottom));
  padding-left: max(20px, env(safe-area-inset-left));
  padding-right: max(20px, env(safe-area-inset-right));
  overflow-y: auto;
  overflow-x: hidden;
}
.gameDefuseOverlay.isOpen {
  display: flex;
  z-index: 210; /* above .gameTopBar (200) so overlay content is fully clickable, including top of stepper buttons */
}

/* Task card: same look as main game card, contains back button + task content */
.gameDefuseCard {
  position: relative;
  width: 100%;
  max-width: min(560px, calc(100vw - 40px));
  padding: 24px;
  padding-top: 52px; /* room for back button in top-left */
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
@media (max-width: 600px) {
  .gameDefuseCard {
    padding: 18px;
    padding-top: 48px;
    max-width: calc(100vw - 24px);
  }
}
@media (max-width: 480px) {
  .gameDefuseCard {
    padding: 16px;
    padding-top: 46px;
    max-width: calc(100vw - 24px);
  }
}

/* Go back to fuse choice: upper left inside the task card (game tasks only) */
.gameDefuseBackBtn {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  display: none;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  z-index: 20;
  transition: background 0.2s, border-color 0.2s;
}
.gameDefuseBackBtn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}
@media (max-width: 480px) {
  .gameDefuseBackBtn {
    top: 10px;
    left: 10px;
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}

@media (max-width: 480px) {
  .gameDefuseOverlay {
    padding-left: max(12px, env(safe-area-inset-left));
    padding-right: max(12px, env(safe-area-inset-right));
    padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
}

.gameDefuseOverlayActions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 16px;
}

/* Practice "tilbage": same position as game back button (upper left of card) */
.gameDefuseLukBtn {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 10px 16px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.2s, border-color 0.2s;
}
.gameDefuseLukBtn:hover {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.35);
}
@media (max-width: 480px) {
  .gameDefuseLukBtn {
    top: 10px;
    left: 10px;
    padding: 8px 12px;
    font-size: 0.9rem;
  }
}

.gameDefuseSpilIgenBtn {
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.gameDefuseSpilIgenBtn:hover {
  background: rgba(255, 255, 255, 0.18);
}

.gameDefusePrompt {
  font-size: clamp(14px, 2.5vw, 17px);
  color: var(--muted);
  text-align: center;
  max-width: 420px;
  margin: 0 0 20px;
}

.gameClocksRow {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
  justify-content: center;
  align-items: flex-start;
}
@media (max-width: 480px) {
  .gameClocksRow {
    gap: 16px;
  }
}

.gameBusTaskContent {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px;
  max-width: 360px;
}
.gameBusTaskLine {
  margin: 0;
  font-size: clamp(15px, 2.8vw, 18px);
  color: var(--ink);
  text-align: center;
}
.gameBusTaskLabel {
  font-weight: 600;
}
.gameBusTaskTimeDisplay {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
#gameBusTaskAnswerSlot .gameClockSlot {
  margin-top: 8px;
}

.gameDefusePairContent {
  display: none;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 420px;
}

.gameClockSlot {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 20px;
  border-radius: var(--radius);
  border: 2px solid transparent;
  transition: border-color .2s, box-shadow .2s;
}
.gameClockSlot.editable {
  border-color: rgba(122, 166, 255, 0.6);
  box-shadow: 0 0 0 4px rgba(122, 166, 255, 0.15);
}
.gameClockSlot.readOnly {
  opacity: 0.85;
}

.gameClockPrompt {
  font-size: 13px;
  color: var(--muted);
  margin: 0;
  min-height: 1.2em;
}

.gameClockWrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

/* Overlay analog clocks: same proportions and readability as main clock on index.html */
.gameClockAnalog.clockShell {
  width: min(320px, 40vw);
  max-width: 100%;
}

/* Same size numbers and marks as index.html for readable faces */
.gameClockAnalog .num span {
  font-size: clamp(16px, 2.2vw, 22px);
}
.gameClockAnalog .minuteNums span {
  font-size: clamp(11px, 1.5vw, 15px);
}
.gameClockAnalog .mark::before {
  width: 2px;
  height: 14px;
  border-radius: 2px;
  background: rgba(234, 240, 255, 0.55);
}
.gameClockAnalog .mark.big::before {
  width: 3px;
  height: 20px;
  background: rgba(234, 240, 255, 0.8);
}

.gameDigitalWrap {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 12px;
  flex-wrap: wrap;
}

.gameDigitalClockCenter {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.gameDigitalWrap .gameDigitalStepperGroup {
  touch-action: none;
}
.gameDigitalWrap .gameDigitalStepperGroup .smallTimeStepperBtn {
  -webkit-tap-highlight-color: transparent;
}

.gameAmPm {
  font-size: 14px;
  padding: 4px 10px;
}

.gameTimeInput {
  width: 120px;
  font-size: 1.5rem;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.18);
  color: var(--ink);
  text-align: center;
  letter-spacing: 1px;
  font-variant-numeric: tabular-nums;
}
.gameClockSlot.editable .gameTimeInput {
  border-color: rgba(122,166,255,.5);
  cursor: text;
}
.gameClockSlot.editable .gameTimeInput[readonly] { cursor: default; }

.gameStepperSpacer {
  color: var(--muted);
  font-size: 1.2rem;
}

.gameTryAgain {
  margin-top: 12px;
  color: #e8a050;
  font-weight: 600;
  font-size: 1rem;
}

/* Explosion effect (from bomb center) */
.gameExplosion {
  position: fixed;
  left: 0;
  top: 0;
  width: 0;
  height: 0;
  z-index: 108;
  pointer-events: none;
}

.gameExplosion-particle {
  position: absolute;
  left: 0;
  top: 0;
  width: 12px;
  height: 12px;
  margin-left: -6px;
  margin-top: -6px;
  border-radius: 50%;
  pointer-events: none;
  animation: explosionBurst 1.8s ease-out forwards;
}

@keyframes explosionBurst {
  0% {
    transform: translate(0, 0) scale(0.2);
    opacity: 1;
  }
  20% {
    opacity: 1;
  }
  100% {
    transform: translate(var(--ex-dx), var(--ex-dy)) scale(1.5);
    opacity: 0;
  }
}

/* GAME OVER overlay */
.gameOverOverlay {
  position: fixed;
  inset: 0;
  z-index: 110;
  background: rgba(80, 20, 20, 0.95);
  display: none;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.gameOverOverlay.isOpen { display: flex; }
.gameOverOverlay.fadeOut { animation: gameOverFade 1.5s ease-out forwards; }
@keyframes gameOverFade {
  to { opacity: 0; }
}

.gameOverText {
  font-size: clamp(48px, 12vw, 80px);
  font-weight: 800;
  color: #ff4444;
  text-shadow: 0 0 30px rgba(255, 50, 50, 0.8);
  letter-spacing: 0.05em;
  animation: gameOverPulse 0.8s ease-in-out infinite alternate;
}
@keyframes gameOverPulse {
  from { transform: scale(1); opacity: 1; }
  to { transform: scale(1.02); opacity: 0.95; }
}

/* Win overlay */
.gameWinOverlay {
  position: fixed;
  inset: 0;
  z-index: 105;
  background: rgba(11, 16, 32, 0.85);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}
.gameWinOverlay.isOpen { display: flex; }

.gameWinText {
  position: relative;
  z-index: 2;
  font-size: clamp(2rem, 8vw, 4rem);
  font-weight: 800;
  color: #ffd700;
  text-shadow: 0 0 20px rgba(255,215,0,.8), 0 0 40px rgba(255,200,0,.5), 0 2px 4px rgba(0,0,0,.4);
  animation: celebrationPop 0.4s ease-out, celebrationFade 2s ease-in 1.5s forwards;
  opacity: 1;
  text-align: center;
  padding: 0 20px;
}

@keyframes celebrationPop {
  0% { transform: scale(0.3); opacity: 0; }
  70% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes celebrationFade {
  to { opacity: 0; transform: scale(1.05); }
}

/* Celebration (fireworks container) */
.gameCelebration {
  position: fixed;
  inset: 0;
  z-index: 90;
  pointer-events: none;
  overflow: hidden;
}

/* Practice/game success "Godt gået!" / "Godt!" – above defuse overlay so it shows on top */
body.gamePage .celebration {
  z-index: 220;
}

/* Make fireworks particles bigger for game win */
.gameCelebration .celebration-particle {
  width: 16px;
  height: 16px;
  margin-left: -8px;
  margin-top: -8px;
}

.gameCelebration .celebration-particle::after {
  inset: -4px;
  filter: blur(8px);
}

/* ---------- Pairing task (12h/24h) overlay ---------- */
.gamePairOverlay {
  position: fixed;
  inset: 0;
  z-index: 250;
  background: rgba(11, 16, 32, 0.95);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: max(56px, env(safe-area-inset-top)) 20px max(80px, env(safe-area-inset-bottom));
  overflow-y: auto;
}
.gamePairOverlay.isOpen {
  display: flex;
}

.gamePairPrompt {
  font-size: clamp(15px, 2.5vw, 18px);
  color: var(--ink);
  text-align: center;
  margin: 0 0 24px;
  max-width: 420px;
}

.gamePairColumnsWrap {
  position: relative;
  display: flex;
  flex-direction: row;
  justify-content: center;
  align-items: stretch;
  gap: 32px;
  min-height: 200px;
  margin-bottom: 20px;
}

.gamePairLinesSvg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
}
.gamePairLine {
  stroke: rgba(122, 166, 255, 0.9);
  stroke-width: 3;
  stroke-linecap: round;
  transition: opacity 0.2s;
  opacity: 0;
}
.gamePairLine.visible {
  opacity: 1;
}

.gamePairColumn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  min-width: 88px;
}

.gamePairColumnTitle {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: 0.05em;
}

.gamePairColumnTimes {
  display: flex;
  flex-direction: column;
  justify-content: space-evenly;
  gap: 12px;
  flex: 1;
}

.gamePairTimeBtn {
  padding: 12px 18px;
  font-size: 1.1rem;
  font-variant-numeric: tabular-nums;
  border-radius: 12px;
  border: 2px solid rgba(255, 255, 255, 0.25);
  background: rgba(0, 0, 0, 0.25);
  color: var(--ink);
  cursor: pointer;
  font-weight: 600;
  -webkit-tap-highlight-color: transparent;
  transition: border-color 0.2s, background 0.2s, transform 0.1s;
}
.gamePairTimeBtn:hover {
  border-color: rgba(122, 166, 255, 0.5);
  background: rgba(122, 166, 255, 0.15);
}
.gamePairTimeBtn.selected {
  border-color: rgba(255, 215, 0, 0.8);
  background: rgba(255, 215, 0, 0.2);
}
.gamePairTimeBtn.paired {
  border-color: rgba(80, 180, 120, 0.6);
  background: rgba(80, 180, 120, 0.15);
  cursor: default;
  opacity: 0.9;
}

.gamePairTryAgain {
  margin: 0 0 16px;
  font-size: 1rem;
  font-weight: 600;
  color: #e8a050;
  min-height: 1.4em;
  opacity: 0;
  transition: opacity 0.15s;
}
.gamePairTryAgain.visible {
  opacity: 1;
  animation: gamePairTryAgainFlash 1.2s ease-out forwards;
}
@keyframes gamePairTryAgainFlash {
  0% { opacity: 1; }
  70% { opacity: 1; }
  100% { opacity: 0; }
}

.gamePairHint {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px 20px;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.gamePairHintClock {
  position: relative;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.2);
  background: radial-gradient(circle at 50% 50%, rgba(255,255,255,.06), rgba(0,0,0,.15));
  flex-shrink: 0;
}
.gamePairHintFace {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  pointer-events: none;
}
.gamePairHintNums {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 100%;
  height: 100%;
  pointer-events: none;
  color: rgba(234, 240, 255, 0.88);
  font-weight: 700;
}
.gamePairHintNums span {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: 11px;
}
.gamePairHintHand {
  position: absolute;
  left: 50%;
  bottom: 50%;
  transform-origin: 50% 100%;
  border-radius: 2px;
  pointer-events: none;
}
.gamePairHintHand.hour {
  width: 4px;
  height: 32%;
  margin-left: -2px;
  background: rgba(234, 240, 255, 0.9);
}
.gamePairHintHand.minute {
  width: 3px;
  height: 40%;
  margin-left: -1.5px;
  background: rgba(122, 166, 255, 0.95);
}
.gamePairHintText {
  font-size: 1rem;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

.gamePairTjekSvar {
  margin-bottom: 12px;
}

.gamePairCloseBtn {
  padding: 10px 20px;
  font-size: 0.95rem;
  font-weight: 600;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.gamePairCloseBtn:hover {
  background: rgba(255, 255, 255, 0.18);
}
