:root {
  --bg-top: #0f5132;
  --bg-mid: #1f7a4f;
  --bg-bottom: #2a9d57;
  --panel: #f4f7e2;
  --ink: #112612;
  --accent: #da8a2b;
  --accent-2: #f0bc63;
  --good: #2f9e44;
  --warn: #f08c00;
  --bad: #d63324;
  --line: rgba(20, 62, 26, 0.22);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  font-family: "Avenir Next Condensed", "Gill Sans", "Trebuchet MS", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 20% 10%, rgba(255, 227, 140, 0.3), transparent 40%),
    radial-gradient(circle at 80% 22%, rgba(187, 232, 177, 0.3), transparent 35%),
    linear-gradient(170deg, var(--bg-top), var(--bg-mid) 45%, var(--bg-bottom));
  overflow: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(120deg, rgba(12, 46, 25, 0.08) 25%, transparent 25%),
    linear-gradient(300deg, rgba(12, 46, 25, 0.08) 25%, transparent 25%);
  background-size: 36px 36px;
  opacity: 0.6;
}

#desktopBlocker {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 0.4rem;
  text-align: center;
  padding: 2rem;
  background: rgba(8, 28, 17, 0.92);
  color: #fffde7;
}

#desktopBlocker h2 {
  margin: 0;
  font-family: "Rockwell", "Palatino Linotype", serif;
  letter-spacing: 0.03em;
}

#app {
  position: relative;
  z-index: 2;
  max-width: 460px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 0.75rem) 0.9rem calc(env(safe-area-inset-bottom) + 1rem);
}

.panel,
#game {
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.4);
  background: linear-gradient(180deg, rgba(244, 247, 226, 0.96), rgba(236, 244, 208, 0.95));
  box-shadow:
    0 20px 35px rgba(7, 32, 18, 0.26),
    inset 0 1px rgba(255, 255, 255, 0.75);
}

.panel {
  padding: 1rem;
}

.panel h1 {
  margin: 0;
  font-size: clamp(1.8rem, 6vw, 2.3rem);
  letter-spacing: 0.03em;
  font-family: "Rockwell", "Palatino Linotype", serif;
}

.panel p {
  margin: 0.55rem 0 1rem;
  line-height: 1.35;
  font-size: 0.98rem;
}

.picker {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.65rem;
}

