* { box-sizing: border-box; }
.slots { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.slot { display: grid; justify-items: center; align-content: start; padding: 5px 3px; }
.slot:disabled { opacity: 1; cursor: default; }
.slot span { font-size: 26px; }
.slot small { font-size: 10px; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #1d1838; font: 600 15px system-ui, sans-serif; color: #332552; }
canvas { position: fixed; inset: 0; touch-action: none; }
button { font: inherit; font-weight: 800; color: inherit; border: 2px solid #b79a62; border-radius: 12px; background: #fff7e2; min-height: 40px; padding: 6px 12px; cursor: pointer; }
button:disabled { opacity: .45; cursor: default; }
.card, .sheet { background: rgba(255, 247, 226, .95); border: 3px solid #b79a62; border-radius: 14px; box-shadow: 0 6px 18px rgba(0, 0, 0, .25); }
header { position: fixed; inset: 8px 8px auto; display: flex; gap: 8px; align-items: flex-start; pointer-events: none; z-index: 2; }
header > * { pointer-events: auto; }
.vitals { width: 190px; padding: 7px 9px; }
.bar { position: relative; height: 15px; margin-top: 4px; border-radius: 8px; background: #4a3d5c; overflow: hidden; }
.bar i { position: absolute; inset: 0 auto 0 0; }
.bar span { position: relative; display: block; text-align: center; font-size: 11px; line-height: 15px; color: #fff; text-shadow: 0 1px 2px #000; }
.hp i { background: #e4556b; } .en i { background: #3d8fe0; } .xp i { background: #f0b429; } .xp { height: 6px; }
.tracker { max-width: 330px; padding: 7px 11px; }
.tracker small { display: block; text-transform: uppercase; font-size: 11px; color: #7a5d9c; }
nav { margin-left: auto; display: grid; gap: 6px; }
#controls { position: fixed; inset: auto 10px max(10px, env(safe-area-inset-bottom)); display: flex; justify-content: space-between; align-items: flex-end; pointer-events: none; z-index: 2; }
#stick { position: relative; width: 118px; height: 118px; border-radius: 50%; background: rgba(255, 247, 226, .4); border: 3px solid #fff; pointer-events: auto; touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px; border-radius: 50%; background: #ff7d9c; border: 3px solid #fff; }
.actions { display: grid; grid-template-columns: repeat(3, 66px); gap: 7px; pointer-events: auto; }
.actions button { position: relative; height: 62px; padding: 2px; font-size: 22px; line-height: 1; overflow: hidden; }
.actions small { display: block; font-size: 10px; }
.actions b { position: absolute; inset: 0; display: grid; place-items: center; background: rgba(30, 20, 60, .65); color: #fff; }
#attack { background: #ffd166; }
#talk { position: fixed; left: 50%; bottom: 160px; transform: translateX(-50%); z-index: 3; background: #ffe39a; white-space: nowrap; }
#toast { position: fixed; left: 50%; top: 108px; transform: translateX(-50%); z-index: 6; margin: 0; max-width: 90vw; width: max-content; text-align: center; color: #fff; background: rgba(35, 25, 70, .9); border-radius: 20px; padding: 8px 16px; pointer-events: none; opacity: 0; transition: opacity .25s; }
#toast.on { opacity: 1; }
#panel, #start { position: fixed; inset: 0; display: grid; place-items: center; padding: 12px; background: rgba(20, 12, 45, .5); z-index: 5; }
#start { background: linear-gradient(#251e55, #7a579e 60%, #f0a0ad); }
.sheet { position: relative; width: min(520px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 16px; }
.sheet h1, .sheet h2 { margin: 0 44px 10px 0; }
.sheet h1 small { display: block; color: #a0527c; font-size: 16px; }
#close { position: absolute; right: 10px; top: 10px; }
.row { display: flex; gap: 10px; align-items: center; justify-content: space-between; border-top: 1px solid #dcc797; padding: 9px 0; }
.row p { margin: 0; flex: 1; }
.row small { display: block; font-weight: 600; color: #6b5a80; }
.row div { display: flex; flex-wrap: wrap; gap: 5px; justify-content: flex-end; }
.up { color: #18803b; } .down { color: #b52b3c; }
h3 { margin: 12px 0 2px; }
label { display: block; }
input { width: 100%; font: inherit; padding: 9px; border-radius: 10px; border: 2px solid #b79a62; }
#avatars { display: grid; grid-template-columns: repeat(auto-fill, minmax(62px, 1fr)); gap: 6px; margin: 10px 0; }
#avatars button { padding: 3px; height: 82px; }
#avatars img { max-width: 100%; max-height: 70px; }
#avatars .on { outline: 4px solid #f0a020; }
#play { width: 100%; background: #ff7d9c; color: #fff; }
#erase { width: 100%; margin-top: 8px; }
@media (max-width: 620px) {
  .vitals { width: 156px; }
  #coins { font-size: 11px; white-space: nowrap; }
  header { flex-wrap: wrap; }
  .tracker { order: 3; max-width: 100%; font-size: 13px; }
  nav button { font-size: 12px; min-height: 36px; padding: 4px 8px; }
  #stick { width: 100px; height: 100px; }
  .actions { grid-template-columns: repeat(3, 58px); }
  #talk { bottom: 170px; }
  #toast { top: 215px; font-size: 13px; }
}

.side { margin-left: auto; display: grid; gap: 6px; justify-items: end; }
#mapButton { padding: 4px; display: grid; gap: 2px; }
#minimap { position: static; width: 168px; height: 114px; border-radius: 8px; background: #241c42; }
#mapButton span { font-size: 12px; }
#count { margin-top: 5px; font-size: 13px; }
.region.here { background: #ffe9a8; border-radius: 8px; padding-left: 8px; }
@media (max-width: 620px) {
  #minimap { width: 108px; height: 74px; }
  #mapButton span { font-size: 10px; }
}
#coins { white-space: nowrap; font-size: 12px; }

/* ---------- tela limpa ---------- */
.card { border-width: 2px; box-shadow: 0 3px 10px rgba(0, 0, 0, .2); }
.vitals { width: 128px; padding: 5px 7px; background: rgba(255, 247, 226, .85); }
.vitals strong { display: block; font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vitals .bar { height: 8px; margin-top: 3px; }
.vitals .bar span, #coins { display: none; }
.vitals .xp { height: 3px; }
.tracker { max-width: 250px; padding: 5px 10px; font-size: 13px; background: rgba(255, 247, 226, .85); }
.tracker small { display: none; }
#count { margin-top: 3px; }
#count .bar { height: 4px; margin: 0; }
.side nav { display: flex; justify-content: flex-end; }
.side nav button { width: 40px; min-height: 40px; padding: 0; font-size: 20px; }
#mapButton { position: relative; padding: 2px; min-height: 0; justify-self: end; }
#minimap { width: 104px; height: 70px; display: block; }
#mapButton span { position: absolute; right: 4px; bottom: 3px; padding: 0 5px; border-radius: 8px; background: rgba(30, 20, 60, .75); color: #fff; font-size: 10px; }
.actions { display: flex; align-items: flex-end; gap: 6px; }
.actions button { width: 52px; height: 52px; border-radius: 50%; opacity: .92; }
.actions #attack { width: 68px; height: 68px; font-size: 28px; }
.actions #attack small { display: none; }
#potion small { position: absolute; right: 7px; bottom: 5px; font-weight: 900; }
#stick { width: 96px; height: 96px; opacity: .65; }
#knob { width: 42px; height: 42px; margin: -21px; }
/* Com mouse e teclado, o controle redondo nao e necessario. */
@media (hover: hover) and (pointer: fine) {
  #stick { visibility: hidden; }
}
@media (max-width: 620px) {
  header { flex-wrap: nowrap; }
  .vitals { width: 104px; }
  .tracker { order: 0; flex: 1; min-width: 0; font-size: 11px; }
  .side nav button { width: 34px; min-height: 34px; font-size: 17px; }
  #minimap { width: 76px; height: 52px; }
  .actions { flex-wrap: wrap; justify-content: flex-end; max-width: 190px; }
  #toast { top: 118px; }
}
#nameError { margin: 4px 0 0; color: #b52b3c; font-weight: 800; }
#nameError:empty, #saveInfo:empty { display: none; }
.slots { grid-template-columns: repeat(4, 1fr); }
@media (max-width: 620px) {
  .side nav { display: grid; grid-template-columns: repeat(2, 44px); }
  .side nav button { width: 44px; min-height: 44px; font-size: 21px; }
}
