:root {
  --ink: #3a2a1a;
  --cream: #fffaf0;
  --line: #e7c98f;
  --purple: #9b5de5;
  --green: #2a9d8f;
  --orange: #ff9f1c;
  --red: #e63946;
  --shadow: 0 5px 0 rgba(0,0,0,.15);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; }
body {
  font-family: 'Baloo 2', system-ui, sans-serif; color: var(--ink);
  background: linear-gradient(#ffd6e7, #cdb4db 60%, #a2d2ff);
  -webkit-tap-highlight-color: transparent; user-select: none;
}
button { font-family: inherit; color: inherit; cursor: pointer; }
input { font-family: inherit; font-size: 18px; padding: 6px 12px; border: 3px solid var(--line); border-radius: 12px; color: var(--ink); background: #fff; }
.hidden { display: none !important; }

.btn {
  display: inline-block; text-decoration: none; font-size: 19px; font-weight: 800; padding: 9px 22px; border: none; border-radius: 16px;
  background: var(--orange); color: #fff; box-shadow: var(--shadow); transition: transform .1s;
}
.btn:active { transform: translateY(3px); box-shadow: 0 2px 0 rgba(0,0,0,.15); }
.btn.green { background: var(--green); } .btn.gray { background: #8d99ae; } .btn.purple { background: var(--purple); } .btn.red { background: var(--red); }
.btn.small { font-size: 15px; padding: 5px 14px; border-radius: 12px; }
.btn:disabled { background: #c9c9c9; box-shadow: none; cursor: default; }
.icon-btn { width: 40px; height: 40px; border: none; border-radius: 12px; background: #fff; font-size: 18px; box-shadow: 0 3px 0 rgba(0,0,0,.12); }

/* ---------- telas iniciais ---------- */
.screen { display: none; height: 100%; }
.screen.active { display: block; }
#screen-profiles.active, #screen-create.active { display: grid; place-items: center; overflow: auto; padding: 16px; }
.card { background: var(--cream); border-radius: 30px; padding: 24px; box-shadow: 0 10px 0 rgba(0,0,0,.12); width: min(640px, 100%); text-align: center; }
.card.wide { width: min(960px, 100%); text-align: left; max-height: calc(100vh - 32px); overflow: auto; }
.logo { font-size: 54px; }
h1 { margin: 0; font-size: clamp(34px, 7vw, 54px); color: var(--purple); line-height: 1.05; }
h2 { margin: 0 0 10px; }
.sub { font-size: 19px; margin: 6px 0 16px; }
.profiles { display: flex; flex-wrap: wrap; gap: 12px; justify-content: center; margin-bottom: 18px; }
.profile {
  position: relative; width: 128px; background: #fff; border-radius: 20px; border: 4px solid transparent; padding: 8px 6px; box-shadow: var(--shadow);
}
.profile:hover { border-color: var(--purple); }
.profile svg { width: 70px; height: 105px; }
.profile .pname { font-weight: 800; font-size: 17px; }
.profile .pmeta { font-size: 13px; opacity: .75; }
.profile .pdel { position: absolute; top: -8px; right: -8px; width: 26px; height: 26px; border-radius: 50%; border: none; background: var(--red); color: #fff; font-size: 13px; }
.empty { opacity: .7; }
.row-btns { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 14px; }
.name-row { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; margin: 10px 0; }
.import { background: #fff; border-radius: 16px; padding: 8px 12px; margin-bottom: 8px; }
.import-title { font-weight: 800; }
.import-list { display: flex; gap: 6px; flex-wrap: wrap; }
.import-list button { background: #f8f1ff; border: 3px solid transparent; border-radius: 14px; padding: 2px 8px; font-weight: 700; display: flex; flex-direction: column; align-items: center; }
.import-list button:hover { border-color: var(--purple); }
.import-list svg { width: 40px; height: 60px; }

/* editor de avatar */
.ae { display: grid; grid-template-columns: 200px 1fr; gap: 16px; }
.ae-preview { display: grid; place-items: center; background: linear-gradient(#bde0fe, #a8e6a1); border-radius: 20px; min-height: 260px; }
.ae-preview svg { width: 170px; height: 255px; }
.ae-row { margin-bottom: 8px; }
.ae-label { font-weight: 800; }
.ae-chips { display: flex; flex-wrap: wrap; gap: 5px; }
.ae-chip { border: 3px solid var(--line); background: #fff; border-radius: 12px; padding: 1px 9px; font-size: 14px; font-weight: 700; }
.ae-chip.sel { border-color: var(--purple); background: #f3e8ff; }
.ae-swatch { width: 30px; height: 30px; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); padding: 0; }
.ae-swatch.sel { box-shadow: 0 0 0 4px var(--purple); }

/* ---------- jogo ---------- */
#game { position: relative; }
#cv { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

.hud-left { position: absolute; top: 10px; left: 10px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; max-width: 300px; }
.me { display: flex; align-items: center; gap: 8px; background: rgba(255,250,240,.94); border-radius: 18px; padding: 4px 12px 4px 4px; box-shadow: var(--shadow); }
.me-face { width: 50px; height: 50px; border-radius: 50%; background: linear-gradient(#bde0fe, #a8e6a1); overflow: hidden; position: relative; flex: none; }
.me-face svg { width: 100%; height: 100%; display: block; }
.me-info b { font-size: 17px; }
.lvl { font-size: 13px; font-weight: 700; margin-top: -3px; }
.xpbar { width: 110px; height: 8px; background: #e9e1d3; border-radius: 4px; overflow: hidden; }
.xpbar i { display: block; height: 100%; background: linear-gradient(90deg, #ffbe0b, #fb8500); width: 0; transition: width .4s; }
.quest-mini { background: rgba(255,250,240,.9); border-radius: 14px; padding: 6px 10px; font-size: 13px; font-weight: 600; box-shadow: var(--shadow); }
.quest-mini div { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quest-mini .done { text-decoration: line-through; opacity: .55; }

.hud-right { position: absolute; top: 10px; right: 10px; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.pill { background: rgba(255,250,240,.94); border-radius: 14px; padding: 2px 12px; font-weight: 800; font-size: 18px; box-shadow: var(--shadow); }
.coins b { color: #c77d00; }
.coins.bump { animation: bump .4s; }
#minimap { width: 160px; height: 107px; border-radius: 14px; border: 3px solid #fff; box-shadow: var(--shadow); cursor: pointer; }

.bottom-bar {
  position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); display: flex; gap: 6px;
  background: rgba(255,250,240,.94); border-radius: 22px; padding: 6px; box-shadow: var(--shadow);
}
.bottom-bar button {
  border: none; background: #fff; border-radius: 16px; width: 64px; padding: 4px 0 2px; font-size: 12px; font-weight: 800;
  display: flex; flex-direction: column; align-items: center; box-shadow: 0 3px 0 rgba(0,0,0,.1);
}
.bottom-bar button span { font-size: 24px; line-height: 1.1; }
.bottom-bar button:active { transform: translateY(2px); }

.action {
  position: absolute; right: 16px; bottom: 90px; border: none; border-radius: 22px; padding: 12px 22px; font-size: 20px; font-weight: 800;
  background: var(--purple); color: #fff; box-shadow: 0 6px 0 #6a3fb0; animation: pulse 1.4s ease-in-out infinite;
}

.sheet {
  position: absolute; left: 50%; bottom: 88px; transform: translateX(-50%); width: min(560px, calc(100% - 20px));
  background: var(--cream); border-radius: 22px; padding: 12px; box-shadow: 0 8px 0 rgba(0,0,0,.15); z-index: 5;
}
.sheet-title { font-weight: 800; margin-bottom: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chips button { border: 3px solid var(--line); background: #fff; border-radius: 14px; padding: 2px 10px; font-weight: 700; font-size: 15px; }
.chips.emojis button { font-size: 22px; padding: 0 6px; }
.chat-form { display: flex; gap: 6px; }
.chat-form input { flex: 1; min-width: 0; }

/* ---------- janelas ---------- */
.overlay { position: fixed; inset: 0; background: rgba(30,20,40,.5); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 10px; }
.panel {
  background: var(--cream); border-radius: 26px; width: min(760px, 100%); max-height: calc(100vh - 20px); display: flex; flex-direction: column;
  box-shadow: 0 10px 0 rgba(0,0,0,.18); animation: popIn .2s;
}
.panel-head { display: flex; align-items: center; gap: 10px; padding: 12px 14px 6px 18px; }
.panel-title { flex: 1; font-size: 24px; font-weight: 800; }
.panel-body { padding: 4px 18px 18px; overflow: auto; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; flex-wrap: wrap; }
.tabs button { border: none; border-radius: 12px; padding: 4px 14px; font-weight: 800; font-size: 16px; background: #efe6d6; }
.tabs button.sel { background: var(--purple); color: #fff; }
.grid-items { display: grid; grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); gap: 10px; }
.item {
  background: #fff; border-radius: 18px; padding: 8px; text-align: center; border: 3px solid transparent; box-shadow: 0 3px 0 rgba(0,0,0,.08);
  display: flex; flex-direction: column; align-items: center; gap: 2px;
}
.item .ie { font-size: 42px; line-height: 1.15; }
.item .iname { font-weight: 800; font-size: 15px; line-height: 1.1; }
.item .imeta { font-size: 13px; opacity: .75; }
.item .btn { margin-top: 4px; }
.item.locked { opacity: .55; }
.item.owned { border-color: var(--green); }
.note { background: #fff3c4; border-radius: 12px; padding: 6px 12px; margin-bottom: 10px; font-weight: 600; }
.npc-talk { display: flex; gap: 14px; align-items: flex-start; }
.npc-talk .portrait { flex: none; width: 110px; height: 165px; background: linear-gradient(#ffd6e7, #cdb4db); border-radius: 18px; display: grid; place-items: center; }
.npc-talk .portrait svg { width: 100px; height: 150px; }
.speech { background: #fff; border-radius: 16px; padding: 10px 14px; font-size: 18px; font-weight: 600; position: relative; }
.hearts { font-size: 18px; letter-spacing: 1px; margin: 4px 0; }
.quest-list { display: flex; flex-direction: column; gap: 8px; }
.quest { background: #fff; border-radius: 14px; padding: 8px 12px; display: flex; align-items: center; gap: 10px; }
.quest .qtext { flex: 1; font-weight: 700; }
.quest .qbar { width: 120px; height: 10px; background: #eee; border-radius: 5px; overflow: hidden; }
.quest .qbar i { display: block; height: 100%; background: var(--green); }
.quest.done { background: #d8f3dc; }
.menu-list { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.menu-list .btn { text-align: center; }

/* pesca */
.fish-scene { position: relative; height: 300px; border-radius: 20px; overflow: hidden; background: linear-gradient(#bde0fe 0 30%, #48cae4 30%, #0077b6); touch-action: none; }
.fish-scene .pier { position: absolute; left: 0; bottom: 0; width: 34%; height: 70%; background: repeating-linear-gradient(90deg, #a47148 0 22px, #8b5e3c 22px 25px); border-top-right-radius: 10px; }
.fish-scene .fisher { position: absolute; left: 10%; bottom: 60%; width: 70px; height: 105px; }
.fish-scene .fisher svg { width: 100%; height: 100%; }
.fish-scene .rod { position: absolute; left: calc(10% + 48px); bottom: calc(60% + 50px); width: 4px; height: 90px; background: #5c3a21; transform-origin: bottom center; transform: rotate(50deg); border-radius: 2px; }
.fish-scene .line { position: absolute; height: 2px; background: rgba(255,255,255,.8); transform-origin: left center; }
.bobber { position: absolute; width: 22px; height: 22px; border-radius: 50%; background: radial-gradient(circle at 50% 35%, #fff 0 35%, var(--red) 36%); transform: translate(-50%, -50%); transition: left .6s ease-out, top .6s cubic-bezier(.3,-0.6,.6,1); }
.bobber.bob { animation: bobber 1.4s ease-in-out infinite; }
.bobber.bite { animation: bite .25s ease-in-out infinite; }
.excl { position: absolute; font-size: 40px; font-weight: 900; color: var(--red); transform: translate(-50%, -150%); animation: pulse .3s infinite; }
.fish-status { text-align: center; font-size: 20px; font-weight: 800; margin: 10px 0; min-height: 32px; }
.reel { position: relative; height: 54px; background: #caf0f8; border-radius: 27px; border: 4px solid #fff; margin: 8px 0; overflow: hidden; }
.reel .zone { position: absolute; top: 0; bottom: 0; background: rgba(42,157,143,.55); border-radius: 22px; }
.reel .rfish { position: absolute; top: 50%; font-size: 34px; transform: translate(-50%, -50%); }
.progress { height: 14px; background: #eee; border-radius: 7px; overflow: hidden; }
.progress i { display: block; height: 100%; background: linear-gradient(90deg, #ffbe0b, #2a9d8f); width: 30%; }
.fish-btn { display: block; margin: 10px auto 0; font-size: 24px; padding: 12px 40px; touch-action: none; }

/* ---------- casa ---------- */
.house { position: fixed; inset: 0; z-index: 15; background: #3d2c52; display: flex; flex-direction: column; }
.house-head { display: flex; align-items: center; gap: 10px; padding: 8px 14px; background: var(--cream); flex-wrap: wrap; }
.house-title { flex: 1; font-size: 22px; font-weight: 800; }
.house-tools { display: flex; gap: 6px; flex-wrap: wrap; }
.house-colors { display: flex; gap: 8px; padding: 8px 14px; background: #fff3c4; flex-wrap: wrap; }
.house-colors button { width: 36px; height: 36px; border-radius: 10px; border: 3px solid #fff; box-shadow: 0 0 0 2px var(--line); }
.room-wrap { flex: 1; display: grid; place-items: center; padding: 10px; min-height: 0; }
.room {
  position: relative; aspect-ratio: 10 / 7; width: min(100%, calc((100vh - 230px) * 10 / 7)); border-radius: 18px; overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,.4); touch-action: none;
}
.room .wall { position: absolute; left: 0; right: 0; top: 0; height: 28.6%; }
.room .wall::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 10px; background: rgba(0,0,0,.15); }
.room .floor { position: absolute; left: 0; right: 0; bottom: 0; top: 28.6%; }
.room .floor::before { content: ''; position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(0,0,0,.06) 0 1px, transparent 1px 10%), repeating-linear-gradient(0deg, rgba(0,0,0,.06) 0 1px, transparent 1px 20%); }
.room .window { position: absolute; top: 4%; width: 13%; height: 18%; background: linear-gradient(#a2d2ff, #e0f2ff); border: 5px solid #fff; border-radius: 8px; }
.furn {
  position: absolute; width: 10%; height: 14.28%; display: grid; place-items: center; font-size: clamp(26px, 5.2vw, 58px); line-height: 1;
  cursor: grab; touch-action: none; filter: drop-shadow(0 4px 2px rgba(0,0,0,.25)); transition: left .15s, top .15s;
}
.furn.dragging { transition: none; z-index: 50; transform: scale(1.2); cursor: grabbing; }
.furn.sel { outline: 3px dashed #fff; border-radius: 10px; }
.room .resident { position: absolute; width: 10%; aspect-ratio: 2/3; transform: translate(-50%, -88%); transition: left 1.6s ease-in-out, top 1.6s ease-in-out; pointer-events: none; z-index: 30; }
.room .resident svg { width: 100%; height: 100%; }
.room .rpet { position: absolute; font-size: clamp(22px, 3.6vw, 40px); transform: translate(-50%, -80%); transition: left 1.9s ease-in-out, top 1.9s ease-in-out; pointer-events: none; z-index: 29; }
.room .cell-hl { position: absolute; width: 10%; height: 14.28%; background: rgba(255,255,255,.35); border: 2px dashed #fff; border-radius: 8px; pointer-events: none; }
.furn-menu { position: absolute; z-index: 60; transform: translate(-50%, -100%); display: flex; gap: 4px; }
.house-inv { background: var(--cream); padding: 8px 12px 12px; }
.house-inv-title { font-weight: 800; font-size: 14px; margin-bottom: 4px; }
.house-inv-list { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 4px; min-height: 64px; }
.inv-furn { flex: none; width: 64px; height: 64px; border-radius: 14px; background: #fff; display: grid; place-items: center; font-size: 34px; position: relative; touch-action: none; cursor: grab; box-shadow: 0 3px 0 rgba(0,0,0,.1); }
.inv-furn b { position: absolute; right: 3px; bottom: 0; font-size: 13px; background: var(--purple); color: #fff; border-radius: 8px; padding: 0 5px; }
.drag-ghost { position: fixed; z-index: 100; font-size: 48px; pointer-events: none; transform: translate(-50%, -50%) scale(1.1); filter: drop-shadow(0 6px 4px rgba(0,0,0,.3)); }

/* ---------- avisos ---------- */
#toasts { position: fixed; left: 50%; top: 70px; transform: translateX(-50%); z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 6px; pointer-events: none; }
.toast { background: rgba(58,42,26,.92); color: #fff; padding: 8px 18px; border-radius: 16px; font-weight: 700; font-size: 17px; animation: toastIn .3s, toastOut .4s 2.6s forwards; max-width: 90vw; text-align: center; }
.toast.gold { background: linear-gradient(90deg, #f4a300, #fb8500); }
.toast.purple { background: var(--purple); }

@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.06); } }
@keyframes popIn { from { transform: scale(.85); opacity: 0; } to { transform: scale(1); opacity: 1; } }
@keyframes toastIn { from { transform: translateY(-20px); opacity: 0; } }
@keyframes toastOut { to { opacity: 0; transform: translateY(-10px); } }
@keyframes bump { 50% { transform: scale(1.2); } }
@keyframes bobber { 0%,100% { margin-top: 0; } 50% { margin-top: 4px; } }
@keyframes bite { 0%,100% { margin-top: 0; } 50% { margin-top: 12px; } }

@media (max-width: 700px) {
  .ae { grid-template-columns: 1fr; }
  .ae-preview { min-height: 200px; } .ae-preview svg { width: 120px; height: 180px; }
  .quest-mini { display: none; }
  #minimap { width: 110px; height: 74px; }
  .bottom-bar button { width: 54px; font-size: 11px; }
  .action { bottom: 84px; right: 10px; font-size: 17px; padding: 10px 16px; }
  .npc-talk .portrait { width: 80px; height: 120px; } .npc-talk .portrait svg { width: 72px; height: 108px; }
}
