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

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  overscroll-behavior: none;
  font-family: 'Quicksand', sans-serif;
  background: #bdeaff;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  display: block;
}

#loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, #bdeaff 0%, #eaffd8 100%);
  color: #5a7247;
  font-size: 22px;
  font-weight: 600;
  z-index: 999;
}

.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(80, 110, 60, 0.25);
  backdrop-filter: blur(4px);
  z-index: 500;
  padding: 20px;
}

.card {
  background: #fff9f0;
  border: 4px solid #ffd9e8;
  border-radius: 28px;
  padding: 36px 30px;
  max-width: 480px;
  text-align: center;
  box-shadow: 0 12px 40px rgba(0,0,0,0.2);
}

.card h1 {
  font-family: 'Patrick Hand', cursive;
  color: #d4658a;
  font-size: 34px;
  margin: 6px 0 12px;
}

.card p {
  color: #6b6456;
  font-size: 17px;
  line-height: 1.5;
  margin: 0 0 20px;
}

.hearts-deco {
  font-size: 30px;
  margin-bottom: 6px;
}

.hint {
  font-size: 13px !important;
  color: #a3b58c !important;
  margin-top: 14px !important;
}

.big-btn {
  background: linear-gradient(180deg, #ffb6cf, #ff8fb3);
  border: none;
  color: white;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 19px;
  padding: 14px 30px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #e46f95, 0 10px 20px rgba(0,0,0,0.15);
  cursor: pointer;
  transition: transform 0.08s ease;
}
.big-btn:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #e46f95, 0 6px 14px rgba(0,0,0,0.15);
}
.big-btn.small {
  font-size: 15px;
  padding: 10px 22px;
  box-shadow: 0 4px 0 #e46f95, 0 8px 16px rgba(0,0,0,0.15);
}

#hud {
  position: fixed;
  top: max(14px, env(safe-area-inset-top));
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 0 18px;
  z-index: 200;
  pointer-events: none;
  gap: 10px;
}

#world-name {
  background: rgba(255,255,255,0.85);
  border: 3px solid #b8d4e8;
  border-radius: 999px;
  padding: 8px 16px;
  font-weight: 700;
  color: #4a6f8a;
  font-size: 14px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  max-width: 42vw;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#letter-counter {
  background: rgba(255,255,255,0.85);
  border: 3px solid #ffd9e8;
  border-radius: 999px;
  padding: 8px 18px;
  font-weight: 700;
  color: #d4658a;
  font-size: 17px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  margin-left: auto;
}

#compass-wrap {
  background: rgba(255,255,255,0.85);
  border: 3px solid #cdeab0;
  border-radius: 50%;
  width: 52px;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
}

#compass-arrow {
  font-size: 24px;
  transition: transform 0.15s ease;
}

#open-prompt {
  position: fixed;
  bottom: 18%;
  left: 50%;
  transform: translateX(-50%);
  background: linear-gradient(180deg, #fff2b0, #ffe07d);
  border: none;
  color: #7a5c00;
  font-family: 'Quicksand', sans-serif;
  font-weight: 700;
  font-size: 18px;
  padding: 14px 26px;
  border-radius: 999px;
  box-shadow: 0 6px 0 #d9ac2c, 0 10px 20px rgba(0,0,0,0.2);
  z-index: 250;
  animation: bob 1.1s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateX(-50%) translateY(0); }
  50% { transform: translateX(-50%) translateY(-8px); }
}

#joystick-base {
  position: fixed;
  left: max(28px, env(safe-area-inset-left));
  bottom: max(28px, env(safe-area-inset-bottom));
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  border: 3px solid rgba(255,255,255,0.6);
  z-index: 300;
  touch-action: none;
}

#joystick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 56px;
  height: 56px;
  margin: -28px 0 0 -28px;
  border-radius: 50%;
  background: rgba(255, 143, 179, 0.85);
  border: 3px solid white;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}

#letter-paper {
  background: #fffdf5;
  background-image: repeating-linear-gradient(#fffdf5 0px, #fffdf5 27px, #f3e9d2 28px);
  border-radius: 10px;
  max-width: 460px;
  width: 100%;
  padding: 40px 34px 30px;
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.35);
  position: relative;
  transform: rotate(-0.6deg);
  border: 1px solid #e8dcc0;
}

.wax-seal {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 40px;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

#letter-title {
  font-family: 'Patrick Hand', cursive;
  font-size: 30px;
  color: #d4658a;
  margin: 10px 0 16px;
}

#letter-text {
  font-family: 'Patrick Hand', cursive;
  font-size: 22px;
  line-height: 1.6;
  color: #4a4034;
  white-space: pre-line;
  margin-bottom: 24px;
}

.hidden {
  display: none !important;
}
