:root {
  --vvh: 100dvh;
  --vv-top: 0px;
  --paper-bg: #FDFBF7;
  --paper-line: #E8E2D5;
  --ink: #2B2623;
  --ink-soft: #6E655F;
  --truth-color: #7EE0C6;
  --dare-color: #FF8B8B;
  --yellow-marker: #FFE46B;
  --lavender-marker: #D5C6FF;
}

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

/* Prevent mobile keyboard from pushing header out of viewport */
html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  position: fixed;
  inset: 0;
  background-color: #EFECE4;
  font-family: 'Patrick Hand', cursive, sans-serif;
  color: var(--ink);
  overscroll-behavior: none;
}

/* Main VisualViewport-locked Shell */
#app-viewport-shell {
  position: fixed;
  left: 0;
  right: 0;
  top: var(--vv-top);
  height: var(--vvh);
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--paper-bg);
  background-image: 
    radial-gradient(#D5CFC2 1px, transparent 1px),
    linear-gradient(to bottom, transparent 27px, var(--paper-line) 28px);
  background-size: 20px 20px, 100% 28px;
  box-shadow: 0 0 40px rgba(43, 38, 35, 0.12);
}

@media (min-width: 500px) {
  #app-viewport-shell {
    border-left: 3px solid var(--ink);
    border-right: 3px solid var(--ink);
  }
}

.font-title {
  font-family: 'Caveat', cursive;
}

.font-ui {
  font-family: 'Fredoka', sans-serif;
}

.font-hand {
  font-family: 'Patrick Hand', cursive;
}

/* Prevent webfont metrics from clipping emojis on any device */
.safe-emoji {
  font-family: "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji", sans-serif;
  line-height: 1.2;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  padding: 0 1px;
  font-style: normal;
}

/* Sketchy Hand-Drawn Borders & Boxes */
.sketch-box {
  background: #FFFFFF;
  border: 2.5px solid var(--ink);
  border-radius: 14px 18px 15px 17px / 16px 14px 18px 15px;
  box-shadow: 3px 3px 0px var(--ink);
}

.sketch-box-alt {
  background: #FFFFFF;
  border: 2.5px solid var(--ink);
  border-radius: 18px 14px 17px 15px / 14px 18px 15px 16px;
  box-shadow: 3px 3px 0px var(--ink);
}

.sketch-card {
  border: 2.5px solid var(--ink);
  border-radius: 16px 22px 18px 20px / 20px 16px 22px 16px;
  box-shadow: 4px 4px 0px var(--ink);
}

.sketch-pill {
  border: 2px solid var(--ink);
  border-radius: 9999px;
  box-shadow: 2px 2px 0px var(--ink);
}

.sketch-btn {
  border: 2.5px solid var(--ink);
  border-radius: 14px 12px 15px 13px / 13px 15px 12px 14px;
  box-shadow: 3px 3px 0px var(--ink);
  transition: transform 0.12s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.12s ease, background-color 0.15s ease;
  cursor: pointer;
  user-select: none;
}

.sketch-btn:active:not(:disabled) {
  transform: translate(2px, 2px);
  box-shadow: 1px 1px 0px var(--ink);
}

.sketch-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.sketch-input {
  border: 2.5px solid var(--ink);
  border-radius: 14px 22px 14px 20px / 20px 14px 22px 14px;
  box-shadow: inset 2px 2px 0px rgba(43, 38, 35, 0.08);
  outline: none;
  background: #FFFFFF;
}

.sketch-input:focus {
  box-shadow: 2px 2px 0px var(--ink);
  background: #FFFEF9;
}

/* Tape decoration at top of cards */
.sketch-tape {
  position: relative;
}
.sketch-tape::before {
  content: '';
  position: absolute;
  top: -10px;
  left: 50%;
  transform: translateX(-50%) rotate(-2deg);
  width: 68px;
  height: 18px;
  background: rgba(255, 228, 107, 0.72);
  border: 1.5px dashed rgba(43, 38, 35, 0.35);
  border-radius: 3px;
  pointer-events: none;
}

/* Animations */
@keyframes floatDoodle {
  0%, 100% { transform: translateY(0px) rotate(-1deg); }
  50% { transform: translateY(-4px) rotate(1.5deg); }
}
.animate-doodle {
  animation: floatDoodle 3.2s ease-in-out infinite;
}

@keyframes popIn {
  0% { opacity: 0; transform: scale(0.88) translateY(8px) rotate(-1.5deg); }
  70% { transform: scale(1.02) translateY(-1px) rotate(0.5deg); }
  100% { opacity: 1; transform: scale(1) translateY(0) rotate(0deg); }
}
.animate-pop {
  animation: popIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cardFlipIn {
  0% { opacity: 0; transform: perspective(600px) rotateX(-25deg) scale(0.92); }
  100% { opacity: 1; transform: perspective(600px) rotateX(0deg) scale(1); }
}
.animate-card-flip {
  animation: cardFlipIn 0.35s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

@keyframes pulseRing {
  0% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0.65), 2px 2px 0px var(--ink); }
  70% { box-shadow: 0 0 0 8px rgba(74, 222, 128, 0), 2px 2px 0px var(--ink); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0), 2px 2px 0px var(--ink); }
}
.mic-live-pulse {
  animation: pulseRing 1.6s infinite;
}

