/* ===== Google Fonts ===== */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@400;600;700;800;900&display=swap');

/* ===== CSS Variables ===== */
:root {
  --pink: #ff6b9d;
  --coral: #ff8a65;
  --violet: #a855f7;
  --sky: #38bdf8;
  --mint: #34d399;
  --yellow: #fbbf24;
  --bg-start: #1a1a2e;
  --bg-mid: #16213e;
  --bg-end: #0f3460;
  --card-bg: rgba(255, 255, 255, 0.08);
  --card-border: rgba(255, 255, 255, 0.18);
  --text: #f8fafc;
  --text-dim: rgba(255, 255, 255, 0.6);
  --shadow: rgba(0, 0, 0, 0.3);
  --radius: 24px;
}

/* ===== Reset ===== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Outfit', sans-serif;
  color: var(--text);
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--bg-start), var(--bg-mid), var(--bg-end));
}

/* ===== Three.js Canvas ===== */
#bg-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
}

/* ===== Game Container ===== */
.game-container {
  position: relative;
  z-index: 10;
  perspective: 1200px;
}

/* ===== Game Card ===== */
.game-card {
  width: 420px;
  max-width: 92vw;
  padding: 44px 38px 38px;
  background: var(--card-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  box-shadow:
    0 8px 32px var(--shadow),
    0 0 80px rgba(168, 85, 247, 0.08),
    inset 0 1px 0 rgba(255, 255, 255, 0.1);
  text-align: center;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.game-card:hover {
  transform: rotateY(2deg) rotateX(-1deg) translateZ(10px);
}

/* ===== Header ===== */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 30px;
}

.game-header > div {
  text-align: left;
}

/* ===== Title ===== */
.game-title {
  font-size: 2rem;
  font-weight: 900;
  letter-spacing: -0.5px;
  margin-bottom: 6px;
  background: linear-gradient(135deg, var(--pink), var(--coral), var(--yellow), var(--mint), var(--sky), var(--violet));
  background-size: 300% 300%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: gradientShift 4s ease infinite;
}

.game-subtitle {
  font-size: 0.95rem;
  color: var(--text-dim);
  margin-bottom: 0;
  font-weight: 400;
}

@keyframes gradientShift {

  0%,
  100% {
    background-position: 0% 50%;
  }

  50% {
    background-position: 100% 50%;
  }
}

/* ===== Hint / Message ===== */
.hint-box {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 24px;
  padding: 12px 18px;
  border-radius: 16px;
  font-size: 1.05rem;
  font-weight: 600;
  transition: all 0.35s ease;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.hint-box.hint-higher {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.3);
  color: var(--sky);
}

.hint-box.hint-lower {
  background: rgba(255, 107, 157, 0.12);
  border-color: rgba(255, 107, 157, 0.3);
  color: var(--pink);
}

.hint-box.hint-win {
  background: rgba(52, 211, 153, 0.15);
  border-color: rgba(52, 211, 153, 0.35);
  color: var(--mint);
  font-size: 1.15rem;
}

.hint-icon {
  margin-right: 8px;
  font-size: 1.3rem;
}

/* ===== Input Group ===== */
.input-group {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.guess-input {
  flex: 1;
  padding: 14px 20px;
  border: 2px solid rgba(255, 255, 255, 0.12);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 600;
  outline: none;
  transition: all 0.3s ease;
  text-align: center;
  letter-spacing: 2px;
}

.guess-input::placeholder {
  color: rgba(255, 255, 255, 0.3);
  font-weight: 400;
  letter-spacing: 0;
}

.guess-input:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 4px rgba(168, 85, 247, 0.15);
  background: rgba(255, 255, 255, 0.08);
}

/* ===== Buttons ===== */
.btn {
  padding: 14px 28px;
  border: none;
  border-radius: 14px;
  font-family: 'Outfit', sans-serif;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
}

.btn::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.2), transparent);
  opacity: 0;
  transition: opacity 0.3s;
}

.btn:hover::after {
  opacity: 1;
}

.btn-guess {
  background: linear-gradient(135deg, var(--violet), var(--pink));
  color: white;
  box-shadow: 0 4px 15px rgba(168, 85, 247, 0.35);
  min-width: 110px;
}

.btn-guess:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow: 0 6px 25px rgba(168, 85, 247, 0.5);
}

.btn-guess:active {
  transform: translateY(0) scale(0.97);
}

.btn-restart {
  width: 100%;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  color: var(--text-dim);
  border: 1.5px solid rgba(255, 255, 255, 0.1);
  margin-top: 4px;
}

