/* ===== Fonts (bundled locally for offline / Android) ===== */
@font-face {
  font-family: "Noto Sans Bengali";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("./assets/fonts/noto-sans-bengali-400.woff2") format("woff2");
}
@font-face {
  font-family: "Noto Sans Bengali";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("./assets/fonts/noto-sans-bengali-700.woff2") format("woff2");
}

/* ===== Base ===== */
* { margin: 0; padding: 0; box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
:root {
  --accent: #ffcc33;
  --accent-2: #ff5a3c;
  --ink: #eaf2ff;
  --panel: rgba(12, 20, 35, 0.82);
  --bangla: "Noto Sans Bengali", "Hind Siliguri", system-ui, sans-serif;
  --ui: "Segoe UI", system-ui, -apple-system, Roboto, Arial, sans-serif;
}
html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #0e1726; color: var(--ink);
  font-family: var(--ui);
  user-select: none; -webkit-user-select: none; touch-action: none;
  overscroll-behavior: none;
}
#game-canvas { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }
.hidden { display: none !important; }

/* ===== Watermark ===== */
#watermark {
  position: fixed; right: 14px; bottom: 12px; z-index: 30;
  display: flex; align-items: center; gap: 8px;
  font-size: clamp(14px, 2.4vw, 22px); font-weight: 700;
  color: rgba(255, 255, 255, 0.42);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.55);
  pointer-events: none; letter-spacing: 0.5px;
}
#watermark .wm-bangla { font-family: var(--bangla); }
#watermark .wm-dot { color: var(--accent); opacity: 0.8; }

/* ===== HUD ===== */
#hud {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: flex-start;
  padding: 14px 16px; gap: 10px;
  background: linear-gradient(180deg, rgba(6, 12, 24, 0.6), transparent);
  pointer-events: none;
}
.hud-box { background: var(--panel); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px; padding: 8px 14px; min-width: 92px; text-align: center;
  backdrop-filter: blur(6px); }
