/* =========================================================
   STUDIO.APP — habillage de la console
   ========================================================= */

#game-shell {
  background: #2b2438;
  padding: 10px 10px 12px;
  border: 2px solid #120d19;
  box-shadow: inset 0 0 0 2px #453a58;
}

/* --- Écran --- */
#game-frame {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 2;      /* 720x480 : la hauteur suit toujours la largeur */
  background: #0d0a14;
  border: 3px solid #100c18;
  box-shadow: inset 0 0 0 2px #56486d, 0 0 0 1px #000;
  overflow: hidden;
}

#game-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* --- Bandeau objectif, posé sur l'écran --- */
#game-hud {
  position: absolute;
  top: 8px;
  left: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: calc(100% - 16px);
  padding: 6px 10px 6px 6px;
  background: rgba(20, 14, 30, 0.82);
  border: 2px solid #f7ecd6;
  border-radius: 3px;
  color: #f7ecd6;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 9px;
  line-height: 1.5;
  letter-spacing: 0.02em;
}

#quest-badge {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  background: #d94f5c;
  border: 2px solid #f7ecd6;
  border-radius: 50%;
  font-size: 9px;
  color: #f7ecd6;
}

#quest-badge.pulse { animation: badge-pop 0.45s ease-out; }

@keyframes badge-pop {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.5); background: #f2c14e; color: #2b2438; }
  100% { transform: scale(1); }
}

#quest-badge.is-done {
  background: #f2c14e;
  color: #2b2438;
}

#game-mute {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 26px;
  height: 26px;
  background: rgba(20, 14, 30, 0.82);
  border: 2px solid #f7ecd6;
  border-radius: 3px;
  color: #f7ecd6;
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
}

/* --- Boîte de dialogue --- */
#game-dialogue {
  position: relative;
  margin-top: 10px;
  min-height: 64px;
  padding: 12px 26px 12px 14px;
  background: #f7ecd6;
  border: 3px solid #2b2438;
  border-radius: 4px;
  box-shadow: inset 0 0 0 2px #f7ecd6, inset 0 0 0 4px #5b7ba3;
  color: #2b2438;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 10px;
  line-height: 1.9;
  cursor: pointer;
}

/* hors dialogue : la boîte rappelle l'objectif en cours */
#game-dialogue.is-quest {
  background: #fdf6e6;
  box-shadow: inset 0 0 0 2px #f7ecd6, inset 0 0 0 4px #f2c14e;
  color: #6b4d12;
}

#game-dialogue.is-open {
  box-shadow: inset 0 0 0 2px #f7ecd6, inset 0 0 0 4px #d94f5c;
}

#dialogue-text {
  margin: 0;
}

#dialogue-arrow {
  position: absolute;
  right: 10px;
  bottom: 8px;
  font-size: 10px;
  color: #d94f5c;
  animation: dlg-blink 0.7s steps(2, end) infinite;
}

@keyframes dlg-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* --- Manette : joystick + bouton A --- */
#game-pad {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 12px;
  padding: 0 6px;
}

#stick {
  position: relative;
  width: 96px;
  height: 96px;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 35%, #55476c, #362c47);
  border: 3px solid #120d19;
  box-shadow: inset 0 3px 6px rgba(0, 0, 0, 0.5);
  touch-action: none;
  cursor: grab;
}

#stick.is-active { cursor: grabbing; }

#stick-knob {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 40px;
  height: 40px;
  margin: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #f7ecd6, #b8a9cc);
  border: 2px solid #120d19;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.45);
  transform: translate(-50%, -50%);
  transition: transform 0.06s linear;
  pointer-events: none;
}

#stick.is-active #stick-knob { transition: none; }

.stick-mark {
  position: absolute;
  color: #8f7fb0;
  font-size: 9px;
  line-height: 1;
  pointer-events: none;
}

.stick-mark.up    { top: 5px;  left: 50%; transform: translateX(-50%); }
.stick-mark.down  { bottom: 5px; left: 50%; transform: translateX(-50%); }
.stick-mark.left  { left: 5px;  top: 50%; transform: translateY(-50%); }
.stick-mark.right { right: 5px; top: 50%; transform: translateY(-50%); }

#btn-action {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #ef7c86, #c23c48);
  border: 3px solid #120d19;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.5);
  color: #f7ecd6;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 13px;
  cursor: pointer;
  touch-action: none;
}

#action-buttons {
  display: flex;
  align-items: center;
  gap: 10px;
}

#btn-jump, #btn-run {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 32%, #8fd0c4, #3f9186);
  border: 3px solid #120d19;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.5);
  color: #f7ecd6;
  font-family: 'Press Start 2P', 'Courier New', monospace;
  font-size: 13px;
  cursor: pointer;
  touch-action: none;
}

#btn-run.is-active {
  background: radial-gradient(circle at 40% 32%, #f2c14e, #c2911e);
}

#btn-jump:active, #btn-run:active {
  transform: translateY(1px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

#btn-action:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.5);
}

/* --- Aide clavier --- */
#game-keys {
  margin-top: 8px;
  color: #a294bd;
  font-size: 10px;
  text-align: center;
  font-family: 'Geneva', 'Verdana', sans-serif;
}

