/* Fonte Omori */
@font-face {
    font-family: 'OmoriFont';
    src: url('../fonts/omoriFont.ttf') format('truetype');
    font-weight: normal;
    font-style: normal;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden;
    background-color: white;
    font-family: 'OmoriFont', Arial, sans-serif;
}

/* Retângulo preto inferior */
#retangulo {
  position: fixed;
  bottom: 20px; 
  left: 50%;
  transform: translateX(-50%) scaleY(0);
  width: 90%;
  height: 180px;
  background-color: black;
  border: 2px solid white;      /* borda principal */
  outline: 1px solid black;     /* borda preta externa real */
  outline-offset: 2px;          /* leve afastamento */
  box-sizing: border-box;
  z-index: 2;
  transform-origin: center center;
  transition: transform 0.2s ease-out;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 14px;
  color: white;
  font-size: 36px;
  overflow: hidden;
}

/* Borda preta fina extra */
#retangulo::after {
    content: '';
    position: absolute;
    top: -2px; left: -2px;
    width: calc(100% + 4px);
    height: calc(100% + 4px);
    border: 1px solid black;
    pointer-events: none;
}

/* Mostrar retângulo */
#retangulo.show {
    transform: translateX(-50%) scaleY(1);
}

/* Texto */
#texto {
    white-space: pre-line;
    word-wrap: break-word;
    overflow-wrap: break-word;
    margin-bottom: 10px;
}

/* Input container do botão 5 */
#input-container {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

#user-input {
    width: 80px;
    font-size: 28px;
    padding: 4px;
    border: 1px solid white;
    background-color: black;
    color: white;
    text-align: center;
    outline: none;
}

#user-input::placeholder {
    color: #ccc;
}

#confirmar, #limpar {
    padding: 4px 10px;
    font-size: 18px;
    cursor: pointer;
    border: 1px solid white;
    background-color: #222;
    color: white;
}

#forca-input {
    display: flex;
    gap: 10px;
    margin-top: 10px;
}

.letra {
    width: 40px;
    font-size: 36px;
    text-align: center;
    border-bottom: 2px solid white;
    color: white;
    display: inline-block;
    transition: transform 0.1s ease;
}

/* animação "pular" letra */
.letra.jump {
    transform: translateY(-10px);
}

/* Parâmetros fáceis de ajustar */
:root{
  --omori-flicker-speed: 1.8s;    /* período do ciclo de flicker */
  --omori-scribble-opacity: 0.20; /* visibilidade dos rabiscos */
  --omori-jitter-amount: 4px;     /* deslocamento do jitter */
  --omori-contrast-high: 1.6;     /* contraste durante o pico do flicker */
  --omori-contrast-low: 0.85;     /* contraste durante o valley do flicker */
}

/* Tela inteira, sem transparência do fundo (preto sólido) */
#intro-screen {
  position: fixed;
  inset: 0;
  background: #000;               /* fundo preto sólido (nada de opacity) */
  color: #fff;
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  font-family: 'OmoriFont', sans-serif;
  font-size: 32px;
  text-align: center;
  z-index: 9999;
  height: 100%;

  /* animação de flicker + leve pulso de brilho */
  animation: omoriFlicker var(--omori-flicker-speed) infinite;
  /* garante camadas pseudo posicionadas corretamente */
  position: relative;
  overflow: visible;
}

/* camada de "rabisco" - múltiplos gradientes cruzados simulando hachura / rascunho */
#intro-screen::before{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: lighten; /* faz os rabiscos aparecerem em branco sobre o preto */
  opacity: var(--omori-scribble-opacity);

  /* sobreposição de várias hachuras/linhas para parecer rabisco */
  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.06) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(60deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(-30deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 10px),
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.02), transparent 15%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.015), transparent 20%);
  background-size: auto;
  transform-origin: center;
  /* jitter/pequena oscilação contínua */
  animation: scribbleJitter 1.4s infinite linear;
  will-change: transform, opacity;
}

/* camadas adicionais de "ruído" pontual que aparecem durante picos do flicker */
#intro-screen::after{
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(0deg, rgba(255,255,255,0.02) 0 2px, transparent 2px 6px),
    linear-gradient(90deg, rgba(255,255,255,0.02) 0 2px, transparent 2px 6px);
  opacity: 0; /* normalmente invisível, aparece nos picos de flicker */
  mix-blend-mode: screen;
  transition: opacity 0.06s linear;
  will-change: opacity;
  animation: noisePulse 0.28s infinite steps(2, end);
}

@keyframes noisePulse {
  0% { opacity: 0.02; }
  50% { opacity: 0.10; }
  100% { opacity: 0.02; }
}


/* texto e hint ficam sobre as camadas */
#intro-screen > * { position: relative; z-index: 2; }

/* hint */
#intro-hint {
  margin-top: 20px;
  font-size: 18px;
  opacity: 0;
  transition: opacity 0.3s;
  color: #ddd;
}

