/* Critter Garden — neo-skeumorfismo suave, fonte Urbanist */
:root {
  --bg: #e7e9f3;
  --bg2: #dfe2ef;
  --surface: #eceef7;
  --hi: #ffffff;
  --lo: #b9bdd3;
  --ink: #2a2650;
  --ink2: #5c5a83;
  --muted: #8a89a8;
  --lilac: #8c8cf2;
  --lilac-d: #6464d6;
  --red: #e2404d;
  --red-d: #b72634;
  --blue: #3563de;
  --blue-d: #2142a8;
  --gold: #f5b82e;
  --ok: #34b37a;
  --r: 22px;
  --sh: 8px 8px 18px var(--lo), -8px -8px 18px var(--hi);
  --sh-sm: 4px 4px 10px var(--lo), -4px -4px 10px var(--hi);
  --in: inset 4px 4px 9px var(--lo), inset -4px -4px 9px var(--hi);
  --in-sm: inset 2px 2px 5px var(--lo), inset -2px -2px 5px var(--hi);
  font-family: "Urbanist", system-ui, sans-serif;
  color: var(--ink);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: radial-gradient(1200px 600px at 10% -10%, #f3f0ff 0%, transparent 60%),
    radial-gradient(900px 600px at 110% 110%, #e2ecff 0%, transparent 60%), var(--bg);
  min-height: 100vh;
  overflow-x: hidden;
}
button, input, select { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.muted { color: var(--muted); margin: 0.3em 0 0; }
.tiny { font-size: 0.85rem; }
h1, h2, h3 { margin: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.6rem; font-weight: 800; }
h3 { font-size: 1.05rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }

/* Superfícies */
.card { background: var(--surface); border-radius: var(--r); box-shadow: var(--sh); padding: 24px; }
.card-sm { background: var(--surface); border-radius: 999px; box-shadow: var(--sh-sm); padding: 8px 10px 8px 16px; }
.well { background: var(--bg2); border-radius: 16px; box-shadow: var(--in); display: flex; align-items: center; padding: 0 14px; min-height: 50px; }
.well input, .well select { border: 0; background: transparent; outline: none; width: 100%; padding: 12px 0; font-weight: 600; }
.well:focus-within { box-shadow: var(--in), 0 0 0 3px #8c8cf255; }
.select { appearance: none; cursor: pointer; font-weight: 700; padding: 0 16px; border: 0; }
.row { display: flex; gap: 12px; align-items: center; }
.grow { flex: 1; }
.pill { background: var(--bg2); box-shadow: var(--in-sm); border-radius: 999px; padding: 2px 10px; font-size: 0.8rem; color: var(--ink2); }

/* Botões */
.btn {
  border: 0; cursor: pointer; border-radius: 16px; padding: 13px 20px; font-weight: 800;
  background: linear-gradient(145deg, #f4f5fc, #dcdfee); box-shadow: var(--sh-sm);
  transition: transform 0.12s, box-shadow 0.12s, filter 0.12s; white-space: nowrap; color: var(--ink);
}
.btn:hover { filter: brightness(1.03); transform: translateY(-1px); }
.btn:active { box-shadow: var(--in-sm); transform: translateY(1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.btn.primary { color: #fff; background: linear-gradient(145deg, #9d9dff, #6c6ce0); box-shadow: 5px 5px 12px #a3a6cf, -5px -5px 12px #fff, inset 1px 1px 2px #ffffff66; text-shadow: 0 1px 1px #0003; }
.btn.red { color: #fff; background: linear-gradient(145deg, #f05a66, #c42e3c); }
.btn.blue { color: #fff; background: linear-gradient(145deg, #5584f0, #2b52c4); }
.btn.danger { color: var(--red-d); }
.btn.ghost { background: transparent; box-shadow: none; }
.btn.ghost:hover { box-shadow: var(--sh-sm); }
.btn.small { padding: 9px 14px; border-radius: 13px; font-size: 0.92rem; }
.btn.big { padding: 17px 28px; font-size: 1.15rem; border-radius: 20px; }
.icon-btn { border: 0; background: none; cursor: pointer; color: var(--muted); font-size: 1rem; padding: 4px 6px; border-radius: 10px; }
.icon-btn:hover { color: var(--ink); box-shadow: var(--sh-sm); }

/* Sprites e animações */
.sp { image-rendering: auto; user-select: none; -webkit-user-drag: none; pointer-events: none; }
@keyframes float { 0%,100% { transform: translateY(0) rotate(-2deg); } 50% { transform: translateY(-10px) rotate(2deg); } }
@keyframes breathe { 0%,100% { transform: scale(1, 1); } 50% { transform: scale(1.03, 0.97); } }
@keyframes hop { 0%,100% { transform: translateY(0) scale(1,1); } 30% { transform: translateY(-16px) scale(0.96,1.05); } 55% { transform: translateY(0) scale(1.06,0.94); } 70% { transform: translateY(-4px); } }
@keyframes wiggle { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-7deg); } 75% { transform: rotate(7deg); } }
@keyframes shake { 0%,100% { transform: translateX(0); } 20%,60% { transform: translateX(-6px); } 40%,80% { transform: translateX(6px); } }
@keyframes pop { 0% { transform: scale(0.6); opacity: 0; } 60% { transform: scale(1.08); opacity: 1; } 100% { transform: scale(1); } }
@keyframes pulse { 0%,100% { box-shadow: var(--sh-sm), 0 0 0 0 #8c8cf255; } 50% { box-shadow: var(--sh-sm), 0 0 0 8px #8c8cf200; } }
.float { animation: float 3.2s ease-in-out infinite; }
.float.d2 { animation-delay: -1.4s; }
.bob { animation: breathe 2.4s ease-in-out infinite; transform-origin: 50% 100%; }

/* Boas-vindas */
.screen { min-height: 100vh; }
#screen-welcome { display: grid; place-items: center; padding: 24px 16px; }
.welcome { max-width: 560px; width: 100%; text-align: center; padding: 36px 32px 32px; }
.welcome-art { display: flex; justify-content: center; align-items: flex-end; gap: 10px; height: 190px; }
.welcome-art img { height: 180px; }
.welcome-art img.small { height: 130px; }
.logo { font-size: clamp(2.4rem, 7vw, 3.4rem); font-weight: 900; margin-top: 10px; color: var(--ink); text-shadow: 2px 2px 0 #fff, 4px 4px 10px #b9bdd3; }
.logo span { color: var(--lilac-d); }
.welcome form { margin-top: 24px; }

/* Topbar */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 18px 28px; max-width: 1360px; margin: 0 auto; }
.brand { display: flex; align-items: center; gap: 4px; font-size: 1.4rem; font-weight: 600; }
.brand b { font-weight: 900; }
.brand img { height: 46px; margin-right: 6px; }
.me { display: flex; align-items: center; gap: 8px; font-weight: 700; }
.dot { width: 10px; height: 10px; border-radius: 50%; background: #c9c9d9; box-shadow: var(--in-sm); }
.dot.on { background: var(--ok); box-shadow: 0 0 8px #34b37a99; }
.code { font-family: ui-monospace, monospace; letter-spacing: 0.15em; background: var(--bg2); box-shadow: var(--in-sm); padding: 4px 12px; border-radius: 10px; font-weight: 800; }

/* Lobby */
.lobby { display: grid; grid-template-columns: 1fr 320px; gap: 28px; padding: 6px 28px 40px; max-width: 1360px; margin: 0 auto; align-items: start; }
.hero { display: flex; justify-content: space-between; align-items: center; gap: 20px; flex-wrap: wrap; }
.hero form .well { width: 130px; }
.hero input { text-transform: uppercase; letter-spacing: 0.15em; text-align: center; }
.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 24px; margin-top: 28px; }
.game-card { position: relative; overflow: hidden; display: flex; flex-direction: column; padding: 0; transition: transform 0.18s; }
.game-card:hover { transform: translateY(-4px); }
.game-art { height: 170px; margin: 14px 14px 0; border-radius: 16px; box-shadow: var(--in); position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 0; overflow: hidden; }
.game-art .sp { height: 150px; transition: transform 0.25s; transform-origin: 50% 100%; }
.game-art .sp + .sp { margin-left: -26px; }
.game-art .sp.flip { transform: scaleX(-1); }
.game-card:hover .game-art .sp { animation: hop 0.7s ease-out; }
.game-card:hover .game-art .sp.flip { animation: none; transform: scaleX(-1) translateY(-6px); }
.game-art .deco { position: absolute; inset: 0; opacity: 0.55; }
.game-body { padding: 16px 20px 20px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.game-body h3 { font-size: 1.25rem; }
.game-body p { margin: 0; color: var(--muted); font-size: 0.95rem; flex: 1; }
.game-body .row { margin-top: 12px; }
.game-body .row .btn { flex: 1; }
.tag { font-size: 0.72rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.08em; color: var(--lilac-d); }

.online { position: sticky; top: 16px; }
.online-list { list-style: none; padding: 0; margin: 16px 0 0; display: flex; flex-direction: column; gap: 12px; }
.online-list li { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-radius: 16px; box-shadow: var(--in-sm); background: var(--bg2); }
.online-list .ava { width: 38px; height: 38px; border-radius: 50%; background: var(--surface); box-shadow: var(--sh-sm); display: grid; place-items: center; overflow: hidden; flex: none; }
.online-list .ava img { height: 44px; margin-top: 10px; }
.online-list .nm { flex: 1; font-weight: 700; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.online-list .st { font-size: 0.75rem; color: var(--muted); display: block; font-weight: 600; }

/* Sala */
.room { display: grid; grid-template-columns: 1fr 320px; gap: 28px; padding: 6px 28px 40px; max-width: 1200px; margin: 0 auto; align-items: start; }
.room-game { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; }
.room-game > div:nth-child(2) { flex: 1; min-width: 200px; }
.game-icon { width: 72px; height: 72px; border-radius: 20px; box-shadow: var(--sh-sm); display: grid; place-items: center; overflow: hidden; background: var(--bg2); }
.game-icon img { height: 82px; margin-top: 14px; }
.versus { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 18px; margin: 28px 0; }
.slot { border-radius: 22px; box-shadow: var(--in); padding: 18px; min-height: 280px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; text-align: center; position: relative; overflow: hidden; }
.slot::before { content: ""; position: absolute; inset: auto -20% -40% -20%; height: 60%; border-radius: 50%; opacity: 0.18; }
.slot.red::before { background: var(--red); }
.slot.blue::before { background: var(--blue); }
.slot .sp { height: 190px; position: relative; animation: breathe 2.6s ease-in-out infinite; transform-origin: 50% 100%; }
.slot.blue .sp { animation-delay: -1.2s; }
.slot .sp.flip { scale: -1 1; }
.slot .who { font-weight: 800; font-size: 1.15rem; margin-top: 10px; position: relative; }
.slot .team { font-size: 0.78rem; font-weight: 800; text-transform: uppercase; letter-spacing: 0.1em; position: relative; }
.slot.red .team { color: var(--red); }
.slot.blue .team { color: var(--blue); }
.slot.empty .sp { opacity: 0.25; filter: grayscale(1); animation: none; }
.slot .you { position: absolute; top: 12px; right: 12px; font-size: 0.72rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: var(--surface); box-shadow: var(--sh-sm); }
.vs { width: 64px; height: 64px; border-radius: 50%; border: 0; cursor: pointer; font-size: 1.4rem; font-weight: 900; background: linear-gradient(145deg, #f4f5fc, #dcdfee); box-shadow: var(--sh-sm); }
.vs:active { box-shadow: var(--in-sm); }
.room-actions { display: flex; flex-direction: column; gap: 14px; align-items: stretch; }
.share { gap: 10px; padding-right: 6px; }
.share input { font-family: ui-monospace, monospace; font-size: 0.85rem; color: var(--ink2); }

/* Jogo */
#screen-game { display: flex; flex-direction: column; height: 100vh; height: 100dvh; }
.game-bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; }
.game-bar-actions { display: flex; gap: 8px; }
.hud { flex: 1; display: flex; justify-content: center; align-items: center; gap: 14px; min-width: 0; }
.hud-player { display: flex; align-items: center; gap: 10px; padding: 6px 16px 6px 8px; border-radius: 18px; background: var(--surface); box-shadow: var(--sh-sm); transition: box-shadow 0.2s, transform 0.2s; min-width: 0; }
.hud-player.blue { flex-direction: row-reverse; padding: 6px 8px 6px 16px; text-align: right; }
.hud-player .ava { width: 52px; height: 52px; border-radius: 14px; overflow: hidden; box-shadow: var(--in-sm); display: grid; place-items: center; flex: none; }
.hud-player .ava img { height: 64px; margin-top: 12px; }
.hud-player.blue .ava img { transform: scaleX(-1); }
.hud-player .nm { font-weight: 800; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 150px; }
.hud-player .sub { font-size: 0.78rem; font-weight: 700; color: var(--muted); }
.hud-player.red .nm { color: var(--red-d); }
.hud-player.blue .nm { color: var(--blue-d); }
.hud-player.turn { box-shadow: var(--sh-sm), 0 0 0 3px var(--lilac); transform: translateY(-1px); }
.hud-player.turn .ava img { animation: hop 1.2s ease-in-out infinite; }
.hud-mid { font-weight: 900; font-size: 1.3rem; padding: 6px 16px; border-radius: 14px; box-shadow: var(--in-sm); background: var(--bg2); min-width: 80px; text-align: center; }
.stage-wrap { flex: 1; min-height: 0; padding: 4px 16px 16px; display: flex; }
.stage { flex: 1; border-radius: 26px; box-shadow: var(--in); background: var(--bg2); position: relative; overflow: hidden; display: grid; place-items: center; }
.stage canvas { display: block; touch-action: none; }
.overlay { position: absolute; inset: 0; display: grid; place-items: center; background: #e7e9f3cc; backdrop-filter: blur(4px); z-index: 5; animation: pop 0.35s ease-out; }
.overlay .card { text-align: center; max-width: 440px; }
.overlay .sp { height: 170px; }
.overlay .sp.cheer { animation: hop 0.9s ease-in-out infinite; }
.overlay .sp.sad { animation: shake 1.6s ease-in-out infinite; filter: saturate(0.6); height: 120px; }
.overlay .row { justify-content: center; margin-top: 18px; flex-wrap: wrap; }
.banner { position: absolute; left: 50%; top: 18px; translate: -50% 0; z-index: 4; padding: 10px 22px; border-radius: 999px; background: var(--surface); box-shadow: var(--sh-sm); font-weight: 800; pointer-events: none; animation: pop 0.3s ease-out; white-space: nowrap; }
.chooser { display: flex; gap: 10px; justify-content: center; margin-top: 12px; }
.chooser button { width: 64px; height: 64px; font-size: 2.2rem; border-radius: 16px; }

.chat { position: fixed; right: 16px; bottom: 16px; width: min(340px, calc(100vw - 32px)); padding: 14px; z-index: 20; }
.chat ul { list-style: none; padding: 4px; margin: 0 0 10px; max-height: 240px; overflow: auto; display: flex; flex-direction: column; gap: 6px; font-size: 0.92rem; }
.chat li b { color: var(--lilac-d); }
.chat .well { min-height: 42px; }

/* Modal e toasts */
.modal { position: fixed; inset: 0; background: #2a265033; backdrop-filter: blur(3px); display: grid; place-items: center; z-index: 50; padding: 16px; }
.modal-box { max-width: 520px; width: 100%; animation: pop 0.25s ease-out; }
.modal-box h3 { margin-bottom: 8px; font-size: 1.3rem; }
.modal-box .row { justify-content: flex-end; margin-top: 20px; flex-wrap: wrap; }
.pick-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-top: 14px; }
.pick-grid button { border: 0; cursor: pointer; border-radius: 16px; padding: 10px 6px; background: var(--surface); box-shadow: var(--sh-sm); font-weight: 800; display: flex; flex-direction: column; align-items: center; gap: 4px; overflow: hidden; }
.pick-grid button img { height: 70px; }
.pick-grid button:active, .pick-grid button.sel { box-shadow: var(--in-sm); }
.help-list { padding-left: 20px; line-height: 1.55; color: var(--ink2); }
.help-list b { color: var(--ink); }
.toasts { position: fixed; top: 16px; left: 50%; translate: -50% 0; display: flex; flex-direction: column; gap: 10px; z-index: 60; width: min(440px, calc(100vw - 32px)); }
.toast { background: var(--surface); border-radius: 18px; box-shadow: var(--sh); padding: 14px 16px; display: flex; align-items: center; gap: 12px; animation: pop 0.3s ease-out; font-weight: 600; }
.toast img { height: 58px; flex: none; }
.toast .grow { min-width: 0; }
.toast .row { margin-top: 8px; }

@media (max-width: 960px) {
  .lobby, .room { grid-template-columns: 1fr; padding: 6px 16px 32px; }
  .topbar { padding: 14px 16px; }
  .online { position: static; }
  .hud-player .nm { max-width: 80px; }
}
@media (max-width: 640px) {
  .versus { grid-template-columns: 1fr; }
  .vs { justify-self: center; }
  .slot { min-height: 220px; }
  .slot .sp { height: 140px; }
  .game-bar { flex-wrap: wrap; padding: 8px; }
  .hud { order: 3; width: 100%; flex-basis: 100%; }
  .hud-player .ava { width: 40px; height: 40px; }
  .hud-player .sub { display: none; }
  .hud-mid { font-size: 1rem; min-width: 56px; padding: 4px 10px; }
  .stage-wrap { padding: 4px 8px 8px; }
  .welcome form { flex-direction: column; align-items: stretch; }
  .pick-grid { grid-template-columns: repeat(2, 1fr); }
  .brand { font-size: 1.15rem; }
}
