/* Uma paleta curta concentra a aparência do jogo. */
:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #f7f8fa;
  background: #000;
  --painel: #141b25;
  --borda: #69737e;
  --suave: #c8d1dc;
  --ouro: #ffd581;
  --verde: #90e9c5;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  min-height: 100vh;
  margin: 0;
  padding: 12px;
  background: #000;
}
/* Até no desktop, o jogo tem a largura aproximada de um celular. */
.app {
  display: flex;
  flex-direction: column;
  width: min(100%, 390px);
  /* No computador, mantém altura de tela de celular (aprox. 9:19,5). */
  aspect-ratio: 9 / 19.5;
  margin: auto;
  padding: 13px;
  border: 4px solid var(--borda);
  border-radius: 22px;
  /* A textura escolhida cobre a tela do jogo; o exterior fica preto. */
  background: linear-gradient(#090d15a0, #090d15c0), var(--fundo-app, url("imagens/fundos/fundo-pedra.webp")) center / cover;
  box-shadow: inset 1px 1px 0 #a5abb4, inset -1px -1px 0 #303843, 0 12px 30px #0009;
}
/* O menu ocupa toda a moldura, para a fotografia aparecer de ponta a ponta. */
.app.em-inicio { display: flex; flex-direction: column; padding: 0; overflow: hidden; }
.tela-inicial {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 24px;
  padding: 27px 22px 28px;
  background-color: #101923;
  background-position: center;
  background-size: cover;
  text-align: center;
}
.inicio-titulo h1 {
  color: #fff9e9;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 10vw, 3.25rem);
  font-weight: 700;
  line-height: 1.05;
  letter-spacing: -.055em;
  text-shadow: 0 2px 12px #000, 0 5px 26px #000;
}
.inicio-titulo p { margin: 14px 0 0; font-size: .86rem; text-shadow: 0 2px 8px #000; }
.inicio-acoes { display: grid; gap: 11px; padding: 16px; border: 1px solid #ffffff55; border-radius: 10px; background: #07111ac9; box-shadow: 0 8px 25px #0009; }
.inicio-acoes button { min-height: 48px; font-size: .94rem; }
.definicoes-icones { position: absolute; width: 0; height: 0; overflow: hidden; }
.botao-icone { display: inline-grid; place-items: center; min-width: 32px; min-height: 32px; padding: 4px; border: 1px solid var(--borda); border-radius: 5px; background: #1a2532; color: #e8edf5; font: inherit; font-size: 1.2rem; cursor: pointer; }
.botao-icone svg { display: block; width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.som-menu { position: absolute; top: 15px; right: 15px; z-index: 1; background: #08131aa8; }

/* Cabeçalho baixo: a versão aparece apenas no rodapé. */
.cabecalho { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: center; min-height: 34px; margin-bottom: 8px; }
.cabecalho h1 { grid-column: 2; text-align: center; }
.cabecalho-acoes { grid-column: 3; display: flex; align-items: center; justify-self: end; gap: 3px; }
.cabecalho-ajuda { grid-column: 1; justify-self: start; font-size: 1rem; font-weight: 800; }
h1 { margin: 0; color: #fff; font-family: Georgia, "Times New Roman", serif; font-size: 1.42rem; letter-spacing: -.055em; }
.navegacao { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 4px; margin-bottom: 9px; }
.navegacao button { min-width: 0; min-height: 34px; padding: 4px 2px; border: 2px solid var(--borda); border-radius: 4px; background: var(--painel); color: #edf1f7; font: inherit; font-size: .78rem; font-weight: 700; cursor: pointer; }
.navegacao button[aria-current="page"] { border-color: var(--ouro); background: #30281f; color: var(--ouro); }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, .rolagem-tabela:focus-visible { outline: 2px solid var(--ouro); outline-offset: 2px; }

/* Métricas à esquerda e uma cena 3:4 à direita, dentro da moldura estreita. */
.visao-personagem { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, .93fr); gap: 7px; align-items: start; }
.indicadores { min-width: 0; display: grid; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(6, 32px); gap: 4px; align-content: start; }
.indicador { min-width: 0; min-height: 0; padding: 3px 5px; border: 2px solid var(--borda); border-radius: 5px; background: linear-gradient(145deg, #243140, #151d28); box-shadow: inset 1px 1px 0 #919ba655; display: flex; align-items: center; justify-content: space-between; gap: 3px; }
.indicador span { color: var(--suave); font-size: .69rem; line-height: 1.12; }
.indicador:nth-child(4) span { font-size: .63rem; }
.indicador output { min-width: 0; overflow-wrap: anywhere; color: #fff; font-size: .77rem; font-weight: 800; font-variant-numeric: tabular-nums; line-height: 1.12; text-align: right; }
.indicador:nth-child(2) output { color: var(--verde); }
.indicador:nth-child(5) output { color: var(--ouro); }
.indicador:nth-child(6) output { color: var(--verde); }
.indicador output.negativo { color: #ff9a9a; }
.retrato-classe { min-width: 0; margin: 0; padding: 3px; border: 3px solid var(--borda); border-radius: 6px; background: #111823; box-shadow: inset 1px 1px 0 #a6adb688; align-self: start; }
.retrato-classe img { display: block; width: 100%; height: auto; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 2px; background: #27323e; }

/* A escolha de personagem entra entre o menu e a introdução. */
.escolha-personagem { padding: 10px 2px; }
.escolha-personagem p { color: var(--suave); font-size: .84rem; line-height: 1.4; }
.opcoes-personagem { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin: 6px 0 13px; }
.opcao-personagem { display: grid; gap: 7px; width: 100%; padding: 6px; border: 2px solid var(--borda); border-radius: 7px; background: var(--painel); color: #fff; cursor: pointer; font: inherit; font-size: .85rem; font-weight: 700; }
.opcao-personagem:hover, .opcao-personagem:focus-visible { border-color: var(--ouro); }
.opcao-personagem img { display: block; width: 100%; height: clamp(130px, 25dvh, 215px); object-fit: contain; object-position: center bottom; border-radius: 3px; background: transparent; }
.escolha-personagem { flex: 1; }
.escolha-personagem h2 { margin: 4px 0; }
.opcoes-dificuldade { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin: 6px 0 12px; }
.opcao-dificuldade { min-width: 0; padding: 4px; border: 2px solid var(--borda); border-radius: 6px; background: var(--painel); color: #fff; font: inherit; font-size: .73rem; font-weight: 700; cursor: pointer; }
.opcao-dificuldade img { display: block; width: 100%; height: clamp(48px, 10dvh, 79px); object-fit: cover; border-radius: 3px; margin-bottom: 4px; }
.opcao-dificuldade small { font-size: .62rem; color: var(--suave); }
.opcao-dificuldade:hover, .opcao-dificuldade:focus-visible { border-color: var(--ouro); }
.opcao-dificuldade[aria-pressed="true"], .opcao-personagem[aria-pressed="true"] { border-color: var(--ouro); box-shadow: 0 0 0 2px #ffd58155; background: #393029; }
.botoes-escolha { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }

/* Bordas cinzas com leve brilho dão aspecto de moldura metálica. */
.cartao { margin-top: 8px; padding: 10px; border: 3px solid var(--borda); border-radius: 6px; background: #151d28e8; box-shadow: inset 1px 1px 0 #a6adb688, inset -1px -1px 0 #303741, 0 2px 0 #040609; }
.linha-titulo { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h2 { margin: 0 0 8px; color: var(--ouro); font-size: 1.02rem; }
.linha-titulo h2 { margin-bottom: 6px; }
h3 { margin: 22px 0 10px; color: #f5f7fa; font-size: 1rem; }
label { display: block; margin: 2px 0 4px; font-size: .83rem; font-weight: 700; }
select, input { width: 100%; min-height: 35px; padding: 5px 7px; border: 2px solid var(--borda); border-radius: 4px; background: #0a1018; color: #fff; font: inherit; font-size: .87rem; }
#area-acao h2 { text-align: center; }
.controle-com-ajuda { display: grid; grid-template-columns: minmax(0, 1fr) 35px; gap: 6px; align-items: center; margin-bottom: 6px; }
.ajuda-escolha { width: 35px; height: 35px; font-weight: 800; }
.resumo-escolhas { display: grid; gap: 4px; margin-top: 9px; }
.resumo-escolhas div { display: flex; align-items: center; justify-content: space-between; gap: 5px; padding: 4px 6px; border: 1px solid var(--borda); border-radius: 4px; background: #0d1622; font-size: .72rem; }
.resumo-escolhas span { max-width: 68%; }
.resumo-escolhas output { text-align: right; color: var(--ouro); font-weight: 800; font-variant-numeric: tabular-nums; }
.passar-ano { width: 100%; min-height: 42px; margin: 9px 0 0; }
.passar-ano.atencao-emprestimo { border-color: #ffd19b; background: #a14a25; }
.passar-ano.atencao-emprestimo:hover { background: #b9582c; }
.passar-ano:disabled { border-color: #555b62; background: #252a30; color: #a5acb5; cursor: not-allowed; opacity: .7; }
.area-projecao h2 { text-align: center; }
.area-projecao h3 { margin: 11px 0 6px; font-size: .86rem; }
.area-projecao .nota { margin: 5px 0; }
.detalhes-projecao { margin: 4px 0; padding: 6px; border: 1px solid var(--borda); border-radius: 4px; background: #0e1927; }
.detalhes-projecao summary { display: list-item; cursor: pointer; color: var(--suave); font-size: .77rem; font-weight: 700; }
.detalhes-projecao summary output { float: right; margin-left: 3px; color: var(--ouro); font-variant-numeric: tabular-nums; }
.area-projecao output.negativo { color: #ff9a9a; }
.detalhes-projecao .resumo div { padding: 5px 0; font-size: .74rem; }
.detalhes-projecao .resumo div:last-child { border: 0; }
.ajuda-escolhas p, .confirmacao-reinicio p { color: #e2e9f2; font-size: .84rem; line-height: 1.5; }
.ajuda-escolhas button { margin-top: 12px; width: 100%; }
.confirmacao-reinicio button { flex: 1; }
.tela-emprestimo p { font-size: .84rem; line-height: 1.45; }
.tela-emprestimo strong { color: var(--ouro); }
.tela-emprestimo .botoes-ajustes button { flex: 1; }
.tela-emprestimo .declarar-falencia { width: 100%; margin-top: 10px; }
.tela-emprestimo .aviso { margin-top: 12px; }
.botao-emprestimo-confirmar, .botao-perigo { min-height: 38px; padding: 5px 4px; border-radius: 4px; font: inherit; font-size: .79rem; font-weight: 800; cursor: pointer; }
.botao-emprestimo-confirmar { border: 2px solid #ffe4a4; background: #e7bb59; color: #211809; }
.botao-emprestimo-confirmar:hover { background: #f5cd73; }
.botao-perigo { border: 2px solid #e38f8f; background: #882d34; color: #fff; }
.botao-perigo:hover { background: #ac3b42; }
button:disabled { cursor: not-allowed; opacity: .6; }
.aviso-divida { margin-top: 6px; border-left-color: #ff9090; background: #482b2c; color: #ffe4e4; }
.nota { color: var(--suave); font-size: .82rem; line-height: 1.4; }
.primario, .secundario { min-height: 38px; padding: 5px 4px; border-radius: 4px; font: inherit; font-size: .79rem; font-weight: 700; cursor: pointer; }
.primario { border: 2px solid #a7eed0; background: #146b54; color: #fff; }
.primario:hover { background: #198766; }
.secundario { border: 2px solid var(--borda); background: #263545; color: #fff; }
.secundario:hover { background: #35485e; }
.aviso { margin: 6px 0 0; padding: 5px 7px; border-left: 3px solid var(--ouro); background: #342b22; color: #ffe4ab; font-size: .73rem; line-height: 1.3; }
.detalhes { padding: 7px 10px; }
.detalhes summary, .ajustes-saude summary { color: var(--ouro); font-size: .85rem; font-weight: 700; cursor: pointer; }
.detalhes h3 { margin: 12px 0 5px; font-size: .86rem; }
.botao-estatisticas-ano { width: 100%; margin-top: 12px; }
.resumo { margin: 7px 0 0; }
.resumo div { display: flex; justify-content: space-between; gap: 10px; padding: 7px 0; border-bottom: 1px solid var(--borda); font-size: .82rem; }
.resumo dt { color: var(--suave); }
.resumo dd { min-width: 0; margin: 0; overflow-wrap: anywhere; text-align: right; color: #fff; font-weight: 700; font-variant-numeric: tabular-nums; }
.historico { margin: 8px 0 0; padding: 0; list-style: none; }
.historico li { padding: 7px 0; border-top: 1px solid var(--borda); color: #e2e9f2; font-size: .79rem; line-height: 1.35; }
.fim { border-color: var(--ouro); background: #241f1c; }
.fim p { font-size: .85rem; }
.fim .destaque-felicidade-fim { margin: 2px 0 8px; color: var(--ouro); font-size: 1rem; font-weight: 400; }
.fim h3 { margin: 17px 0 4px; color: var(--ouro); }
.imagem-fim { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; border: 2px solid var(--borda); border-radius: 5px; }
.historia-final { color: #f0e8dd; line-height: 1.5; }
.fim .botoes-ajustes button { flex: 1; }
.botao-ranking-fim { width: 100%; margin-top: 16px; }

/* Ranking compacto para caber na mesma largura do jogo. */
#painel-rankings .cartao h3 { margin: 0 0 9px; color: var(--ouro); }
#painel-rankings .cartao p { margin: 5px 0 10px; font-size: .83rem; }
#form-ranking button { width: 100%; margin-top: 10px; }
#mensagem-ranking { min-height: 1.3em; }
.tabela-ranking { table-layout: fixed; }
.tabela-ranking th:first-child { width: 35px; }
.tabela-ranking th:last-child { width: 115px; }
.tabela-ranking td:nth-child(2), .tabela-ranking th:nth-child(2) { text-align: left; white-space: normal; overflow-wrap: anywhere; }
.tabela-ranking td:last-child { color: var(--ouro); font-weight: 800; }

/* Tabelas permanecem dentro da coluna estreita e rolam lateralmente. */
.rolagem-tabela { max-width: 100%; overflow: auto; border: 3px solid var(--borda); border-radius: 5px; }
table { width: 100%; border-collapse: collapse; color: #f6f8fb; font-size: .79rem; font-variant-numeric: tabular-nums; }
th, td { padding: 5px 4px; border: 2px solid #69737e; text-align: right; white-space: nowrap; }
th:first-child, td:first-child { text-align: left; }
thead { background: linear-gradient(#69737e, #39424e); color: #fff; }
tbody tr:nth-child(odd) { background: #202a38; }
tbody tr:nth-child(even) { background: #131c29; }
#painel-estatisticas table { min-width: 3180px; }
.cartao-grafico h3 { margin: 0 0 8px; color: var(--ouro); }
.rolagem-grafico { width: 100%; overflow-x: auto; border: 1px solid var(--borda); border-radius: 4px; background: #0c1521; }
.rolagem-grafico svg { display: block; max-width: none; }
.grafico-grade { stroke: #65717e; stroke-width: 1; }
.grafico-linha { fill: none; stroke: #ffd581; stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.grafico-ponto { fill: #ffe4a4; stroke: #14212e; stroke-width: 1; }
.grafico-rotulo { fill: #d1d8e4; font: 12px system-ui, sans-serif; }
#painel-ajustes .rolagem-tabela:not(.saude-tabela) table { min-width: 460px; }
.campos-gerais { display: grid; gap: 10px; }
.subabas-ajustes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; margin: 12px 0; }
.amostra-fundo { height: 210px; margin-top: 12px; border: 3px solid var(--borda); border-radius: 6px; background: linear-gradient(#090d15a0, #090d15c0), url("imagens/fundos/fundo-pedra.webp") center / cover; }
.voltar-tela-jogo { display: block; width: 100%; margin: 15px 0 5px; }
.subabas-ajustes button { min-height: 35px; border: 2px solid var(--borda); border-radius: 4px; background: var(--painel); color: #fff; font: inherit; font-size: .82rem; font-weight: 700; cursor: pointer; }
.subabas-ajustes button[aria-selected="true"] { border-color: var(--ouro); color: var(--ouro); background: #30281f; }
.campos-gerais label { margin-top: 0; }
#ajustes-classes input { width: 115px; font-size: .8rem; }
#ajustes-classes input[data-felicidade] { width: 70px; }
.ajustes-saude { margin-top: 20px; }
.saude-tabela { max-height: 290px; }
.saude-tabela input { width: 110px; }
.botoes-ajustes { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 18px; }
#mensagem-ajustes { min-height: 1.3em; color: var(--verde); font-size: .82rem; }
.aviso-ajustes { margin: 8px 0 12px; padding: 10px; font-size: .82rem; }
.confirmacao-ajustes { margin-top: 12px; border-color: var(--ouro); background: #30251d; }
.confirmacao-ajustes h3 { margin: 0 0 8px; color: var(--ouro); }
.confirmacao-ajustes p { margin: 0; font-size: .83rem; line-height: 1.4; }
.confirmacao-ajustes .botoes-ajustes { margin-top: 10px; }
.confirmacao-ajustes button { flex: 1; }
.rodape { margin-top: auto; padding-top: 12px; color: #aeb9c7; font-size: .65rem; text-align: center; }
/* A introdução deixa o texto principal primeiro e as dicas logo antes do botão. */
.introducao { display: flex; flex-direction: column; min-height: 650px; padding: 2px 4px 12px; }
.introducao h2 { margin: 1px 0 9px; font-size: 1.3rem; line-height: 1.18; }
.imagem-formatura { display: block; width: 100%; height: auto; aspect-ratio: 4 / 3; object-fit: cover; margin: 0 0 7px; border: 2px solid var(--borda); border-radius: 5px; }
.introducao p { color: #e3eaf3; font-size: .9rem; line-height: 1.5; }
.introducao strong { color: var(--ouro); }
.introducao .nota { font-size: .78rem; }
.cartao-dica { display: grid; grid-template-columns: 32px minmax(0, 1fr) 32px; align-items: center; gap: 7px; min-height: 106px; padding: 9px 7px; margin-top: 18px; }
.cartao-dica p { margin: 0; color: #fff; text-align: center; font-size: .84rem; }
.cartao-dica .botao-icone { width: 32px; height: 32px; min-width: 32px; min-height: 32px; padding: 0; line-height: 1; }
.cartao-dica .botao-icone svg { width: 17px; height: 17px; }
.botoes-introducao { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin: 3px 0 9px; }
.botoes-introducao button { min-height: 44px; }
/* Ajuda em blocos curtos para a leitura na largura de um celular. */
.ajuda > section { padding: 1px 10px 9px; margin-top: 10px; border: 2px solid var(--borda); border-radius: 6px; background: var(--painel); }
.ajuda h3 { margin: 13px 0 7px; color: var(--ouro); }
.ajuda p, .ajuda li { color: #e2e9f2; font-size: .81rem; line-height: 1.48; }
.ajuda ol { padding-left: 20px; }
.ajuda li + li { margin-top: 8px; }
.ajuda table { font-size: .75rem; }
.ajuda th, .ajuda td { padding: 5px 3px; }
.ajuda .botoes-ajustes button { flex: 1; }

@media (max-width: 430px) {
  body { padding: 0; }
  .app { width: 100%; max-width: 100%; min-height: 100vh; min-height: 100dvh; aspect-ratio: auto; border-radius: 0; padding: 8px; }
  .tela-inicial { min-height: calc(100vh - 8px); min-height: calc(100dvh - 8px); }
  .app.em-inicio { min-height: 100vh; min-height: 100dvh; }
  .introducao { min-height: calc(100dvh - 115px); }
}
@media (max-width: 340px) {
  .cabecalho h1 { font-size: 1.18rem; }
  .indicador { padding: 2px 3px; }
  .indicador output { font-size: .7rem; }
  .navegacao button { font-size: .67rem; }
}
