/* ===========================================================
   Yunus & Lulu Adventure — 8/16-bit pixel-art Mario styling
   =========================================================== */

:root {
  --ink: #0b1b3a;
  --sky-top: #1f7fd6;
  --sky-mid: #2f9be6;
  --sky-low: #6fd0ff;
  --gold: #f6c026;
  --gold-dark: #b97e0e;
  --panel: #122a63;
  --panel-edge: #0a1838;
  --blue: #2f6fd6;
  --pink: #e85a9a;
  --teal: #2fb6a0;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  font-family: "Press Start 2P", ui-monospace, monospace;
  color: #fff;
  background: var(--sky-mid);
  overflow-x: hidden;
  /* crisp pixels everywhere */
  -webkit-font-smoothing: none;
  text-rendering: geometricPrecision;
}

img {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* -----------------------------------------------------------
   World scene (behind the UI)
   ----------------------------------------------------------- */
.scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 50% 30%, #6fc4f5 0%, #3a9fe6 38%, #1d79c9 100%);
}

.rays {
  position: absolute;
  inset: -40% -10% auto -10%;
  height: 120%;
  top: -20%;
  background: repeating-conic-gradient(
    from 0deg at 50% 28%,
    rgba(255, 255, 255, 0.10) 0deg 6deg,
    rgba(255, 255, 255, 0) 6deg 12deg
  );
  pointer-events: none;
}

/* chunky pixel clouds */
.cloud {
  position: absolute;
  width: 96px;
  height: 32px;
  background: #fff;
  box-shadow:
    -32px 0 0 #fff, 32px 0 0 #fff,
    -16px -16px 0 #fff, 16px -16px 0 #fff,
    0 -16px 0 #fff,
    0 16px 0 6px #cfe8ff;
  border-radius: 6px;
}
.cloud::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: inset 0 6px 0 rgba(255, 255, 255, 0.9);
}
.cloud-1 { left: 6%;  top: 16%; transform: scale(1.1); }
.cloud-2 { left: 70%; top: 10%; transform: scale(0.9); }
.cloud-3 { left: 40%; top: 22%; transform: scale(0.7); opacity: 0.9; }