/* flicker: alterna brilho/contraste e ativa a camada ::after rapidamente em certos frames */
@keyframes omoriFlicker {
  0%   { filter: contrast(var(--omori-contrast-high)) brightness(1.05); }
  8%   { filter: contrast(0.95) brightness(0.95); }
  12%  { filter: contrast(1.4) brightness(1.08); }
  20%  { filter: contrast(var(--omori-contrast-low)) brightness(0.92); }
  28%  { filter: contrast(1.2) brightness(1.02); }
  35%  { filter: contrast(0.9) brightness(0.9); }
  45%  { filter: contrast(var(--omori-contrast-high)) brightness(1.1); }
  55%  { filter: contrast(0.9) brightness(0.92); }
  72%  { filter: contrast(1.3) brightness(1.03); }
  85%  { filter: contrast(var(--omori-contrast-low)) brightness(0.9); }
  100% { filter: contrast(1) brightness(1); }
}

/* jitter leve e contínuo pra dar sensação de instabilidade rabiscada */
@keyframes scribbleJitter {
  0%   { transform: translate(0,0) rotate(0deg); }
  20%  { transform: translate(4px, -2px) rotate(-0.3deg); }
  49%  { transform: translate(-3px, 3px) rotate(0.25deg); }
  61%  { transform: translate(1px, -3px) rotate(-0.2deg); }
  85%  { transform: translate(-2px, 1px) rotate(0.15deg); }
  100% { transform: translate(0,0) rotate(0deg); }
}


/* durante picos visuais podemos ativar a camada ::after pulsando sua opacidade via JS (opcional) */
/* Ex.: document.querySelector('#intro-screen').classList.add('peak'); */
#intro-screen.peak::after { opacity: 0.12; }

/* ajustes responsivos (reduzir intensidade em telas pequenas) */
@media (max-width: 600px) {
  :root {
    --omori-scribble-opacity: 0.08;
    --omori-jitter-amount: 1px;
    --omori-flicker-speed: 1.2s;
  }
  #intro-screen { font-size: 20px; }
}


#cenario {
  position: absolute;
  left: 50%;
  top: 55%;
  transform: translate(-50%, -50%);
  width: 25%;
  height: 48%; /* ligeiramente maior que o retângulo */
}

#janela-vazada {
  position: relative;
  width: 100%;
  height: 88%;
  border: 4px solid black;
  background: transparent;
  box-sizing: border-box;
  z-index: 0;
}

#tissues {
  position: absolute;
  bottom: 3%;
  right: 3%;
  width: 2.5vw;                /* menor proporção que antes */
  max-width: 100px;          /* limite superior */
  min-width: 60px;           /* limite inferior */
  cursor: pointer;
  z-index: 10;
}

#sketchbook {
  position: absolute;
  top: 2%;
  right: 2%;
  width: 6vw;                /* ligeiramente menor (por causa do fundo extra) */
  max-width: 90px;
  min-width: 55px;
  cursor: pointer;
  z-index: 10;
}

#computer {
  position: absolute;
  top: 3%;
  left: 28%;                /* um pouco à esquerda do centro */
  width: 3.4vw;               /* proporcional ao resto */
  max-width: 95px;
  min-width: 55px;
  cursor: pointer;
  z-index: 10;
}

#mewo {
  position: absolute;
  bottom: -10%;         /* antes era 0 — agora ele fica levemente abaixo da borda */
  left: 5%;
  width: 6vw;          /* estava 7vw — reduzido um pouco */
  max-width: 85px;     /* também limitamos */
  min-width: 50px;
  cursor: pointer;
  z-index: 10;
}

#agatha {
  position: absolute;
  top: 50%;                     /* centro vertical */
  left: 55%;                    /* entre computer (~35%) e sketchbook (~90%) */
  transform: translateY(-50%);  /* centraliza verticalmente */
  width: 6vw;                   /* mesma proporção do computer */
  max-width: 90px;
  min-width: 55px;
  cursor: pointer;
  z-index: 10;
}

#lamp {
  position: fixed;
  left: 53%;
  transform: translateX(-50%);
  width: 5.5vw;
  max-width: 90px;
  min-width: 55px;
  z-index: 4;
  pointer-events: none;
}

#door {
  position: absolute;
  left: 5%; /* mesma coluna do Mewo */
  cursor: pointer;
  z-index: 10;
  transition: all 0.25s ease-out;
}

/* fade para preto + estática */
#transition-overlay {
  position: fixed;
  inset: 0;
  background: black;
  z-index: 999;
  opacity: 0;
  pointer-events: none;
}
#transition-overlay.fadein {
  animation: fadeIn 2s forwards;
}
#static {
  width: 100%;
  height: 100%;
  background-image: repeating-linear-gradient(transparent 0 2px, rgba(255,255,255,0.08) 2px 4px);
  animation: noise 0.3s infinite;
}
@keyframes fadeIn {
  to { opacity: 1; }
}
@keyframes noise {
  0%,100% { transform: translate(0,0); }
  25% { transform: translate(1px,-1px); }
  50% { transform: translate(-1px,1px); }
  75% { transform: translate(1px,1px); }
}

