/* Sprunki Mix — main stylesheet
 * Designed for iPad 9 (A13, 3GB RAM)
 * GPU-friendly transforms only; no box-shadow on moving elements
 */

:root {
  --sky: #4FC3F7;
  --sky-bottom: #81D4FA;
  --grass: #7CB342;
  --grass-dark: #558B2F;
  --panel-bg: #141414;
  --panel-bg-2: #1F1F1F;
  --podium: #2A2A2A;
  --podium-active: #3D4D3D;
  --slot-tint: rgba(255, 255, 255, 0.06);
  --tile-bg: #2D2D2D;
  --tile-bg-hover: #3D3D3D;
  --tile-border: #4A4A4A;
  --text: #FFFFFF;
  --text-dim: #B0B0B0;
  --accent: #FFD740;
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: #000;
  font-family: -apple-system, BlinkMacSystemFont, 'Helvetica Neue', sans-serif;
  color: var(--text);
  touch-action: none;
  overscroll-behavior: none;
}

#game-root {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  max-width: 100vw;
  max-height: 100vh;
  overflow: hidden;
}

/* ─── STAGE (top half) ─────────────────────────────── */
#stage {
  position: relative;
  flex: 0 0 60%;
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-bottom) 70%, var(--sky-bottom) 100%);
  overflow: hidden;
}

#sky {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, #4FC3F7 0%, #81D4FA 100%);
}

#cloud-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.cloud {
  position: absolute;
  background: #fff;
  border-radius: 100px;
  opacity: 0.95;
  filter: drop-shadow(0 2px 6px rgba(0, 0, 0, 0.08));
}

.cloud::before, .cloud::after {
  content: '';
  position: absolute;
  background: #fff;
  border-radius: 50%;
}

.cloud-1 {
  width: 80px;
  height: 22px;
  top: 8%;
  left: 8%;
  animation: cloud-drift 60s linear infinite;
}
.cloud-1::before {
  width: 36px;
  height: 36px;
  top: -16px;
  left: 12px;
}
.cloud-1::after {
  width: 28px;
  height: 28px;
  top: -12px;
  left: 42px;
}

.cloud-2 {
  width: 60px;
  height: 18px;
  top: 14%;
  right: 14%;
  animation: cloud-drift 80s linear infinite reverse;
}
.cloud-2::before {
  width: 28px;
  height: 28px;
  top: -12px;
  left: 8px;
}
.cloud-2::after {
  width: 22px;
  height: 22px;
  top: -10px;
  left: 32px;
}

.cloud-3 {
  width: 50px;
  height: 16px;
  top: 4%;
  left: 50%;
  animation: cloud-drift 100s linear infinite;
}
.cloud-3::before {
  width: 24px;
  height: 24px;
  top: -10px;
  left: 6px;
}
.cloud-3::after {
  width: 18px;
  height: 18px;
  top: -8px;
  left: 26px;
}

@keyframes cloud-drift {
  from { transform: translateX(-30px); }
  to { transform: translateX(30px); }
}

#grass {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 18%;
  background: linear-gradient(180deg, var(--grass) 0%, var(--grass-dark) 100%);
  border-top: 2px solid var(--grass-dark);
}

#grass::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 6px;
  background: linear-gradient(180deg, rgba(255,255,255,0.15), transparent);
}

#sun-logo {
  position: absolute;
  top: 6%;
  right: 4%;
  width: 70px;
  height: 70px;
  background: radial-gradient(circle, #FFD740 0%, #FF6F00 100%);
  border-radius: 50%;
  box-shadow: 0 0 20px rgba(255, 193, 7, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  z-index: 5;
}
#sun-logo::before {
  content: '';
  position: absolute;
  inset: -15px;
  background:
    linear-gradient(0deg, transparent 48%, #FF6F00 48%, #FF6F00 52%, transparent 52%),
    linear-gradient(45deg, transparent 48%, #FF6F00 48%, #FF6F00 52%, transparent 52%),
    linear-gradient(90deg, transparent 48%, #FF6F00 48%, #FF6F00 52%, transparent 52%),
    linear-gradient(135deg, transparent 48%, #FF6F00 48%, #FF6F00 52%, transparent 52%);
  border-radius: 50%;
  z-index: -1;
  animation: sun-spin 30s linear infinite;
}
#sun-logo span {
  position: relative;
  z-index: 2;
  font-size: 11px;
  font-weight: 800;
  color: #000;
  text-align: center;
  line-height: 1;
  letter-spacing: -0.5px;
}
@keyframes sun-spin {
  to { transform: rotate(360deg); }
}

/* ─── SLOTS ────────────────────────────────────────── */
#slots {
  position: absolute;
  bottom: 14%;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  padding: 0 6px;
  z-index: 10;
}

.slot {
  position: relative;
  width: 12%;
  aspect-ratio: 1 / 1.1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease-out;
}

.slot.podium {
  background: var(--podium);
  border-radius: 14px 14px 18px 18px;
  border-top: 2px solid #3A3A3A;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, 0.3);
}
.slot.drag-over {
  background: var(--podium-active);
  transform: scale(1.05);
}

.slot-character {
  position: absolute;
  width: 90%;
  height: 90%;
  bottom: 0;
  object-fit: contain;
  pointer-events: none;
  transform-origin: 50% 100%;
}

.slot-character.idle {
  animation: idle-bob 2.4s ease-in-out infinite;
}
.slot-character.active {
  animation: active-bob 0.5s ease-in-out infinite;
}

@keyframes idle-bob {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.02) translateY(-1px); }
}

