* { margin:0; padding:0; box-sizing:border-box; }
html,body { width:100%; height:100%; background:#221606; overflow:hidden;
  font-family:"Courier New", ui-monospace, monospace; }
#wrap { position:relative; width:100vw; height:100vh; display:flex; align-items:center; justify-content:center;
  background:radial-gradient(circle at 50% 40%, #3a2a14 0%, #221606 70%); }
#game { image-rendering:pixelated; image-rendering:crisp-edges; background:#63b644;
  width:min(100vw, calc(100vh * 480 / 270)); height:min(100vh, calc(100vw * 270 / 480));
  border:4px solid #6b4a24; border-radius:10px; box-shadow:0 10px 30px rgba(0,0,0,.5); }

/* ---- HUD: barra de madeira ---- */
#hud { position:absolute; top:0; left:0; right:0; display:flex; gap:14px; align-items:center;
  padding:7px 12px; background:#3a2814; color:#ffe9b0; font-size:14px; z-index:5;
  border-bottom:3px solid #23160a; box-shadow:0 2px 8px rgba(0,0,0,.4); flex-wrap:wrap; gap:10px; }
/* Os três textos encolhem antes de a barra quebrar em duas linhas: com dez botões, a
   soma de "R$ 4.000.000 ▪ patrim. R$ 4.297.000" mais data e previsão empurrava os botões
   para uma segunda linha já em 1000px, comendo 35px do mundo. */
#hud-money { color:#8fe06a; font-weight:bold; letter-spacing:.5px;
  white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
#hud-date { color:#ffdca0; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; min-width:0; }
#hud-weather { white-space:nowrap; overflow:hidden; min-width:0; flex-shrink:2; }
/* Com dez botões, o HUD estourava a janela abaixo de ~600px e o 💾 salvar ficava fora da
   tela, sem nenhum aviso. Agora a barra quebra em duas linhas e os botões encolhem. */
.hud-btns { margin-left:auto; display:flex; gap:5px; flex-wrap:wrap; flex-shrink:0; }
@media (max-width: 700px){
  #hud { gap:8px; padding:5px 8px; font-size:12.5px; }
  .hud-btns { margin-left:0; gap:4px; flex:1 1 100%; max-width:100%; justify-content:flex-start; }
  .hud-btns button { padding:3px 6px; font-size:12px; }
}
@media (max-width: 460px){
  #hud { font-size:11.5px; }
  .hud-btns button { padding:2px 5px; font-size:11.5px; }
}
.hud-btns button { background:#5a4024; color:#ffe9b0; border:2px solid #7a5c30; border-bottom:3px solid #4a3418;
  padding:3px 9px; cursor:pointer; font-family:inherit; font-size:13px; border-radius:6px; transition:background .1s; }
.hud-btns button:hover { background:#6d4f2c; }
.hud-btns button:active { transform:translateY(1px); border-bottom-width:2px; }

/* ---- Dica contextual ---- */
#hint { position:absolute; bottom:64px; left:50%; transform:translateX(-50%);
  background:#3a2814; color:#fff3c8; padding:5px 16px; font-size:14px;
  border:2px solid #8a6a34; border-radius:8px; display:none; z-index:5; box-shadow:0 3px 10px rgba(0,0,0,.4); }

/* ---- Log ---- */
#log { position:absolute; left:10px; bottom:10px; width:352px; max-height:150px; overflow:hidden;
  font-size:12px; color:#eafcd6; text-shadow:1px 1px 0 #000; z-index:4; pointer-events:none; }
#log div { background:rgba(26,16,6,.62); margin-top:3px; padding:3px 8px; border-radius:6px;
  border-left:3px solid #6b4a24; }

/* ---- Painéis: madeira escura com moldura dupla (estilo Stardew) ---- */
#panel { position:absolute; inset:0; display:none; align-items:center; justify-content:center;
  background:rgba(10,6,2,.6); z-index:10; }
.pbox { background:#33230f; border:3px solid #caa15e; border-radius:14px; color:#ffe9c8; padding:18px;
  max-width:720px; width:92%; max-height:86vh; overflow:auto; font-size:14px;
  box-shadow:0 0 0 4px #6b4a24, 0 14px 40px rgba(0,0,0,.6); }
.pbox h2 { color:#ffd86e; margin-bottom:10px; font-size:19px; }
.pbox h3 { color:#ffc96e; margin:12px 0 5px; font-size:15px; border-bottom:1px dashed #6b4a24; padding-bottom:3px; }
.pbox table { width:100%; border-collapse:collapse; margin:7px 0; }
.pbox td,.pbox th { border:1px solid #5a4526; padding:4px 7px; font-size:13px; text-align:left; }
.pbox th { background:#4a3418; color:#ffdca0; }
.pbox tr:nth-child(even) td { background:rgba(255,255,255,.03); }
.pbox button { background:#5a9a35; color:#fff; border:2px solid #7ec44e; border-bottom:3px solid #3f7222;
  padding:6px 13px; margin:4px 4px 0 0; cursor:pointer; font-family:inherit; font-size:13px; border-radius:7px; }
.pbox button:hover { background:#6ab040; }
.pbox button:active { transform:translateY(1px); border-bottom-width:2px; }
.pbox button.danger { background:#a5482f; border-color:#d07b58; border-bottom-color:#7a3220; }
.pbox button.gray { background:#4a4a48; border-color:#777; border-bottom-color:#333; }
.pbox button:disabled { opacity:.42; cursor:not-allowed; }
.pbox input,.pbox select { background:#1a1006; color:#ffe9c8; border:2px solid #7a5c30; border-radius:6px;
  padding:5px 7px; font-family:inherit; font-size:13px; width:120px; }
.pbox .row { margin:7px 0; }
.pbox .muted { color:#c2b090; font-size:12px; }
.pbox .good { color:#8fe06a; } .pbox .bad { color:#ff9a8a; } .pbox .warn { color:#ffd76e; }

/* ---- Telas de início e vitória ---- */
#start-overlay,#victory-overlay { position:absolute; inset:0; background:rgba(14,9,3,.94);
  display:flex; align-items:center; justify-content:center; z-index:20; }
.start-box { background:#33230f; border:4px solid #caa15e; border-radius:16px; padding:30px 36px; max-width:560px;
  text-align:center; color:#ffe9c8; box-shadow:0 0 0 5px #6b4a24, 0 18px 50px rgba(0,0,0,.6); }
.start-box h1 { color:#8fe06a; font-size:36px; margin-bottom:6px; text-shadow:2px 2px 0 #23160a; }
.start-box .sub { color:#ffd76e; margin-bottom:12px; }
.start-box .desc { font-size:13px; line-height:1.55; margin-bottom:10px; }
.start-box .save-note { font-size:12px; color:#c2b090; margin-bottom:14px; }
.start-box button { background:#5a9a35; color:#fff; border:2px solid #7ec44e; border-bottom:4px solid #3f7222;
  padding:11px 24px; margin:6px; cursor:pointer; font-family:inherit; font-size:15px; border-radius:9px; }
.start-box button:hover { background:#6ab040; }
.start-box button:active { transform:translateY(1px); border-bottom-width:3px; }
.start-box .controls { margin-top:14px; font-size:12px; color:#c2b090; }
#lineage-list { text-align:left; max-height:220px; overflow:auto; margin:8px 0;
  border:2px solid #5a4526; border-radius:8px; padding:8px; background:#291c0c; }
#lineage-list label { display:block; padding:4px; cursor:pointer; font-size:13px; border-radius:5px; }
#lineage-list label:hover { background:#3f2c14; }