/* cena do Cap */
#scene-cap {
  position: fixed;
  inset: 0;
  background: white;
  color: black;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  font-family: monospace;
  text-align: center;
  transition: opacity 1s;
}

/* --- CONTAINER GERAL --- */
#dialog-container {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) scaleY(0);
  width: 90%;
  max-width: 1000px;
  height: 180px;
  transform-origin: center bottom;
  transition: transform 0.2s ease-out;
  z-index: 5;
}

#dialog-container.show {
  transform: translateX(-50%) scaleY(1);
}

/* --- CAIXA PRINCIPAL (TEXTO) --- */
#dialog-box {
  position: relative;
  width: 100%;
  height: 100%;
  background-color: black;
  outline: 1px solid black;     /* borda preta externa */
  outline-offset: 2px;          /* pequeno afastamento */
  color: white;
  font-family: 'OmoriFont', Arial, sans-serif;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: flex-start;
  padding: 14px;
  font-size: 36px;
  overflow: hidden;
}

/* Borda preta extra, como o retângulo original */
#dialog-box::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  border: 1px solid black;
  pointer-events: none;
}

/* --- TEXTO --- */
#dialog-text {
  white-space: pre-line;
  word-wrap: break-word;
  overflow-wrap: break-word;
  text-align: left;
  margin-bottom: 10px;
  line-height: 1.4;
}

/* --- CAIXA DE NOME --- */
#name-box {
  position: absolute;
  bottom: 100%;
  left: 0;
  margin-bottom: 8px;
  background-color: black;
  outline: 1px solid black;     /* borda preta externa */
  outline-offset: 2px;          /* pequeno afastamento */
  color: white;
  font-family: 'OmoriFont', Arial, sans-serif;
  box-sizing: border-box;
  height: 40%;
  padding: 0 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  font-size: 2vw;
  letter-spacing: 1px;
  white-space: nowrap;
}

#name-box::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  pointer-events: none;
}

/* --- RETRATO (maior que o retângulo, com borda dupla) --- */
#portrait {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 16px;
  height: 120%;
  aspect-ratio: 1/1;
  background-color: black;
  outline: 1px solid black;     /* borda preta externa */
  outline-offset: 2px;          /* pequeno afastamento */
  color: white;
  font-family: 'OmoriFont', Arial, sans-serif;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: visible;
  z-index: 15;
  transition: transform 0.2s ease-out, opacity 0.3s ease-out;
  opacity: 1;
  transform: translateY(0);
}

#portrait::after {
  content: '';
  position: absolute;
  top: -2px;
  left: -2px;
  width: calc(100% + 4px);
  height: calc(100% + 4px);
  border: 1px solid black;
  pointer-events: none;
}

#portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* --- ANIMAÇÃO ABRIR/FECHAR --- */
@keyframes dialogOpen {
  from { transform: translateX(-50%) scaleY(0); }
  to { transform: translateX(-50%) scaleY(1); }
}
@keyframes dialogClose {
  from { transform: translateX(-50%) scaleY(1); }
  to { transform: translateX(-50%) scaleY(0); }
}

#portrait.show {
  opacity: 1;
  transform: translateY(0);
}

/* --- TELA FINAL (rabiscada como a intro) --- */
#fin-screen {
  position: fixed;
  inset: 0;
  background: black;
  color: white;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;

  font-family: 'OmoriFont', sans-serif;
  z-index: 99999;

  /* mesmo efeito do intro */
  animation: omoriFlicker var(--omori-flicker-speed) infinite;
  overflow: visible;
}

/* camada de rabiscos */
#fin-screen::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  mix-blend-mode: screen;
  opacity: var(--omori-scribble-opacity);

  background-image:
    repeating-linear-gradient(90deg, rgba(255,255,255,0.06) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(60deg, rgba(255,255,255,0.03) 0 1px, transparent 1px 8px),
    repeating-linear-gradient(-30deg, rgba(255,255,255,0.02) 0 1px, transparent 1px 10px),
    radial-gradient(circle at 10% 20%, rgba(255,255,255,0.02), transparent 15%),
    radial-gradient(circle at 80% 80%, rgba(255,255,255,0.015), transparent 20%);
  animation: scribbleJitter 1.4s infinite linear;
}

/* FIN texto */
#fin-text {
  font-size: 6rem;
  letter-spacing: 4px;
  position: relative;
  z-index: 2;
}

/* Hint */
#fin-hint {
  margin-top: 20px;
  font-size: 20px;
  opacity: 0;
  transition: opacity 0.4s;
  color: #ddd;
  position: relative;
  z-index: 2;
}