/* styles.css — Angry Pigs UI */

:root {
  --pink: #ff8fb1;
  --pink-deep: #e8578a;
  --green: #4caf50;
  --green-deep: #2e7d32;
  --yellow: #ffcf3f;
  --yellow-deep: #f4a300;
  --ink: #3a2233;
  --panel: rgba(38, 24, 40, 0.82);
  --panel-light: rgba(255, 255, 255, 0.14);
  font-family: 'Baloo 2', 'Trebuchet MS', 'Segoe UI', system-ui, sans-serif;
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #8fd4ff;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

#ui { position: fixed; inset: 0; pointer-events: none; }

.screen {
  position: absolute;
  inset: 0;
  display: none;
  pointer-events: none;
}
.screen.visible { display: flex; }
.screen.visible :where(button, .map-card, .icon-button) { pointer-events: auto; }

/* ============ START SCREEN ============ */
#start-screen {
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6vh;
}
.logo {
  text-align: center;
  transform: rotate(-3deg);
  filter: drop-shadow(0 8px 0 rgba(0,0,0,0.18));
  animation: logo-pop 0.6s cubic-bezier(.2,1.6,.4,1) both;
}
@keyframes logo-pop { from { transform: rotate(-3deg) scale(0.4); opacity: 0; } to { transform: rotate(-3deg) scale(1); opacity: 1; } }
.logo-angry {
  display: block;
  font-size: clamp(38px, 9vw, 110px);
  font-weight: 900;
  letter-spacing: 2px;
  color: #fff;
  -webkit-text-stroke: clamp(3px, 0.7vw, 7px) var(--ink);
  text-stroke: 4px var(--ink);
  line-height: 0.9;
}
.logo-pigs {
  position: relative;
  display: inline-block;
  font-size: clamp(52px, 13vw, 160px);
  font-weight: 900;
  letter-spacing: 3px;
  color: var(--pink);
  -webkit-text-stroke: clamp(3px, 0.8vw, 8px) var(--ink);
  line-height: 0.9;
}
.logo-letter { display: inline-block; }
.pig-o {
  position: relative;
  color: #ffb3cb;
}
.logo-pigface {
  position: absolute;
  top: -6%;
  left: 30%;
  width: clamp(24px, 6vw, 70px);
  height: clamp(24px, 6vw, 70px);
  background: var(--pink);
  border: clamp(3px,0.7vw,6px) solid var(--ink);
  border-radius: 50%;
  box-shadow: inset 0 -6px 0 rgba(0,0,0,0.08);
}
.logo-pigface::before {
  content: '';
  position: absolute;
  left: 30%; top: 45%;
  width: 40%; height: 30%;
  background: var(--pink-deep);
  border-radius: 40%;
  box-shadow: -3px 0 0 var(--ink), 3px 0 0 var(--ink);
}

/* ============ BIG BUTTON ============ */
.big-button {
  pointer-events: auto;
  font-family: inherit;
  font-size: clamp(24px, 5vw, 44px);
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  background: linear-gradient(180deg, #6fd36f, var(--green));
  border: none;
  border-radius: 999px;
  padding: 0.5em 1.6em;
  cursor: pointer;
  box-shadow: 0 10px 0 var(--green-deep), 0 16px 26px rgba(0,0,0,0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease;
  animation: btn-breathe 2.2s ease-in-out infinite;
}
@keyframes btn-breathe { 0%,100% { transform: scale(1);} 50% { transform: scale(1.05);} }
.big-button:hover { filter: brightness(1.06); }
.big-button:active {
  transform: translateY(8px) scale(1);
  box-shadow: 0 2px 0 var(--green-deep), 0 6px 12px rgba(0,0,0,0.3);
  animation: none;
}

/* ============ MAP SELECT ============ */
#map-select {
  flex-direction: column;
  align-items: center;
  padding: clamp(12px, 3vh, 30px);
  background: linear-gradient(180deg, rgba(20,12,26,0.35), rgba(20,12,26,0.6));
  pointer-events: auto;
  overflow-y: auto;
}
.select-header {
  width: 100%;
  max-width: 900px;
  display: grid;
  grid-template-columns: 60px 1fr auto;
  align-items: center;
  gap: 12px;
  margin-bottom: clamp(12px, 3vh, 28px);
}
.select-title {
  text-align: center;
  font-size: clamp(28px, 6vw, 56px);
  font-weight: 900;
  color: #fff;
  letter-spacing: 3px;
  -webkit-text-stroke: 3px var(--ink);
}
.select-stars {
  font-size: clamp(14px, 2.6vw, 22px);
  font-weight: 900;
  color: var(--yellow);
  background: rgba(0,0,0,0.35);
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
}
.icon-button {
  pointer-events: auto;
  width: 54px; height: 54px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.9);
  color: var(--ink);
  font-size: 26px;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0,0,0,0.25);
  transition: transform 0.08s;
}
.icon-button:active { transform: translateY(4px); box-shadow: 0 1px 0 rgba(0,0,0,0.25); }

