
#endScreen.overlay{
  position: absolute;    
  inset: 0;                
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.25);
  backdrop-filter: blur(2px);
  z-index: 9999;
  border-radius: 18px;    
}

#endScreen.overlay.overlay--show{
  display: flex;
}

#endScreen .overlay-card{
  position: relative;
  width: 720px;
  height: 480px;
  border-radius: 18px;
  overflow: hidden;
}

#endScreen .overlay-preview{
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

@media (max-width: 760px), (max-height: 520px){
  #endScreen .overlay-card{
    width: min(92vw, 720px);
    height: auto;
    aspect-ratio: 720 / 480;
  }
}

#endScreen .overlay-card{
  position: relative; 
}

#endScreen .overlay-actions{
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 14px;
  justify-content: center;
  background: transparent;
  padding: 0;
  z-index: 50;
}

#controlsModal.overlay{
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  background: rgba(0,0,0,.25);
  backdrop-filter: blur(2px);
}

#controlsModal.overlay.overlay--show{ display:flex; }

.controls-card{
  width: min(560px, 92%);
  border-radius: 18px;
  padding: 22px 22px 18px;
  background: #e9c67e;
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  position: relative;
  border: 2px solid rgba(0,0,0,.12);
}

.controls-close{
  position: absolute;
  top: 12px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  border: none;
  background: transparent;
  font-size: 22px;
  cursor: pointer;
  color: #2b1d00;
}

.controls-card h2{
  margin: 0 0 14px;
  text-align: center;
  font-size: 32px;
  letter-spacing: 1px;
  color: #2b1d00;
}

.controls-grid{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 22px;
}

.controls-col h3{
  margin: 0 0 10px;
  font-size: 22px;
  color: #2b1d00;
}

.controls-row{
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 6px 0;
  font-size: 16px;
  color: #2b1d00;
}

.controls-row span:first-child{
  opacity: .95;
}

.controls-row span:last-child{
  font-weight: 800;
}

@media (max-width: 520px){
  .controls-grid{ grid-template-columns: 1fr; }
  .controls-card h2{ font-size: 26px; }
}

.game-wrap:fullscreen{
  width: 100vw;
  height: 100vh;
  border-radius: 0;
  overflow: hidden;
}

.game-wrap:fullscreen #canvas{
  width: 100%;
  height: 100%;
}

.game-wrap:fullscreen .overlay{
  inset: 0;
}

.game-wrap:fullscreen .overlay-card{
  width: 100%;
  height: 100%;
  border-radius: 0;
}

.game-wrap:fullscreen .overlay-preview{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-wrap:fullscreen .overlay-actions--top{
  top: 20px;
}

.fs-btn{
  position: absolute;
  right: 14px;
  bottom: 14px;
  z-index: 80;
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,.18);
  background: rgba(20, 12, 6, .45);
  backdrop-filter: blur(6px);
  color: #f5c400;
  font-size: 22px;
  line-height: 1;
  display: grid;
  place-items: center;
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  box-shadow: 0 10px 22px rgba(0,0,0,.25);
  transition: transform .08s ease, background .12s ease, filter .12s ease;
}

.fs-btn:hover{ filter: brightness(1.05); }
.fs-btn:active{ transform: translateY(1px) scale(.98); background: rgba(20, 12, 6, .62); }

.game-wrap:fullscreen .fs-btn{
  right: 18px;
  bottom: 18px;
}

.game-wrap:fullscreen{
  width: 100vw;
  height: 100vh;
  border-radius: 0;
}

.game-wrap:fullscreen #canvas{
  width: 100%;
  height: 100%;
  object-fit: contain; 
}

.game-wrap:fullscreen .overlay{
  border-radius: 0;
}

.game-wrap:fullscreen #endScreen .overlay-card{
  width: 100% !important;
  height: 100% !important;
  border-radius: 0;
}

.game-wrap:fullscreen #endScreen .overlay-preview{
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#startScreen .overlay-card,
#endScreen .overlay-card{
  width: 100%;
  height: 100%;
  border-radius: 18px;
  overflow: hidden;
  background: transparent;
}

#startScreen .overlay-preview,
#endScreen .overlay-preview{
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;   
}

.fs-btn{
  top: 14px;
  right: 14px;
  bottom: auto; 
  left: auto;
}

.game-wrap:fullscreen .fs-btn{
  top: 18px;
  right: 18px;
  bottom: auto;
}