html, body { margin: 0; height: 100%; overflow: hidden; background: #1c2a38; font: 14px/1.35 Georgia, 'Times New Roman', serif; color: #3a2a14; }
* { box-sizing: border-box; }
canvas { position: fixed; inset: 0; width: 100vw; height: 100vh; display: block; touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; }
button { font: inherit; cursor: pointer; border: 1px solid #8a6a3a; background: linear-gradient(#f6ecd2, #e2cfa2); color: #3a2a14; border-radius: 6px; padding: 3px 8px; }
button:hover { background: linear-gradient(#fff6dc, #ecdcb2); }
button:disabled { opacity: 0.5; cursor: default; }
button.on { background: linear-gradient(#e9c060, #cf9f3a); border-color: #6a4a1a; }
.hidden { display: none !important; }

#top { position: fixed; top: 0; left: 0; right: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 4px 12px; padding: 5px 10px;
  background: linear-gradient(#f3e6c4ee, #e2cd9cee); border-bottom: 2px solid #8a6a3a; box-shadow: 0 2px 6px #0005; z-index: 5; }
#top .res { white-space: nowrap; font-weight: bold; }
#top .res small { font-weight: normal; color: #6a5434; }
#top .grow { flex: 1; }
#top .btns { display: flex; gap: 3px; flex-wrap: wrap; }
#top .btns button { padding: 2px 7px; }
#date { font-style: italic; white-space: nowrap; }
.bad { color: #a02010; }

#msgs { position: fixed; left: 50%; transform: translateX(-50%); top: calc(var(--top-h, 44px) + 4px); width: min(440px, calc(100vw - 16px)); pointer-events: none; z-index: 4; display: flex; flex-direction: column; gap: 4px; }
#msgs div { background: #f6ecd2e8; border-left: 4px solid #8a6a3a; padding: 4px 8px; border-radius: 4px; box-shadow: 0 1px 4px #0004; transition: opacity 1s; }
#msgs div.good { border-left-color: #4a9a3a; }
#msgs div.bad { border-left-color: #c03020; }

.panel { position: fixed; right: 8px; top: calc(var(--top-h, 44px) + 8px); width: 300px; max-height: calc(100vh - var(--top-h, 44px) - var(--bottom-h, 130px) - 20px); overflow: auto; z-index: 6;
  background: #f6ecd2f4; border: 2px solid #8a6a3a; border-radius: 8px; padding: 10px 12px; box-shadow: 0 3px 12px #0006; }
.panel h2 { margin: 0 0 4px; font-size: 18px; }
.panel .x { position: absolute; right: 6px; top: 6px; padding: 0 7px; }
.panel .desc { color: #5a4424; font-size: 13px; margin: 2px 0 8px; }
.panel .line { margin: 3px 0; }
.panel .ok { color: #2a7a2a; } .panel .no { color: #a02010; }
.panel .row { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.bar { height: 8px; background: #d8c49a; border-radius: 4px; overflow: hidden; margin: 2px 0 4px; }
.bar i { display: block; height: 100%; }
.god { border-top: 1px solid #c8b080; padding: 6px 0; }
.god:first-of-type { border-top: 0; }
#side { right: auto; left: 8px; width: 340px; }

#toast { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--bottom-h, 130px) + 20px); background: #3a2a14ee; color: #fff3d6; padding: 6px 14px; border-radius: 6px; z-index: 7; opacity: 0; transition: opacity .3s; pointer-events: none; max-width: 90vw; text-align: center; }
#toast.show { opacity: 1; }

#bottom { position: fixed; left: 0; right: 0; bottom: 0; z-index: 5; background: linear-gradient(#e2cd9cee, #d4ba84f4); border-top: 2px solid #8a6a3a; box-shadow: 0 -2px 6px #0005; }
#hint { padding: 4px 10px; font-size: 13px; min-height: 24px; color: #4a3418; }
#hint b { color: #3a2a14; }
#items { display: flex; gap: 5px; overflow-x: auto; padding: 2px 8px 6px; min-height: 58px; }
#items button { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; min-width: 74px; padding: 3px 6px; line-height: 1.15; }
#items button .ic { font-size: 20px; }
#items button .nm { font-size: 12px; }
#items button .co { font-size: 11px; color: #6a5434; }
#tabs { display: flex; gap: 2px; overflow-x: auto; padding: 0 6px 6px; }
#tabs button { flex: 0 0 auto; border-radius: 0 0 6px 6px; padding: 3px 9px; }

.overlay { position: fixed; inset: 0; background: #0b141dcc; display: flex; align-items: center; justify-content: center; z-index: 20; padding: 12px; }
.card { background: #f6ecd2; border: 3px solid #8a6a3a; border-radius: 10px; max-width: 560px; padding: 18px 24px; box-shadow: 0 6px 30px #000a; max-height: 96vh; overflow: auto; }
.card h1 { margin: 0; font-size: 44px; letter-spacing: 6px; text-align: center; color: #6a3a10; font-variant: small-caps; }
.card .sub { text-align: center; font-style: italic; margin-bottom: 10px; color: #8a5a20; }
.card ul { padding-left: 20px; }
.card .keys { font-size: 13px; color: #5a4424; }
.card .row { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 10px; }
button.big { font-size: 17px; padding: 8px 18px; }

@media (max-width: 640px) {
  body { font-size: 13px; }
  #top { gap: 2px 8px; padding: 4px 6px; }
  .panel { left: 6px; right: 6px; width: auto; top: auto; bottom: calc(var(--bottom-h, 150px) + 6px); max-height: 45vh; }
  #side { width: auto; right: 6px; }
  #msgs { top: calc(var(--top-h, 70px) + 4px); }
  #top .lbl { display: none; }
  #items button { min-width: 64px; }
}

/* map views (overlays), legend, city report, minimap */
#views { position: fixed; right: 8px; top: calc(var(--top-h, 44px) + 4px); z-index: 8; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; padding: 8px;
  background: #f6ecd2f6; border: 2px solid #8a6a3a; border-radius: 8px; box-shadow: 0 3px 12px #0006; }
#views .t { grid-column: 1 / -1; font-weight: bold; }
#views button { text-align: left; white-space: nowrap; padding: 4px 8px; }
#legend { position: fixed; left: 8px; bottom: calc(var(--bottom-h, 130px) + 8px); max-width: min(420px, calc(100vw - 220px)); z-index: 4; font-size: 13px;
  background: #f6ecd2ee; border: 1px solid #8a6a3a; border-left: 4px solid var(--vc, #8a6a3a); border-radius: 6px; padding: 4px 8px; box-shadow: 0 1px 4px #0004; }
#legend b { margin-right: 4px; }
#legend button { margin-left: 6px; padding: 0 6px; font-size: 12px; }
#minibox { position: fixed; right: 8px; bottom: calc(var(--bottom-h, 130px) + 8px); z-index: 4; border: 2px solid #8a6a3a; border-radius: 6px; background: #1c3a52; box-shadow: 0 2px 8px #0006; line-height: 0; }
#mini { position: static; width: 176px; height: 88px; cursor: pointer; }
#mini-x { position: absolute; right: 2px; top: 2px; padding: 0 5px; font-size: 12px; line-height: 1.3; opacity: 0.85; }
body.mini-on #info { max-height: calc(100vh - var(--top-h, 44px) - var(--bottom-h, 130px) - 124px); }
body.view-on #side { max-height: calc(100vh - var(--top-h, 44px) - var(--bottom-h, 130px) - 64px); }
.panel h3 { margin: 10px 0 2px; font-size: 15px; border-bottom: 1px solid #c8b080; }
table.rep { width: 100%; border-collapse: collapse; font-size: 13px; }
table.rep td { padding: 1px 3px; }
table.rep td.n { text-align: right; white-space: nowrap; }
table.rep tr.sum td { border-top: 1px solid #c8b080; font-weight: bold; }
.advice { margin: 3px 0; padding: 3px 6px; background: #efe0b8; border-radius: 4px; font-size: 13px; }
.advice.bad { background: #f3d2c0; color: #5a1a08; }
.advice button { padding: 0 6px; font-size: 12px; margin-left: 4px; }
@media (max-width: 1400px) { #top .lbl2 { display: none; } }
@media (max-width: 640px) {
  body.mini-on #info, body.view-on #side { max-height: 45vh; }
  #views { left: 6px; right: 6px; }
  #legend { left: 6px; right: 6px; max-width: none; font-size: 12px; }
  body.mini-on #legend { bottom: calc(var(--bottom-h, 150px) + 86px); }
  #mini { width: 140px; height: 70px; }
}
