* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: #fff9f0;
  font-family: 'Nunito', sans-serif;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  padding: 12px;
}

/* Background dots */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: radial-gradient(circle, #f0d8b0 1.5px, transparent 1.5px);
  background-size: 28px 28px;
  z-index: 0;
  pointer-events: none;
}

.wrapper {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  width: 100%;
  min-height: calc(100dvh - 24px);
  justify-content: center;
}

.title {
  font-family: 'Rampart One', 'M PLUS Rounded 1c', 'Nunito', sans-serif;
  font-weight: 800;
  font-size: 62px;
  color: #ff6b6b;
  text-shadow: 4px 4px 0 #ffb347, 6px 6px 0 #ffd93d;
  letter-spacing: 1px;
  
}

.subtitle {
  font-size: 15px;
  color: #9b7b5c;
  font-weight: 700;
  letter-spacing: 1px;
  margin-top: -14px;
  text-transform: uppercase;
}

/* Game area */
.game-area {
  position: relative;
}

canvas {
  border-radius: 16px;
  cursor: pointer;
  display: block;
  box-shadow: 0 8px 0 #e8c87a, 0 12px 24px rgba(0,0,0,0.12);
  background: white;
  touch-action: none;
}

/* Bottom controls */
.controls {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
}

.mode-btn {
  font-family: 'Fredoka One', cursive;
  font-size: 16px;
  letter-spacing: 0.6px;
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  cursor: pointer;
  color: #8a5c1d;
  background: #ffe7bc;
  transition: transform 0.1s, box-shadow 0.1s, background 0.2s, color 0.2s;
  box-shadow: 0 3px 0 #e0be87;
}

.mode-btn:hover {
  transform: translateY(-1px);
}

.mode-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #e0be87;
}

.mode-btn.active {
  background: #ffb347;
  color: #fff;
  box-shadow: 0 3px 0 #d98b2d;
}

.btn {
  font-family: 'Fredoka One', cursive;
  font-size: 18px;
  padding: 10px 28px;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.1s;
  letter-spacing: 1px;
}

.btn:active { transform: translateY(3px); box-shadow: none !important; }

.btn-new {
  background: #ff6b6b;
  color: white;
  box-shadow: 0 5px 0 #cc4444;
}
.btn-new:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #cc4444; }

.btn-hint {
  background: #ffd93d;
  color: #7a5a00;
  box-shadow: 0 5px 0 #c9a800;
}
.btn-hint:hover { transform: translateY(-2px); box-shadow: 0 7px 0 #c9a800; }

/* Win overlay */
.win-overlay {
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.85);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s;
  backdrop-filter: blur(4px);
}
.win-overlay.show {
  opacity: 1;
  pointer-events: all;
}
.win-emoji {
  font-size: 80px;
  animation: spin 0.6s ease-out;
}
@keyframes spin {
  from { transform: rotate(-20deg) scale(0.5); }
  to { transform: rotate(0deg) scale(1); }
}
.win-text {
  font-family: 'Fredoka One', cursive;
  font-size: 48px;
  color: #ff6b6b;
  text-shadow: 3px 3px 0 #ffb347;
  margin: 10px 0;
}
.win-sub {
  font-size: 18px;
  color: #9b7b5c;
  font-weight: 700;
  margin-bottom: 24px;
}

/* Stars display */
.stars {
  font-size: 22px;
  color: #ffd93d;
  letter-spacing: 4px;
}

/* Instructions */
.instructions {
  font-size: 13px;
  color: #b09070;
  font-weight: 700;
  text-align: center;
  max-width: 340px;
  line-height: 1.7;
}

@media (max-width: 640px) {
  body {
    padding: 8px;
  }

  .wrapper {
    gap: 14px;
    min-height: calc(100dvh - 16px);
  }

  .title {
    font-size: 38px;
    text-shadow: 3px 3px 0 #ffb347, 5px 5px 0 #ffd93d;
  }

  .subtitle {
    font-size: 12px;
    margin-top: -10px;
  }

  .btn {
    font-size: 16px;
    padding: 9px 18px;
  }

  .mode-btn {
    font-size: 15px;
    padding: 8px 14px;
  }

  .instructions {
    font-size: 12px;
    max-width: 92vw;
  }
}

/* Compact iframe layout: smaller viewport */
@media (max-height: 605px) {
  body {
    padding: 4px;
  }

  .wrapper {
    gap: 8px;
    min-height: calc(100dvh - 8px);
  }

  .title {
    font-size: 28px;
    text-shadow: 2px 2px 0 #ffb347, 3px 3px 0 #ffd93d;
    margin: 0;
  }

  .subtitle {
    font-size: 10px;
    margin-top: -6px;
  }

  .btn {
    font-size: 13px;
    padding: 6px 14px;
  }

  .mode-btn {
    font-size: 12px;
    padding: 5px 10px;
  }
}