@keyframes pencilWiggle {
  0%, 100% { transform: rotate(0deg) translateX(0); }
  25% { transform: rotate(-12deg) translateX(-2px); }
  75% { transform: rotate(8deg) translateX(2px); }
}
.animate-pencil {
  display: inline-block;
  animation: pencilWiggle 0.55s ease-in-out infinite;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 5px;
  height: 5px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: rgba(43, 38, 35, 0.22);
  border-radius: 99px;
}

/* Hide scroll indicator in chat message textarea */
#chat-message-input {
  scrollbar-width: none;
  -ms-overflow-style: none;
}
#chat-message-input::-webkit-scrollbar {
  display: none;
  width: 0px;
  height: 0px;
}

/* Polaroid Photo Frame */
.polaroid-frame {
  background: #FFFFFF;
  padding: 8px 8px 18px 8px;
  border: 2.5px solid var(--ink);
  border-radius: 8px 14px 10px 12px;
  box-shadow: 3px 3px 0px var(--ink);
  transform: rotate(-1deg);
  transition: transform 0.2s ease;
  overflow: hidden;
  max-width: 100%;
  word-break: break-word;
  overflow-wrap: anywhere;
}
.polaroid-frame:hover {
  transform: rotate(0deg) scale(1.01);
}

@keyframes sketchShake {
  0%, 100% { transform: translateX(0); }
  20%, 60% { transform: translateX(-5px); }
  40%, 80% { transform: translateX(5px); }
}
.animate-shake {
  animation: sketchShake 0.38s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
}

/* Double-Tap Heart Reaction Animation */
@keyframes heartBurst {
  0% { transform: scale(0) rotate(-20deg); opacity: 0; }
  45% { transform: scale(1.45) rotate(8deg); opacity: 1; }
  65% { transform: scale(1.15) rotate(-4deg); opacity: 1; }
  100% { transform: scale(1.6) translateY(-28px); opacity: 0; }
}
.animate-heart-burst {
  animation: heartBurst 0.7s cubic-bezier(0.17, 0.89, 0.32, 1.28) forwards;
  pointer-events: none;
}

/* Heart Reaction Badge with User Doodle Avatars */
.msg-reaction-badge {
  position: absolute;
  bottom: -9px;
  right: 8px;
  background: #FFFFFF;
  border: 1.8px solid var(--ink);
  border-radius: 9999px;
  padding: 1.5px 5.5px;
  font-size: 11px;
  line-height: 1.2;
  box-shadow: 1.5px 1.5px 0px var(--ink);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 3.5px;
  transition: transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.15s ease, border-color 0.15s ease;
  z-index: 10;
}
.msg-reaction-badge:active {
  transform: scale(1.18);
}
.msg-reaction-badge.my-liked {
  background: #FFF0F5;
  border-color: #E11D48;
}
.reaction-avatar-mini {
  width: 17px;
  height: 17px;
  border-radius: 9999px;
  border: 1.2px solid var(--ink);
  background: #FFFFFF;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: 1px;
  flex-shrink: 0;
  box-shadow: 0.5px 0.5px 0px var(--ink);
}
.reaction-avatar-mini svg {
  width: 100%;
  height: 100%;
}

/* Swipe To Reply Touch Styles */
.msg-swipe-wrapper {
  position: relative;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.msg-swipe-target {
  position: relative;
  transition: transform 0.18s cubic-bezier(0.2, 0, 0, 1);
  will-change: transform;
}
.swipe-reply-cue {
  position: absolute;
  left: -32px;
  top: 50%;
  transform: translateY(-50%) scale(0.6);
  opacity: 0;
  width: 28px;
  height: 28px;
  border-radius: 9999px;
  background: #FFE46B;
  border: 1.5px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  transition: opacity 0.15s ease, transform 0.15s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
  z-index: 5;
}
.swipe-reply-active .swipe-reply-cue {
  opacity: 1;
  transform: translateY(-50%) scale(1);
}

/* Quick reply button on desktop hover */
.quick-reply-btn {
  opacity: 0;
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.msg-swipe-wrapper:hover .quick-reply-btn {
  opacity: 1;
}

/* Clean mobile toolbar styles */
.mobile-toolbar-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
  font-size: 15px;
  flex-shrink: 0;
}

/* Sleek Compact Header Buttons for Mobile */
.header-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  border: 1.8px solid var(--ink);
  box-shadow: 1.5px 1.5px 0px var(--ink);
  flex-shrink: 0;
  transition: transform 0.1s ease, filter 0.1s ease;
  user-select: none;
}
.header-btn:active {
  transform: scale(0.92) translate(1px, 1px);
  box-shadow: 0.5px 0.5px 0px var(--ink);
}

/* Sleek Compact Game Stage for Mobile */
@media (max-width: 640px) {
  #game-stage-section {
    padding-top: 4px;
    padding-bottom: 4px;
  }
  #game-card-container {
    padding: 6px 10px;
  }
  #stage-pick-title {
    font-size: 1.05rem;
    margin-bottom: 4px;
  }
  #choose-truth-btn, #choose-dare-btn {
    padding: 5px 8px;
  }
  #choose-truth-btn span.font-title, #choose-dare-btn span.font-title {
    font-size: 1.1rem;
  }
  #stage-waiting-prompt {
    padding: 4px 0;
  }
  #waiting-prompt-title {
    font-size: 1.05rem;
  }
  #active-card-text {
    font-size: 1.15rem;
    margin: 3px 0;
    line-height: 1.25;
  }
  #active-card-instruction {
    display: none;
  }
}
