/* ==========================================================================
   Floor is Lava! — AAA Kid-Friendly Stylesheet
   ========================================================================== */

:root {
  --font-display: ui-rounded, "SF Pro Rounded", "Nunito", "Fredoka", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --gold: #ffd43b;
  --gold-dark: #e69500;
  --orange: #ff7a1a;
  --orange-dark: #c94a00;
  --green: #4cd94c;
  --green-dark: #259b24;
  --pink: #ff66a3;
  --pink-dark: #c42b6a;
  --blue: #4bb8ff;
  --blue-dark: #167ac6;
  --cream: #fff9ec;
  --brown: #5c3317;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #2b1408;
  font-family: var(--font-display);
  touch-action: none;
  overscroll-behavior: none;
}

#game-shell {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

/* ==========================================================================
   HUD Overlay (Matches Concept Art!)
   ========================================================================== */

#hud {
  position: absolute;
  inset: 0;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(14px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left));
  z-index: 10;
}

#hud.hidden {
  display: none;
}

.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
}

.hud-left {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Star Progress Bar */
.star-bar-wrap {
  position: relative;
  display: flex;
  align-items: center;
  background: rgba(92, 51, 23, 0.72);
  border: 4px solid #fff3d6;
  border-radius: 999px;
  padding: 4px 10px 4px 42px;
  min-width: 190px;
  height: 44px;
  box-shadow: 0 5px 0 rgba(70, 30, 10, 0.45), 0 8px 18px rgba(0, 0, 0, 0.28);
}

.hud-star-icon {
  position: absolute;
  left: -8px;
  width: 52px;
  height: 52px;
  filter: drop-shadow(0 3px 4px rgba(0,0,0,0.35));
  animation: gentleBob 2.4s ease-in-out infinite;
}

.star-bar-track {
  width: 140px;
  height: 22px;
  background: #6b3b1e;
  border-radius: 999px;
  overflow: hidden;
  box-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.45);
}

.star-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(180deg, #ffe97a 0%, #ffb703 55%, #fb8500 100%);
  border-radius: 999px;
  transition: width 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  box-shadow: inset 0 3px 0 rgba(255, 255, 255, 0.55);
}

/* Coin Pill */
.coin-pill {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: var(--cream);
  border: 4px solid #fff;
  outline: 3px solid #d48c32;
  border-radius: 999px;
  padding: 4px 18px 4px 46px;
  height: 42px;
  width: fit-content;
  box-shadow: 0 4px 0 #b87324, 0 8px 14px rgba(0, 0, 0, 0.25);
}

.hud-coin-icon {
  position: absolute;
  left: -4px;
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 2px 3px rgba(0,0,0,0.3));
}

#coin-count {
  font-size: 24px;
  font-weight: 900;
  color: var(--brown);
  line-height: 1;
}

/* Center Level Badge */
.hud-center {
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none;
}