.btn-restart:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.06));
  color: var(--text);
  border-color: rgba(255, 255, 255, 0.2);
  transform: translateY(-1px);
}

/* ===== Stats Bar ===== */
.stats-bar {
  display: flex;
  justify-content: center;
  gap: 28px;
  margin-bottom: 18px;
}

.stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.stat-value {
  font-size: 1.6rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--sky), var(--violet));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.stat-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  font-weight: 600;
}

/* ===== Range indicator ===== */
.range-bar {
  width: 100%;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  margin-bottom: 24px;
  position: relative;
  overflow: hidden;
}

.range-fill {
  height: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, var(--sky), var(--violet), var(--pink));
  transition: width 0.4s ease;
  box-shadow: 0 0 10px rgba(168, 85, 247, 0.4);
}

/* ===== Shake Animation ===== */
@keyframes shake {

  0%,
  100% {
    transform: translateX(0);
  }

  10%,
  30%,
  50%,
  70%,
  90% {
    transform: translateX(-6px);
  }

  20%,
  40%,
  60%,
  80% {
    transform: translateX(6px);
  }
}

.shake {
  animation: shake 0.5s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* ===== Bounce In ===== */
@keyframes bounceIn {
  0% {
    transform: scale(0.3);
    opacity: 0;
  }

  50% {
    transform: scale(1.05);
  }

  70% {
    transform: scale(0.95);
  }

  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.bounce-in {
  animation: bounceIn 0.6s ease;
}

/* ===== Pulse animation for win ===== */
@keyframes pulse {

  0%,
  100% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.04);
  }
}

.pulse {
  animation: pulse 1s ease infinite;
}

/* ===== Confetti Particle ===== */
.confetti {
  position: fixed;
  z-index: 100;
  width: 10px;
  height: 10px;
  border-radius: 2px;
  pointer-events: none;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg) scale(1);
  }

  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg) scale(0.3);
  }
}

/* ===== Number pop ===== */
@keyframes numberPop {
  0% {
    transform: scale(1);
  }

  50% {
    transform: scale(1.3);
  }

  100% {
    transform: scale(1);
  }
}

.number-pop {
  animation: numberPop 0.3s ease;
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
  .game-card {
    padding: 30px 22px 26px;
  }

  .game-title {
    font-size: 1.6rem;
  }

  .input-group {
    flex-direction: column;
  }

  .btn-guess {
    width: 100%;
  }
}

/* ===== Daily Stats Ribbon ===== */
.daily-stats {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.daily-stat {
  display: flex;
  align-items: center;
  gap: 10px;
}

.daily-stat-icon {
  font-size: 1.4rem;
}

.daily-stat-info {
  display: flex;
  flex-direction: column;
}

.daily-stat-value {
  font-size: 1.2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--yellow), var(--coral));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.2;
}

.daily-stat-label {
  font-size: 0.65rem;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-dim);
  font-weight: 600;
}

.daily-stat-divider {
  width: 1px;
  height: 32px;
  background: rgba(255, 255, 255, 0.1);
}

/* ===== Header Button ===== */
.btn-icon {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  background: rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(8px);
  color: var(--text);
  font-size: 1.2rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.btn-icon:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px) rotate(10deg);
  border-color: var(--sky);
}

/* ===== Rules Modal ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 1;
  transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
  opacity: 0 !important;
  pointer-events: none !important;
  display: flex !important;
}

.modal-content {
  width: 90%;
  max-width: 420px;
  background: var(--card-bg);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1.5px solid var(--card-border);
  border-radius: var(--radius);
  padding: 34px;
  position: relative;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5), 0 0 80px rgba(56, 189, 248, 0.1);
  transform: translateY(0) scale(1);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-overlay.hidden .modal-content {
  transform: translateY(30px) scale(0.95);
}

.btn-close-modal {
  position: absolute;
  top: 16px;
  right: 18px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 1.8rem;
  cursor: pointer;
  transition: color 0.3s ease, transform 0.3s ease;
  line-height: 1;
}

.btn-close-modal:hover {
  color: var(--pink);
  transform: scale(1.1) rotate(90deg);
}

.modal-content h2 {
  font-size: 1.8rem;
  font-weight: 800;
  margin-bottom: 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--sky), var(--mint));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.rules-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.rules-list li {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.85);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.rule-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.rules-list strong {
  color: var(--text);
  font-weight: 700;
  display: inline-block;
  margin-right: 4px;
}

/* ===== Hidden utility ===== */
.hidden {
  display: none !important;
}