.cubCard {
  border: 1px solid rgba(17, 55, 22, 0.15);
  border-radius: 14px;
  background: #f7f2db;
  color: #173918;
  padding: 0.8rem 0.7rem;
  text-align: left;
  min-height: 88px;
  transition: transform 0.18s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.cubCard.active {
  border-color: rgba(187, 103, 6, 0.55);
  box-shadow: 0 8px 14px rgba(195, 114, 26, 0.25);
  transform: translateY(-2px);
}

.cubName {
  display: block;
  font-size: 1.05rem;
  font-weight: 700;
}

.cubMeta {
  display: block;
  margin-top: 0.3rem;
  font-size: 0.84rem;
  opacity: 0.82;
}

.introActions {
  margin-top: 1rem;
  display: flex;
  gap: 0.55rem;
}

button {
  font: inherit;
  border: 0;
  border-radius: 12px;
  background: #e3e7cc;
  color: #102911;
  padding: 0.72rem 0.86rem;
  box-shadow: 0 8px 15px rgba(25, 53, 22, 0.18);
}

button:active {
  transform: translateY(1px) scale(0.99);
}

.primary {
  flex: 1;
  background: linear-gradient(180deg, #f1b95c, #de8a22);
  color: #fffef7;
  font-weight: 700;
}

#continueBtn {
  background: linear-gradient(180deg, #c6e29f, #84b85f);
  color: #123212;
}

#game {
  position: relative;
  padding: 0.58rem;
  border-width: 3px;
  border-color: rgba(27, 68, 31, 0.65);
  background:
    linear-gradient(180deg, rgba(243, 247, 216, 0.97), rgba(223, 233, 187, 0.95)),
    repeating-linear-gradient(
      0deg,
      rgba(34, 67, 29, 0.07) 0px,
      rgba(34, 67, 29, 0.07) 2px,
      transparent 2px,
      transparent 4px
    );
}

.hudTop {
  display: flex;
  justify-content: space-between;
  gap: 0.8rem;
  align-items: flex-start;
  margin-bottom: 0.6rem;
}

.hudTop h2 {
  margin: 0;
  font-size: 1.1rem;
  font-family: "Courier New", "Lucida Console", monospace;
  letter-spacing: 0.03em;
}

.hudTop p {
  margin: 0.1rem 0 0;
  font-size: 0.73rem;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

.hudRight {
  text-align: right;
}

.sceneShell {
  position: relative;
  border-radius: 9px;
  overflow: hidden;
  border: 2px solid rgba(23, 58, 26, 0.52);
  background: #6aa778;
  box-shadow: inset 0 0 0 3px rgba(240, 255, 215, 0.42);
}

#scene {
  width: 100%;
  height: auto;
  display: block;
  touch-action: manipulation;
}

.jaguarFeedback {
  margin-top: 0.46rem;
  border-radius: 8px;
  border: 2px solid rgba(26, 63, 29, 0.28);
  background: linear-gradient(180deg, rgba(248, 246, 221, 0.95), rgba(231, 239, 201, 0.9));
  padding: 0.42rem 0.46rem;
}

.jaguarFeedback[data-mood="feliz"] {
  border-color: rgba(47, 158, 68, 0.35);
}

.jaguarFeedback[data-mood="alerta"] {
  border-color: rgba(214, 51, 36, 0.38);
}

.jaguarFeedback[data-mood="hambrienta"],
.jaguarFeedback[data-mood="cansada"] {
  border-color: rgba(240, 140, 0, 0.35);
}

.jaguarFeedback[data-mood="orgullosa"] {
  border-color: rgba(222, 138, 34, 0.46);
}

.jaguarFeedback[data-mood="solitaria"] {
  border-color: rgba(87, 109, 129, 0.42);
}

.voiceLine {
  margin: 0;
  min-height: 1.75rem;
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.2;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

.voiceLine.pop {
  animation: voicePop 0.3s ease;
}

.microHud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.microHud span {
  border-radius: 6px;
  border: 1px solid rgba(16, 51, 19, 0.28);
  background: rgba(247, 250, 226, 0.95);
  padding: 0.11rem 0.33rem;
  font-size: 0.62rem;
  font-weight: 700;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

#comboBadge.hot {
  border-color: rgba(179, 83, 0, 0.44);
  background: linear-gradient(180deg, rgba(255, 218, 128, 0.96), rgba(255, 184, 77, 0.95));
}

#alertBadge.high {
  border-color: rgba(186, 92, 0, 0.55);
  background: linear-gradient(180deg, rgba(255, 216, 153, 0.95), rgba(255, 178, 102, 0.95));
}

#alertBadge.critical {
  border-color: rgba(179, 31, 31, 0.65);
  background: linear-gradient(180deg, rgba(255, 179, 179, 0.95), rgba(255, 128, 128, 0.96));
}

#desireLine {
  margin: 0.28rem 0 0;
  font-size: 0.68rem;
  font-weight: 600;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

.tapHint {
  display: block;
  margin-top: 0.18rem;
  font-size: 0.6rem;
  opacity: 0.72;
  font-family: "Courier New", "Lucida Console", monospace;
}

.goalHud {
  margin-top: 0.36rem;
  display: grid;
  gap: 0.2rem;
}

.goalBar {
  height: 0.58rem;
  border-radius: 999px;
  border: 1px solid rgba(14, 48, 19, 0.22);
  background: rgba(207, 228, 170, 0.72);
  overflow: hidden;
}

