/* ============================================================
   BigBack Benny: Chonky Crossing — Styles
   ============================================================ */

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #1a1a2e;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

/* ── Game Container ── */
#game-container {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

#gameCanvas {
  display: block;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* ── Screens ── */
.screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: auto;
}

.screen.hidden {
  display: none;
}

/* ── Title Screen ── */
#title-screen {
  background: linear-gradient(180deg, #0d2137 0%, #1a3a1a 100%);
}

.title-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 20px;
  max-width: 420px;
  width: 100%;
}

.game-title {
  font-size: clamp(2rem, 8vw, 3.2rem);
  font-weight: 900;
  color: #ff8c00;
  text-shadow: 3px 3px 0 #7a3800, 0 0 30px #ff6600;
  letter-spacing: -1px;
  text-align: center;
  line-height: 1.1;
}

.game-subtitle {
  font-size: clamp(1.1rem, 4vw, 1.5rem);
  color: #ffd700;
  font-weight: 700;
  text-shadow: 2px 2px 0 #7a6000;
  text-align: center;
}

.tagline {
  color: #90ee90;
  font-size: 0.9rem;
  font-style: italic;
  margin-top: -4px;
}

#title-canvas {
  border-radius: 50%;
  background: rgba(255,255,255,0.05);
  border: 3px solid rgba(255,140,0,0.3);
}

.instructions {
  color: #b0c4de;
  font-size: 0.85rem;
  text-align: center;
  line-height: 1.7;
  background: rgba(0,0,0,0.3);
  padding: 10px 18px;
  border-radius: 10px;
  margin-top: 4px;
}

/* ── Game Over Screen ── */
#gameover-screen {
  background: rgba(10, 10, 30, 0.92);
  backdrop-filter: blur(4px);
}

.gameover-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 24px;
  max-width: 380px;
  width: 100%;
  animation: slideIn 0.4s ease-out;
}

@keyframes slideIn {
  from { transform: translateY(-30px); opacity: 0; }
  to   { transform: translateY(0);     opacity: 1; }
}

#squish-canvas {
  margin-bottom: 4px;
}

.gameover-title {
  font-size: clamp(1.3rem, 5vw, 1.8rem);
  color: #ff6b6b;
  font-style: italic;
  text-shadow: 2px 2px 0 #7a0000;
  text-align: center;
}

.score-box {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,140,0,0.3);
  border-radius: 12px;
  padding: 14px 28px;
  text-align: center;
  color: #fff;
  font-size: 1.05rem;
  line-height: 2;
  width: 100%;
}

.score-value {
  color: #ffd700;
  font-weight: 900;
  font-size: 1.3em;
}

.chonk-value {
  color: #ff8c00;
  font-weight: 700;
}

.gameover-btns {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.share-notice {
  color: #90ee90;
  font-size: 0.85rem;
  animation: fadeIn 0.3s ease;
}

.share-notice.hidden {
  display: none;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 28px;
  font-size: 1rem;
  font-weight: 700;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 0.5px;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, #ff8c00, #ff5500);
  color: #fff;
  box-shadow: 0 4px 15px rgba(255,85,0,0.5), 0 2px 0 #7a2800;
}

.btn-primary:hover {
  box-shadow: 0 6px 20px rgba(255,85,0,0.7), 0 2px 0 #7a2800;
  transform: translateY(-1px);
}

.btn-share {
  background: linear-gradient(135deg, #1da1f2, #0d8ecf);
  color: #fff;
  box-shadow: 0 4px 15px rgba(29,161,242,0.4), 0 2px 0 #0a5c8a;
}

.btn-share:hover {
  box-shadow: 0 6px 20px rgba(29,161,242,0.6), 0 2px 0 #0a5c8a;
  transform: translateY(-1px);
}

/* ── Touch / D-Pad Controls ── */
#touch-controls {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 5;
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

#touch-controls.visible {
  opacity: 1;
  pointer-events: auto;
}

.dpad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.dpad-row {
  display: flex;
  gap: 4px;
  align-items: center;
}

.dpad-center {
  width: 46px;
  height: 46px;
  background: rgba(255,255,255,0.05);
  border-radius: 6px;
}

.dpad-btn {
  width: 46px;
  height: 46px;
  background: rgba(255, 140, 0, 0.25);
  border: 2px solid rgba(255, 140, 0, 0.5);
  border-radius: 8px;
  color: #ffd700;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.1s, transform 0.1s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.dpad-btn:active {
  background: rgba(255, 140, 0, 0.6);
  transform: scale(0.9);
}

/* ── Responsive tweaks ── */
@media (max-width: 480px) {
  .title-content {
    gap: 8px;
  }
  .dpad-btn {
    width: 52px;
    height: 52px;
    font-size: 1.3rem;
  }
  .dpad-center {
    width: 52px;
    height: 52px;
  }
}

@media (hover: none) and (pointer: coarse) {
  /* Force D-pad visible on genuine touch devices regardless of JS .visible class.
     This intentionally overrides the JS-controlled opacity so the D-pad is always
     available on mobile even if JS hasn't added the .visible class yet. */
  #touch-controls {
    opacity: 1;
    pointer-events: auto;
  }
}
