/* Hématome - univers Tamagotchi (1997). Œuf violet translucide, LCD 1-bit. */

:root {
  --tg-shell-1: #8a5fc4;
  --tg-shell-2: #5f3a96;
  --tg-shell-3: #47286f;
  --tg-lcd: #c9d6b8;
  --tg-lcd-dark: #aebc9c;
  --tg-ink: #23301c;
  --tg-ink-dim: #55654a;
  --tg-btn: #e8e3f5;
  color-scheme: light;
}

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

body {
  min-height: 100dvh;
  background:
    radial-gradient(circle at 18% 22%, rgba(255, 255, 255, 0.14) 0 3px, transparent 4px),
    radial-gradient(circle at 76% 64%, rgba(255, 255, 255, 0.1) 0 2px, transparent 3px),
    linear-gradient(160deg, #ffd9ec 0%, #ffb3d9 40%, #c9a6f0 100%);
  background-size: 120px 120px, 90px 90px, cover;
  font-family: "Press Start 2P", "Courier New", monospace;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 30px 16px 110px;
}

.tg-caption {
  font-size: 11px;
  line-height: 1.9;
  color: #5f2d7e;
  text-align: center;
  max-width: 560px;
  letter-spacing: 0.04em;
}

.tg-caption i { font-style: normal; font-size: 0.6em; vertical-align: super; }

/* -- L'œuf ------------------------------ */
.tg-egg {
  position: relative;
  width: min(430px, 100%);
  background:
    radial-gradient(circle at 32% 24%, rgba(255, 255, 255, 0.5) 0%, transparent 34%),
    linear-gradient(155deg, var(--tg-shell-1) 0%, var(--tg-shell-2) 55%, var(--tg-shell-3) 100%);
  border: 3px solid var(--tg-shell-3);
  border-radius: 48% 48% 46% 46% / 56% 56% 42% 42%;
  padding: 56px 34px 44px;
  box-shadow:
    inset 0 3px 0 rgba(255, 255, 255, 0.35),
    inset 0 -10px 24px rgba(30, 10, 60, 0.35),
    0 18px 42px rgba(60, 20, 90, 0.5);
}

/* Anneau porte-clés */
.tg-ring {
  position: absolute;
  top: -26px;
  left: 50%;
  transform: translateX(-50%);
  width: 46px;
  height: 46px;
  border: 8px solid var(--tg-shell-3);
  border-radius: 50%;
  background: transparent;
  z-index: -1;
}

/* -- Écran ------------------------------ */
.tg-screen-frame {
  background: var(--tg-shell-3);
  border-radius: 22px;
  padding: 14px;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.4);
}

.tg-screen {
  background: var(--tg-lcd);
  background-image: repeating-linear-gradient(0deg, rgba(35, 48, 28, 0.05) 0 1px, transparent 1px 3px);
  border: 2px solid var(--tg-ink);
  border-radius: 8px;
  padding: 12px;
  color: var(--tg-ink);
  min-height: 330px;
  display: flex;
  flex-direction: column;
}

/* Icônes du haut */
.tg-icons {
  display: flex;
  justify-content: space-around;
  padding-bottom: 8px;
  border-bottom: 2px dotted var(--tg-ink-dim);
  margin-bottom: 10px;
}

.tg-ico { width: 18px; height: 18px; position: relative; opacity: 0.75; }
.tg-ico::before, .tg-ico::after { content: ""; position: absolute; }

/* bol de nourriture */
.tg-ico-food::before { left: 1px; right: 1px; bottom: 2px; height: 8px; border: 2px solid var(--tg-ink); border-radius: 0 0 8px 8px; border-top: none; }
.tg-ico-food::after { left: 4px; right: 4px; top: 3px; height: 4px; background: var(--tg-ink); border-radius: 2px; }

/* ampoule */
.tg-ico-bulb::before { left: 3px; top: 1px; width: 12px; height: 12px; border: 2px solid var(--tg-ink); border-radius: 50%; }
.tg-ico-bulb::after { left: 7px; bottom: 0; width: 4px; height: 4px; background: var(--tg-ink); }

/* manette de jeu */
.tg-ico-game::before { left: 0; right: 0; top: 4px; height: 10px; border: 2px solid var(--tg-ink); border-radius: 4px; }
.tg-ico-game::after { left: 4px; top: 8px; width: 2px; height: 2px; background: var(--tg-ink); box-shadow: 8px 0 0 var(--tg-ink); }

/* cœur */
.tg-ico-heart::before { left: 2px; top: 3px; width: 6px; height: 6px; border-radius: 50% 50% 0 0; background: var(--tg-ink); box-shadow: 6px 0 0 var(--tg-ink); }
.tg-ico-heart::after { left: 2px; top: 6px; width: 12px; height: 7px; background: var(--tg-ink); clip-path: polygon(0 0, 100% 0, 50% 100%); }

/* -- Vues ------------------------------- */
.tg-view { display: none; flex-grow: 1; }
.tg-view.is-active { display: block; }

.tg-h {
  font-size: 11px;
  background: var(--tg-ink);
  color: var(--tg-lcd);
  display: inline-block;
  padding: 5px 8px;
  margin-bottom: 10px;
  letter-spacing: 0.08em;
}

.tg-line { font-size: 9px; line-height: 2; margin-bottom: 10px; }
.tg-line b { font-size: inherit; }

/* La créature (pixel-art en box-shadow, pixels de 6px) */
.tg-sprite-zone { position: relative; height: 120px; margin: 6px 0 10px; }