#game-keys kbd {
  display: inline-block;
  padding: 1px 5px;
  margin: 0 1px;
  background: #453a58;
  border: 1px solid #120d19;
  border-radius: 2px;
  color: #f7ecd6;
  font-family: inherit;
  font-size: 10px;
}

/* =========================================================
   TÉLÉVISION (fenêtre Vidéos)
   ========================================================= */
#tv-screen {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #0d1017;
  border: 2px solid #000;
  box-shadow: inset 0 0 40px rgba(0, 0, 0, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  color: #7fdcd0;
}

/* lignes de balayage, façon écran cathodique */
#tv-screen::after {
  content: '';
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    to bottom,
    rgba(255, 255, 255, 0.05) 0px,
    rgba(255, 255, 255, 0.05) 1px,
    transparent 1px,
    transparent 3px
  );
}

.tv-menu {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: 100%;
  max-height: 100%;
  padding: 10px 14px;
  overflow-y: auto;
}

.tv-menu--center {
  align-items: center;
  justify-content: center;
  text-align: center;
}

.tv-title,
.tv-status {
  margin: 0 0 4px;
  color: #7fdcd0;
  font-family: monospace;
  font-size: 12px;
  letter-spacing: 0.08em;
}

.tv-channel-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: #121a22;
  border: 1px solid #2f4a52;
  border-left: 3px solid #7fdcd0;
  padding: 6px 8px;
  color: #cdeee8;
  font-family: monospace;
  font-size: 12px;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}

.tv-channel-btn:hover,
.tv-channel-btn:focus-visible {
  background: #7fdcd0;
  border-left-color: #fff;
  color: #0d1017;
  outline: none;
}

.tv-num {
  flex: none;
  width: 18px;
  height: 18px;
  display: grid;
  place-items: center;
  background: #7fdcd0;
  color: #0d1017;
  font-weight: bold;
}

.tv-channel-btn:hover .tv-num { background: #0d1017; color: #7fdcd0; }

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

.tv-iframe {
  width: 100%;
  height: 100%;
  border: 0;
}

.tv-back-btn {
  position: absolute;
  bottom: 8px;
  right: 8px;
  z-index: 3;
  background: rgba(13, 16, 23, 0.9);
  border: 1px solid #7fdcd0;
  padding: 4px 8px;
  color: #7fdcd0;
  font-family: monospace;
  font-size: 11px;
  cursor: pointer;
}

.tv-back-btn:hover { background: #7fdcd0; color: #0d1017; }

/* ==========================================
   AMÉLIORATION GRAPHIQUE DE LA CHAMBRE
   ========================================== */

#game-map {
    position: relative;
    width: 416px; 
    height: 300px;
    background-color: #7c9070; /* Un vert pastel plus chaleureux */
    background-image: 
        linear-gradient(rgba(0,0,0,0.08) 1px, transparent 1px),
        linear-gradient(90deg, rgba(0,0,0,0.08) 1px, transparent 1px);
    background-size: 24px 24px;
    border: 3px solid #000;
    box-shadow: inset 3px 3px 0px rgba(0,0,0,0.2);
    overflow: hidden; 
}

/* Le Tapis au sol */
#rug-element {
    position: absolute;
    top: 100px;
    left: 130px;
    width: 140px;
    height: 90px;
    background-color: #d97706; /* Tapis orange rétro */
    border: 2px dashed #b45309;
    border-radius: 10px;
    z-index: 1;
}

/* Le Lit */
#bed-element {
    position: absolute;
    top: 20px;
    right: 25px;
    width: 75px;
    height: 60px;
    background-color: #e0e7ff;
    border: 2px solid #000;
    border-radius: 4px;
    color: #3730a3;
    font-size: 10px;
    font-family: monospace;
    font-weight: bold;
    text-align: center;
    line-height: 56px;
    z-index: 2;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.3);
}

/* Le Poster */
#poster-element {
    position: absolute;
    top: 15px;
    left: 140px;
    width: 45px;
    height: 30px;
    background-color: #f43f5e;
    border: 2px solid #000;
    color: #fff;
    font-size: 9px;
    font-family: monospace;
    text-align: center;
    line-height: 26px;
    z-index: 2;
}

/* Ajustement des meubles pour qu'ils passent par-dessus le tapis (z-index) */
#tv-element {
    position: absolute;
    top: 20px;
    left: 40px;
    width: 64px;
    height: 48px;
    background-color: #2c2c2c;
    color: #00ff00;
    font-size: 9px;
    font-family: monospace;
    font-weight: bold;
    text-align: center;
    line-height: 44px;
    border: 2px solid #000;
    border-radius: 4px;
    box-shadow: 2px 2px 0px rgba(0,0,0,0.4);
    z-index: 3;
}

#desk-element {
    position: absolute;
    top: 155px;
    right: 25px;
    width: 80px;
    height: 50px;
    background-color: #b08d57; 
    color: #fff;
    font-size: 10px;
    font-family: monospace;
    font-weight: bold;
    text-align: center;
    line-height: 46px;
    border: 2px solid #000;
    border-radius: 3px;
    box-shadow: 3px 3px 0px rgba(0,0,0,0.4);
    z-index: 3;
}

#player {
    position: absolute;
    width: 24px;
    height: 32px;
    z-index: 4; /* Toujours au-dessus du décor */
    left: 196px; 
    top: 138px;
}