/* ════════════════════════════════════════
   TAMAWEB v2.0 – Folha de estilos retro
   ════════════════════════════════════════ */

@import url("https://fonts.googleapis.com/css2?family=Press+Start+2P&display=swap");

/* ── Variáveis ────────────────────────── */
:root {
  --lcd-bg: #9bbc0f;
  --lcd-dark: #0f380f;
  --lcd-mid: #306230;
  --lcd-light: #8bac0f;
  --shell-color: #c8a83c;
  --shell-dark: #8c6e1f;
  --shell-light: #e8d080;
  --btn-a: #c44040;
  --btn-b: #3060c0;
  --btn-c: #208040;
  --btn-d: #805000;
  --bezel-color: #1a1a1a;
  --pixel-font: "Press Start 2P", monospace;
  --bar-hunger: #c04000;
  --bar-happy: #0060a0;
  --bar-energy: #c0a000;
  --bar-hygiene: #007080;
}

/* ── Reset ────────────────────────────── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background: #0d0d1a;
  background-image:
    radial-gradient(ellipse at 15% 15%, #1a1a3e 0%, transparent 55%),
    radial-gradient(ellipse at 85% 85%, #0a1a0a 0%, transparent 55%),
    url("data:image/svg+xml,%3Csvg width='4' height='4' viewBox='0 0 4 4' xmlns='http://www.w3.org/2000/svg'%3E%3Crect x='0' y='0' width='1' height='1' fill='%23ffffff08'/%3E%3C/svg%3E");
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--pixel-font);
  image-rendering: pixelated;
  user-select: none; /* Melhora experiência mobile evitando seleção acidental */
  -webkit-user-select: none;
}

input,
textarea {
  user-select: auto;
  -webkit-user-select: auto;
}

.pixel-text {
  font-family: var(--pixel-font);
}

/* ════════════════════════════════════════
   TELA DE BOOT
════════════════════════════════════════ */
.boot-screen {
  position: fixed;
  inset: 0;
  background: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  transition: opacity 0.6s ease;
}
.boot-screen.fade-out {
  opacity: 0;
  pointer-events: none;
}

.boot-content {
  text-align: center;
  width: 300px;
}

.boot-logo-img {
  width: 90px;
  margin-bottom: 15px;
  filter: drop-shadow(0 0 10px rgba(155, 188, 15, 0.4));
  animation: bootPulse 1.2s ease-in-out infinite alternate;
}

.boot-logo {
  font-size: clamp(22px, 5vw, 44px);
  color: #9bbc0f;
  text-shadow:
    0 0 20px #9bbc0f88,
    0 0 60px #9bbc0f44;
  letter-spacing: 4px;
  animation: bootPulse 1.2s ease-in-out infinite alternate;
}
.boot-logo span {
  color: #c8a83c;
  text-shadow: 0 0 20px #c8a83c88;
}

@keyframes bootPulse {
  from {
    opacity: 0.6;
    text-shadow: 0 0 10px #9bbc0f66;
  }
  to {
    opacity: 1;
    text-shadow:
      0 0 30px #9bbc0fcc,
      0 0 60px #9bbc0f44;
  }
}

.boot-tagline {
  margin-top: 6px;
  font-size: 7px;
  color: #306230;
  letter-spacing: 2px;
}

.boot-bar-wrap {
  margin: 20px auto 6px;
  width: 200px;
  height: 12px;
  border: 2px solid #306230;
  background: #0a0a0a;
  position: relative;
}
.boot-bar {
  height: 100%;
  width: 0%;
  background: repeating-linear-gradient(
    90deg,
    #9bbc0f 0px,
    #9bbc0f 6px,
    #6a8c0a 6px,
    #6a8c0a 8px
  );
  transition: width 0.1s steps(1);
  box-shadow: 0 0 8px #9bbc0f88;
}
.boot-pct {
  font-size: 8px;
  color: #9bbc0f;
  margin-bottom: 8px;
}
.boot-sub {
  font-size: 7px;
  color: #1a4a1a;
}

