/* Bicho Come Bicho — visual único (mapa de território), sem tema escuro de propósito. */
:root {
  color-scheme: light;
  --ground: #d5e2bc;
  --ink: #1e2a1c;
  --ink-soft: #4b5a45;
  --paper: #f7faef;
  --paper-glass: rgba(247, 250, 239, 0.9);
  --sun: #ffc93c;
  --sun-deep: #f0a91c;
  --prey: #2fa35a;
  --danger: #e5484d;
  --line: 3px solid var(--ink);
  --shadow: 4px 4px 0 var(--ink);
  --font-display: "Lilita One", "Arial Rounded MT Bold", "Trebuchet MS", sans-serif;
  --font-body: "Fredoka", "Nunito", "Segoe UI", system-ui, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 15px;
  -webkit-user-select: none;
  user-select: none;
  touch-action: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: crosshair;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

kbd {
  font-family: var(--font-body);
  font-weight: 600;
  font-size: 12px;
  padding: 1px 6px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: var(--paper);
}

/* ---------- Painéis ---------- */
.panel {
  background: var(--paper-glass);
  border: var(--line);
  border-radius: 14px;
  box-shadow: var(--shadow);
}

.hud {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.status {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  left: 16px;
  width: 230px;
  padding: 12px 14px;
  display: grid;
  gap: 10px;
}

.status-animal {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-emoji {
  font-size: 40px;
  line-height: 1;
}

.status-name {
  font-family: var(--font-display);
  font-size: 22px;
  line-height: 1.05;
}

.status-mass {
  font-size: 14px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.status-mass span {
  font-weight: 700;
  color: var(--ink);
}

.evo {
  display: grid;
  gap: 4px;
}

.evo-bar {
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 99px;
  background: var(--paper);
  overflow: hidden;
}

.evo-fill {
  height: 100%;
  width: 0;
  background: var(--sun);
  border-right: 2px solid var(--ink);
  transition: width 0.25s ease-out;
}

.evo-label {
  font-size: 13px;
  color: var(--ink-soft);
}

.status-row {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.status-row b {
  color: var(--ink);
}

.board {
  position: absolute;
  top: calc(16px + env(safe-area-inset-top, 0px));
  right: 16px;
  width: 210px;
  padding: 10px 12px 12px;
}

.board-title {
  margin: 0 0 6px;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 18px;
  letter-spacing: 0.02em;
}

.board-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 2px;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.board-list li {
  display: grid;
  grid-template-columns: 22px 22px 1fr auto;
  align-items: center;
  gap: 4px;
  padding: 1px 4px;
  border-radius: 6px;
}

.board-list li.me {
  background: var(--sun);
  font-weight: 700;
}

.board-list li.gap {
  display: block;
  text-align: center;
  color: var(--ink-soft);
  line-height: 0.8;
}

.board-list .rank {
  color: var(--ink-soft);
  font-size: 12px;
}

.board-list .name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.minimap {
  position: absolute;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  width: 150px;
  height: 150px;
  padding: 0;
  border-radius: 10px;
}

.hints {
  position: absolute;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  gap: 14px;
  font-size: 13px;
  color: var(--ink);
  background: var(--paper-glass);
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 6px 10px;
}

.touch-buttons {
  position: absolute;
  left: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: none;
  gap: 12px;
  pointer-events: auto;
}

.touch-btn {
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: var(--line);
  box-shadow: var(--shadow);
  background: var(--sun);
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 15px;
  touch-action: manipulation;
}

.touch-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 var(--ink);
}

body.is-touch .touch-buttons { display: flex; }
body.is-touch .hints { display: none; }

/* ---------- Avisos ---------- */
.toasts {
  position: fixed;
  top: calc(18px + env(safe-area-inset-top, 0px));
  left: 50%;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  justify-items: center;
  pointer-events: none;
  width: min(420px, calc(100% - 32px));
}

.toast {
  padding: 8px 16px;
  background: var(--paper);
  border: var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: 15px;
  text-align: center;
  animation: toast-in 0.25s ease-out, toast-out 0.4s ease-in 2.4s forwards;
}

.toast.evolve {
  background: var(--sun);
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 20px;
}

.toast.warn {
  background: var(--danger);
  color: #fff;
}

@keyframes toast-in {
  from { transform: translateY(-12px) scale(0.9); opacity: 0; }
}

@keyframes toast-out {
  to { transform: translateY(-8px); opacity: 0; }
}

/* ---------- Telas sobrepostas ---------- */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  padding: 24px 16px;
  overflow-y: auto;
  background: rgba(30, 42, 28, 0.28);
}

.card {
  margin: auto;
  width: min(520px, 100%);
  grid-template-columns: minmax(0, 1fr);
  background: var(--paper);
  border: var(--line);
  border-radius: 22px;
  box-shadow: 8px 8px 0 var(--ink);
  padding: 26px 26px 22px;
  display: grid;
  gap: 16px;
}

.logo {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: clamp(44px, 11vw, 68px);
  line-height: 0.9;
  letter-spacing: 0.01em;
  color: var(--sun);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 4px 4px 0 var(--ink);
  text-wrap: balance;
}

.tagline {
  margin: 0;
  font-size: 16px;
  line-height: 1.4;
  color: var(--ink-soft);
  max-width: 44ch;
}

.chain {
  margin: 0;
  padding: 10px 8px;
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: 4px 2px;
  border: 2px dashed var(--ink-soft);
  border-radius: 14px;
}

.chain li {
  display: grid;
  justify-items: center;
  gap: 1px;
  min-width: 40px;
  flex: 1 1 40px;
  position: relative;
}

.chain .c-emoji {
  font-size: 26px;
  line-height: 1.1;
}

.chain .c-name {
  font-size: 11px;
  font-weight: 600;
}

.chain .c-mass {
  font-size: 10px;
  color: var(--ink-soft);
  font-variant-numeric: tabular-nums;
}

.start-form {
  display: flex;
  gap: 10px;
}

#player-name {
  flex: 1 1 0;
  width: 0;
  min-width: 0;
  font: 600 18px var(--font-body);
  padding: 10px 14px;
  border: var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  -webkit-user-select: text;
  user-select: text;
}

#player-name:focus-visible {
  outline: 3px solid var(--sun-deep);
  outline-offset: 2px;
}

.btn-primary {
  font-family: var(--font-display);
  font-size: 22px;
  padding: 10px 26px;
  background: var(--sun);
  color: var(--ink);
  border: var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
  cursor: pointer;
  transition: transform 0.08s, box-shadow 0.08s;
}

.btn-primary:hover { background: var(--sun-deep); }

.btn-primary:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 var(--ink);
}