.level-badge {
  background: linear-gradient(180deg, #fff9ec 0%, #ffe6b8 100%);
  border: 3px solid #fff;
  outline: 3px solid #d47a1a;
  border-radius: 999px;
  padding: 6px 22px;
  font-size: 18px;
  font-weight: 900;
  color: var(--brown);
  box-shadow: 0 4px 0 #b85f10, 0 8px 16px rgba(0,0,0,0.25);
  letter-spacing: 0.4px;
}

/* Right HUD Buttons */
.hud-right {
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: auto;
}

.hud-icon-btn {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: 4px solid #fff5db;
  background: linear-gradient(180deg, #ffa94d 0%, #ff7a1a 60%, #e85d04 100%);
  box-shadow: 0 5px 0 #a83c00, 0 8px 16px rgba(0, 0, 0, 0.3), inset 0 4px 0 rgba(255,255,255,0.45);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
  padding: 0;
}

.hud-icon-btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 #a83c00, 0 3px 6px rgba(0, 0, 0, 0.3);
}

.hud-icon-btn svg {
  width: 30px;
  height: 30px;
  fill: #fff;
  filter: drop-shadow(0 2px 0 rgba(120, 40, 0, 0.5));
}

/* ==========================================================================
   Bottom Touch Controls (Big, Chunky, Kid-Friendly!)
   ========================================================================== */

.hud-bottom {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  width: 100%;
  padding-bottom: 4px;
}

.move-controls {
  display: flex;
  gap: 14px;
  pointer-events: auto;
}

.arrow-btn {
  width: 76px;
  height: 70px;
  border-radius: 22px;
  border: 4px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  touch-action: none;
}

.arrow-btn.left {
  background: linear-gradient(180deg, #ff9ec4 0%, #ff5c9d 60%, #e0357a 100%);
  box-shadow: 0 7px 0 #9e1b52, 0 12px 20px rgba(0,0,0,0.35), inset 0 4px 0 rgba(255,255,255,0.55);
}

.arrow-btn.right {
  background: linear-gradient(180deg, #8ef075 0%, #4cd94c 60%, #2ab82a 100%);
  box-shadow: 0 7px 0 #1b7d1b, 0 12px 20px rgba(0,0,0,0.35), inset 0 4px 0 rgba(255,255,255,0.55);
}

.arrow-btn.pressed,
.arrow-btn:active {
  transform: translateY(5px) scale(0.96);
}

.arrow-btn.left.pressed,
.arrow-btn.left:active {
  box-shadow: 0 2px 0 #9e1b52, 0 4px 10px rgba(0,0,0,0.35);
}

.arrow-btn.right.pressed,
.arrow-btn.right:active {
  box-shadow: 0 2px 0 #1b7d1b, 0 4px 10px rgba(0,0,0,0.35);
}

.arrow-btn svg {
  width: 40px;
  height: 40px;
  fill: #fff;
  filter: drop-shadow(0 2px 0 rgba(0,0,0,0.28));
}

.tap-hint {
  background: rgba(255, 249, 236, 0.92);
  border: 3px solid #fff;
  outline: 3px solid #e07a16;
  border-radius: 999px;
  padding: 8px 20px;
  font-size: 18px;
  font-weight: 900;
  color: var(--brown);
  box-shadow: 0 5px 14px rgba(0,0,0,0.28);
  animation: gentleBob 2s ease-in-out infinite;
  transition: opacity 0.4s ease;
}

.tap-hint.faded {
  opacity: 0;
}

.jump-btn {
  pointer-events: auto;
  min-width: 196px;
  height: 86px;
  padding: 0 32px;
  border-radius: 28px;
  border: 5px solid #fff;
  background: linear-gradient(180deg, #98f576 0%, #48d648 55%, #23b023 100%);
  box-shadow: 0 8px 0 #157515, 0 14px 24px rgba(0,0,0,0.4), inset 0 5px 0 rgba(255,255,255,0.6);
  color: #fff;
  font-family: var(--font-display);
  font-size: 38px;
  font-weight: 900;
  letter-spacing: 1.5px;
  text-shadow: 0 3px 0 #157515, 0 5px 8px rgba(0,0,0,0.25);
  cursor: pointer;
  touch-action: none;
  transition: transform 0.08s ease, box-shadow 0.08s ease;
}

.jump-btn.pressed,
.jump-btn:active {
  transform: translateY(6px) scale(0.96);
  box-shadow: 0 2px 0 #157515, 0 5px 10px rgba(0,0,0,0.35);
}

/* ==========================================================================
   Screens & Modals (Title / Level Select / Pause / Victory)
   ========================================================================== */

.overlay-screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 20;
  background: radial-gradient(circle at 50% 35%, rgba(255, 224, 150, 0.25), rgba(45, 16, 4, 0.72));
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  transition: opacity 0.25s ease;
}

.overlay-screen.hidden {
  display: none;
}

/* Title Logo */
.game-logo {
  text-align: center;
  margin-bottom: 18px;
  animation: gentleBob 3s ease-in-out infinite;
}

.logo-top {
  display: block;
  font-size: clamp(46px, 7vw, 76px);
  font-weight: 900;
  line-height: 0.95;
  color: #5cd6ff;
  -webkit-text-stroke: 4px #4a2308;
  text-shadow: 0 6px 0 #1a78b5, 0 12px 22px rgba(0,0,0,0.4);
  letter-spacing: 1px;
}

.logo-bottom {
  display: block;
  font-size: clamp(42px, 6.5vw, 70px);
  font-weight: 900;
  line-height: 1.05;
  color: #ffb703;
  -webkit-text-stroke: 4px #4a2308;
  text-shadow: 0 6px 0 #c94a00, 0 12px 22px rgba(0,0,0,0.4);
}

.logo-is {
  color: #fff9ec;
  font-size: 0.72em;
  vertical-align: middle;
  margin-right: 8px;
}

.subtitle-pill {
  background: rgba(255, 249, 236, 0.95);
  color: var(--brown);
  border: 3px solid #fff;
  border-radius: 999px;
  padding: 6px 20px;
  font-size: clamp(14px, 2vw, 18px);
  font-weight: 800;
  margin-bottom: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.25);
}

/* Level Cards Grid (8 levels: 4x2 on iPad/desktop) */
.level-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(130px, 200px));
  gap: 14px;
  max-width: 880px;
  width: 100%;
  max-height: 62vh;
  overflow-y: auto;
  padding: 6px;
  justify-content: center;
}