@keyframes active-bob {
  0%, 100% { transform: scale(1) translateY(0); }
  50% { transform: scale(1.05) translateY(-2px); }
}

/* ─── PANEL (bottom half) ──────────────────────────── */
#panel {
  flex: 1;
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  border-top: 2px solid #000;
  position: relative;
}

#inventory {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  grid-template-rows: repeat(2, 1fr);
  gap: 8px;
  padding: 12px;
  overflow: hidden;
}

.inv-tile {
  position: relative;
  background: var(--tile-bg);
  border: 2px solid var(--tile-border);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: grab;
  transition: transform 0.1s ease-out, background 0.1s ease-out;
  overflow: hidden;
}

.inv-tile.dragging {
  cursor: grabbing;
  transform: scale(0.95);
  opacity: 0.5;
}

.inv-tile.drag-over {
  background: var(--tile-bg-hover);
  border-color: var(--accent);
}

.inv-tile-img {
  width: 80%;
  height: 80%;
  object-fit: contain;
  pointer-events: none;
  -webkit-user-drag: none;
}

.inv-tile-label {
  position: absolute;
  bottom: 1px;
  left: 0;
  right: 0;
  text-align: center;
  font-size: 9px;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  pointer-events: none;
}

/* ─── CONTROLS ─────────────────────────────────────── */
#controls {
  display: flex;
  gap: 8px;
  padding: 8px 12px 12px;
  background: var(--panel-bg-2);
  border-top: 1px solid #2A2A2A;
}

#controls button {
  flex: 1;
  background: var(--tile-bg);
  color: var(--text);
  border: 2px solid var(--tile-border);
  border-radius: 10px;
  padding: 10px 16px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.1s ease-out, background 0.1s ease-out;
  font-family: inherit;
}

#controls button:active {
  transform: scale(0.96);
  background: var(--tile-bg-hover);
}

#mute-btn {
  flex: 0 0 50px;
  font-size: 18px;
}

#mute-btn.muted {
  opacity: 0.5;
}

/* ─── DRAG GHOST ───────────────────────────────────── */
.drag-ghost {
  position: fixed;
  width: 64px;
  height: 64px;
  pointer-events: none;
  z-index: 9999;
  transform: translate(-50%, -50%) scale(1.15);
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.5));
  opacity: 0.92;
  will-change: transform;
}

.drag-ghost img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* ─── AUDIO UNLOCK OVERLAY ─────────────────────────── */
#audio-unlock {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  cursor: pointer;
  transition: opacity 0.3s ease-out;
}

#audio-unlock.hidden {
  opacity: 0;
  pointer-events: none;
}

.audio-unlock-card {
  text-align: center;
  padding: 24px 32px;
  animation: unlock-pulse 1.6s ease-in-out infinite;
}

@keyframes unlock-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.audio-unlock-icon {
  font-size: 64px;
  margin-bottom: 8px;
}

.audio-unlock-title {
  font-size: 28px;
  font-weight: 800;
  margin-bottom: 4px;
}

.audio-unlock-sub {
  font-size: 16px;
  color: var(--text-dim);
  font-weight: 600;
}

/* ─── RESPONSIVE ───────────────────────────────────── */
@media (max-aspect-ratio: 4/5) {
  /* Portrait phones — keep horizontal layout but compress */
  #slots {
    bottom: 10%;
  }
  .slot {
    width: 12%;
  }
}

/* iPad landscape — make slots bigger */
@media (min-width: 1024px) and (orientation: landscape) {
  .slot {
    width: 11%;
  }
  #sun-logo {
    width: 90px;
    height: 90px;
  }
}

/* iPad portrait — adjust for less vertical space */
@media (min-width: 768px) and (orientation: portrait) {
  #stage {
    flex: 0 0 55%;
  }
}