/* question block */
.qblock {
  position: absolute;
  left: 4%;
  top: 44%;
  width: 76px;
  height: 76px;
  background: #f0a818;
  border: 5px solid #8a4f10;
  box-shadow: inset 0 0 0 4px #ffd35e, inset -10px -10px 0 #d98a0c;
  display: grid;
  place-items: center;
}
.qblock span {
  font-size: 34px;
  color: #fff;
  text-shadow: 3px 3px 0 #8a4f10;
}
.qblock::before,
.qblock::after {
  content: "";
  position: absolute;
  width: 6px;
  height: 6px;
  background: #5c3208;
}
.qblock::before { left: 6px; top: 6px; box-shadow: 58px 0 0 #5c3208; }
.qblock::after  { left: 6px; bottom: 6px; box-shadow: 58px 0 0 #5c3208; }

/* green pipe */
.pipe {
  position: absolute;
  right: 3%;
  bottom: 96px;
  width: 120px;
  height: 150px;
}
.pipe-lip {
  position: absolute;
  top: 0;
  left: -8px;
  width: 136px;
  height: 40px;
  background: #34b14e;
  border: 5px solid #0c4a1f;
  box-shadow: inset 0 0 0 5px #6ee089, inset -16px 0 0 -5px #1c7e35;
}
.pipe-body {
  position: absolute;
  top: 36px;
  left: 8px;
  width: 104px;
  bottom: 0;
  background: #2faf4f;
  border: 5px solid #0c4a1f;
  box-shadow: inset 0 0 0 5px #5fd47d, inset -18px 0 0 -5px #1c7e35;
}

/* bushes + ground strip */
.bushes {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 84px;
  height: 70px;
  background:
    radial-gradient(circle at 8% 100%, #3fa838 0 60px, transparent 61px),
    radial-gradient(circle at 20% 100%, #2f8f2f 0 80px, transparent 81px),
    radial-gradient(circle at 52% 100%, #3fa838 0 74px, transparent 75px),
    radial-gradient(circle at 78% 100%, #2f8f2f 0 88px, transparent 89px),
    radial-gradient(circle at 93% 100%, #3fa838 0 66px, transparent 67px);
}
.ground {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 90px;
  background:
    linear-gradient(#5ac84a 0 22px, #3aa83a 22px 30px, #b5692f 30px 100%);
  border-top: 5px solid #2e7d28;
  background-size: 100% 100%, 100% 100%;
}
.ground::after {
  content: "";
  position: absolute;
  inset: 30px 0 0 0;
  background-image:
    linear-gradient(90deg, rgba(0, 0, 0, 0.18) 2px, transparent 2px),
    linear-gradient(rgba(0, 0, 0, 0.18) 2px, transparent 2px);
  background-size: 32px 32px;
  opacity: 0.5;
}

.flower {
  position: absolute;
  bottom: 70px;
  width: 18px;
  height: 18px;
  background: #ff5b45;
  box-shadow:
    -14px 0 0 #ffd35e, 14px 0 0 #ff8a2a,
    0 -14px 0 #fff26e, 0 14px 0 #2e7d28;
  border-radius: 50%;
}
.flower-1 { left: 16%; }
.flower-2 { left: 60%; }

/* -----------------------------------------------------------
   Layout shell
   ----------------------------------------------------------- */
.app-shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 20px;
}

.select-screen {
  width: min(1180px, 100%);
  display: grid;
  gap: clamp(16px, 2.6vw, 30px);
  justify-items: center;
  text-align: center;
}

/* -----------------------------------------------------------
   Top HUD counters
   ----------------------------------------------------------- */
.top-hud {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.counter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 18px;
  font-size: clamp(13px, 1.6vw, 20px);
  color: #fff;
  background: var(--panel);
  border: 4px solid var(--gold);
  box-shadow:
    0 0 0 4px var(--panel-edge),
    inset 0 0 0 3px rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  text-shadow: 2px 2px 0 #000;
}
.counter .x { opacity: 0.85; }

.coin-icon {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, #ffe98a 0 30%, var(--gold) 32%);
  border: 3px solid var(--gold-dark);
  box-shadow: inset 0 0 0 3px #ffdf6b;
  display: inline-block;
}

.star-badge {
  width: 24px;
  height: 24px;
  display: inline-block;
  background: var(--gold);
  filter: drop-shadow(2px 2px 0 var(--gold-dark));
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.star-badge.sm { width: 18px; height: 18px; }

/* -----------------------------------------------------------
   Title
   ----------------------------------------------------------- */
.title {
  margin: 0;
  display: grid;
  gap: 12px;
  line-height: 1;
}
.title-sub {
  font-size: clamp(16px, 3vw, 34px);
  color: #fff;
  -webkit-text-stroke: 2px #0b1b3a;
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 #0b1b3a;
  letter-spacing: 2px;
}
.title-main {
  font-size: clamp(34px, 8vw, 92px);
  letter-spacing: 2px;
}
.title-main span {
  color: var(--c);
  -webkit-text-stroke: 4px #fff;
  paint-order: stroke fill;
  text-shadow:
    0 5px 0 #0b1b3a,
    5px 5px 0 #0b1b3a;
}

/* -----------------------------------------------------------
   Character cards
   ----------------------------------------------------------- */
.character-grid {
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: clamp(14px, 2.4vw, 30px);
}

.character-card {
  --frame: var(--blue);
  --frame-dark: #16407f;
  appearance: none;
  position: relative;
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 16px 16px 20px;
  background: var(--frame);
  border: 6px solid var(--frame-dark);
  border-radius: 18px;
  box-shadow:
    0 0 0 5px var(--panel-edge),
    inset 0 0 0 4px rgba(255, 255, 255, 0.35),
    0 14px 0 rgba(0, 0, 0, 0.25);
  cursor: pointer;
  color: #fff;
  transition: transform 90ms steps(2), filter 90ms;
  image-rendering: pixelated;
}
.card-yunus { --frame: #2f6fd6; --frame-dark: #16407f; }
.card-lulu  { --frame: #e85a9a; --frame-dark: #9c2e60; }
.card-sufy  { --frame: #2fb6a0; --frame-dark: #176f62; }

.character-card:hover,
.character-card:focus-visible {
  transform: translateY(-6px);
  outline: none;
  filter: brightness(1.06);
}

.character-card.selected {
  transform: translateY(-4px);
  box-shadow:
    0 0 0 5px var(--panel-edge),
    0 0 0 11px var(--gold),
    inset 0 0 0 4px rgba(255, 255, 255, 0.4),
    0 16px 0 rgba(0, 0, 0, 0.25);
  animation: bob 1.1s steps(2) infinite alternate;
}
@keyframes bob {
  to { transform: translateY(-12px); }
}

.card-star {
  position: absolute;
  top: 8px;
  width: 22px;
  height: 22px;
  z-index: 3;
  background: var(--gold);
  filter: drop-shadow(2px 2px 0 var(--gold-dark));
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.card-star.tl { left: 12px; }
.card-star.tr { right: 12px; }

.portrait {
  width: 100%;
  aspect-ratio: 338 / 312;
  overflow: hidden;
  border: 5px solid var(--frame-dark);
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.5);
  border-radius: 8px;
  background: #2f9be6;
}
.portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.nameplate {
  width: 86%;
  padding: 10px 6px;
  font-size: clamp(14px, 1.8vw, 24px);
  letter-spacing: 1px;
  color: #fff;
  background: var(--frame-dark);
  border: 4px solid rgba(255, 255, 255, 0.65);
  border-radius: 10px;
  text-shadow: 2px 2px 0 #000;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.3);
}

.stats {
  display: grid;
  gap: 6px;
  width: 86%;
}
.stat {
  display: flex;
  align-items: center;
  gap: 8px;
}
.si {
  width: 16px;
  height: 16px;
  flex: 0 0 auto;
}
.si.heart {
  background: #ff3b3b;
  clip-path: polygon(50% 100%, 0 38%, 18% 12%, 50% 30%, 82% 12%, 100% 38%);
}
.si.star {
  background: var(--gold);
  clip-path: polygon(50% 0, 61% 35%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 35%);
}
.si.bolt {
  background: #38c6ff;
  clip-path: polygon(56% 0, 12% 56%, 46% 56%, 30% 100%, 88% 40%, 52% 40%);
}
.bar {
  flex: 1;
  display: flex;
  gap: 3px;
  height: 14px;
  padding: 3px;
  background: #0a1838;
  border: 2px solid rgba(255, 255, 255, 0.5);
  border-radius: 4px;
}
.bar i {
  flex: 1;
  background: #ffd35e;
  border-radius: 1px;
}
.bar i.off {
  background: rgba(255, 255, 255, 0.16);
}

/* -----------------------------------------------------------
   Bottom control bar
   ----------------------------------------------------------- */
.control-bar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  padding: 14px 18px;
  font-size: clamp(11px, 1.5vw, 18px);
  background: var(--panel);
  border: 4px solid var(--gold);
  box-shadow: 0 0 0 4px var(--panel-edge), inset 0 0 0 3px rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  text-shadow: 2px 2px 0 #000;
}
.ctrl {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}
.ctrl-center { color: #ffe98a; }

.dpad {
  position: relative;
  width: 26px;
  height: 26px;
  background:
    linear-gradient(#9aa6c4 0 0) center/26px 9px no-repeat,
    linear-gradient(#9aa6c4 0 0) center/9px 26px no-repeat;
  filter: drop-shadow(2px 2px 0 #0a1838);
}

.key-btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  font-size: inherit;
  color: #fff;
  background: transparent;
  border: 0;
  cursor: pointer;
  text-shadow: 2px 2px 0 #000;
}
.key-btn.ghost { cursor: default; opacity: 0.92; }
.key {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-size: 14px;
  border: 3px solid rgba(255, 255, 255, 0.85);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.35);
}
.key.green { background: #36b14e; }
.key.red { background: #e23b3b; }
.key-btn:hover .key.green { filter: brightness(1.12); }

/* -----------------------------------------------------------
   Game screen
   ----------------------------------------------------------- */
.game-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: block;
  padding: 0;
  margin: 0;
  border: 0;
  border-radius: 0;
  background: #2f9be6;
}

/* Canvas fills the whole viewport — no frame around the game. */
canvas {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 0;
  background: #2f9be6;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* HUD + controls float on top of the game as translucent bars. */
.hud,
.game-help {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 11;
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 18px;
  font-size: clamp(9px, 1.3vw, 14px);
  background: rgba(10, 24, 56, 0.55);
  color: #fff;
  text-shadow: 2px 2px 0 #000;
  pointer-events: none;
}
.hud {
  top: 0;
  border-bottom: 3px solid rgba(255, 255, 255, 0.2);
}
.hud span { white-space: nowrap; }
#statusHud {
  overflow: hidden;
  color: #ffe98a;
  text-overflow: ellipsis;
}

.game-help {
  bottom: 0;
  justify-content: center;
  color: #cfe0ff;
  border-top: 3px solid rgba(255, 255, 255, 0.2);
}

.hidden {
  display: none;
}

/* -----------------------------------------------------------
   Responsive
   ----------------------------------------------------------- */
@media (max-width: 820px) {
  .character-grid {
    grid-template-columns: 1fr;
    max-width: 360px;
    margin: 0 auto;
  }
  .control-bar { justify-content: center; text-align: center; }
  .qblock, .pipe { display: none; }
}