.tg-creature {
  position: absolute;
  left: 50%;
  top: 12px;
  width: 6px;
  height: 6px;
  margin-left: -33px;
  animation: tg-idle 1.6s steps(2) infinite;
  box-shadow:
    /* tête ronde */
    18px 0 var(--tg-ink), 24px 0 var(--tg-ink), 30px 0 var(--tg-ink), 36px 0 var(--tg-ink),
    12px 6px var(--tg-ink), 42px 6px var(--tg-ink),
    6px 12px var(--tg-ink), 48px 12px var(--tg-ink),
    /* yeux */
    18px 18px var(--tg-ink), 36px 18px var(--tg-ink),
    0 18px var(--tg-ink), 54px 18px var(--tg-ink),
    /* bouche */
    24px 30px var(--tg-ink), 30px 30px var(--tg-ink),
    0 24px var(--tg-ink), 54px 24px var(--tg-ink),
    0 30px var(--tg-ink), 54px 30px var(--tg-ink),
    /* corps */
    6px 36px var(--tg-ink), 48px 36px var(--tg-ink),
    6px 42px var(--tg-ink), 48px 42px var(--tg-ink),
    12px 48px var(--tg-ink), 42px 48px var(--tg-ink),
    /* pattes */
    18px 54px var(--tg-ink), 24px 54px var(--tg-ink), 30px 54px var(--tg-ink), 36px 54px var(--tg-ink),
    18px 60px var(--tg-ink), 36px 60px var(--tg-ink);
}

@keyframes tg-idle {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(6px); }
}

.tg-creature.is-happy { animation: tg-jump 700ms steps(3) 2; }

@keyframes tg-jump {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-18px); }
}

/* Miam : petit gâteau qui apparaît */
.tg-food {
  position: absolute;
  right: 18%;
  bottom: 12px;
  width: 6px;
  height: 6px;
  opacity: 0;
  box-shadow:
    0 0 var(--tg-ink), 6px 0 var(--tg-ink), 12px 0 var(--tg-ink),
    -3px 6px var(--tg-ink), 3px 6px var(--tg-ink), 9px 6px var(--tg-ink), 15px 6px var(--tg-ink);
}

.tg-food.is-eating { animation: tg-eat 1.4s steps(4) forwards; }

@keyframes tg-eat {
  0% { opacity: 1; transform: scale(1); }
  70% { opacity: 1; transform: scale(0.5); }
  100% { opacity: 0; transform: scale(0); }
}

.tg-name {
  font-size: 10px;
  text-align: center;
  letter-spacing: 0.1em;
  margin-bottom: 10px;
}

/* Jauge bonheur */
.tg-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 2px solid var(--tg-ink);
  padding: 8px 10px;
  font-size: 9px;
}

.tg-meter-hearts { letter-spacing: 4px; font-size: 12px; }
.tg-meter-val { margin-left: auto; }

/* Liste d'outils */
.tg-tools { list-style: none; }
.tg-tools li + li { margin-top: 4px; }

.tg-tools a {
  display: flex;
  align-items: center;
  min-height: 40px;
  font-size: 9px;
  color: var(--tg-ink);
  text-decoration: none;
  border: 2px solid var(--tg-ink);
  padding: 6px 8px;
  cursor: pointer;
}

.tg-tools a::before { content: "> "; white-space: pre; }
.tg-tools a:hover, .tg-tools a:focus-visible { background: var(--tg-ink); color: var(--tg-lcd); }
.tg-tools a:focus-visible { outline: 3px solid var(--tg-shell-2); outline-offset: 2px; }

.tg-pager {
  text-align: center;
  font-size: 9px;
  letter-spacing: 6px;
  padding-top: 10px;
  color: var(--tg-ink-dim);
  flex-shrink: 0;
}

/* -- Boutons A/B/C ---------------------- */
.tg-buttons {
  display: flex;
  justify-content: center;
  gap: 34px;
  margin-top: 30px;
}

.tg-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 3px solid var(--tg-shell-3);
  background: radial-gradient(circle at 36% 30%, #ffffff 0%, var(--tg-btn) 55%, #c3b8dd 100%);
  color: var(--tg-shell-3);
  font-family: inherit;
  font-size: 15px;
  cursor: pointer;
  box-shadow:
    inset 0 2px 0 rgba(255, 255, 255, 0.8),
    0 5px 0 var(--tg-shell-3);
  transition: transform 100ms ease-out, box-shadow 100ms ease-out;
}

.tg-btn:hover { filter: brightness(1.05); }
.tg-btn:active { transform: translateY(4px); box-shadow: inset 0 2px 0 rgba(255,255,255,0.8), 0 1px 0 var(--tg-shell-3); }
.tg-btn:focus-visible { outline: 4px solid #ffffff; outline-offset: 3px; }

.tg-btn-labels {
  display: flex;
  justify-content: center;
  gap: 30px;
  margin-top: 12px;
}

.tg-btn-labels span {
  font-size: 7px;
  color: #d9c8ef;
  letter-spacing: 0.15em;
  width: 62px;
  text-align: center;
}

@media (max-width: 470px) {
  .tg-egg { padding: 46px 22px 36px; }
  .tg-screen { min-height: 300px; }
  .tg-buttons { gap: 22px; }
  .tg-btn { width: 52px; height: 52px; }
}

@media (prefers-reduced-motion: reduce) {
  .tg-creature, .tg-creature.is-happy, .tg-food.is-eating { animation: none; }
  .tg-food.is-eating { opacity: 1; }
  .tg-btn { transition: none; }
}
