:root {
  --deep-brown: #1a1209;
  --parchment-dark: #2a1f14;
  --parchment-mid: #3d2e1e;
  --gold: #d4a841;
  --gold-dim: #c9952b;
  --gold-bright: #f0d060;
  --cream: #f0e6d3;
  --cream-dim: #c4b8a4;
  --ink: #0d0906;
  --blood: #8b2500;
  --sea: #2a4a5e;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  background: var(--deep-brown);
  color: var(--cream);
  font-family: 'Crimson Pro', Georgia, serif;
  overflow-x: hidden;
}

html {
  height: 100%;
}

body {
  height: 100%;
  overflow: hidden;
}

#root {
  height: 100%;
  overflow: hidden;
}

/* Mobile layout uses dvh for proper sizing */
@supports (height: 100dvh) {
  .mobile-layout {
    height: 100dvh;
  }
}

/* When keyboard is open on mobile, allow scrolling in the content area */
.mobile-content {
  -webkit-overflow-scrolling: touch;
}

.mobile-content > div {
  overscroll-behavior: contain;
}

/* Make inputs and textareas not zoom on iOS */
input, textarea, select {
  font-size: 16px !important;
  -webkit-text-size-adjust: 100%;
}

/* Custom scrollbar */
::-webkit-scrollbar {
  width: 6px;
}
::-webkit-scrollbar-track {
  background: var(--deep-brown);
}
::-webkit-scrollbar-thumb {
  background: var(--gold-dim);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--gold);
}

/* Compass spin animation */
@keyframes compassSpin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 8px rgba(212,168,65,0.4), inset 0 0 8px rgba(212,168,65,0.1); }
  50% { box-shadow: 0 0 24px rgba(212,168,65,0.8), inset 0 0 16px rgba(212,168,65,0.2); }
}

@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes shimmer {
  0% { background-position: -200% center; }
  100% { background-position: 200% center; }
}

@keyframes floatMarker {
  0%, 100% { transform: translate(-50%, -100%) scale(1); }
  50% { transform: translate(-50%, -100%) scale(1.1); }
}

@keyframes timerPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.compass-spin {
  animation: compassSpin 3s linear infinite;
}

.pulse-glow {
  animation: pulseGlow 2s ease-in-out infinite;
}

.fade-in-up {
  animation: fadeInUp 0.6s ease-out forwards;
}

.shimmer-text {
  background: linear-gradient(90deg, var(--gold-dim), var(--gold-bright), var(--gold-dim));
  background-size: 200% auto;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmer 3s linear infinite;
}

.timer-pulse {
  animation: timerPulse 1s ease-in-out infinite;
}

.map-border {
  border: 3px solid var(--gold-dim);
  box-shadow:
    0 0 0 1px var(--deep-brown),
    0 0 0 4px var(--parchment-mid),
    0 0 0 5px var(--gold-dim),
    0 0 30px rgba(0,0,0,0.6),
    inset 0 0 30px rgba(0,0,0,0.3);
}

.parchment-bg {
  background:
    radial-gradient(ellipse at 20% 50%, rgba(61,46,30,0.8) 0%, transparent 70%),
    radial-gradient(ellipse at 80% 50%, rgba(61,46,30,0.6) 0%, transparent 70%),
    linear-gradient(180deg, var(--parchment-dark) 0%, var(--deep-brown) 100%);
}

.gold-btn {
  background: linear-gradient(180deg, var(--gold) 0%, var(--gold-dim) 100%);
  color: var(--deep-brown);
  font-family: 'Cinzel', serif;
  font-weight: 700;
  border: 1px solid var(--gold-bright);
  transition: all 0.3s ease;
  text-shadow: 0 1px 0 rgba(255,255,255,0.2);
}

.gold-btn:hover {
  background: linear-gradient(180deg, var(--gold-bright) 0%, var(--gold) 100%);
  box-shadow: 0 0 20px rgba(212,168,65,0.5);
  transform: translateY(-1px);
}

.gold-btn:active {
  transform: translateY(0);
}

.gold-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.input-field {
  background: rgba(13,9,6,0.6);
  border: 1px solid var(--parchment-mid);
  color: var(--cream);
  font-family: 'Crimson Pro', serif;
  transition: border-color 0.3s ease;
}

.input-field:focus {
  outline: none;
  border-color: var(--gold-dim);
  box-shadow: 0 0 8px rgba(212,168,65,0.2);
}

.input-field::placeholder {
  color: var(--cream-dim);
  opacity: 0.5;
}

.style-pill {
  background: rgba(13,9,6,0.5);
  border: 1px solid var(--parchment-mid);
  color: var(--cream-dim);
  font-family: 'Crimson Pro', serif;
  cursor: pointer;
  transition: all 0.2s ease;
}

.style-pill:hover {
  border-color: var(--gold-dim);
  color: var(--cream);
}

.style-pill.active {
  background: rgba(212,168,65,0.15);
  border-color: var(--gold);
  color: var(--gold);
}

.sidebar-panel {
  background: linear-gradient(180deg, rgba(42,31,20,0.95) 0%, rgba(26,18,9,0.98) 100%);
  border: 1px solid var(--parchment-mid);
}

.marker-pin {
  position: absolute;
  cursor: pointer;
  transform: translate(-50%, -100%);
  font-size: 24px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.8));
  transition: transform 0.2s ease;
  z-index: 10;
}

.marker-pin:hover {
  transform: translate(-50%, -100%) scale(1.3);
}

.history-thumb {
  border: 1px solid var(--parchment-mid);
  transition: all 0.2s ease;
  cursor: pointer;
}

.history-thumb:hover {
  border-color: var(--gold);
  box-shadow: 0 0 10px rgba(212,168,65,0.3);
}

/* Mobile layout - fixed structure to prevent keyboard shifting */
.mobile-layout {
  display: flex;
  flex-direction: column;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
}

.mobile-content {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Builder panel on mobile - must scroll properly */
.mobile-builder-scroll {
  height: 100%;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 120px;
}

.mobile-tab-bar {
  flex-shrink: 0;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 30;
}

/* Mobile tab bar */
.mobile-tab {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--cream-dim);
  transition: color 0.2s ease;
}

.mobile-tab.active {
  color: var(--gold);
}

.tooltip-panel {
  background: var(--parchment-dark);
  border: 1px solid var(--gold-dim);
  box-shadow: 0 4px 20px rgba(0,0,0,0.5);
}

/* Timer bar styling */
.timer-bar {
  background: linear-gradient(90deg, var(--gold-dim), var(--gold));
  transition: width 1s linear;
  border-radius: 2px;
  height: 100%;
}

.timer-container {
  background: rgba(13,9,6,0.6);
  border: 1px solid var(--parchment-mid);
  border-radius: 6px;
  overflow: hidden;
}

.timer-warning {
  border-color: var(--blood) !important;
}

.timer-warning .timer-bar {
  background: linear-gradient(90deg, var(--blood), #ff4400);
}