@import url('https://fonts.googleapis.com/css2?family=Fredoka+One&family=Nunito:wght@700;900&display=swap');

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: #0a1f10;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-family: 'Fredoka One', cursive;
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  -webkit-user-drag: none;
}

/* ── Header ── */
#header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 432px;
  padding: 0 6px 8px;
}

h1 {
  font-size: 1.75rem;
  color: #52b788;
  text-shadow: 0 3px 0 #1b4332, 0 0 20px rgba(82,183,136,0.4);
  letter-spacing: 1px;
}

#score-panel { display: flex; gap: 10px; }

.sbox {
  background: rgba(82,183,136,0.1);
  border: 2px solid #52b788;
  border-radius: 12px;
  padding: 3px 14px;
  text-align: center;
  min-width: 70px;
}

.slabel {
  font-family: 'Nunito', sans-serif;
  font-size: 0.6rem;
  color: #74c69d;
  text-transform: uppercase;
  letter-spacing: 1px;
  font-weight: 900;
}

.sval {
  font-size: 1.4rem;
  color: #fff;
}

/* ── Canvas wrap ── */
#wrap {
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 3px solid #52b788;
  box-shadow: 0 0 50px rgba(82,183,136,0.25), 0 20px 50px rgba(0,0,0,0.6);
}

canvas { display: block; }

/* ── Overlay ── */
#overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(8,28,14,0.86);
  z-index: 20;
  gap: 10px;
  padding: 28px 20px;
  backdrop-filter: blur(3px);
}

#ov-emoji { font-size: 3.4rem; line-height: 1; }

#ov-title {
  font-size: 2.2rem;
  color: #52b788;
  text-shadow: 0 3px 0 #1b4332;
  text-align: center;
}

#ov-sub {
  font-family: 'Nunito', sans-serif;
  font-size: 0.88rem;
  color: #b7e4c7;
  text-align: center;
  line-height: 1.6;
  font-weight: 700;
}

#result-box {
  display: none;
  flex-direction: column;
  align-items: center;
  background: rgba(255,255,255,0.06);
  border: 2px solid rgba(82,183,136,0.35);
  border-radius: 14px;
  padding: 10px 30px;
  gap: 3px;
  margin: 4px 0;
}

#res-score {
  font-size: 1.9rem;
  color: #ffd166;
}

#res-best {
  font-family: 'Nunito', sans-serif;
  font-size: 0.85rem;
  color: #b7e4c7;
  font-weight: 700;
}

#play-btn {
  background: #52b788;
  color: #1b4332;
  border: none;
  border-radius: 50px;
  padding: 13px 38px;
  font-family: 'Fredoka One', cursive;
  font-size: 1.35rem;
  cursor: pointer;
  box-shadow: 0 6px 0 #2d6a4f, 0 10px 24px rgba(0,0,0,0.35);
  transition: transform 0.1s, box-shadow 0.1s;
  margin-top: 4px;
  -webkit-tap-highlight-color: transparent;
}

#play-btn:active { transform: translateY(3px);  box-shadow: 0 3px 0 #2d6a4f; }

.btn-home {
  background: transparent;
  color: rgba(183,228,199,0.5);
  border: 2px solid rgba(82,183,136,0.25);
  border-radius: 50px;
  padding: 9px 32px;
  font-family: 'Fredoka One', cursive;
  font-size: 1rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.btn-home:active { transform: scale(0.95); }

#hint {
  font-family: 'Nunito', sans-serif;
  font-size: 0.75rem;
  color: #52b788;
  font-weight: 700;
}

/* ── D-pad ── */
#dpad {
  display: grid;
  grid-template-columns: repeat(3, 58px);
  grid-template-rows:    repeat(2, 58px);
  gap: 5px;
  margin-top: 14px;
}

.dp {
  background: rgba(82,183,136,0.14);
  border: 2px solid #52b788;
  border-radius: 12px;
  color: #52b788;
  font-size: 1.3rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.08s, transform 0.07s;
  -webkit-tap-highlight-color: transparent;
}
.dp:active {
  background: rgba(82,183,136,0.38);
  transform: scale(0.91);
}

@media (max-width: 460px) {
  h1 { font-size: 1.4rem; }
  .sval { font-size: 1.1rem; }
  #dpad { grid-template-columns: repeat(3,52px); grid-template-rows: repeat(2,52px); }
}