/* ════════════════════════════════════════
   SHELL DO DISPOSITIVO
════════════════════════════════════════ */
.device-shell {
  background: linear-gradient(
    160deg,
    var(--shell-light) 0%,
    var(--shell-color) 30%,
    #b09030 60%,
    var(--shell-dark) 100%
  );
  border-radius: 26px 26px 52px 52px;
  padding: 16px 18px 26px;
  width: 284px;
  box-shadow:
    inset 0 3px 6px rgba(255, 255, 255, 0.55),
    inset 0 -4px 8px rgba(0, 0, 0, 0.45),
    0 10px 30px rgba(0, 0, 0, 0.7),
    0 2px 6px rgba(0, 0, 0, 0.9),
    0 0 0 1px rgba(0, 0, 0, 0.3);
  position: relative;
  flex-shrink: 0;
}

/* Textura plástico */
.device-shell::before {
  content: "";
  position: absolute;
  inset: 2px;
  border-radius: 24px 24px 50px 50px;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(255, 255, 255, 0.04) 3px,
    rgba(255, 255, 255, 0.04) 4px
  );
  pointer-events: none;
  z-index: 1;
}

.device-shell > * {
  position: relative;
  z-index: 2;
}

/* ── Cabeçalho ─────────────────────────── */
.device-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}
.device-title {
  font-size: 7px;
  color: var(--shell-dark);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3);
}
.device-age {
  font-size: 6px;
  color: var(--shell-dark);
}
.device-time {
  font-size: 6px;
  color: var(--shell-dark);
}
.device-coins {
  font-size: 6px;
  color: var(--shell-dark);
}
.device-cloud {
  font-size: 8px;
  color: var(--shell-dark);
  opacity: 0.4;
  transition:
    color 0.5s,
    opacity 0.5s;
}
.device-cloud.online {
  color: #208040;
  opacity: 1;
}

/* ── Ícones de status ─────────────────── */
.status-icons {
  display: flex;
  justify-content: space-around;
  margin-bottom: 7px;
  padding: 0 4px;
}
.status-icon {
  font-size: 13px;
  opacity: 0.3;
  transition:
    opacity 0.2s,
    transform 0.1s,
    filter 0.2s;
  cursor: default;
  filter: grayscale(1);
}
.status-icon.alert {
  opacity: 1;
  filter: none;
  animation: iconBlink 0.55s steps(1) infinite;
}
@keyframes iconBlink {
  0%,
  100% {
    opacity: 1;
    transform: scale(1.1);
  }
  50% {
    opacity: 0.2;
    transform: scale(1);
  }
}

/* ── Bisel + tela LCD ─────────────────── */
.screen-bezel {
  background: var(--bezel-color);
  border-radius: 6px;
  padding: 7px;
  box-shadow:
    inset 0 4px 10px rgba(0, 0, 0, 0.9),
    inset 0 1px 3px rgba(0, 0, 0, 0.8),
    0 2px 4px rgba(0, 0, 0, 0.4);
}

.lcd-screen {
  background: var(--lcd-bg);
  border-radius: 3px;
  min-height: 128px;
  position: relative;
  overflow: hidden;
  background-image: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0, 0, 0, 0.05) 3px,
    rgba(0, 0, 0, 0.05) 4px
  );
  box-shadow: inset 0 0 16px rgba(0, 56, 0, 0.35);
}

/* Reflexo */
.lcd-screen::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 55%;
  height: 45%;
  background: linear-gradient(
    130deg,
    rgba(255, 255, 255, 0.1) 0%,
    transparent 100%
  );
  border-radius: 3px 0 0 0;
  pointer-events: none;
  z-index: 10;
}

.lcd-inner {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 128px;
  padding: 6px;
}

#pet-canvas {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  width: 160px;
  height: 128px;
  display: block;
  position: relative;
  z-index: 2;
}