.btn-primary:focus-visible,
.btn-link:focus-visible,
.touch-btn:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 3px;
}

.btn-link {
  justify-self: center;
  background: none;
  border: 0;
  font: 600 15px var(--font-body);
  color: var(--ink-soft);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}

.net-status {
  margin: -6px 0 0;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-soft);
}

.net-status::before {
  content: "";
  width: 10px;
  height: 10px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--sun);
}

.net-status[data-state="online"]::before { background: var(--prey); }
.net-status[data-state="lost"]::before { background: var(--danger); }
.net-status[data-state="offline"]::before { background: var(--paper); }

.btn-primary:disabled {
  opacity: 0.55;
  cursor: wait;
}

.best {
  margin: -6px 0 0;
  font-size: 14px;
  color: var(--ink-soft);
}

.rules {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

.rules div {
  display: grid;
  gap: 1px;
}

.rules dt {
  font-family: var(--font-display);
  font-size: 15px;
}

.rules dd {
  margin: 0;
  font-size: 13px;
  line-height: 1.35;
  color: var(--ink-soft);
}

/* ---------- Morte ---------- */
.death-card {
  width: min(420px, 100%);
  text-align: center;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.death-title {
  margin: -8px 0 0;
  font-family: var(--font-display);
  font-weight: 400;
  font-size: 54px;
  line-height: 1;
  color: var(--danger);
  -webkit-text-stroke: 2px var(--ink);
  paint-order: stroke fill;
  text-shadow: 3px 3px 0 var(--ink);
}

.death-by {
  margin: 0;
  font-size: 17px;
}

.stats {
  margin: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  text-align: left;
}

.stats div {
  border: 2px solid var(--ink);
  border-radius: 10px;
  padding: 6px 10px;
  background: #fff;
}

.stats div:last-child {
  grid-column: 1 / -1;
}

.stats dt {
  font-size: 12px;
  color: var(--ink-soft);
}

.stats dd {
  margin: 0;
  font-family: var(--font-display);
  font-size: 22px;
  font-variant-numeric: tabular-nums;
}

/* ---------- Telas estreitas ---------- */
@media (max-width: 640px) {
  .status {
    width: 170px;
    padding: 8px 10px;
    gap: 6px;
  }
  .status-emoji { font-size: 30px; }
  .status-name { font-size: 18px; }
  .status-row { display: none; }
  .board {
    width: 150px;
    padding: 8px 8px 10px;
  }
  .board-title { font-size: 15px; }
  .board-list { font-size: 12px; }
  .board-list li { grid-template-columns: 18px 18px 1fr auto; }
  .board-list li:nth-child(n+6):not(.me):not(.gap) { display: none; }
  .minimap {
    width: 100px;
    height: 100px;
  }
  .card { padding: 20px 18px 18px; }
  .rules { grid-template-columns: 1fr; }
  .toasts { top: calc(150px + env(safe-area-inset-top, 0px)); }
}

@media (prefers-reduced-motion: reduce) {
  .toast { animation: toast-out 0.01s linear 2.6s forwards; }
  .evo-fill { transition: none; }
}