#goalFill {
  display: block;
  height: 100%;
  width: 0%;
  border-radius: inherit;
  transition: width 0.35s ease;
  background: linear-gradient(90deg, #da8a2b, #ffd43b);
}

#goalText,
#challengeLine,
#miniGameLine {
  display: block;
  font-size: 0.61rem;
  font-weight: 700;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

#challengeLine.hot {
  color: #8f3f00;
}

#miniGameLine.hot {
  color: #7f2f8f;
}

#ceremonyLine {
  display: block;
  font-size: 0.61rem;
  font-weight: 700;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

#ceremonyLine.hot {
  color: #8b5a00;
}

.stats {
  margin-top: 0.45rem;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.34rem;
}

.statRow {
  display: block;
  border-radius: 8px;
  border: 1px solid rgba(19, 58, 22, 0.22);
  background: rgba(242, 247, 221, 0.84);
  padding: 0.28rem 0.32rem;
}

.statRow label {
  display: block;
  margin-bottom: 0.18rem;
  font-size: 0.58rem;
  font-weight: 600;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

.bar {
  background: #d7e8c0;
  border: 1px solid rgba(18, 63, 23, 0.16);
  height: 0.52rem;
  border-radius: 999px;
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: 50%;
  border-radius: inherit;
  transition: width 0.35s ease;
  background: linear-gradient(90deg, #3ba951, #9ad05e);
}

.actions {
  margin-top: 0.45rem;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.32rem;
}

.actions button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.14rem;
  background: linear-gradient(180deg, #f3ebc6, #dde7b2);
  border: 1px solid rgba(23, 59, 24, 0.26);
  min-height: 50px;
  font-size: 0.58rem;
  font-weight: 700;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
  padding: 0.38rem 0.22rem;
}

.actIcon {
  font-size: 1rem;
  line-height: 1;
}

.logSection {
  margin-top: 0.44rem;
  border-radius: 8px;
  border: 1px dashed rgba(15, 60, 27, 0.24);
  background: rgba(245, 248, 229, 0.82);
  padding: 0.34rem 0.44rem 0.4rem;
}

#message {
  margin: 0;
  font-size: 0.7rem;
  font-weight: 600;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

#log {
  margin: 0.22rem 0 0;
  padding-left: 0.9rem;
  max-height: 3.1rem;
  overflow: auto;
  font-size: 0.63rem;
  font-family: "Courier New", "Lucida Console", monospace;
}

#log li {
  margin-bottom: 0.18rem;
}

.gameFooter {
  margin-top: 0.55rem;
  display: flex;
  justify-content: flex-end;
}

#restartBtn {
  background: #ffd8a8;
  font-size: 0.68rem;
  border: 1px solid rgba(76, 34, 9, 0.2);
  box-shadow: none;
  font-family: "Courier New", "Lucida Console", monospace;
  text-transform: uppercase;
}

@media (max-width: 360px) {
  .statRow {
    padding: 0.22rem 0.26rem;
  }

  .actions button {
    font-size: 0.54rem;
  }
}

@media (hover: hover) and (pointer: fine) and (min-width: 1024px) {
  #desktopBlocker {
    display: flex;
  }

  #app {
    filter: blur(1.5px) brightness(0.8);
    pointer-events: none;
  }
}

@keyframes pulseAlert {
  0%,
  100% {
    box-shadow: 0 0 0 0 rgba(214, 51, 36, 0.36);
  }
  50% {
    box-shadow: 0 0 0 10px rgba(214, 51, 36, 0);
  }
}

@keyframes voicePop {
  0% {
    transform: scale(0.97);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

body.danger .sceneShell {
  animation: pulseAlert 1.6s ease infinite;
}

body.urgent .sceneShell {
  animation: pulseAlert 1s ease infinite;
}

body.critical .sceneShell {
  animation: pulseAlert 0.6s ease infinite;
}