/* ── Balão de fala ─────────────────────── */
.speech-bubble {
  position: absolute;
  top: 3px;
  right: 3px;
  background: var(--lcd-light);
  border: 2px solid var(--lcd-dark);
  padding: 4px 6px;
  font-size: 5px;
  color: var(--lcd-dark);
  max-width: 88px;
  text-align: center;
  line-height: 1.8;
  z-index: 20;
  animation: bubblePop 0.15s steps(3) forwards;
}
@keyframes bubblePop {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}
.speech-bubble::after {
  content: "";
  position: absolute;
  bottom: -6px;
  left: 10px;
  border: 3px solid transparent;
  border-top-color: var(--lcd-dark);
}

/* ── Mensagem de evento ────────────────── */
.event-msg {
  position: absolute;
  bottom: 3px;
  font-size: 5px;
  color: var(--lcd-dark);
  text-align: center;
  z-index: 20;
  animation: eventBlink 0.4s steps(1) infinite;
}
@keyframes eventBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}

/* ── Mini-jogo ─────────────────────────── */
.minigame-overlay {
  position: absolute;
  inset: 0;
  background: var(--lcd-bg);
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: center;
}
#minigame-canvas {
  image-rendering: pixelated;
  width: 160px;
  height: 128px;
  touch-action: none;
}

/* ════════════════════════════════════════
   BARRAS DE STATUS
════════════════════════════════════════ */
.status-bars {
  margin-top: 9px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bar-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.bar-label {
  font-size: 5px;
  color: var(--shell-dark);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}
.bar-val {
  font-size: 5px;
  color: var(--shell-dark);
  width: 18px;
  text-align: left;
  flex-shrink: 0;
}
.bar-track {
  flex: 1;
  height: 7px;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(0, 0, 0, 0.4);
  border-radius: 0;
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.35s steps(10);
  position: relative;
}
.bar-fill::after {
  content: "";
  display: block;
  height: 100%;
  background: repeating-linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.2) 0px,
    rgba(255, 255, 255, 0.2) 3px,
    transparent 3px,
    transparent 5px
  );
}
.hunger-bar {
  background: var(--bar-hunger);
}
.happy-bar {
  background: var(--bar-happy);
}
.energy-bar {
  background: var(--bar-energy);
}
.hygiene-bar {
  background: var(--bar-hygiene);
}

.bar-fill.low {
  animation: barLow 0.45s steps(1) infinite;
}
@keyframes barLow {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.25;
  }
}

/* ════════════════════════════════════════
   BOTÕES FÍSICOS
════════════════════════════════════════ */
.btn-row {
  display: flex;
  justify-content: space-around;
  margin-top: 14px;
  gap: 6px;
}
.btn-group {
  display: flex;
  gap: 8px;
}

