:root {
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bar-bg: rgba(8, 17, 28, 0.94);
  --bar-border: rgba(255, 255, 255, 0.08);
  --btn-bg: rgba(255, 255, 255, 0.08);
  --btn-border: rgba(255, 255, 255, 0.12);
  --text: #ddeeff;
  --text-dim: rgba(200, 224, 255, 0.45);
  --accent: #4ecb8d;
  --danger: #ff4f4f;
  --gold: #ffd040;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}

body {
  margin: 0;
  width: 100vw;
  height: 100dvh;
  overflow: hidden;
  background: #0a1422;
  user-select: none;
  -webkit-user-select: none;
  overscroll-behavior: none;
  color-scheme: dark;
}

button {
  color: inherit;
  cursor: pointer;
  font: inherit;
  border: none;
  outline: none;
  background: none;
  padding: 0;
}

/* ───────────────────────────────
   Coquille principale : 3 lignes
   status-bar | viewport | action-bar
─────────────────────────────── */
.shell {
  width: 100vw;
  height: 100dvh;
  max-width: 500px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ───────────────────────────────
   Status bar (haut)
─────────────────────────────── */
.status-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(10px + var(--safe-top)) 14px 10px;
  background: var(--bar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--bar-border);
}

/* Rangée des 5 besoins */
.needs-row {
  display: flex;
  gap: 9px;
  flex: 1;
}

.need-widget {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.need-icon {
  font-size: 12px;
  line-height: 1;
  opacity: 0.8;
}

.need-dots {
  display: flex;
  gap: 2px;
}

.need-dots span {
  display: block;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  transition: background 0.3s ease;
}

.need-dots span.on {
  background: rgba(200, 230, 255, 0.78);
}

.need-widget.low .need-dots span.on {
  background: var(--gold);
}

.need-widget.critical .need-dots span.on {
  background: var(--danger);
  animation: blink 0.65s steps(1) infinite;
}

@keyframes blink {
  50% { opacity: 0.1; }
}

/* Badge identité (centre) */
.identity-badge {
  display: flex;
  flex-direction: column;
  align-items: center;
  flex-shrink: 0;
  color: var(--text);
}

.identity-badge strong {
  font-size: 0.86rem;
  font-weight: 800;
  line-height: 1.15;
}

.identity-badge span {
  font-size: 0.6rem;
  color: var(--text-dim);
}

/* Badge pièces (droite) */
.coins-badge {
  display: flex;
  align-items: center;
  gap: 3px;
  color: var(--gold);
  font-weight: 800;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.coins-star {
  font-size: 0.75rem;
  opacity: 0.85;
}

/* ───────────────────────────────
   Viewport : le monde de Yohan
─────────────────────────────── */
.viewport {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: #0a1a28;
}

/* Le canvas est positionné et scalé par JS (cover) */
#petCanvas {
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  touch-action: none;
  cursor: pointer;
  transform-origin: 0 0;
  image-rendering: auto;
}

/* Bulle de dialogue */
.speech {
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: 12px;
  padding: 8px 14px;
  background: rgba(6, 14, 24, 0.80);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  color: #e8f4ff;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.35;
  pointer-events: none;
  z-index: 10;
}

/* Badge humeur (emoji) */
.mood-badge {
  position: absolute;
  top: 10px;
  right: 12px;
  font-size: 1.6rem;
  line-height: 1;
  filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.6));
  pointer-events: none;
  z-index: 10;
}

/* ───────────────────────────────
   Action bar (bas)
─────────────────────────────── */
.action-bar {
  flex-shrink: 0;
  background: var(--bar-bg);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--bar-border);
  padding: 10px 10px calc(6px + var(--safe-bottom));
}

/* Grille 4×2 */
.action-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}

.action-grid button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 7px 4px;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  border-radius: 10px;
  color: var(--text);
  min-height: 52px;
  transition: transform 0.1s ease, background 0.12s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  position: relative;
}

.action-grid button:active {
  transform: scale(0.91);
  background: rgba(255, 255, 255, 0.14);
}

/* Bouton recommandé : lueur verte */
.action-grid button.recommended {
  border-color: rgba(78, 203, 141, 0.5);
  background: rgba(78, 203, 141, 0.12);
  box-shadow: 0 0 14px rgba(78, 203, 141, 0.22);
}

.action-grid button.recommended .btn-icon {
  animation: nudge 1.8s ease-in-out infinite;
}

@keyframes nudge {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-2px); }
}

.action-grid button:disabled {
  opacity: 0.28;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 1.3rem;
  line-height: 1;
}

.btn-label {
  font-size: 0.59rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
}

.btn-cost {
  font-size: 0.55rem;
  font-weight: 700;
  color: var(--text-dim);
}

/* Utilitaires footer */
.footer-utils {
  display: flex;
  justify-content: flex-end;
  gap: 6px;
  margin-top: 7px;
}

.footer-utils button {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.6rem;
  font-weight: 700;
  padding: 3px 9px;
  transition: background 0.12s;
}

.footer-utils button:active {
  background: rgba(255, 255, 255, 0.14);
}

.footer-utils button[hidden] {
  display: none;
}
