/****************************************
  ==== LAYOUT
****************************************/

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #0b0e14;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  user-select: none;
}

#game-wrapper {
  position: relative;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #0b0e14;
}

canvas#canvas {
  width: min(100vw, calc(100vh * (1024 / 640)));
  height: min(100vh, calc(100vw * (640 / 1024)));
  max-width: 100vw;
  max-height: 100vh;
  display: block;
  margin: auto;
  box-shadow: 0 0 40px rgba(0, 0, 0, 0.85);
}

body.stretch-mode canvas#canvas {
  width: 100vw;
  height: 100vh;
}

#fullscreen-btn, #stretch-btn, #reward-ad-btn {
  position: fixed;
  z-index: 999;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-radius: 8px;
  color: #fff;
  cursor: pointer;
  padding: 8px 12px;
  height: 38px;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: opacity 0.25s ease, transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

#fullscreen-btn {
  top: 14px;
  right: 14px;
  padding: 8px;
  width: 38px;
  background: rgba(15, 20, 30, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.18);
  opacity: 0.7;
}

#stretch-btn {
  top: 14px;
  right: 60px;
  background: rgba(15, 20, 30, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.18);
  opacity: 0.7;
}

#reward-ad-btn {
  top: 14px;
  right: 160px;
  background: linear-gradient(135deg, rgba(234, 179, 8, 0.85), rgba(202, 138, 4, 0.9));
  border: 1px solid rgba(254, 240, 138, 0.4);
  color: #1a1300;
  font-weight: 700;
  box-shadow: 0 2px 10px rgba(234, 179, 8, 0.3);
  opacity: 0.9;
}

#fullscreen-btn:hover, #stretch-btn:hover {
  opacity: 1;
  transform: scale(1.05);
  background: rgba(30, 40, 60, 0.9);
  border-color: rgba(255, 255, 255, 0.35);
}

#reward-ad-btn:hover {
  opacity: 1;
  transform: scale(1.05);
  background: linear-gradient(135deg, rgba(250, 204, 21, 0.95), rgba(234, 179, 8, 1));
  box-shadow: 0 4px 16px rgba(234, 179, 8, 0.55);
}

.controls-hidden #fullscreen-btn, 
.controls-hidden #stretch-btn, 
.controls-hidden #reward-ad-btn {
  opacity: 0;
  pointer-events: none;
}

/* Modal Overlay */
#reward-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(4, 7, 13, 0.75);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 10000;
  align-items: center;
  justify-content: center;
  user-select: none;
}

#reward-modal.active {
  display: flex;
}

.modal-content {
  background: #111827;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  width: 90%;
  max-width: 440px;
  padding: 24px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(234, 179, 8, 0.2);
  color: #fff;
  text-align: center;
  position: relative;
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes modalPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.modal-header h2 {
  margin: 0 0 6px 0;
  font-size: 22px;
  font-weight: 800;
  color: #fbbf24;
  letter-spacing: -0.5px;
}

.modal-header p {
  margin: 0 0 20px 0;
  font-size: 13px;
  color: #9ca3af;
}

.reward-options {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 20px;
}

.reward-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.reward-card:hover {
  background: rgba(234, 179, 8, 0.08);
  border-color: rgba(234, 179, 8, 0.4);
  transform: translateY(-2px);
}

.reward-info {
  display: flex;
  align-items: center;
  gap: 12px;
  text-align: left;
}

.reward-icon {
  font-size: 24px;
}

.reward-title {
  font-size: 14px;
  font-weight: 700;
  color: #f3f4f6;
}

.reward-desc {
  font-size: 12px;
  color: #9ca3af;
}

.reward-btn {
  background: #f59e0b;
  border: none;
  border-radius: 8px;
  color: #1a1300;
  font-weight: 700;
  font-size: 12px;
  padding: 8px 14px;
  cursor: pointer;
  transition: background 0.15s ease;
}

.reward-card:hover .reward-btn {
  background: #fbbf24;
}

.modal-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-top: 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.close-modal-btn {
  background: transparent;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: #9ca3af;
  font-size: 12px;
  padding: 8px 16px;
  cursor: pointer;
}

.close-modal-btn:hover {
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.ad-badge {
  font-size: 10px;
  color: #6b7280;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* Toast Notifications */
#ad-toast {
  position: fixed;
  top: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(-50px);
  background: #1f2937;
  color: #fff;
  padding: 12px 24px;
  border-radius: 30px;
  font-size: 13px;
  font-weight: 600;
  z-index: 100000;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
}

#ad-toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

#ad-toast.success {
  border-color: #10b981;
  background: rgba(16, 185, 129, 0.15);
  backdrop-filter: blur(10px);
  color: #6ee7b7;
}

#ad-toast.info {
  border-color: #3b82f6;
  background: rgba(59, 130, 246, 0.15);
  backdrop-filter: blur(10px);
  color: #93c5fd;
}

#ad-toast.warning {
  border-color: #f59e0b;
  background: rgba(245, 158, 11, 0.15);
  backdrop-filter: blur(10px);
  color: #fde68a;
}

div#loadingBox {
  width: 100%;
  height: 20px;
  position: absolute;
  top: 50%;
  margin-top: -10px;
  text-align: center;
}

div#bgBar {
  position: absolute;
  width: 200px;
  margin-left: -100px;
  left: 50%;
  height: 2px;
  display: block;
  background-color: #333;
}
div#progressBar {
  left: 50%;
  position: absolute;
  margin-left: -100px;
  width: 0px;
  height: 2px;
  background-color: white;
  border-radius: 2px;
}
div#bgBar {
  border-radius: 2px;
}

p#loadingInfo {
  color: #666;
  letter-spacing: 1px;
  position: absolute;
  width: 100%;
  font-family: "Monaco", sans-serif;
  text-transform: uppercase;
  text-align: center;
  font-size: 14px;
  margin-top: 10px;
}