.hw-btn {
  background: linear-gradient(145deg, #e0e0e0, #a0a0a0);
  border: none;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  box-shadow:
    0 5px 0 rgba(0, 0, 0, 0.45),
    inset 0 1px 3px rgba(255, 255, 255, 0.65),
    inset 0 -2px 3px rgba(0, 0, 0, 0.35);
  transition:
    transform 0.05s,
    box-shadow 0.05s;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
#btn-a {
  background: linear-gradient(145deg, #e06868, #a02020);
}
#btn-b {
  background: linear-gradient(145deg, #6888e0, #2040b0);
}
#btn-c {
  background: linear-gradient(145deg, #58c078, #1a7040);
}
#btn-d {
  background: linear-gradient(145deg, #d0a048, #805010);
}

.hw-btn:active,
.hw-btn.pressed {
  transform: translateY(4px);
  box-shadow:
    0 1px 0 rgba(0, 0, 0, 0.45),
    inset 0 3px 5px rgba(0, 0, 0, 0.5);
}
.hw-btn:focus {
  outline: none;
}

.btn-icon {
  font-size: 15px;
  line-height: 1;
}
.btn-label {
  font-size: 4px;
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
  line-height: 1;
}

/* Botão de remédio */
.medicine-row {
  display: flex;
  justify-content: center;
  margin-top: 8px;
}
.medicine-btn {
  width: 80px !important;
  border-radius: 12px !important;
  background: linear-gradient(145deg, #e0a0e0, #9020a0) !important;
  animation: medicinePulse 0.8s steps(2) infinite;
}
@keyframes medicinePulse {
  0%,
  100% {
    box-shadow:
      0 5px 0 rgba(0, 0, 0, 0.45),
      0 0 8px #9020a080;
  }
  50% {
    box-shadow:
      0 5px 0 rgba(0, 0, 0, 0.45),
      0 0 16px #9020a0cc;
  }
}

/* ── Alça ─────────────────────────────── */
.device-strap {
  width: 22px;
  height: 22px;
  background: radial-gradient(
    circle at 35% 35%,
    var(--shell-color),
    var(--shell-dark)
  );
  border-radius: 50%;
  margin: 12px auto 0;
  box-shadow:
    inset 0 2px 5px rgba(0, 0, 0, 0.45),
    0 1px 2px rgba(255, 255, 255, 0.2);
}
.device-strap::before {
  content: "";
  display: block;
  width: 9px;
  height: 9px;
  background: #111;
  border-radius: 50%;
  margin: 6px auto;
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.15);
}

/* ════════════════════════════════════════
   TELA DE NOME
════════════════════════════════════════ */
.name-screen {
  display: flex;
  align-items: center;
  justify-content: center;
}
.name-shell {
  padding: 22px 20px 28px;
}

.name-header {
  font-size: 8px;
  color: var(--lcd-dark);
  text-align: center;
  margin-bottom: 14px;
  animation: bootPulse 1s ease-in-out infinite alternate;
}
.name-prompt {
  font-size: 7px;
  color: var(--lcd-dark);
  margin-bottom: 6px;
}
.retro-input {
  background: transparent;
  border: none;
  border-bottom: 2px solid var(--lcd-dark);
  color: var(--lcd-dark);
  font-size: 9px;
  width: 100%;
  padding: 4px 2px;
  outline: none;
  text-transform: uppercase;
  letter-spacing: 3px;
  font-family: var(--pixel-font);
}
.retro-input::placeholder {
  color: var(--lcd-mid);
  opacity: 0.5;
}

.name-species {
  font-size: 6px;
  color: var(--lcd-dark);
  margin: 14px 0 8px;
  text-align: center;
}
.species-row {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 4px;
}
.species-btn {
  font-size: 20px;
  background: transparent;
  border: 2px solid transparent;
  border-radius: 4px;
  cursor: pointer;
  padding: 4px;
  filter: grayscale(1);
  opacity: 0.5;
  transition:
    filter 0.1s,
    opacity 0.1s,
    border-color 0.1s;
  -webkit-tap-highlight-color: transparent;
}
.species-btn:hover,
.species-btn.selected {
  filter: none;
  opacity: 1;
  border-color: var(--lcd-dark);
}

.retro-btn-wide {
  display: block;
  width: 100%;
  margin-top: 16px;
  padding: 10px 0;
  background: linear-gradient(145deg, var(--shell-light), var(--shell-color));
  border: 2px solid var(--shell-dark);
  border-radius: 4px;
  font-size: 8px;
  color: var(--shell-dark);
  cursor: pointer;
  box-shadow: 0 3px 0 var(--shell-dark);
  transition:
    transform 0.05s,
    box-shadow 0.05s;
  font-family: var(--pixel-font);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}
.retro-btn-wide:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--shell-dark);
}
.retro-btn-wide:focus {
  outline: none;
}

/* ════════════════════════════════════════
   LAYOUT PRINCIPAL
════════════════════════════════════════ */
.main-screen {
  display: flex;
  align-items: flex-start;
  justify-content: center;
  gap: 20px;
  padding: 20px;
}