/* SCORE + BEST grouped on the left so the top-right is free for the sound/pause buttons */
.hud-left { display: flex; gap: 10px; pointer-events: none; }
/* SPEED stays visually centered regardless of the side clusters */
.hud-center { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); text-align: center; }
.hud-right { position: relative; }
.hud-label { font-size: 11px; letter-spacing: 2px; color: #9fb3d1; }
.hud-value { font-size: clamp(20px, 4vw, 30px); font-weight: 800; line-height: 1.05; }
.hud-unit { font-size: 12px; font-weight: 600; color: #9fb3d1; margin-left: 3px; }
.hud-mult {
  position: absolute; top: -10px; right: -10px;
  background: var(--accent-2); color: #fff; font-weight: 800; font-size: 13px;
  padding: 2px 8px; border-radius: 20px; box-shadow: 0 4px 12px rgba(255,90,60,0.5);
  animation: pulse 0.5s infinite alternate;
}
@keyframes pulse { from { transform: scale(1); } to { transform: scale(1.12); } }

/* ===== Touch controls ===== */
#touch-controls {
  position: fixed; inset: auto 0 0 0; bottom: 0; z-index: 25;
  display: flex; justify-content: space-between; align-items: flex-end;
  padding: 0 22px 26px; pointer-events: none;
}
.touch-cluster { display: flex; gap: 20px; pointer-events: auto; }
.touch-btn {
  width: 96px; height: 96px; border-radius: 50%;
  border: 2px solid rgba(255,255,255,0.25);
  background: rgba(20, 30, 50, 0.55); color: var(--ink);
  font-size: 34px; font-weight: 800; backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  transition: transform 0.06s, background 0.1s;
}
.touch-btn:active { transform: scale(0.92); background: rgba(40, 60, 95, 0.8); }
.touch-btn.brake { background: rgba(120, 30, 30, 0.6); font-size: 18px; }
.touch-btn.boost { background: rgba(30, 90, 50, 0.6); font-size: 18px; }
.touch-btn.pressed { background: var(--accent); color: #1a1300; border-color: var(--accent); }

/* ===== Utility buttons ===== */
#util-buttons { position: fixed; top: 14px; right: 16px; z-index: 26; display: flex; gap: 8px; }
.util-btn {
  width: 42px; height: 42px; border-radius: 10px; border: 1px solid rgba(255,255,255,0.12);
  background: var(--panel); color: var(--ink); font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; backdrop-filter: blur(6px);
}
.util-btn:active { transform: scale(0.94); }

/* ===== Screens ===== */
.screen {
  position: fixed; inset: 0; z-index: 40;
  display: flex; align-items: center; justify-content: center; padding: 20px;
  background: radial-gradient(120% 90% at 50% 0%, rgba(20,40,80,0.45), rgba(6,10,20,0.86));
  backdrop-filter: blur(3px);
  animation: fade 0.25s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.screen-inner {
  width: min(560px, 94vw); text-align: center;
  display: flex; flex-direction: column; align-items: center; gap: 14px;
}
.brand { margin-bottom: 4px; }
.brand-title {
  font-size: clamp(30px, 8vw, 62px); font-weight: 900; letter-spacing: 1px; line-height: 0.95;
  color: var(--accent); text-shadow: 0 4px 0 #b9760e, 0 10px 28px rgba(0,0,0,0.6);
}
.brand-title span { display: block; font-size: 0.42em; letter-spacing: 6px; color: var(--ink); margin-top: 6px; }
.brand-bangla { font-family: var(--bangla); font-weight: 700; font-size: clamp(18px, 4.4vw, 30px); color: #ffe6a1; margin-top: 8px; }
.tagline { color: #b9c8e2; font-size: clamp(13px, 2.6vw, 17px); }
.menu-best { font-size: 15px; color: #9fb3d1; }
.menu-best span { color: var(--accent); font-weight: 800; }

.screen-title { font-size: clamp(26px, 6vw, 44px); font-weight: 900; letter-spacing: 2px; }
.screen-title.danger { color: var(--accent-2); text-shadow: 0 3px 16px rgba(255,90,60,0.4); }

.result { background: var(--panel); border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px; padding: 14px 22px; width: min(320px, 80vw); }
.result-row { display: flex; justify-content: space-between; font-size: 18px; padding: 6px 0; }
.result-row b { color: var(--accent); }
.newbest { color: var(--accent); font-weight: 800; margin-top: 6px; letter-spacing: 1px;
  animation: pulse 0.6s infinite alternate; }

.primary-btn {
  margin-top: 6px; padding: 14px 40px; font-size: 20px; font-weight: 800; letter-spacing: 1px;
  color: #1a1300; background: linear-gradient(180deg, #ffd95e, var(--accent));
  border: none; border-radius: 14px; cursor: pointer;
  box-shadow: 0 6px 0 #b9760e, 0 12px 24px rgba(0,0,0,0.4);
  transition: transform 0.08s, box-shadow 0.08s;
}
.primary-btn:active { transform: translateY(4px); box-shadow: 0 2px 0 #b9760e, 0 6px 14px rgba(0,0,0,0.4); }
.ghost-btn {
  padding: 10px 26px; font-size: 15px; font-weight: 700; color: var(--ink);
  background: transparent; border: 1px solid rgba(255,255,255,0.22); border-radius: 12px; cursor: pointer;
}
.ghost-btn:active { background: rgba(255,255,255,0.08); }

.controls-hint { margin-top: 10px; font-size: 12.5px; color: #93a6c4; line-height: 1.7; }
.controls-hint b { color: var(--ink); }
.tilt-toggle { font-size: 13px; color: #b9c8e2; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.tilt-toggle input { width: 18px; height: 18px; accent-color: var(--accent); }

.boot-error {
  position: fixed; inset: 0; z-index: 99; display: flex; align-items: center; justify-content: center;
  background: #0e1726; color: #ff9b8b; font-size: 15px; text-align: center; padding: 30px; line-height: 1.6;
}

/* ===== Portrait blocker (landscape lock) ===== */
#rotate-overlay {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: radial-gradient(120% 90% at 50% 0%, rgba(20,40,80,0.6), #0e1726);
  color: var(--ink); align-items: center; justify-content: center; text-align: center; padding: 24px;
}
/* Show it only when the device/window is in portrait */
@media (orientation: portrait) { #rotate-overlay { display: flex; } }
.rotate-inner { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.rotate-icon { font-size: 72px; transform-origin: center; animation: rotateHint 1.8s ease-in-out infinite; }
@keyframes rotateHint { 0%, 100% { transform: rotate(0deg); } 50% { transform: rotate(90deg); } }
.rotate-title { font-size: clamp(18px, 5vw, 24px); font-weight: 800; margin-top: 16px; }
.rotate-sub { color: #9fb3d1; font-size: 14px; }
.rotate-bangla { font-family: var(--bangla); color: #ffe6a1; font-weight: 700; margin-top: 8px; }

/* Landscape phones: shrink screen text a bit so it fits */
@media (max-height: 480px) and (orientation: landscape) {
  .brand-title { font-size: clamp(26px, 7vh, 44px); }
  .screen-inner { gap: 9px; }
  .controls-hint { display: none; }
  .touch-btn { width: 84px; height: 84px; font-size: 30px; }
  .touch-btn.brake, .touch-btn.boost { font-size: 17px; }
}