.map-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: clamp(14px, 3vw, 26px);
  width: 100%;
  max-width: 900px;
}
@media (max-width: 620px) { .map-grid { grid-template-columns: 1fr; } }

.map-card {
  pointer-events: auto;
  display: flex;
  gap: 16px;
  align-items: center;
  text-align: left;
  padding: 16px;
  border: none;
  border-radius: 22px;
  background: rgba(255,255,255,0.95);
  cursor: pointer;
  box-shadow: 0 8px 0 rgba(0,0,0,0.22), 0 14px 24px rgba(0,0,0,0.25);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
  font-family: inherit;
}
.map-card:hover:not(.locked) { transform: translateY(-4px); box-shadow: 0 12px 0 rgba(0,0,0,0.22), 0 20px 30px rgba(0,0,0,0.3); }
.map-card:active:not(.locked) { transform: translateY(2px); }
.map-card.locked { filter: grayscale(0.85) brightness(0.7); cursor: not-allowed; box-shadow: 0 6px 0 rgba(0,0,0,0.25); }

.card-thumb {
  position: relative;
  width: clamp(90px, 22vw, 130px);
  height: clamp(90px, 22vw, 130px);
  border-radius: 16px;
  overflow: hidden;
  flex-shrink: 0;
  box-shadow: inset 0 0 0 3px rgba(0,0,0,0.12);
}
.thumb-art { position: absolute; inset: 0; }
.thumb-farm .thumb-art { background: linear-gradient(180deg, #8fd4ff 55%, #86d16a 55%); }
.thumb-farm .thumb-art::after { content:''; position:absolute; right:12%; bottom:20%; width:34%; height:34%; background:#c0392b; clip-path: polygon(50% 0,100% 40%,100% 100%,0 100%,0 40%); }
.thumb-canyon .thumb-art { background: linear-gradient(180deg, #f0a05a 55%, #cf9b5f 55%); }
.thumb-canyon .thumb-art::after { content:''; position:absolute; left:20%; bottom:22%; width:60%; height:45%; background:#9a5b34; clip-path: polygon(0 100%,20% 40%,40% 70%,60% 20%,80% 60%,100% 100%); }
.thumb-frozen .thumb-art { background: linear-gradient(180deg, #16233f 55%, #e8f0fb 55%); }
.thumb-frozen .thumb-art::before { content:''; position:absolute; right:18%; top:14%; width:22%; height:22%; background:#eef2ff; border-radius:50%; }
.thumb-frozen .thumb-art::after { content:''; position:absolute; left:12%; bottom:20%; width:26%; height:40%; background:#274d3a; clip-path: polygon(50% 0,100% 100%,0 100%); }
.thumb-volcanic .thumb-art { background: linear-gradient(180deg, #3a0f12 55%, #3a2b26 55%); }
.thumb-volcanic .thumb-art::after { content:''; position:absolute; left:22%; bottom:22%; width:56%; height:48%; background:#201716; clip-path: polygon(0 100%,30% 20%,55% 55%,80% 0,100% 100%); box-shadow: 0 6px 12px rgba(255,80,0,0.5); }

.lock {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(30px, 8vw, 48px);
  background: rgba(0,0,0,0.35);
}
.card-info { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.card-title { font-size: clamp(14px, 2.4vw, 18px); font-weight: 900; color: var(--pink-deep); letter-spacing: 1px; }
.card-name { font-size: clamp(18px, 3.4vw, 26px); font-weight: 900; color: var(--ink); }
.card-stars { font-size: clamp(20px, 4vw, 28px); }
.card-best { font-size: clamp(12px, 2.2vw, 16px); font-weight: 700; color: #7a6a72; }

.star { color: #cfc6cc; }
.star.earned { color: var(--yellow); text-shadow: 0 2px 3px rgba(0,0,0,0.25); }
.star.empty { color: #cfc6cc; opacity: 0.5; }

/* ============ HUD ============ */
.hud { pointer-events: none; }
.hud-top {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: clamp(8px, 2vw, 16px);
  gap: 8px;
}
.hud-left { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.hud-btn {
  pointer-events: auto;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(13px, 2vw, 16px);
  color: #fff;
  background: var(--panel);
  border: 2px solid rgba(255,255,255,0.2);
  border-radius: 14px;
  padding: 8px 12px;
  cursor: pointer;
  transition: transform 0.08s, background 0.1s;
}
.hud-btn:hover { background: rgba(58, 34, 51, 0.95); }
.hud-btn:active { transform: scale(0.94); }
.hud-map-name {
  align-self: center;
  font-size: clamp(12px, 2vw, 16px);
  font-weight: 900;
  color: #fff;
  background: var(--panel);
  padding: 8px 14px;
  border-radius: 14px;
  white-space: nowrap;
}
.hud-center { text-align: center; background: var(--panel); border-radius: 16px; padding: 6px 18px; }
.hud-label { font-size: clamp(10px, 1.6vw, 13px); font-weight: 900; color: var(--yellow); letter-spacing: 2px; }
.hud-score { font-size: clamp(22px, 4.5vw, 40px); font-weight: 900; color: #fff; line-height: 1; }
.hud-right { text-align: right; background: var(--panel); border-radius: 16px; padding: 6px 16px; }
.hud-pigs { display: flex; align-items: center; gap: 8px; justify-content: flex-end; }
.hud-pigs-count { font-size: clamp(22px, 4.5vw, 40px); font-weight: 900; color: #fff; }
.hud-pig-icons { display: flex; gap: 4px; }
.pig-icon {
  width: clamp(14px, 3vw, 20px); height: clamp(14px, 3vw, 20px);
  border-radius: 50%;
  background: var(--pink);
  border: 2px solid var(--ink);
  box-shadow: inset 0 -3px 0 rgba(0,0,0,0.1);
  transition: opacity 0.2s, transform 0.2s;
}
.pig-icon.used { opacity: 0.25; transform: scale(0.7); }

.drag-hint {
  position: absolute;
  left: 12%;
  bottom: 22%;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  animation: hint-pulse 1.2s ease-in-out infinite;
}
.drag-hint.visible { display: flex; }
.hand { font-size: clamp(30px, 7vw, 54px); transform: rotate(-20deg); }
.hint-text { font-size: clamp(12px, 2vw, 16px); font-weight: 900; color: #fff; background: var(--panel); padding: 6px 12px; border-radius: 12px; }
@keyframes hint-pulse { 0%,100% { transform: translate(0,0);} 50% { transform: translate(-14px, 14px);} }

/* ============ OVERLAY / RESULT PANELS ============ */
.overlay {
  align-items: center;
  justify-content: center;
  background: rgba(10, 6, 14, 0.68);
  pointer-events: auto;
  backdrop-filter: blur(2px);
}
.overlay-panel {
  width: min(92vw, 460px);
  background: linear-gradient(180deg, #4a2f4f, #2c1a30);
  border: 4px solid rgba(255,255,255,0.15);
  border-radius: 28px;
  padding: clamp(20px, 4vw, 34px);
  text-align: center;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  animation: panel-in 0.4s cubic-bezier(.2,1.5,.4,1) both;
}
@keyframes panel-in { from { transform: scale(0.7); opacity: 0; } to { transform: scale(1); opacity: 1; } }
.panel-title {
  font-size: clamp(28px, 6vw, 46px);
  font-weight: 900;
  color: var(--yellow);
  letter-spacing: 2px;
  -webkit-text-stroke: 2px var(--ink);
  margin-bottom: 16px;
}
.panel-title.fail { color: #ff6b6b; }
.panel-stars { display: flex; justify-content: center; gap: 14px; margin-bottom: 18px; min-height: 60px; }
.big-star {
  font-size: clamp(40px, 10vw, 66px);
  color: #55445a;
  transform: scale(0.5);
  transition: transform 0.35s cubic-bezier(.2,1.8,.4,1), color 0.35s;
}
.big-star.lit { color: var(--yellow); transform: scale(1); text-shadow: 0 0 18px rgba(255,207,63,0.8); }
.panel-rows { display: flex; flex-direction: column; gap: 8px; margin-bottom: 20px; }
.prow {
  display: flex; justify-content: space-between; align-items: center;
  background: rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 10px 16px;
  font-size: clamp(14px, 2.6vw, 18px);
  font-weight: 700;
  color: #e6d8e6;
}
.prow b { color: #fff; font-size: 1.2em; }
.prow.big { font-size: clamp(18px, 3.4vw, 24px); }
.panel-buttons { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; }
.pbtn {
  pointer-events: auto;
  font-family: inherit;
  font-weight: 900;
  font-size: clamp(14px, 2.6vw, 20px);
  letter-spacing: 1px;
  color: #fff;
  border: none;
  border-radius: 16px;
  padding: 12px 20px;
  cursor: pointer;
  transition: transform 0.08s, filter 0.1s;
}
.pbtn.primary { background: linear-gradient(180deg, #6fd36f, var(--green)); box-shadow: 0 6px 0 var(--green-deep); }
.pbtn.secondary { background: linear-gradient(180deg, #ffa3c2, var(--pink-deep)); box-shadow: 0 6px 0 #b03a68; }
.pbtn:hover { filter: brightness(1.08); }
.pbtn:active { transform: translateY(5px); box-shadow: 0 1px 0 rgba(0,0,0,0.3); }

/* GAME OVER */
.overlay-panel.gameover { width: min(94vw, 520px); }
.gameover-title {
  font-size: clamp(40px, 11vw, 84px);
  font-weight: 900;
  color: #ff5a5a;
  letter-spacing: 3px;
  -webkit-text-stroke: 3px var(--ink);
  margin-bottom: 16px;
  animation: go-throb 1.5s ease-in-out infinite;
}
@keyframes go-throb { 0%,100% { transform: scale(1);} 50% { transform: scale(1.05);} }
.gameover-stars-label { font-size: clamp(16px, 3vw, 22px); font-weight: 900; color: var(--yellow); margin: 12px 0 8px; }
.gameover-stars { display: flex; justify-content: center; gap: clamp(10px, 3vw, 22px); margin-bottom: 20px; flex-wrap: wrap; }
.star-group { display: flex; gap: 3px; background: rgba(0,0,0,0.25); padding: 8px 12px; border-radius: 14px; font-size: clamp(18px, 4vw, 26px); }

/* ============ SCORE POPUPS ============ */
#popups { position: absolute; inset: 0; pointer-events: none; }
.score-popup {
  position: absolute;
  transform: translate(-50%, -50%);
  font-size: clamp(18px, 3vw, 28px);
  font-weight: 900;
  color: var(--yellow);
  -webkit-text-stroke: 1.5px var(--ink);
  text-shadow: 0 2px 4px rgba(0,0,0,0.4);
  animation: popup-rise 0.95s ease-out forwards;
}
@keyframes popup-rise {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.6); }
  20% { opacity: 1; transform: translate(-50%, -60%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -160%) scale(1); }
}

/* ============ ROTATE HINT ============ */
.rotate-hint {
  position: absolute;
  bottom: 14px; left: 50%;
  transform: translateX(-50%);
  display: none;
  background: rgba(0,0,0,0.7);
  color: #fff;
  font-size: 14px;
  font-weight: 700;
  padding: 8px 16px;
  border-radius: 999px;
  white-space: nowrap;
}
.rotate-hint.visible { display: block; }

/* ============ FADE TRANSITION ============ */
#fade {
  position: absolute;
  inset: 0;
  background: #1a0f1e;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.26s ease;
}
#fade.active { opacity: 1; pointer-events: auto; }