/* ── Painel lateral ───────────────────── */
.side-panel {
  background: rgba(0, 0, 0, 0.55);
  border: 1px solid rgba(155, 188, 15, 0.25);
  border-radius: 8px;
  padding: 14px;
  width: 192px;
  color: #9bbc0f;
  flex-shrink: 0;
  box-shadow: 0 0 20px rgba(155, 188, 15, 0.05);
}
.panel-title {
  font-size: 7px;
  color: #c8a83c;
  margin-bottom: 8px;
}
.panel-row {
  font-size: 6px;
  color: #9bbc0f;
  margin-bottom: 6px;
  line-height: 2;
}
.retro-hr {
  border: none;
  border-top: 1px solid rgba(155, 188, 15, 0.2);
  margin: 10px 0;
}

#log-list {
  max-height: 160px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: #306230 #111;
}
.log-entry {
  font-size: 5px;
  color: #9bbc0f;
  margin-bottom: 5px;
  opacity: 0.85;
  border-left: 2px solid #306230;
  padding-left: 5px;
  line-height: 2;
}
.log-entry.warn {
  color: #c8a83c;
  border-color: #c8a83c;
}
.log-entry.danger {
  color: #c04040;
  border-color: #c04040;
}
.log-entry.good {
  color: #40c060;
  border-color: #40c060;
}

@media (max-width: 640px) {
  .side-panel {
    display: none;
  }
  .name-screen,
  .main-screen {
    padding: 0;
    height: 100vh;
    width: 100vw;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .device-shell {
    transform: scale(1.3);
    transform-origin: center center;
    margin: auto;
  }
}

@media (max-width: 400px) {
  .device-shell {
    transform: scale(1.2);
  }
}

/* ════════════════════════════════════════
   MODAIS
════════════════════════════════════════ */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.88);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 8888;
}
.modal-box {
  background: var(--lcd-bg);
  border: 4px solid var(--lcd-dark);
  padding: 22px;
  text-align: center;
  max-width: 290px;
  width: 92%;
  box-shadow:
    0 0 0 8px rgba(0, 0, 0, 0.5),
    0 0 40px rgba(155, 188, 15, 0.2);
}
.modal-title {
  font-size: 11px;
  color: var(--lcd-dark);
  margin-bottom: 14px;
  animation: modalBlink 0.7s steps(1) infinite;
}
.evolve-title {
  animation: none;
  color: var(--lcd-dark);
}
@keyframes modalBlink {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0;
  }
}
.modal-msg {
  font-size: 7px;
  color: var(--lcd-dark);
  margin-bottom: 12px;
  line-height: 2.2;
  white-space: pre-line;
}
.modal-score {
  font-size: 8px;
  color: var(--lcd-dark);
  margin-bottom: 14px;
  padding: 8px;
  border: 1px solid var(--lcd-dark);
}
.evolve-box .modal-title {
  animation: evolvePulse 0.5s steps(2) infinite;
}
@keyframes evolvePulse {
  0%,
  100% {
    color: var(--lcd-dark);
  }
  50% {
    color: var(--lcd-mid);
  }
}

/* ════════════════════════════════════════
   UTILITÁRIOS
════════════════════════════════════════ */
.hidden {
  display: none !important;
}

@keyframes shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-5px);
  }
  40% {
    transform: translateX(5px);
  }
  60% {
    transform: translateX(-3px);
  }
  80% {
    transform: translateX(3px);
  }
}
.shake {
  animation: shake 0.3s steps(4);
}

@keyframes flash {
  0%,
  100% {
    filter: brightness(1);
  }
  50% {
    filter: brightness(2);
  }
}
.flash {
  animation: flash 0.15s steps(2) 3;
}

/* Responsivo (Celulares Pequenos) */
@media (max-width: 350px) {
  .device-shell {
    width: 262px;
    padding: 14px 14px 22px;
    transform: scale(1.1);
  }
  .hw-btn {
    width: 44px;
    height: 44px;
  }
  .btn-icon {
    font-size: 13px;
  }
}