.level-card {
  position: relative;
  background: var(--cream);
  border: 5px solid #fff;
  border-radius: 26px;
  padding: 10px 10px 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  box-shadow: 0 8px 0 #c97324, 0 14px 26px rgba(0,0,0,0.4);
  transition: transform 0.14s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.14s ease;
}

.level-card:hover {
  transform: translateY(-4px) scale(1.03);
}

.level-card:active {
  transform: translateY(4px) scale(0.98);
  box-shadow: 0 3px 0 #c97324, 0 6px 12px rgba(0,0,0,0.35);
}

.level-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  object-fit: cover;
  border: 3px solid #ffd89b;
  background: #ffd89b;
}

.level-name {
  font-size: clamp(15px, 1.8vw, 19px);
  font-weight: 900;
  color: var(--brown);
  text-align: center;
}

.level-stars {
  display: flex;
  gap: 4px;
  font-size: 20px;
  line-height: 1;
}

.star-earned {
  color: #ffb703;
  text-shadow: 0 2px 0 #b86c00;
}

.star-empty {
  color: #d6c3a5;
}

/* Modal Card (Pause & Victory) */
.modal-card {
  background: linear-gradient(180deg, #fffaf0 0%, #ffeed1 100%);
  border: 6px solid #fff;
  outline: 4px solid #e07a16;
  border-radius: 34px;
  padding: 28px 36px;
  max-width: 480px;
  width: 92%;
  text-align: center;
  box-shadow: 0 12px 0 #b85b0c, 0 22px 42px rgba(0,0,0,0.5);
  animation: popIn 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-title {
  font-size: 38px;
  font-weight: 900;
  color: var(--brown);
  margin: 0 0 10px;
}

.modal-subtitle {
  font-size: 19px;
  font-weight: 700;
  color: #8a5228;
  margin: 0 0 20px;
}

.victory-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  font-size: 52px;
  margin-bottom: 18px;
}

.modal-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  align-items: center;
}

.big-pill-btn {
  width: 100%;
  max-width: 300px;
  height: 62px;
  border-radius: 999px;
  border: 4px solid #fff;
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.big-pill-btn.green {
  background: linear-gradient(180deg, #8ef075 0%, #48d648 60%, #23b023 100%);
  box-shadow: 0 6px 0 #157515, 0 10px 18px rgba(0,0,0,0.25);
  text-shadow: 0 2px 0 #157515;
}

.big-pill-btn.orange {
  background: linear-gradient(180deg, #ffa94d 0%, #ff7a1a 60%, #e85d04 100%);
  box-shadow: 0 6px 0 #a83c00, 0 10px 18px rgba(0,0,0,0.25);
  text-shadow: 0 2px 0 #a83c00;
}

.big-pill-btn.blue {
  background: linear-gradient(180deg, #74ccff 0%, #3aa3f5 60%, #167ac6 100%);
  box-shadow: 0 6px 0 #0e548a, 0 10px 18px rgba(0,0,0,0.25);
  text-shadow: 0 2px 0 #0e548a;
}

.big-pill-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

/* Portrait Orientation Hint on Phones/iPads */
@media (orientation: portrait) and (max-width: 760px) {
  .level-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
  .arrow-btn {
    width: 68px;
    height: 64px;
  }
  .jump-btn {
    min-width: 148px;
    height: 70px;
    font-size: 28px;
  }
}

@keyframes gentleBob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}

@keyframes popIn {
  0% { transform: scale(0.75); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
